babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. /**
  95. * User defined information that will be sent to observers
  96. */
  97. userInfo?: any;
  98. }
  99. /**
  100. * Represent an Observer registered to a given Observable object.
  101. */
  102. export class Observer<T> {
  103. /**
  104. * Defines the callback to call when the observer is notified
  105. */
  106. callback: (eventData: T, eventState: EventState) => void;
  107. /**
  108. * Defines the mask of the observer (used to filter notifications)
  109. */
  110. mask: number;
  111. /**
  112. * Defines the current scope used to restore the JS context
  113. */
  114. scope: any;
  115. /** @hidden */
  116. _willBeUnregistered: boolean;
  117. /**
  118. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  119. */
  120. unregisterOnNextCall: boolean;
  121. /**
  122. * Creates a new observer
  123. * @param callback defines the callback to call when the observer is notified
  124. * @param mask defines the mask of the observer (used to filter notifications)
  125. * @param scope defines the current scope used to restore the JS context
  126. */
  127. constructor(
  128. /**
  129. * Defines the callback to call when the observer is notified
  130. */
  131. callback: (eventData: T, eventState: EventState) => void,
  132. /**
  133. * Defines the mask of the observer (used to filter notifications)
  134. */
  135. mask: number,
  136. /**
  137. * Defines the current scope used to restore the JS context
  138. */
  139. scope?: any);
  140. }
  141. /**
  142. * Represent a list of observers registered to multiple Observables object.
  143. */
  144. export class MultiObserver<T> {
  145. private _observers;
  146. private _observables;
  147. /**
  148. * Release associated resources
  149. */
  150. dispose(): void;
  151. /**
  152. * Raise a callback when one of the observable will notify
  153. * @param observables defines a list of observables to watch
  154. * @param callback defines the callback to call on notification
  155. * @param mask defines the mask used to filter notifications
  156. * @param scope defines the current scope used to restore the JS context
  157. * @returns the new MultiObserver
  158. */
  159. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  160. }
  161. /**
  162. * The Observable class is a simple implementation of the Observable pattern.
  163. *
  164. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  165. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  166. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  167. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  168. */
  169. export class Observable<T> {
  170. private _observers;
  171. private _eventState;
  172. private _onObserverAdded;
  173. /**
  174. * Gets the list of observers
  175. */
  176. get observers(): Array<Observer<T>>;
  177. /**
  178. * Creates a new observable
  179. * @param onObserverAdded defines a callback to call when a new observer is added
  180. */
  181. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  182. /**
  183. * Create a new Observer with the specified callback
  184. * @param callback the callback that will be executed for that Observer
  185. * @param mask the mask used to filter observers
  186. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  187. * @param scope optional scope for the callback to be called from
  188. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  189. * @returns the new observer created for the callback
  190. */
  191. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  192. /**
  193. * Create a new Observer with the specified callback and unregisters after the next notification
  194. * @param callback the callback that will be executed for that Observer
  195. * @returns the new observer created for the callback
  196. */
  197. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  198. /**
  199. * Remove an Observer from the Observable object
  200. * @param observer the instance of the Observer to remove
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. remove(observer: Nullable<Observer<T>>): boolean;
  204. /**
  205. * Remove a callback from the Observable object
  206. * @param callback the callback to remove
  207. * @param scope optional scope. If used only the callbacks with this scope will be removed
  208. * @returns false if it doesn't belong to this Observable
  209. */
  210. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  211. private _deferUnregister;
  212. private _remove;
  213. /**
  214. * Moves the observable to the top of the observer list making it get called first when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverTopPriority(observer: Observer<T>): void;
  218. /**
  219. * Moves the observable to the bottom of the observer list making it get called last when notified
  220. * @param observer the observer to move
  221. */
  222. makeObserverBottomPriority(observer: Observer<T>): void;
  223. /**
  224. * Notify all Observers by calling their respective callback with the given data
  225. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  226. * @param eventData defines the data to send to all observers
  227. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  228. * @param target defines the original target of the state
  229. * @param currentTarget defines the current target of the state
  230. * @param userInfo defines any user info to send to observers
  231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  232. */
  233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  234. /**
  235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  238. * and it is crucial that all callbacks will be executed.
  239. * The order of the callbacks is kept, callbacks are not executed parallel.
  240. *
  241. * @param eventData The data to be sent to each callback
  242. * @param mask is used to filter observers defaults to -1
  243. * @param target defines the callback target (see EventState)
  244. * @param currentTarget defines he current object in the bubbling phase
  245. * @param userInfo defines any user info to send to observers
  246. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  247. */
  248. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  249. /**
  250. * Notify a specific observer
  251. * @param observer defines the observer to notify
  252. * @param eventData defines the data to be sent to each callback
  253. * @param mask is used to filter observers defaults to -1
  254. */
  255. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  256. /**
  257. * Gets a boolean indicating if the observable has at least one observer
  258. * @returns true is the Observable has at least one Observer registered
  259. */
  260. hasObservers(): boolean;
  261. /**
  262. * Clear the list of observers
  263. */
  264. clear(): void;
  265. /**
  266. * Clone the current observable
  267. * @returns a new observable
  268. */
  269. clone(): Observable<T>;
  270. /**
  271. * Does this observable handles observer registered with a given mask
  272. * @param mask defines the mask to be tested
  273. * @return whether or not one observer registered with the given mask is handeled
  274. **/
  275. hasSpecificMask(mask?: number): boolean;
  276. }
  277. }
  278. declare module "babylonjs/Misc/domManagement" {
  279. /**
  280. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  281. * Babylon.js
  282. */
  283. export class DomManagement {
  284. /**
  285. * Checks if the window object exists
  286. * @returns true if the window object exists
  287. */
  288. static IsWindowObjectExist(): boolean;
  289. /**
  290. * Checks if the navigator object exists
  291. * @returns true if the navigator object exists
  292. */
  293. static IsNavigatorAvailable(): boolean;
  294. /**
  295. * Check if the document object exists
  296. * @returns true if the document object exists
  297. */
  298. static IsDocumentAvailable(): boolean;
  299. /**
  300. * Extracts text content from a DOM element hierarchy
  301. * @param element defines the root element
  302. * @returns a string
  303. */
  304. static GetDOMTextContent(element: HTMLElement): string;
  305. }
  306. }
  307. declare module "babylonjs/Misc/logger" {
  308. /**
  309. * Logger used througouht the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. private static _LogCache;
  334. /**
  335. * Gets a value indicating the number of loading errors
  336. * @ignorenaming
  337. */
  338. static errorsCount: number;
  339. /**
  340. * Callback called when a new log is added
  341. */
  342. static OnNewCacheEntry: (entry: string) => void;
  343. private static _AddLogEntry;
  344. private static _FormatMessage;
  345. private static _LogDisabled;
  346. private static _LogEnabled;
  347. private static _WarnDisabled;
  348. private static _WarnEnabled;
  349. private static _ErrorDisabled;
  350. private static _ErrorEnabled;
  351. /**
  352. * Log a message to the console
  353. */
  354. static Log: (message: string) => void;
  355. /**
  356. * Write a warning message to the console
  357. */
  358. static Warn: (message: string) => void;
  359. /**
  360. * Write an error message to the console
  361. */
  362. static Error: (message: string) => void;
  363. /**
  364. * Gets current log cache (list of logs)
  365. */
  366. static get LogCache(): string;
  367. /**
  368. * Clears the log cache
  369. */
  370. static ClearLogCache(): void;
  371. /**
  372. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  373. */
  374. static set LogLevels(level: number);
  375. }
  376. }
  377. declare module "babylonjs/Misc/typeStore" {
  378. /** @hidden */
  379. export class _TypeStore {
  380. /** @hidden */
  381. static RegisteredTypes: {
  382. [key: string]: Object;
  383. };
  384. /** @hidden */
  385. static GetClass(fqdn: string): any;
  386. }
  387. }
  388. declare module "babylonjs/Misc/stringTools" {
  389. /**
  390. * Helper to manipulate strings
  391. */
  392. export class StringTools {
  393. /**
  394. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static EndsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static StartsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Decodes a buffer into a string
  409. * @param buffer The buffer to decode
  410. * @returns The decoded string
  411. */
  412. static Decode(buffer: Uint8Array | Uint16Array): string;
  413. /**
  414. * Encode a buffer to a base64 string
  415. * @param buffer defines the buffer to encode
  416. * @returns the encoded string
  417. */
  418. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  419. /**
  420. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  421. * @param num the number to convert and pad
  422. * @param length the expected length of the string
  423. * @returns the padded string
  424. */
  425. static PadNumber(num: number, length: number): string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/deepCopier" {
  429. /**
  430. * Class containing a set of static utilities functions for deep copy.
  431. */
  432. export class DeepCopier {
  433. /**
  434. * Tries to copy an object by duplicating every property
  435. * @param source defines the source object
  436. * @param destination defines the target object
  437. * @param doNotCopyList defines a list of properties to avoid
  438. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  439. */
  440. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  441. }
  442. }
  443. declare module "babylonjs/Misc/precisionDate" {
  444. /**
  445. * Class containing a set of static utilities functions for precision date
  446. */
  447. export class PrecisionDate {
  448. /**
  449. * Gets either window.performance.now() if supported or Date.now() else
  450. */
  451. static get Now(): number;
  452. }
  453. }
  454. declare module "babylonjs/Misc/devTools" {
  455. /** @hidden */
  456. export class _DevTools {
  457. static WarnImport(name: string): string;
  458. }
  459. }
  460. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  461. /**
  462. * Interface used to define the mechanism to get data from the network
  463. */
  464. export interface IWebRequest {
  465. /**
  466. * Returns client's response url
  467. */
  468. responseURL: string;
  469. /**
  470. * Returns client's status
  471. */
  472. status: number;
  473. /**
  474. * Returns client's status as a text
  475. */
  476. statusText: string;
  477. }
  478. }
  479. declare module "babylonjs/Misc/webRequest" {
  480. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  481. import { Nullable } from "babylonjs/types";
  482. /**
  483. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  484. */
  485. export class WebRequest implements IWebRequest {
  486. private _xhr;
  487. /**
  488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  489. * i.e. when loading files, where the server/service expects an Authorization header
  490. */
  491. static CustomRequestHeaders: {
  492. [key: string]: string;
  493. };
  494. /**
  495. * Add callback functions in this array to update all the requests before they get sent to the network
  496. */
  497. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  498. private _injectCustomRequestHeaders;
  499. /**
  500. * Gets or sets a function to be called when loading progress changes
  501. */
  502. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  503. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  504. /**
  505. * Returns client's state
  506. */
  507. get readyState(): number;
  508. /**
  509. * Returns client's status
  510. */
  511. get status(): number;
  512. /**
  513. * Returns client's status as a text
  514. */
  515. get statusText(): string;
  516. /**
  517. * Returns client's response
  518. */
  519. get response(): any;
  520. /**
  521. * Returns client's response url
  522. */
  523. get responseURL(): string;
  524. /**
  525. * Returns client's response as text
  526. */
  527. get responseText(): string;
  528. /**
  529. * Gets or sets the expected response type
  530. */
  531. get responseType(): XMLHttpRequestResponseType;
  532. set responseType(value: XMLHttpRequestResponseType);
  533. /** @hidden */
  534. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  535. /** @hidden */
  536. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  537. /**
  538. * Cancels any network activity
  539. */
  540. abort(): void;
  541. /**
  542. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  543. * @param body defines an optional request body
  544. */
  545. send(body?: Document | BodyInit | null): void;
  546. /**
  547. * Sets the request method, request URL
  548. * @param method defines the method to use (GET, POST, etc..)
  549. * @param url defines the url to connect with
  550. */
  551. open(method: string, url: string): void;
  552. /**
  553. * Sets the value of a request header.
  554. * @param name The name of the header whose value is to be set
  555. * @param value The value to set as the body of the header
  556. */
  557. setRequestHeader(name: string, value: string): void;
  558. /**
  559. * Get the string containing the text of a particular header's value.
  560. * @param name The name of the header
  561. * @returns The string containing the text of the given header name
  562. */
  563. getResponseHeader(name: string): Nullable<string>;
  564. }
  565. }
  566. declare module "babylonjs/Misc/fileRequest" {
  567. import { Observable } from "babylonjs/Misc/observable";
  568. /**
  569. * File request interface
  570. */
  571. export interface IFileRequest {
  572. /**
  573. * Raised when the request is complete (success or error).
  574. */
  575. onCompleteObservable: Observable<IFileRequest>;
  576. /**
  577. * Aborts the request for a file.
  578. */
  579. abort: () => void;
  580. }
  581. }
  582. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  583. /**
  584. * Define options used to create a render target texture
  585. */
  586. export class RenderTargetCreationOptions {
  587. /**
  588. * Specifies is mipmaps must be generated
  589. */
  590. generateMipMaps?: boolean;
  591. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  592. generateDepthBuffer?: boolean;
  593. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  594. generateStencilBuffer?: boolean;
  595. /** Defines texture type (int by default) */
  596. type?: number;
  597. /** Defines sampling mode (trilinear by default) */
  598. samplingMode?: number;
  599. /** Defines format (RGBA by default) */
  600. format?: number;
  601. }
  602. }
  603. declare module "babylonjs/Engines/constants" {
  604. /** Defines the cross module used constants to avoid circular dependncies */
  605. export class Constants {
  606. /** Defines that alpha blending is disabled */
  607. static readonly ALPHA_DISABLE: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  609. static readonly ALPHA_ADD: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_COMBINE: number;
  612. /** Defines that alpha blending is DEST - SRC * DEST */
  613. static readonly ALPHA_SUBTRACT: number;
  614. /** Defines that alpha blending is SRC * DEST */
  615. static readonly ALPHA_MULTIPLY: number;
  616. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  617. static readonly ALPHA_MAXIMIZED: number;
  618. /** Defines that alpha blending is SRC + DEST */
  619. static readonly ALPHA_ONEONE: number;
  620. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  621. static readonly ALPHA_PREMULTIPLIED: number;
  622. /**
  623. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  624. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  625. */
  626. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  627. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  628. static readonly ALPHA_INTERPOLATE: number;
  629. /**
  630. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  631. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  632. */
  633. static readonly ALPHA_SCREENMODE: number;
  634. /**
  635. * Defines that alpha blending is SRC + DST
  636. * Alpha will be set to SRC ALPHA + DST ALPHA
  637. */
  638. static readonly ALPHA_ONEONE_ONEONE: number;
  639. /**
  640. * Defines that alpha blending is SRC * DST ALPHA + DST
  641. * Alpha will be set to 0
  642. */
  643. static readonly ALPHA_ALPHATOCOLOR: number;
  644. /**
  645. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  646. */
  647. static readonly ALPHA_REVERSEONEMINUS: number;
  648. /**
  649. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  650. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  651. */
  652. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  653. /**
  654. * Defines that alpha blending is SRC + DST
  655. * Alpha will be set to SRC ALPHA
  656. */
  657. static readonly ALPHA_ONEONE_ONEZERO: number;
  658. /**
  659. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  660. * Alpha will be set to DST ALPHA
  661. */
  662. static readonly ALPHA_EXCLUSION: number;
  663. /** Defines that alpha blending equation a SUM */
  664. static readonly ALPHA_EQUATION_ADD: number;
  665. /** Defines that alpha blending equation a SUBSTRACTION */
  666. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  667. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  668. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  669. /** Defines that alpha blending equation a MAX operation */
  670. static readonly ALPHA_EQUATION_MAX: number;
  671. /** Defines that alpha blending equation a MIN operation */
  672. static readonly ALPHA_EQUATION_MIN: number;
  673. /**
  674. * Defines that alpha blending equation a DARKEN operation:
  675. * It takes the min of the src and sums the alpha channels.
  676. */
  677. static readonly ALPHA_EQUATION_DARKEN: number;
  678. /** Defines that the ressource is not delayed*/
  679. static readonly DELAYLOADSTATE_NONE: number;
  680. /** Defines that the ressource was successfully delay loaded */
  681. static readonly DELAYLOADSTATE_LOADED: number;
  682. /** Defines that the ressource is currently delay loading */
  683. static readonly DELAYLOADSTATE_LOADING: number;
  684. /** Defines that the ressource is delayed and has not started loading */
  685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  687. static readonly NEVER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  689. static readonly ALWAYS: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  691. static readonly LESS: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  693. static readonly EQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  695. static readonly LEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  697. static readonly GREATER: number;
  698. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  699. static readonly GEQUAL: number;
  700. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  701. static readonly NOTEQUAL: number;
  702. /** Passed to stencilOperation to specify that stencil value must be kept */
  703. static readonly KEEP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  705. static readonly REPLACE: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  707. static readonly INCR: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  709. static readonly DECR: number;
  710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  711. static readonly INVERT: number;
  712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  713. static readonly INCR_WRAP: number;
  714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  715. static readonly DECR_WRAP: number;
  716. /** Texture is not repeating outside of 0..1 UVs */
  717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  718. /** Texture is repeating outside of 0..1 UVs */
  719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  720. /** Texture is repeating and mirrored */
  721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  722. /** ALPHA */
  723. static readonly TEXTUREFORMAT_ALPHA: number;
  724. /** LUMINANCE */
  725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  726. /** LUMINANCE_ALPHA */
  727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  728. /** RGB */
  729. static readonly TEXTUREFORMAT_RGB: number;
  730. /** RGBA */
  731. static readonly TEXTUREFORMAT_RGBA: number;
  732. /** RED */
  733. static readonly TEXTUREFORMAT_RED: number;
  734. /** RED (2nd reference) */
  735. static readonly TEXTUREFORMAT_R: number;
  736. /** RG */
  737. static readonly TEXTUREFORMAT_RG: number;
  738. /** RED_INTEGER */
  739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  740. /** RED_INTEGER (2nd reference) */
  741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  742. /** RG_INTEGER */
  743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  744. /** RGB_INTEGER */
  745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  746. /** RGBA_INTEGER */
  747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  748. /** UNSIGNED_BYTE */
  749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  750. /** UNSIGNED_BYTE (2nd reference) */
  751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  752. /** FLOAT */
  753. static readonly TEXTURETYPE_FLOAT: number;
  754. /** HALF_FLOAT */
  755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  756. /** BYTE */
  757. static readonly TEXTURETYPE_BYTE: number;
  758. /** SHORT */
  759. static readonly TEXTURETYPE_SHORT: number;
  760. /** UNSIGNED_SHORT */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  762. /** INT */
  763. static readonly TEXTURETYPE_INT: number;
  764. /** UNSIGNED_INT */
  765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  766. /** UNSIGNED_SHORT_4_4_4_4 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  768. /** UNSIGNED_SHORT_5_5_5_1 */
  769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  770. /** UNSIGNED_SHORT_5_6_5 */
  771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  772. /** UNSIGNED_INT_2_10_10_10_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  774. /** UNSIGNED_INT_24_8 */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  776. /** UNSIGNED_INT_10F_11F_11F_REV */
  777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  778. /** UNSIGNED_INT_5_9_9_9_REV */
  779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  782. /** nearest is mag = nearest and min = nearest and no mip */
  783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** Bilinear is mag = linear and min = linear and no mip */
  787. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  788. /** mag = linear and min = linear and mip = none */
  789. static readonly TEXTURE_LINEAR_LINEAR: number;
  790. /** Trilinear is mag = linear and min = linear and mip = linear */
  791. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  792. /** Trilinear is mag = linear and min = linear and mip = linear */
  793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = nearest and mip = nearest */
  795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  796. /** mag = nearest and min = linear and mip = nearest */
  797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  798. /** mag = nearest and min = linear and mip = linear */
  799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  800. /** mag = nearest and min = linear and mip = none */
  801. static readonly TEXTURE_NEAREST_LINEAR: number;
  802. /** nearest is mag = nearest and min = nearest and mip = linear */
  803. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  804. /** mag = linear and min = nearest and mip = nearest */
  805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = linear */
  807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  810. /** mag = linear and min = nearest and mip = none */
  811. static readonly TEXTURE_LINEAR_NEAREST: number;
  812. /** Explicit coordinates mode */
  813. static readonly TEXTURE_EXPLICIT_MODE: number;
  814. /** Spherical coordinates mode */
  815. static readonly TEXTURE_SPHERICAL_MODE: number;
  816. /** Planar coordinates mode */
  817. static readonly TEXTURE_PLANAR_MODE: number;
  818. /** Cubic coordinates mode */
  819. static readonly TEXTURE_CUBIC_MODE: number;
  820. /** Projection coordinates mode */
  821. static readonly TEXTURE_PROJECTION_MODE: number;
  822. /** Skybox coordinates mode */
  823. static readonly TEXTURE_SKYBOX_MODE: number;
  824. /** Inverse Cubic coordinates mode */
  825. static readonly TEXTURE_INVCUBIC_MODE: number;
  826. /** Equirectangular coordinates mode */
  827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  828. /** Equirectangular Fixed coordinates mode */
  829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  830. /** Equirectangular Fixed Mirrored coordinates mode */
  831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  832. /** Offline (baking) quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  834. /** High quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  836. /** Medium quality for texture filtering */
  837. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  838. /** Low quality for texture filtering */
  839. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  840. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  841. static readonly SCALEMODE_FLOOR: number;
  842. /** Defines that texture rescaling will look for the nearest power of 2 size */
  843. static readonly SCALEMODE_NEAREST: number;
  844. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  845. static readonly SCALEMODE_CEILING: number;
  846. /**
  847. * The dirty texture flag value
  848. */
  849. static readonly MATERIAL_TextureDirtyFlag: number;
  850. /**
  851. * The dirty light flag value
  852. */
  853. static readonly MATERIAL_LightDirtyFlag: number;
  854. /**
  855. * The dirty fresnel flag value
  856. */
  857. static readonly MATERIAL_FresnelDirtyFlag: number;
  858. /**
  859. * The dirty attribute flag value
  860. */
  861. static readonly MATERIAL_AttributesDirtyFlag: number;
  862. /**
  863. * The dirty misc flag value
  864. */
  865. static readonly MATERIAL_MiscDirtyFlag: number;
  866. /**
  867. * The dirty prepass flag value
  868. */
  869. static readonly MATERIAL_PrePassDirtyFlag: number;
  870. /**
  871. * The all dirty flag value
  872. */
  873. static readonly MATERIAL_AllDirtyFlag: number;
  874. /**
  875. * Returns the triangle fill mode
  876. */
  877. static readonly MATERIAL_TriangleFillMode: number;
  878. /**
  879. * Returns the wireframe mode
  880. */
  881. static readonly MATERIAL_WireFrameFillMode: number;
  882. /**
  883. * Returns the point fill mode
  884. */
  885. static readonly MATERIAL_PointFillMode: number;
  886. /**
  887. * Returns the point list draw mode
  888. */
  889. static readonly MATERIAL_PointListDrawMode: number;
  890. /**
  891. * Returns the line list draw mode
  892. */
  893. static readonly MATERIAL_LineListDrawMode: number;
  894. /**
  895. * Returns the line loop draw mode
  896. */
  897. static readonly MATERIAL_LineLoopDrawMode: number;
  898. /**
  899. * Returns the line strip draw mode
  900. */
  901. static readonly MATERIAL_LineStripDrawMode: number;
  902. /**
  903. * Returns the triangle strip draw mode
  904. */
  905. static readonly MATERIAL_TriangleStripDrawMode: number;
  906. /**
  907. * Returns the triangle fan draw mode
  908. */
  909. static readonly MATERIAL_TriangleFanDrawMode: number;
  910. /**
  911. * Stores the clock-wise side orientation
  912. */
  913. static readonly MATERIAL_ClockWiseSideOrientation: number;
  914. /**
  915. * Stores the counter clock-wise side orientation
  916. */
  917. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  918. /**
  919. * Nothing
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_NothingTrigger: number;
  923. /**
  924. * On pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickTrigger: number;
  928. /**
  929. * On left pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnLeftPickTrigger: number;
  933. /**
  934. * On right pick
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnRightPickTrigger: number;
  938. /**
  939. * On center pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnCenterPickTrigger: number;
  943. /**
  944. * On pick down
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickDownTrigger: number;
  948. /**
  949. * On double pick
  950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  951. */
  952. static readonly ACTION_OnDoublePickTrigger: number;
  953. /**
  954. * On pick up
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickUpTrigger: number;
  958. /**
  959. * On pick out.
  960. * This trigger will only be raised if you also declared a OnPickDown
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPickOutTrigger: number;
  964. /**
  965. * On long press
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnLongPressTrigger: number;
  969. /**
  970. * On pointer over
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnPointerOverTrigger: number;
  974. /**
  975. * On pointer out
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnPointerOutTrigger: number;
  979. /**
  980. * On every frame
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnEveryFrameTrigger: number;
  984. /**
  985. * On intersection enter
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnIntersectionEnterTrigger: number;
  989. /**
  990. * On intersection exit
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnIntersectionExitTrigger: number;
  994. /**
  995. * On key down
  996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  997. */
  998. static readonly ACTION_OnKeyDownTrigger: number;
  999. /**
  1000. * On key up
  1001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1002. */
  1003. static readonly ACTION_OnKeyUpTrigger: number;
  1004. /**
  1005. * Billboard mode will only apply to Y axis
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1008. /**
  1009. * Billboard mode will apply to all axes
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1012. /**
  1013. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1014. */
  1015. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1017. * Test order :
  1018. * Is the bounding sphere outside the frustum ?
  1019. * If not, are the bounding box vertices outside the frustum ?
  1020. * It not, then the cullable object is in the frustum.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1023. /** Culling strategy : Bounding Sphere Only.
  1024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1025. * It's also less accurate than the standard because some not visible objects can still be selected.
  1026. * Test : is the bounding sphere outside the frustum ?
  1027. * If not, then the cullable object is in the frustum.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1030. /** Culling strategy : Optimistic Inclusion.
  1031. * This in an inclusion test first, then the standard exclusion test.
  1032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1034. * Anyway, it's as accurate as the standard strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the default culling strategy.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1043. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1045. * Test :
  1046. * Is the cullable object bounding sphere center in the frustum ?
  1047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1048. */
  1049. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1050. /**
  1051. * No logging while loading
  1052. */
  1053. static readonly SCENELOADER_NO_LOGGING: number;
  1054. /**
  1055. * Minimal logging while loading
  1056. */
  1057. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1058. /**
  1059. * Summary logging while loading
  1060. */
  1061. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1062. /**
  1063. * Detailled logging while loading
  1064. */
  1065. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1066. /**
  1067. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1069. */
  1070. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the position texture index in the textures array in the prepass
  1073. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1074. */
  1075. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1078. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1079. */
  1080. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1091. /**
  1092. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1093. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1094. */
  1095. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1096. /**
  1097. * Constant used to retrieve albedo index in the textures array in the prepass
  1098. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1099. */
  1100. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1101. }
  1102. }
  1103. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1104. import { Nullable } from "babylonjs/types";
  1105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1106. /**
  1107. * This represents the required contract to create a new type of texture loader.
  1108. */
  1109. export interface IInternalTextureLoader {
  1110. /**
  1111. * Defines wether the loader supports cascade loading the different faces.
  1112. */
  1113. supportCascades: boolean;
  1114. /**
  1115. * This returns if the loader support the current file information.
  1116. * @param extension defines the file extension of the file being loaded
  1117. * @param mimeType defines the optional mime type of the file being loaded
  1118. * @returns true if the loader can load the specified file
  1119. */
  1120. canLoad(extension: string, mimeType?: string): boolean;
  1121. /**
  1122. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1123. * @param data contains the texture data
  1124. * @param texture defines the BabylonJS internal texture
  1125. * @param createPolynomials will be true if polynomials have been requested
  1126. * @param onLoad defines the callback to trigger once the texture is ready
  1127. * @param onError defines the callback to trigger in case of error
  1128. * @param options options to be passed to the loader
  1129. */
  1130. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1131. /**
  1132. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1133. * @param data contains the texture data
  1134. * @param texture defines the BabylonJS internal texture
  1135. * @param callback defines the method to call once ready to upload
  1136. * @param options options to be passed to the loader
  1137. */
  1138. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/IPipelineContext" {
  1142. /**
  1143. * Class used to store and describe the pipeline context associated with an effect
  1144. */
  1145. export interface IPipelineContext {
  1146. /**
  1147. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1148. */
  1149. isAsync: boolean;
  1150. /**
  1151. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1152. */
  1153. isReady: boolean;
  1154. /** @hidden */
  1155. _getVertexShaderCode(): string | null;
  1156. /** @hidden */
  1157. _getFragmentShaderCode(): string | null;
  1158. /** @hidden */
  1159. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1160. }
  1161. }
  1162. declare module "babylonjs/Meshes/dataBuffer" {
  1163. /**
  1164. * Class used to store gfx data (like WebGLBuffer)
  1165. */
  1166. export class DataBuffer {
  1167. /**
  1168. * Gets or sets the number of objects referencing this buffer
  1169. */
  1170. references: number;
  1171. /** Gets or sets the size of the underlying buffer */
  1172. capacity: number;
  1173. /**
  1174. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1175. */
  1176. is32Bits: boolean;
  1177. /**
  1178. * Gets the underlying buffer
  1179. */
  1180. get underlyingResource(): any;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1184. /** @hidden */
  1185. export interface IShaderProcessor {
  1186. attributeProcessor?: (attribute: string) => string;
  1187. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1188. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1189. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1190. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1191. lineProcessor?: (line: string, isFragment: boolean) => string;
  1192. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1193. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1194. }
  1195. }
  1196. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1197. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1198. /** @hidden */
  1199. export interface ProcessingOptions {
  1200. defines: string[];
  1201. indexParameters: any;
  1202. isFragment: boolean;
  1203. shouldUseHighPrecisionShader: boolean;
  1204. supportsUniformBuffers: boolean;
  1205. shadersRepository: string;
  1206. includesShadersStore: {
  1207. [key: string]: string;
  1208. };
  1209. processor?: IShaderProcessor;
  1210. version: string;
  1211. platformName: string;
  1212. lookForClosingBracketForUniformBuffer?: boolean;
  1213. }
  1214. }
  1215. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1216. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1217. /** @hidden */
  1218. export class ShaderCodeNode {
  1219. line: string;
  1220. children: ShaderCodeNode[];
  1221. additionalDefineKey?: string;
  1222. additionalDefineValue?: string;
  1223. isValid(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. process(preprocessors: {
  1227. [key: string]: string;
  1228. }, options: ProcessingOptions): string;
  1229. }
  1230. }
  1231. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1232. /** @hidden */
  1233. export class ShaderCodeCursor {
  1234. private _lines;
  1235. lineIndex: number;
  1236. get currentLine(): string;
  1237. get canRead(): boolean;
  1238. set lines(value: string[]);
  1239. }
  1240. }
  1241. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1242. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1243. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1244. /** @hidden */
  1245. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1246. process(preprocessors: {
  1247. [key: string]: string;
  1248. }, options: ProcessingOptions): string;
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1252. /** @hidden */
  1253. export class ShaderDefineExpression {
  1254. isTrue(preprocessors: {
  1255. [key: string]: string;
  1256. }): boolean;
  1257. private static _OperatorPriority;
  1258. private static _Stack;
  1259. static postfixToInfix(postfix: string[]): string;
  1260. static infixToPostfix(infix: string): string[];
  1261. }
  1262. }
  1263. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1264. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1265. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1266. /** @hidden */
  1267. export class ShaderCodeTestNode extends ShaderCodeNode {
  1268. testExpression: ShaderDefineExpression;
  1269. isValid(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1275. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1276. /** @hidden */
  1277. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1278. define: string;
  1279. not: boolean;
  1280. constructor(define: string, not?: boolean);
  1281. isTrue(preprocessors: {
  1282. [key: string]: string;
  1283. }): boolean;
  1284. }
  1285. }
  1286. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1287. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1288. /** @hidden */
  1289. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1290. leftOperand: ShaderDefineExpression;
  1291. rightOperand: ShaderDefineExpression;
  1292. isTrue(preprocessors: {
  1293. [key: string]: string;
  1294. }): boolean;
  1295. }
  1296. }
  1297. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1298. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1299. /** @hidden */
  1300. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1301. leftOperand: ShaderDefineExpression;
  1302. rightOperand: ShaderDefineExpression;
  1303. isTrue(preprocessors: {
  1304. [key: string]: string;
  1305. }): boolean;
  1306. }
  1307. }
  1308. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1309. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1310. /** @hidden */
  1311. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1312. define: string;
  1313. operand: string;
  1314. testValue: string;
  1315. constructor(define: string, operand: string, testValue: string);
  1316. isTrue(preprocessors: {
  1317. [key: string]: string;
  1318. }): boolean;
  1319. }
  1320. }
  1321. declare module "babylonjs/Offline/IOfflineProvider" {
  1322. /**
  1323. * Class used to enable access to offline support
  1324. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1325. */
  1326. export interface IOfflineProvider {
  1327. /**
  1328. * Gets a boolean indicating if scene must be saved in the database
  1329. */
  1330. enableSceneOffline: boolean;
  1331. /**
  1332. * Gets a boolean indicating if textures must be saved in the database
  1333. */
  1334. enableTexturesOffline: boolean;
  1335. /**
  1336. * Open the offline support and make it available
  1337. * @param successCallback defines the callback to call on success
  1338. * @param errorCallback defines the callback to call on error
  1339. */
  1340. open(successCallback: () => void, errorCallback: () => void): void;
  1341. /**
  1342. * Loads an image from the offline support
  1343. * @param url defines the url to load from
  1344. * @param image defines the target DOM image
  1345. */
  1346. loadImage(url: string, image: HTMLImageElement): void;
  1347. /**
  1348. * Loads a file from offline support
  1349. * @param url defines the URL to load from
  1350. * @param sceneLoaded defines a callback to call on success
  1351. * @param progressCallBack defines a callback to call when progress changed
  1352. * @param errorCallback defines a callback to call on error
  1353. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1354. */
  1355. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1356. }
  1357. }
  1358. declare module "babylonjs/Misc/filesInputStore" {
  1359. /**
  1360. * Class used to help managing file picking and drag'n'drop
  1361. * File Storage
  1362. */
  1363. export class FilesInputStore {
  1364. /**
  1365. * List of files ready to be loaded
  1366. */
  1367. static FilesToLoad: {
  1368. [key: string]: File;
  1369. };
  1370. }
  1371. }
  1372. declare module "babylonjs/Misc/retryStrategy" {
  1373. import { WebRequest } from "babylonjs/Misc/webRequest";
  1374. /**
  1375. * Class used to define a retry strategy when error happens while loading assets
  1376. */
  1377. export class RetryStrategy {
  1378. /**
  1379. * Function used to defines an exponential back off strategy
  1380. * @param maxRetries defines the maximum number of retries (3 by default)
  1381. * @param baseInterval defines the interval between retries
  1382. * @returns the strategy function to use
  1383. */
  1384. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1385. }
  1386. }
  1387. declare module "babylonjs/Misc/baseError" {
  1388. /**
  1389. * @ignore
  1390. * Application error to support additional information when loading a file
  1391. */
  1392. export abstract class BaseError extends Error {
  1393. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1394. }
  1395. }
  1396. declare module "babylonjs/Misc/fileTools" {
  1397. import { WebRequest } from "babylonjs/Misc/webRequest";
  1398. import { Nullable } from "babylonjs/types";
  1399. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1400. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1401. import { BaseError } from "babylonjs/Misc/baseError";
  1402. /** @ignore */
  1403. export class LoadFileError extends BaseError {
  1404. request?: WebRequest;
  1405. file?: File;
  1406. /**
  1407. * Creates a new LoadFileError
  1408. * @param message defines the message of the error
  1409. * @param request defines the optional web request
  1410. * @param file defines the optional file
  1411. */
  1412. constructor(message: string, object?: WebRequest | File);
  1413. }
  1414. /** @ignore */
  1415. export class RequestFileError extends BaseError {
  1416. request: WebRequest;
  1417. /**
  1418. * Creates a new LoadFileError
  1419. * @param message defines the message of the error
  1420. * @param request defines the optional web request
  1421. */
  1422. constructor(message: string, request: WebRequest);
  1423. }
  1424. /** @ignore */
  1425. export class ReadFileError extends BaseError {
  1426. file: File;
  1427. /**
  1428. * Creates a new ReadFileError
  1429. * @param message defines the message of the error
  1430. * @param file defines the optional file
  1431. */
  1432. constructor(message: string, file: File);
  1433. }
  1434. /**
  1435. * @hidden
  1436. */
  1437. export class FileTools {
  1438. /**
  1439. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1440. */
  1441. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1442. /**
  1443. * Gets or sets the base URL to use to load assets
  1444. */
  1445. static BaseUrl: string;
  1446. /**
  1447. * Default behaviour for cors in the application.
  1448. * It can be a string if the expected behavior is identical in the entire app.
  1449. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1450. */
  1451. static CorsBehavior: string | ((url: string | string[]) => string);
  1452. /**
  1453. * Gets or sets a function used to pre-process url before using them to load assets
  1454. */
  1455. static PreprocessUrl: (url: string) => string;
  1456. /**
  1457. * Removes unwanted characters from an url
  1458. * @param url defines the url to clean
  1459. * @returns the cleaned url
  1460. */
  1461. private static _CleanUrl;
  1462. /**
  1463. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1464. * @param url define the url we are trying
  1465. * @param element define the dom element where to configure the cors policy
  1466. */
  1467. static SetCorsBehavior(url: string | string[], element: {
  1468. crossOrigin: string | null;
  1469. }): void;
  1470. /**
  1471. * Loads an image as an HTMLImageElement.
  1472. * @param input url string, ArrayBuffer, or Blob to load
  1473. * @param onLoad callback called when the image successfully loads
  1474. * @param onError callback called when the image fails to load
  1475. * @param offlineProvider offline provider for caching
  1476. * @param mimeType optional mime type
  1477. * @returns the HTMLImageElement of the loaded image
  1478. */
  1479. 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>;
  1480. /**
  1481. * Reads a file from a File object
  1482. * @param file defines the file to load
  1483. * @param onSuccess defines the callback to call when data is loaded
  1484. * @param onProgress defines the callback to call during loading process
  1485. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1486. * @param onError defines the callback to call when an error occurs
  1487. * @returns a file request object
  1488. */
  1489. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1490. /**
  1491. * Loads a file from a url
  1492. * @param url url to load
  1493. * @param onSuccess callback called when the file successfully loads
  1494. * @param onProgress callback called while file is loading (if the server supports this mode)
  1495. * @param offlineProvider defines the offline provider for caching
  1496. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1497. * @param onError callback called when the file fails to load
  1498. * @returns a file request object
  1499. */
  1500. 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;
  1501. /**
  1502. * Loads a file
  1503. * @param url url to load
  1504. * @param onSuccess callback called when the file successfully loads
  1505. * @param onProgress callback called while file is loading (if the server supports this mode)
  1506. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1507. * @param onError callback called when the file fails to load
  1508. * @param onOpened callback called when the web request is opened
  1509. * @returns a file request object
  1510. */
  1511. 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;
  1512. /**
  1513. * Checks if the loaded document was accessed via `file:`-Protocol.
  1514. * @returns boolean
  1515. */
  1516. static IsFileURL(): boolean;
  1517. }
  1518. }
  1519. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1520. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1521. import { WebRequest } from "babylonjs/Misc/webRequest";
  1522. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1523. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1524. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1525. /** @hidden */
  1526. export class ShaderProcessor {
  1527. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1528. private static _ProcessPrecision;
  1529. private static _ExtractOperation;
  1530. private static _BuildSubExpression;
  1531. private static _BuildExpression;
  1532. private static _MoveCursorWithinIf;
  1533. private static _MoveCursor;
  1534. private static _EvaluatePreProcessors;
  1535. private static _PreparePreProcessors;
  1536. private static _ProcessShaderConversion;
  1537. private static _ProcessIncludes;
  1538. /**
  1539. * Loads a file from a url
  1540. * @param url url to load
  1541. * @param onSuccess callback called when the file successfully loads
  1542. * @param onProgress callback called while file is loading (if the server supports this mode)
  1543. * @param offlineProvider defines the offline provider for caching
  1544. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1545. * @param onError callback called when the file fails to load
  1546. * @returns a file request object
  1547. * @hidden
  1548. */
  1549. 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;
  1550. }
  1551. }
  1552. declare module "babylonjs/Maths/math.like" {
  1553. import { float, int, DeepImmutable } from "babylonjs/types";
  1554. /**
  1555. * @hidden
  1556. */
  1557. export interface IColor4Like {
  1558. r: float;
  1559. g: float;
  1560. b: float;
  1561. a: float;
  1562. }
  1563. /**
  1564. * @hidden
  1565. */
  1566. export interface IColor3Like {
  1567. r: float;
  1568. g: float;
  1569. b: float;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IVector4Like {
  1575. x: float;
  1576. y: float;
  1577. z: float;
  1578. w: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IVector3Like {
  1584. x: float;
  1585. y: float;
  1586. z: float;
  1587. }
  1588. /**
  1589. * @hidden
  1590. */
  1591. export interface IVector2Like {
  1592. x: float;
  1593. y: float;
  1594. }
  1595. /**
  1596. * @hidden
  1597. */
  1598. export interface IMatrixLike {
  1599. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1600. updateFlag: int;
  1601. }
  1602. /**
  1603. * @hidden
  1604. */
  1605. export interface IViewportLike {
  1606. x: float;
  1607. y: float;
  1608. width: float;
  1609. height: float;
  1610. }
  1611. /**
  1612. * @hidden
  1613. */
  1614. export interface IPlaneLike {
  1615. normal: IVector3Like;
  1616. d: float;
  1617. normalize(): void;
  1618. }
  1619. }
  1620. declare module "babylonjs/Materials/iEffectFallbacks" {
  1621. import { Effect } from "babylonjs/Materials/effect";
  1622. /**
  1623. * Interface used to define common properties for effect fallbacks
  1624. */
  1625. export interface IEffectFallbacks {
  1626. /**
  1627. * Removes the defines that should be removed when falling back.
  1628. * @param currentDefines defines the current define statements for the shader.
  1629. * @param effect defines the current effect we try to compile
  1630. * @returns The resulting defines with defines of the current rank removed.
  1631. */
  1632. reduce(currentDefines: string, effect: Effect): string;
  1633. /**
  1634. * Removes the fallback from the bound mesh.
  1635. */
  1636. unBindMesh(): void;
  1637. /**
  1638. * Checks to see if more fallbacks are still availible.
  1639. */
  1640. hasMoreFallbacks: boolean;
  1641. }
  1642. }
  1643. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1644. /**
  1645. * Class used to evalaute queries containing `and` and `or` operators
  1646. */
  1647. export class AndOrNotEvaluator {
  1648. /**
  1649. * Evaluate a query
  1650. * @param query defines the query to evaluate
  1651. * @param evaluateCallback defines the callback used to filter result
  1652. * @returns true if the query matches
  1653. */
  1654. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1655. private static _HandleParenthesisContent;
  1656. private static _SimplifyNegation;
  1657. }
  1658. }
  1659. declare module "babylonjs/Misc/tags" {
  1660. /**
  1661. * Class used to store custom tags
  1662. */
  1663. export class Tags {
  1664. /**
  1665. * Adds support for tags on the given object
  1666. * @param obj defines the object to use
  1667. */
  1668. static EnableFor(obj: any): void;
  1669. /**
  1670. * Removes tags support
  1671. * @param obj defines the object to use
  1672. */
  1673. static DisableFor(obj: any): void;
  1674. /**
  1675. * Gets a boolean indicating if the given object has tags
  1676. * @param obj defines the object to use
  1677. * @returns a boolean
  1678. */
  1679. static HasTags(obj: any): boolean;
  1680. /**
  1681. * Gets the tags available on a given object
  1682. * @param obj defines the object to use
  1683. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1684. * @returns the tags
  1685. */
  1686. static GetTags(obj: any, asString?: boolean): any;
  1687. /**
  1688. * Adds tags to an object
  1689. * @param obj defines the object to use
  1690. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1691. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1692. */
  1693. static AddTagsTo(obj: any, tagsString: string): void;
  1694. /**
  1695. * @hidden
  1696. */
  1697. static _AddTagTo(obj: any, tag: string): void;
  1698. /**
  1699. * Removes specific tags from a specific object
  1700. * @param obj defines the object to use
  1701. * @param tagsString defines the tags to remove
  1702. */
  1703. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1704. /**
  1705. * @hidden
  1706. */
  1707. static _RemoveTagFrom(obj: any, tag: string): void;
  1708. /**
  1709. * Defines if tags hosted on an object match a given query
  1710. * @param obj defines the object to use
  1711. * @param tagsQuery defines the tag query
  1712. * @returns a boolean
  1713. */
  1714. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1715. }
  1716. }
  1717. declare module "babylonjs/Maths/math.scalar" {
  1718. /**
  1719. * Scalar computation library
  1720. */
  1721. export class Scalar {
  1722. /**
  1723. * Two pi constants convenient for computation.
  1724. */
  1725. static TwoPi: number;
  1726. /**
  1727. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1728. * @param a number
  1729. * @param b number
  1730. * @param epsilon (default = 1.401298E-45)
  1731. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1732. */
  1733. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1734. /**
  1735. * Returns a string : the upper case translation of the number i to hexadecimal.
  1736. * @param i number
  1737. * @returns the upper case translation of the number i to hexadecimal.
  1738. */
  1739. static ToHex(i: number): string;
  1740. /**
  1741. * Returns -1 if value is negative and +1 is value is positive.
  1742. * @param value the value
  1743. * @returns the value itself if it's equal to zero.
  1744. */
  1745. static Sign(value: number): number;
  1746. /**
  1747. * Returns the value itself if it's between min and max.
  1748. * Returns min if the value is lower than min.
  1749. * Returns max if the value is greater than max.
  1750. * @param value the value to clmap
  1751. * @param min the min value to clamp to (default: 0)
  1752. * @param max the max value to clamp to (default: 1)
  1753. * @returns the clamped value
  1754. */
  1755. static Clamp(value: number, min?: number, max?: number): number;
  1756. /**
  1757. * the log2 of value.
  1758. * @param value the value to compute log2 of
  1759. * @returns the log2 of value.
  1760. */
  1761. static Log2(value: number): number;
  1762. /**
  1763. * Loops the value, so that it is never larger than length and never smaller than 0.
  1764. *
  1765. * This is similar to the modulo operator but it works with floating point numbers.
  1766. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1767. * With t = 5 and length = 2.5, the result would be 0.0.
  1768. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1769. * @param value the value
  1770. * @param length the length
  1771. * @returns the looped value
  1772. */
  1773. static Repeat(value: number, length: number): number;
  1774. /**
  1775. * Normalize the value between 0.0 and 1.0 using min and max values
  1776. * @param value value to normalize
  1777. * @param min max to normalize between
  1778. * @param max min to normalize between
  1779. * @returns the normalized value
  1780. */
  1781. static Normalize(value: number, min: number, max: number): number;
  1782. /**
  1783. * Denormalize the value from 0.0 and 1.0 using min and max values
  1784. * @param normalized value to denormalize
  1785. * @param min max to denormalize between
  1786. * @param max min to denormalize between
  1787. * @returns the denormalized value
  1788. */
  1789. static Denormalize(normalized: number, min: number, max: number): number;
  1790. /**
  1791. * Calculates the shortest difference between two given angles given in degrees.
  1792. * @param current current angle in degrees
  1793. * @param target target angle in degrees
  1794. * @returns the delta
  1795. */
  1796. static DeltaAngle(current: number, target: number): number;
  1797. /**
  1798. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1799. * @param tx value
  1800. * @param length length
  1801. * @returns The returned value will move back and forth between 0 and length
  1802. */
  1803. static PingPong(tx: number, length: number): number;
  1804. /**
  1805. * Interpolates between min and max with smoothing at the limits.
  1806. *
  1807. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1808. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1809. * @param from from
  1810. * @param to to
  1811. * @param tx value
  1812. * @returns the smooth stepped value
  1813. */
  1814. static SmoothStep(from: number, to: number, tx: number): number;
  1815. /**
  1816. * Moves a value current towards target.
  1817. *
  1818. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1819. * Negative values of maxDelta pushes the value away from target.
  1820. * @param current current value
  1821. * @param target target value
  1822. * @param maxDelta max distance to move
  1823. * @returns resulting value
  1824. */
  1825. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1826. /**
  1827. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1828. *
  1829. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1830. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1831. * @param current current value
  1832. * @param target target value
  1833. * @param maxDelta max distance to move
  1834. * @returns resulting angle
  1835. */
  1836. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1837. /**
  1838. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1839. * @param start start value
  1840. * @param end target value
  1841. * @param amount amount to lerp between
  1842. * @returns the lerped value
  1843. */
  1844. static Lerp(start: number, end: number, amount: number): number;
  1845. /**
  1846. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1847. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1848. * @param start start value
  1849. * @param end target value
  1850. * @param amount amount to lerp between
  1851. * @returns the lerped value
  1852. */
  1853. static LerpAngle(start: number, end: number, amount: number): number;
  1854. /**
  1855. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1856. * @param a start value
  1857. * @param b target value
  1858. * @param value value between a and b
  1859. * @returns the inverseLerp value
  1860. */
  1861. static InverseLerp(a: number, b: number, value: number): number;
  1862. /**
  1863. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1864. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1865. * @param value1 spline value
  1866. * @param tangent1 spline value
  1867. * @param value2 spline value
  1868. * @param tangent2 spline value
  1869. * @param amount input value
  1870. * @returns hermite result
  1871. */
  1872. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1873. /**
  1874. * Returns a random float number between and min and max values
  1875. * @param min min value of random
  1876. * @param max max value of random
  1877. * @returns random value
  1878. */
  1879. static RandomRange(min: number, max: number): number;
  1880. /**
  1881. * This function returns percentage of a number in a given range.
  1882. *
  1883. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1884. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1885. * @param number to convert to percentage
  1886. * @param min min range
  1887. * @param max max range
  1888. * @returns the percentage
  1889. */
  1890. static RangeToPercent(number: number, min: number, max: number): number;
  1891. /**
  1892. * This function returns number that corresponds to the percentage in a given range.
  1893. *
  1894. * PercentToRange(0.34,0,100) will return 34.
  1895. * @param percent to convert to number
  1896. * @param min min range
  1897. * @param max max range
  1898. * @returns the number
  1899. */
  1900. static PercentToRange(percent: number, min: number, max: number): number;
  1901. /**
  1902. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1903. * @param angle The angle to normalize in radian.
  1904. * @return The converted angle.
  1905. */
  1906. static NormalizeRadians(angle: number): number;
  1907. }
  1908. }
  1909. declare module "babylonjs/Maths/math.constants" {
  1910. /**
  1911. * Constant used to convert a value to gamma space
  1912. * @ignorenaming
  1913. */
  1914. export const ToGammaSpace: number;
  1915. /**
  1916. * Constant used to convert a value to linear space
  1917. * @ignorenaming
  1918. */
  1919. export const ToLinearSpace = 2.2;
  1920. /**
  1921. * Constant used to define the minimal number value in Babylon.js
  1922. * @ignorenaming
  1923. */
  1924. let Epsilon: number;
  1925. export { Epsilon };
  1926. }
  1927. declare module "babylonjs/Maths/math.viewport" {
  1928. /**
  1929. * Class used to represent a viewport on screen
  1930. */
  1931. export class Viewport {
  1932. /** viewport left coordinate */
  1933. x: number;
  1934. /** viewport top coordinate */
  1935. y: number;
  1936. /**viewport width */
  1937. width: number;
  1938. /** viewport height */
  1939. height: number;
  1940. /**
  1941. * Creates a Viewport object located at (x, y) and sized (width, height)
  1942. * @param x defines viewport left coordinate
  1943. * @param y defines viewport top coordinate
  1944. * @param width defines the viewport width
  1945. * @param height defines the viewport height
  1946. */
  1947. constructor(
  1948. /** viewport left coordinate */
  1949. x: number,
  1950. /** viewport top coordinate */
  1951. y: number,
  1952. /**viewport width */
  1953. width: number,
  1954. /** viewport height */
  1955. height: number);
  1956. /**
  1957. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1958. * @param renderWidth defines the rendering width
  1959. * @param renderHeight defines the rendering height
  1960. * @returns a new Viewport
  1961. */
  1962. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1963. /**
  1964. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1965. * @param renderWidth defines the rendering width
  1966. * @param renderHeight defines the rendering height
  1967. * @param ref defines the target viewport
  1968. * @returns the current viewport
  1969. */
  1970. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1971. /**
  1972. * Returns a new Viewport copied from the current one
  1973. * @returns a new Viewport
  1974. */
  1975. clone(): Viewport;
  1976. }
  1977. }
  1978. declare module "babylonjs/Misc/arrayTools" {
  1979. /**
  1980. * Class containing a set of static utilities functions for arrays.
  1981. */
  1982. export class ArrayTools {
  1983. /**
  1984. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1985. * @param size the number of element to construct and put in the array
  1986. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1987. * @returns a new array filled with new objects
  1988. */
  1989. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1990. }
  1991. }
  1992. declare module "babylonjs/Maths/math.plane" {
  1993. import { DeepImmutable } from "babylonjs/types";
  1994. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1995. /**
  1996. * Represents a plane by the equation ax + by + cz + d = 0
  1997. */
  1998. export class Plane {
  1999. private static _TmpMatrix;
  2000. /**
  2001. * Normal of the plane (a,b,c)
  2002. */
  2003. normal: Vector3;
  2004. /**
  2005. * d component of the plane
  2006. */
  2007. d: number;
  2008. /**
  2009. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2010. * @param a a component of the plane
  2011. * @param b b component of the plane
  2012. * @param c c component of the plane
  2013. * @param d d component of the plane
  2014. */
  2015. constructor(a: number, b: number, c: number, d: number);
  2016. /**
  2017. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2018. */
  2019. asArray(): number[];
  2020. /**
  2021. * @returns a new plane copied from the current Plane.
  2022. */
  2023. clone(): Plane;
  2024. /**
  2025. * @returns the string "Plane".
  2026. */
  2027. getClassName(): string;
  2028. /**
  2029. * @returns the Plane hash code.
  2030. */
  2031. getHashCode(): number;
  2032. /**
  2033. * Normalize the current Plane in place.
  2034. * @returns the updated Plane.
  2035. */
  2036. normalize(): Plane;
  2037. /**
  2038. * Applies a transformation the plane and returns the result
  2039. * @param transformation the transformation matrix to be applied to the plane
  2040. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2041. */
  2042. transform(transformation: DeepImmutable<Matrix>): Plane;
  2043. /**
  2044. * Compute the dot product between the point and the plane normal
  2045. * @param point point to calculate the dot product with
  2046. * @returns the dot product (float) of the point coordinates and the plane normal.
  2047. */
  2048. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2049. /**
  2050. * Updates the current Plane from the plane defined by the three given points.
  2051. * @param point1 one of the points used to contruct the plane
  2052. * @param point2 one of the points used to contruct the plane
  2053. * @param point3 one of the points used to contruct the plane
  2054. * @returns the updated Plane.
  2055. */
  2056. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2057. /**
  2058. * Checks if the plane is facing a given direction
  2059. * @param direction the direction to check if the plane is facing
  2060. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2061. * @returns True is the vector "direction" is the same side than the plane normal.
  2062. */
  2063. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2064. /**
  2065. * Calculates the distance to a point
  2066. * @param point point to calculate distance to
  2067. * @returns the signed distance (float) from the given point to the Plane.
  2068. */
  2069. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2070. /**
  2071. * Creates a plane from an array
  2072. * @param array the array to create a plane from
  2073. * @returns a new Plane from the given array.
  2074. */
  2075. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2076. /**
  2077. * Creates a plane from three points
  2078. * @param point1 point used to create the plane
  2079. * @param point2 point used to create the plane
  2080. * @param point3 point used to create the plane
  2081. * @returns a new Plane defined by the three given points.
  2082. */
  2083. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2084. /**
  2085. * Creates a plane from an origin point and a normal
  2086. * @param origin origin of the plane to be constructed
  2087. * @param normal normal of the plane to be constructed
  2088. * @returns a new Plane the normal vector to this plane at the given origin point.
  2089. * Note : the vector "normal" is updated because normalized.
  2090. */
  2091. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2092. /**
  2093. * Calculates the distance from a plane and a point
  2094. * @param origin origin of the plane to be constructed
  2095. * @param normal normal of the plane to be constructed
  2096. * @param point point to calculate distance to
  2097. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2098. */
  2099. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2100. }
  2101. }
  2102. declare module "babylonjs/Engines/performanceConfigurator" {
  2103. /** @hidden */
  2104. export class PerformanceConfigurator {
  2105. /** @hidden */
  2106. static MatrixUse64Bits: boolean;
  2107. /** @hidden */
  2108. static MatrixTrackPrecisionChange: boolean;
  2109. /** @hidden */
  2110. static MatrixCurrentType: any;
  2111. /** @hidden */
  2112. static MatrixTrackedMatrices: Array<any> | null;
  2113. /** @hidden */
  2114. static SetMatrixPrecision(use64bits: boolean): void;
  2115. }
  2116. }
  2117. declare module "babylonjs/Maths/math.vector" {
  2118. import { Viewport } from "babylonjs/Maths/math.viewport";
  2119. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2120. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2121. import { Plane } from "babylonjs/Maths/math.plane";
  2122. /**
  2123. * Class representing a vector containing 2 coordinates
  2124. */
  2125. export class Vector2 {
  2126. /** defines the first coordinate */
  2127. x: number;
  2128. /** defines the second coordinate */
  2129. y: number;
  2130. /**
  2131. * Creates a new Vector2 from the given x and y coordinates
  2132. * @param x defines the first coordinate
  2133. * @param y defines the second coordinate
  2134. */
  2135. constructor(
  2136. /** defines the first coordinate */
  2137. x?: number,
  2138. /** defines the second coordinate */
  2139. y?: number);
  2140. /**
  2141. * Gets a string with the Vector2 coordinates
  2142. * @returns a string with the Vector2 coordinates
  2143. */
  2144. toString(): string;
  2145. /**
  2146. * Gets class name
  2147. * @returns the string "Vector2"
  2148. */
  2149. getClassName(): string;
  2150. /**
  2151. * Gets current vector hash code
  2152. * @returns the Vector2 hash code as a number
  2153. */
  2154. getHashCode(): number;
  2155. /**
  2156. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2157. * @param array defines the source array
  2158. * @param index defines the offset in source array
  2159. * @returns the current Vector2
  2160. */
  2161. toArray(array: FloatArray, index?: number): Vector2;
  2162. /**
  2163. * Update the current vector from an array
  2164. * @param array defines the destination array
  2165. * @param index defines the offset in the destination array
  2166. * @returns the current Vector3
  2167. */
  2168. fromArray(array: FloatArray, index?: number): Vector2;
  2169. /**
  2170. * Copy the current vector to an array
  2171. * @returns a new array with 2 elements: the Vector2 coordinates.
  2172. */
  2173. asArray(): number[];
  2174. /**
  2175. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2176. * @param source defines the source Vector2
  2177. * @returns the current updated Vector2
  2178. */
  2179. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2180. /**
  2181. * Sets the Vector2 coordinates with the given floats
  2182. * @param x defines the first coordinate
  2183. * @param y defines the second coordinate
  2184. * @returns the current updated Vector2
  2185. */
  2186. copyFromFloats(x: number, y: number): Vector2;
  2187. /**
  2188. * Sets the Vector2 coordinates with the given floats
  2189. * @param x defines the first coordinate
  2190. * @param y defines the second coordinate
  2191. * @returns the current updated Vector2
  2192. */
  2193. set(x: number, y: number): Vector2;
  2194. /**
  2195. * Add another vector with the current one
  2196. * @param otherVector defines the other vector
  2197. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2198. */
  2199. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2202. * @param otherVector defines the other vector
  2203. * @param result defines the target vector
  2204. * @returns the unmodified current Vector2
  2205. */
  2206. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2207. /**
  2208. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. addVector3(otherVector: Vector3): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2221. * @param otherVector defines the other vector
  2222. * @returns a new Vector2
  2223. */
  2224. subtract(otherVector: Vector2): Vector2;
  2225. /**
  2226. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2227. * @param otherVector defines the other vector
  2228. * @param result defines the target vector
  2229. * @returns the unmodified current Vector2
  2230. */
  2231. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2232. /**
  2233. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @returns the current updated Vector2
  2236. */
  2237. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2238. /**
  2239. * Multiplies in place the current Vector2 coordinates by the given ones
  2240. * @param otherVector defines the other vector
  2241. * @returns the current updated Vector2
  2242. */
  2243. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2246. * @param otherVector defines the other vector
  2247. * @returns a new Vector2
  2248. */
  2249. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2250. /**
  2251. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2252. * @param otherVector defines the other vector
  2253. * @param result defines the target vector
  2254. * @returns the unmodified current Vector2
  2255. */
  2256. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2257. /**
  2258. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2259. * @param x defines the first coordinate
  2260. * @param y defines the second coordinate
  2261. * @returns a new Vector2
  2262. */
  2263. multiplyByFloats(x: number, y: number): Vector2;
  2264. /**
  2265. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2266. * @param otherVector defines the other vector
  2267. * @returns a new Vector2
  2268. */
  2269. divide(otherVector: Vector2): Vector2;
  2270. /**
  2271. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2272. * @param otherVector defines the other vector
  2273. * @param result defines the target vector
  2274. * @returns the unmodified current Vector2
  2275. */
  2276. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2277. /**
  2278. * Divides the current Vector2 coordinates by the given ones
  2279. * @param otherVector defines the other vector
  2280. * @returns the current updated Vector2
  2281. */
  2282. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2283. /**
  2284. * Gets a new Vector2 with current Vector2 negated coordinates
  2285. * @returns a new Vector2
  2286. */
  2287. negate(): Vector2;
  2288. /**
  2289. * Negate this vector in place
  2290. * @returns this
  2291. */
  2292. negateInPlace(): Vector2;
  2293. /**
  2294. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2295. * @param result defines the Vector3 object where to store the result
  2296. * @returns the current Vector2
  2297. */
  2298. negateToRef(result: Vector2): Vector2;
  2299. /**
  2300. * Multiply the Vector2 coordinates by scale
  2301. * @param scale defines the scaling factor
  2302. * @returns the current updated Vector2
  2303. */
  2304. scaleInPlace(scale: number): Vector2;
  2305. /**
  2306. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2307. * @param scale defines the scaling factor
  2308. * @returns a new Vector2
  2309. */
  2310. scale(scale: number): Vector2;
  2311. /**
  2312. * Scale the current Vector2 values by a factor to a given Vector2
  2313. * @param scale defines the scale factor
  2314. * @param result defines the Vector2 object where to store the result
  2315. * @returns the unmodified current Vector2
  2316. */
  2317. scaleToRef(scale: number, result: Vector2): Vector2;
  2318. /**
  2319. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2320. * @param scale defines the scale factor
  2321. * @param result defines the Vector2 object where to store the result
  2322. * @returns the unmodified current Vector2
  2323. */
  2324. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2325. /**
  2326. * Gets a boolean if two vectors are equals
  2327. * @param otherVector defines the other vector
  2328. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2329. */
  2330. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2331. /**
  2332. * Gets a boolean if two vectors are equals (using an epsilon value)
  2333. * @param otherVector defines the other vector
  2334. * @param epsilon defines the minimal distance to consider equality
  2335. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2336. */
  2337. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2338. /**
  2339. * Gets a new Vector2 from current Vector2 floored values
  2340. * @returns a new Vector2
  2341. */
  2342. floor(): Vector2;
  2343. /**
  2344. * Gets a new Vector2 from current Vector2 floored values
  2345. * @returns a new Vector2
  2346. */
  2347. fract(): Vector2;
  2348. /**
  2349. * Gets the length of the vector
  2350. * @returns the vector length (float)
  2351. */
  2352. length(): number;
  2353. /**
  2354. * Gets the vector squared length
  2355. * @returns the vector squared length (float)
  2356. */
  2357. lengthSquared(): number;
  2358. /**
  2359. * Normalize the vector
  2360. * @returns the current updated Vector2
  2361. */
  2362. normalize(): Vector2;
  2363. /**
  2364. * Gets a new Vector2 copied from the Vector2
  2365. * @returns a new Vector2
  2366. */
  2367. clone(): Vector2;
  2368. /**
  2369. * Gets a new Vector2(0, 0)
  2370. * @returns a new Vector2
  2371. */
  2372. static Zero(): Vector2;
  2373. /**
  2374. * Gets a new Vector2(1, 1)
  2375. * @returns a new Vector2
  2376. */
  2377. static One(): Vector2;
  2378. /**
  2379. * Gets a new Vector2 set from the given index element of the given array
  2380. * @param array defines the data source
  2381. * @param offset defines the offset in the data source
  2382. * @returns a new Vector2
  2383. */
  2384. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2385. /**
  2386. * Sets "result" from the given index element of the given array
  2387. * @param array defines the data source
  2388. * @param offset defines the offset in the data source
  2389. * @param result defines the target vector
  2390. */
  2391. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2392. /**
  2393. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2394. * @param value1 defines 1st point of control
  2395. * @param value2 defines 2nd point of control
  2396. * @param value3 defines 3rd point of control
  2397. * @param value4 defines 4th point of control
  2398. * @param amount defines the interpolation factor
  2399. * @returns a new Vector2
  2400. */
  2401. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2402. /**
  2403. * 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".
  2404. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2405. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2406. * @param value defines the value to clamp
  2407. * @param min defines the lower limit
  2408. * @param max defines the upper limit
  2409. * @returns a new Vector2
  2410. */
  2411. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2414. * @param value1 defines the 1st control point
  2415. * @param tangent1 defines the outgoing tangent
  2416. * @param value2 defines the 2nd control point
  2417. * @param tangent2 defines the incoming tangent
  2418. * @param amount defines the interpolation factor
  2419. * @returns a new Vector2
  2420. */
  2421. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2422. /**
  2423. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2424. * @param start defines the start vector
  2425. * @param end defines the end vector
  2426. * @param amount defines the interpolation factor
  2427. * @returns a new Vector2
  2428. */
  2429. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2430. /**
  2431. * Gets the dot product of the vector "left" and the vector "right"
  2432. * @param left defines first vector
  2433. * @param right defines second vector
  2434. * @returns the dot product (float)
  2435. */
  2436. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2437. /**
  2438. * Returns a new Vector2 equal to the normalized given vector
  2439. * @param vector defines the vector to normalize
  2440. * @returns a new Vector2
  2441. */
  2442. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2443. /**
  2444. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2445. * @param left defines 1st vector
  2446. * @param right defines 2nd vector
  2447. * @returns a new Vector2
  2448. */
  2449. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2450. /**
  2451. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2452. * @param left defines 1st vector
  2453. * @param right defines 2nd vector
  2454. * @returns a new Vector2
  2455. */
  2456. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2457. /**
  2458. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2459. * @param vector defines the vector to transform
  2460. * @param transformation defines the matrix to apply
  2461. * @returns a new Vector2
  2462. */
  2463. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2464. /**
  2465. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2466. * @param vector defines the vector to transform
  2467. * @param transformation defines the matrix to apply
  2468. * @param result defines the target vector
  2469. */
  2470. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2471. /**
  2472. * Determines if a given vector is included in a triangle
  2473. * @param p defines the vector to test
  2474. * @param p0 defines 1st triangle point
  2475. * @param p1 defines 2nd triangle point
  2476. * @param p2 defines 3rd triangle point
  2477. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2478. */
  2479. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2480. /**
  2481. * Gets the distance between the vectors "value1" and "value2"
  2482. * @param value1 defines first vector
  2483. * @param value2 defines second vector
  2484. * @returns the distance between vectors
  2485. */
  2486. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2487. /**
  2488. * Returns the squared distance between the vectors "value1" and "value2"
  2489. * @param value1 defines first vector
  2490. * @param value2 defines second vector
  2491. * @returns the squared distance between vectors
  2492. */
  2493. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2494. /**
  2495. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2496. * @param value1 defines first vector
  2497. * @param value2 defines second vector
  2498. * @returns a new Vector2
  2499. */
  2500. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2501. /**
  2502. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2503. * @param p defines the middle point
  2504. * @param segA defines one point of the segment
  2505. * @param segB defines the other point of the segment
  2506. * @returns the shortest distance
  2507. */
  2508. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2509. }
  2510. /**
  2511. * Class used to store (x,y,z) vector representation
  2512. * A Vector3 is the main object used in 3D geometry
  2513. * It can represent etiher the coordinates of a point the space, either a direction
  2514. * Reminder: js uses a left handed forward facing system
  2515. */
  2516. export class Vector3 {
  2517. private static _UpReadOnly;
  2518. private static _ZeroReadOnly;
  2519. /** @hidden */
  2520. _x: number;
  2521. /** @hidden */
  2522. _y: number;
  2523. /** @hidden */
  2524. _z: number;
  2525. /** @hidden */
  2526. _isDirty: boolean;
  2527. /** Gets or sets the x coordinate */
  2528. get x(): number;
  2529. set x(value: number);
  2530. /** Gets or sets the y coordinate */
  2531. get y(): number;
  2532. set y(value: number);
  2533. /** Gets or sets the z coordinate */
  2534. get z(): number;
  2535. set z(value: number);
  2536. /**
  2537. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2538. * @param x defines the first coordinates (on X axis)
  2539. * @param y defines the second coordinates (on Y axis)
  2540. * @param z defines the third coordinates (on Z axis)
  2541. */
  2542. constructor(x?: number, y?: number, z?: number);
  2543. /**
  2544. * Creates a string representation of the Vector3
  2545. * @returns a string with the Vector3 coordinates.
  2546. */
  2547. toString(): string;
  2548. /**
  2549. * Gets the class name
  2550. * @returns the string "Vector3"
  2551. */
  2552. getClassName(): string;
  2553. /**
  2554. * Creates the Vector3 hash code
  2555. * @returns a number which tends to be unique between Vector3 instances
  2556. */
  2557. getHashCode(): number;
  2558. /**
  2559. * Creates an array containing three elements : the coordinates of the Vector3
  2560. * @returns a new array of numbers
  2561. */
  2562. asArray(): number[];
  2563. /**
  2564. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2565. * @param array defines the destination array
  2566. * @param index defines the offset in the destination array
  2567. * @returns the current Vector3
  2568. */
  2569. toArray(array: FloatArray, index?: number): Vector3;
  2570. /**
  2571. * Update the current vector from an array
  2572. * @param array defines the destination array
  2573. * @param index defines the offset in the destination array
  2574. * @returns the current Vector3
  2575. */
  2576. fromArray(array: FloatArray, index?: number): Vector3;
  2577. /**
  2578. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2579. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2580. */
  2581. toQuaternion(): Quaternion;
  2582. /**
  2583. * Adds the given vector to the current Vector3
  2584. * @param otherVector defines the second operand
  2585. * @returns the current updated Vector3
  2586. */
  2587. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2588. /**
  2589. * Adds the given coordinates to the current Vector3
  2590. * @param x defines the x coordinate of the operand
  2591. * @param y defines the y coordinate of the operand
  2592. * @param z defines the z coordinate of the operand
  2593. * @returns the current updated Vector3
  2594. */
  2595. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2596. /**
  2597. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2598. * @param otherVector defines the second operand
  2599. * @returns the resulting Vector3
  2600. */
  2601. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2602. /**
  2603. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2604. * @param otherVector defines the second operand
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the current Vector3
  2607. */
  2608. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2609. /**
  2610. * Subtract the given vector from the current Vector3
  2611. * @param otherVector defines the second operand
  2612. * @returns the current updated Vector3
  2613. */
  2614. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2615. /**
  2616. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2617. * @param otherVector defines the second operand
  2618. * @returns the resulting Vector3
  2619. */
  2620. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2621. /**
  2622. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2623. * @param otherVector defines the second operand
  2624. * @param result defines the Vector3 object where to store the result
  2625. * @returns the current Vector3
  2626. */
  2627. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2628. /**
  2629. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2630. * @param x defines the x coordinate of the operand
  2631. * @param y defines the y coordinate of the operand
  2632. * @param z defines the z coordinate of the operand
  2633. * @returns the resulting Vector3
  2634. */
  2635. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2636. /**
  2637. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2638. * @param x defines the x coordinate of the operand
  2639. * @param y defines the y coordinate of the operand
  2640. * @param z defines the z coordinate of the operand
  2641. * @param result defines the Vector3 object where to store the result
  2642. * @returns the current Vector3
  2643. */
  2644. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2645. /**
  2646. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2647. * @returns a new Vector3
  2648. */
  2649. negate(): Vector3;
  2650. /**
  2651. * Negate this vector in place
  2652. * @returns this
  2653. */
  2654. negateInPlace(): Vector3;
  2655. /**
  2656. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2657. * @param result defines the Vector3 object where to store the result
  2658. * @returns the current Vector3
  2659. */
  2660. negateToRef(result: Vector3): Vector3;
  2661. /**
  2662. * Multiplies the Vector3 coordinates by the float "scale"
  2663. * @param scale defines the multiplier factor
  2664. * @returns the current updated Vector3
  2665. */
  2666. scaleInPlace(scale: number): Vector3;
  2667. /**
  2668. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2669. * @param scale defines the multiplier factor
  2670. * @returns a new Vector3
  2671. */
  2672. scale(scale: number): Vector3;
  2673. /**
  2674. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2675. * @param scale defines the multiplier factor
  2676. * @param result defines the Vector3 object where to store the result
  2677. * @returns the current Vector3
  2678. */
  2679. scaleToRef(scale: number, result: Vector3): Vector3;
  2680. /**
  2681. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2682. * @param scale defines the scale factor
  2683. * @param result defines the Vector3 object where to store the result
  2684. * @returns the unmodified current Vector3
  2685. */
  2686. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2687. /**
  2688. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2689. * @param origin defines the origin of the projection ray
  2690. * @param plane defines the plane to project to
  2691. * @returns the projected vector3
  2692. */
  2693. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2694. /**
  2695. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2696. * @param origin defines the origin of the projection ray
  2697. * @param plane defines the plane to project to
  2698. * @param result defines the Vector3 where to store the result
  2699. */
  2700. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2701. /**
  2702. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2703. * @param otherVector defines the second operand
  2704. * @returns true if both vectors are equals
  2705. */
  2706. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2707. /**
  2708. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2709. * @param otherVector defines the second operand
  2710. * @param epsilon defines the minimal distance to define values as equals
  2711. * @returns true if both vectors are distant less than epsilon
  2712. */
  2713. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2714. /**
  2715. * Returns true if the current Vector3 coordinates equals the given floats
  2716. * @param x defines the x coordinate of the operand
  2717. * @param y defines the y coordinate of the operand
  2718. * @param z defines the z coordinate of the operand
  2719. * @returns true if both vectors are equals
  2720. */
  2721. equalsToFloats(x: number, y: number, z: number): boolean;
  2722. /**
  2723. * Multiplies the current Vector3 coordinates by the given ones
  2724. * @param otherVector defines the second operand
  2725. * @returns the current updated Vector3
  2726. */
  2727. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2728. /**
  2729. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2730. * @param otherVector defines the second operand
  2731. * @returns the new Vector3
  2732. */
  2733. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2734. /**
  2735. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2736. * @param otherVector defines the second operand
  2737. * @param result defines the Vector3 object where to store the result
  2738. * @returns the current Vector3
  2739. */
  2740. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2743. * @param x defines the x coordinate of the operand
  2744. * @param y defines the y coordinate of the operand
  2745. * @param z defines the z coordinate of the operand
  2746. * @returns the new Vector3
  2747. */
  2748. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2751. * @param otherVector defines the second operand
  2752. * @returns the new Vector3
  2753. */
  2754. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2755. /**
  2756. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2757. * @param otherVector defines the second operand
  2758. * @param result defines the Vector3 object where to store the result
  2759. * @returns the current Vector3
  2760. */
  2761. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2762. /**
  2763. * Divides the current Vector3 coordinates by the given ones.
  2764. * @param otherVector defines the second operand
  2765. * @returns the current updated Vector3
  2766. */
  2767. divideInPlace(otherVector: Vector3): Vector3;
  2768. /**
  2769. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2770. * @param other defines the second operand
  2771. * @returns the current updated Vector3
  2772. */
  2773. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2774. /**
  2775. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2776. * @param other defines the second operand
  2777. * @returns the current updated Vector3
  2778. */
  2779. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2780. /**
  2781. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2782. * @param x defines the x coordinate of the operand
  2783. * @param y defines the y coordinate of the operand
  2784. * @param z defines the z coordinate of the operand
  2785. * @returns the current updated Vector3
  2786. */
  2787. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2788. /**
  2789. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2790. * @param x defines the x coordinate of the operand
  2791. * @param y defines the y coordinate of the operand
  2792. * @param z defines the z coordinate of the operand
  2793. * @returns the current updated Vector3
  2794. */
  2795. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2796. /**
  2797. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2798. * Check if is non uniform within a certain amount of decimal places to account for this
  2799. * @param epsilon the amount the values can differ
  2800. * @returns if the the vector is non uniform to a certain number of decimal places
  2801. */
  2802. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2803. /**
  2804. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2805. */
  2806. get isNonUniform(): boolean;
  2807. /**
  2808. * Gets a new Vector3 from current Vector3 floored values
  2809. * @returns a new Vector3
  2810. */
  2811. floor(): Vector3;
  2812. /**
  2813. * Gets a new Vector3 from current Vector3 floored values
  2814. * @returns a new Vector3
  2815. */
  2816. fract(): Vector3;
  2817. /**
  2818. * Gets the length of the Vector3
  2819. * @returns the length of the Vector3
  2820. */
  2821. length(): number;
  2822. /**
  2823. * Gets the squared length of the Vector3
  2824. * @returns squared length of the Vector3
  2825. */
  2826. lengthSquared(): number;
  2827. /**
  2828. * Normalize the current Vector3.
  2829. * Please note that this is an in place operation.
  2830. * @returns the current updated Vector3
  2831. */
  2832. normalize(): Vector3;
  2833. /**
  2834. * Reorders the x y z properties of the vector in place
  2835. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2836. * @returns the current updated vector
  2837. */
  2838. reorderInPlace(order: string): this;
  2839. /**
  2840. * Rotates the vector around 0,0,0 by a quaternion
  2841. * @param quaternion the rotation quaternion
  2842. * @param result vector to store the result
  2843. * @returns the resulting vector
  2844. */
  2845. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2846. /**
  2847. * Rotates a vector around a given point
  2848. * @param quaternion the rotation quaternion
  2849. * @param point the point to rotate around
  2850. * @param result vector to store the result
  2851. * @returns the resulting vector
  2852. */
  2853. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2854. /**
  2855. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2856. * The cross product is then orthogonal to both current and "other"
  2857. * @param other defines the right operand
  2858. * @returns the cross product
  2859. */
  2860. cross(other: Vector3): Vector3;
  2861. /**
  2862. * Normalize the current Vector3 with the given input length.
  2863. * Please note that this is an in place operation.
  2864. * @param len the length of the vector
  2865. * @returns the current updated Vector3
  2866. */
  2867. normalizeFromLength(len: number): Vector3;
  2868. /**
  2869. * Normalize the current Vector3 to a new vector
  2870. * @returns the new Vector3
  2871. */
  2872. normalizeToNew(): Vector3;
  2873. /**
  2874. * Normalize the current Vector3 to the reference
  2875. * @param reference define the Vector3 to update
  2876. * @returns the updated Vector3
  2877. */
  2878. normalizeToRef(reference: Vector3): Vector3;
  2879. /**
  2880. * Creates a new Vector3 copied from the current Vector3
  2881. * @returns the new Vector3
  2882. */
  2883. clone(): Vector3;
  2884. /**
  2885. * Copies the given vector coordinates to the current Vector3 ones
  2886. * @param source defines the source Vector3
  2887. * @returns the current updated Vector3
  2888. */
  2889. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2890. /**
  2891. * Copies the given floats to the current Vector3 coordinates
  2892. * @param x defines the x coordinate of the operand
  2893. * @param y defines the y coordinate of the operand
  2894. * @param z defines the z coordinate of the operand
  2895. * @returns the current updated Vector3
  2896. */
  2897. copyFromFloats(x: number, y: number, z: number): Vector3;
  2898. /**
  2899. * Copies the given floats to the current Vector3 coordinates
  2900. * @param x defines the x coordinate of the operand
  2901. * @param y defines the y coordinate of the operand
  2902. * @param z defines the z coordinate of the operand
  2903. * @returns the current updated Vector3
  2904. */
  2905. set(x: number, y: number, z: number): Vector3;
  2906. /**
  2907. * Copies the given float to the current Vector3 coordinates
  2908. * @param v defines the x, y and z coordinates of the operand
  2909. * @returns the current updated Vector3
  2910. */
  2911. setAll(v: number): Vector3;
  2912. /**
  2913. * Get the clip factor between two vectors
  2914. * @param vector0 defines the first operand
  2915. * @param vector1 defines the second operand
  2916. * @param axis defines the axis to use
  2917. * @param size defines the size along the axis
  2918. * @returns the clip factor
  2919. */
  2920. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2921. /**
  2922. * Get angle between two vectors
  2923. * @param vector0 angle between vector0 and vector1
  2924. * @param vector1 angle between vector0 and vector1
  2925. * @param normal direction of the normal
  2926. * @return the angle between vector0 and vector1
  2927. */
  2928. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2929. /**
  2930. * Returns a new Vector3 set from the index "offset" of the given array
  2931. * @param array defines the source array
  2932. * @param offset defines the offset in the source array
  2933. * @returns the new Vector3
  2934. */
  2935. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2938. * @param array defines the source array
  2939. * @param offset defines the offset in the source array
  2940. * @returns the new Vector3
  2941. * @deprecated Please use FromArray instead.
  2942. */
  2943. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2944. /**
  2945. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2946. * @param array defines the source array
  2947. * @param offset defines the offset in the source array
  2948. * @param result defines the Vector3 where to store the result
  2949. */
  2950. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2951. /**
  2952. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2953. * @param array defines the source array
  2954. * @param offset defines the offset in the source array
  2955. * @param result defines the Vector3 where to store the result
  2956. * @deprecated Please use FromArrayToRef instead.
  2957. */
  2958. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2959. /**
  2960. * Sets the given vector "result" with the given floats.
  2961. * @param x defines the x coordinate of the source
  2962. * @param y defines the y coordinate of the source
  2963. * @param z defines the z coordinate of the source
  2964. * @param result defines the Vector3 where to store the result
  2965. */
  2966. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2967. /**
  2968. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2969. * @returns a new empty Vector3
  2970. */
  2971. static Zero(): Vector3;
  2972. /**
  2973. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2974. * @returns a new unit Vector3
  2975. */
  2976. static One(): Vector3;
  2977. /**
  2978. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2979. * @returns a new up Vector3
  2980. */
  2981. static Up(): Vector3;
  2982. /**
  2983. * Gets a up Vector3 that must not be updated
  2984. */
  2985. static get UpReadOnly(): DeepImmutable<Vector3>;
  2986. /**
  2987. * Gets a zero Vector3 that must not be updated
  2988. */
  2989. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2990. /**
  2991. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2992. * @returns a new down Vector3
  2993. */
  2994. static Down(): Vector3;
  2995. /**
  2996. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2997. * @param rightHandedSystem is the scene right-handed (negative z)
  2998. * @returns a new forward Vector3
  2999. */
  3000. static Forward(rightHandedSystem?: boolean): Vector3;
  3001. /**
  3002. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3003. * @param rightHandedSystem is the scene right-handed (negative-z)
  3004. * @returns a new forward Vector3
  3005. */
  3006. static Backward(rightHandedSystem?: boolean): Vector3;
  3007. /**
  3008. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3009. * @returns a new right Vector3
  3010. */
  3011. static Right(): Vector3;
  3012. /**
  3013. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3014. * @returns a new left Vector3
  3015. */
  3016. static Left(): Vector3;
  3017. /**
  3018. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3019. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3020. * @param vector defines the Vector3 to transform
  3021. * @param transformation defines the transformation matrix
  3022. * @returns the transformed Vector3
  3023. */
  3024. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3025. /**
  3026. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3027. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3028. * @param vector defines the Vector3 to transform
  3029. * @param transformation defines the transformation matrix
  3030. * @param result defines the Vector3 where to store the result
  3031. */
  3032. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3033. /**
  3034. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3035. * This method computes tranformed coordinates only, not transformed direction vectors
  3036. * @param x define the x coordinate of the source vector
  3037. * @param y define the y coordinate of the source vector
  3038. * @param z define the z coordinate of the source vector
  3039. * @param transformation defines the transformation matrix
  3040. * @param result defines the Vector3 where to store the result
  3041. */
  3042. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3043. /**
  3044. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3045. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3046. * @param vector defines the Vector3 to transform
  3047. * @param transformation defines the transformation matrix
  3048. * @returns the new Vector3
  3049. */
  3050. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3051. /**
  3052. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3053. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3054. * @param vector defines the Vector3 to transform
  3055. * @param transformation defines the transformation matrix
  3056. * @param result defines the Vector3 where to store the result
  3057. */
  3058. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3059. /**
  3060. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3061. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3062. * @param x define the x coordinate of the source vector
  3063. * @param y define the y coordinate of the source vector
  3064. * @param z define the z coordinate of the source vector
  3065. * @param transformation defines the transformation matrix
  3066. * @param result defines the Vector3 where to store the result
  3067. */
  3068. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3069. /**
  3070. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3071. * @param value1 defines the first control point
  3072. * @param value2 defines the second control point
  3073. * @param value3 defines the third control point
  3074. * @param value4 defines the fourth control point
  3075. * @param amount defines the amount on the spline to use
  3076. * @returns the new Vector3
  3077. */
  3078. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3079. /**
  3080. * 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"
  3081. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3082. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3083. * @param value defines the current value
  3084. * @param min defines the lower range value
  3085. * @param max defines the upper range value
  3086. * @returns the new Vector3
  3087. */
  3088. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3089. /**
  3090. * 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"
  3091. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3092. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3093. * @param value defines the current value
  3094. * @param min defines the lower range value
  3095. * @param max defines the upper range value
  3096. * @param result defines the Vector3 where to store the result
  3097. */
  3098. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3099. /**
  3100. * Checks if a given vector is inside a specific range
  3101. * @param v defines the vector to test
  3102. * @param min defines the minimum range
  3103. * @param max defines the maximum range
  3104. */
  3105. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3106. /**
  3107. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3108. * @param value1 defines the first control point
  3109. * @param tangent1 defines the first tangent vector
  3110. * @param value2 defines the second control point
  3111. * @param tangent2 defines the second tangent vector
  3112. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3113. * @returns the new Vector3
  3114. */
  3115. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3116. /**
  3117. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3118. * @param start defines the start value
  3119. * @param end defines the end value
  3120. * @param amount max defines amount between both (between 0 and 1)
  3121. * @returns the new Vector3
  3122. */
  3123. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3124. /**
  3125. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3126. * @param start defines the start value
  3127. * @param end defines the end value
  3128. * @param amount max defines amount between both (between 0 and 1)
  3129. * @param result defines the Vector3 where to store the result
  3130. */
  3131. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3132. /**
  3133. * Returns the dot product (float) between the vectors "left" and "right"
  3134. * @param left defines the left operand
  3135. * @param right defines the right operand
  3136. * @returns the dot product
  3137. */
  3138. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3139. /**
  3140. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3141. * The cross product is then orthogonal to both "left" and "right"
  3142. * @param left defines the left operand
  3143. * @param right defines the right operand
  3144. * @returns the cross product
  3145. */
  3146. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3147. /**
  3148. * Sets the given vector "result" with the cross product of "left" and "right"
  3149. * The cross product is then orthogonal to both "left" and "right"
  3150. * @param left defines the left operand
  3151. * @param right defines the right operand
  3152. * @param result defines the Vector3 where to store the result
  3153. */
  3154. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3155. /**
  3156. * Returns a new Vector3 as the normalization of the given vector
  3157. * @param vector defines the Vector3 to normalize
  3158. * @returns the new Vector3
  3159. */
  3160. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3161. /**
  3162. * Sets the given vector "result" with the normalization of the given first vector
  3163. * @param vector defines the Vector3 to normalize
  3164. * @param result defines the Vector3 where to store the result
  3165. */
  3166. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3167. /**
  3168. * Project a Vector3 onto screen space
  3169. * @param vector defines the Vector3 to project
  3170. * @param world defines the world matrix to use
  3171. * @param transform defines the transform (view x projection) matrix to use
  3172. * @param viewport defines the screen viewport to use
  3173. * @returns the new Vector3
  3174. */
  3175. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3176. /**
  3177. * Project a Vector3 onto screen space to reference
  3178. * @param vector defines the Vector3 to project
  3179. * @param world defines the world matrix to use
  3180. * @param transform defines the transform (view x projection) matrix to use
  3181. * @param viewport defines the screen viewport to use
  3182. * @param result the vector in which the screen space will be stored
  3183. * @returns the new Vector3
  3184. */
  3185. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3186. /** @hidden */
  3187. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3188. /**
  3189. * Unproject from screen space to object space
  3190. * @param source defines the screen space Vector3 to use
  3191. * @param viewportWidth defines the current width of the viewport
  3192. * @param viewportHeight defines the current height of the viewport
  3193. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3194. * @param transform defines the transform (view x projection) matrix to use
  3195. * @returns the new Vector3
  3196. */
  3197. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3198. /**
  3199. * Unproject from screen space to object space
  3200. * @param source defines the screen space Vector3 to use
  3201. * @param viewportWidth defines the current width of the viewport
  3202. * @param viewportHeight defines the current height of the viewport
  3203. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3204. * @param view defines the view matrix to use
  3205. * @param projection defines the projection matrix to use
  3206. * @returns the new Vector3
  3207. */
  3208. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3209. /**
  3210. * Unproject from screen space to object space
  3211. * @param source defines the screen space Vector3 to use
  3212. * @param viewportWidth defines the current width of the viewport
  3213. * @param viewportHeight defines the current height of the viewport
  3214. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3215. * @param view defines the view matrix to use
  3216. * @param projection defines the projection matrix to use
  3217. * @param result defines the Vector3 where to store the result
  3218. */
  3219. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3220. /**
  3221. * Unproject from screen space to object space
  3222. * @param sourceX defines the screen space x coordinate to use
  3223. * @param sourceY defines the screen space y coordinate to use
  3224. * @param sourceZ defines the screen space z coordinate to use
  3225. * @param viewportWidth defines the current width of the viewport
  3226. * @param viewportHeight defines the current height of the viewport
  3227. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3228. * @param view defines the view matrix to use
  3229. * @param projection defines the projection matrix to use
  3230. * @param result defines the Vector3 where to store the result
  3231. */
  3232. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3233. /**
  3234. * Gets the minimal coordinate values between two Vector3
  3235. * @param left defines the first operand
  3236. * @param right defines the second operand
  3237. * @returns the new Vector3
  3238. */
  3239. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3240. /**
  3241. * Gets the maximal coordinate values between two Vector3
  3242. * @param left defines the first operand
  3243. * @param right defines the second operand
  3244. * @returns the new Vector3
  3245. */
  3246. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3247. /**
  3248. * Returns the distance between the vectors "value1" and "value2"
  3249. * @param value1 defines the first operand
  3250. * @param value2 defines the second operand
  3251. * @returns the distance
  3252. */
  3253. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3254. /**
  3255. * Returns the squared distance between the vectors "value1" and "value2"
  3256. * @param value1 defines the first operand
  3257. * @param value2 defines the second operand
  3258. * @returns the squared distance
  3259. */
  3260. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3261. /**
  3262. * Returns a new Vector3 located at the center between "value1" and "value2"
  3263. * @param value1 defines the first operand
  3264. * @param value2 defines the second operand
  3265. * @returns the new Vector3
  3266. */
  3267. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3268. /**
  3269. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3270. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3271. * to something in order to rotate it from its local system to the given target system
  3272. * Note: axis1, axis2 and axis3 are normalized during this operation
  3273. * @param axis1 defines the first axis
  3274. * @param axis2 defines the second axis
  3275. * @param axis3 defines the third axis
  3276. * @returns a new Vector3
  3277. */
  3278. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3279. /**
  3280. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3281. * @param axis1 defines the first axis
  3282. * @param axis2 defines the second axis
  3283. * @param axis3 defines the third axis
  3284. * @param ref defines the Vector3 where to store the result
  3285. */
  3286. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3287. }
  3288. /**
  3289. * Vector4 class created for EulerAngle class conversion to Quaternion
  3290. */
  3291. export class Vector4 {
  3292. /** x value of the vector */
  3293. x: number;
  3294. /** y value of the vector */
  3295. y: number;
  3296. /** z value of the vector */
  3297. z: number;
  3298. /** w value of the vector */
  3299. w: number;
  3300. /**
  3301. * Creates a Vector4 object from the given floats.
  3302. * @param x x value of the vector
  3303. * @param y y value of the vector
  3304. * @param z z value of the vector
  3305. * @param w w value of the vector
  3306. */
  3307. constructor(
  3308. /** x value of the vector */
  3309. x: number,
  3310. /** y value of the vector */
  3311. y: number,
  3312. /** z value of the vector */
  3313. z: number,
  3314. /** w value of the vector */
  3315. w: number);
  3316. /**
  3317. * Returns the string with the Vector4 coordinates.
  3318. * @returns a string containing all the vector values
  3319. */
  3320. toString(): string;
  3321. /**
  3322. * Returns the string "Vector4".
  3323. * @returns "Vector4"
  3324. */
  3325. getClassName(): string;
  3326. /**
  3327. * Returns the Vector4 hash code.
  3328. * @returns a unique hash code
  3329. */
  3330. getHashCode(): number;
  3331. /**
  3332. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3333. * @returns the resulting array
  3334. */
  3335. asArray(): number[];
  3336. /**
  3337. * Populates the given array from the given index with the Vector4 coordinates.
  3338. * @param array array to populate
  3339. * @param index index of the array to start at (default: 0)
  3340. * @returns the Vector4.
  3341. */
  3342. toArray(array: FloatArray, index?: number): Vector4;
  3343. /**
  3344. * Update the current vector from an array
  3345. * @param array defines the destination array
  3346. * @param index defines the offset in the destination array
  3347. * @returns the current Vector3
  3348. */
  3349. fromArray(array: FloatArray, index?: number): Vector4;
  3350. /**
  3351. * Adds the given vector to the current Vector4.
  3352. * @param otherVector the vector to add
  3353. * @returns the updated Vector4.
  3354. */
  3355. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3356. /**
  3357. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3358. * @param otherVector the vector to add
  3359. * @returns the resulting vector
  3360. */
  3361. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3362. /**
  3363. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3364. * @param otherVector the vector to add
  3365. * @param result the vector to store the result
  3366. * @returns the current Vector4.
  3367. */
  3368. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3369. /**
  3370. * Subtract in place the given vector from the current Vector4.
  3371. * @param otherVector the vector to subtract
  3372. * @returns the updated Vector4.
  3373. */
  3374. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3375. /**
  3376. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3377. * @param otherVector the vector to add
  3378. * @returns the new vector with the result
  3379. */
  3380. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3381. /**
  3382. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3383. * @param otherVector the vector to subtract
  3384. * @param result the vector to store the result
  3385. * @returns the current Vector4.
  3386. */
  3387. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3388. /**
  3389. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3390. */
  3391. /**
  3392. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3393. * @param x value to subtract
  3394. * @param y value to subtract
  3395. * @param z value to subtract
  3396. * @param w value to subtract
  3397. * @returns new vector containing the result
  3398. */
  3399. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3400. /**
  3401. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3402. * @param x value to subtract
  3403. * @param y value to subtract
  3404. * @param z value to subtract
  3405. * @param w value to subtract
  3406. * @param result the vector to store the result in
  3407. * @returns the current Vector4.
  3408. */
  3409. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3410. /**
  3411. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3412. * @returns a new vector with the negated values
  3413. */
  3414. negate(): Vector4;
  3415. /**
  3416. * Negate this vector in place
  3417. * @returns this
  3418. */
  3419. negateInPlace(): Vector4;
  3420. /**
  3421. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3422. * @param result defines the Vector3 object where to store the result
  3423. * @returns the current Vector4
  3424. */
  3425. negateToRef(result: Vector4): Vector4;
  3426. /**
  3427. * Multiplies the current Vector4 coordinates by scale (float).
  3428. * @param scale the number to scale with
  3429. * @returns the updated Vector4.
  3430. */
  3431. scaleInPlace(scale: number): Vector4;
  3432. /**
  3433. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3434. * @param scale the number to scale with
  3435. * @returns a new vector with the result
  3436. */
  3437. scale(scale: number): Vector4;
  3438. /**
  3439. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3440. * @param scale the number to scale with
  3441. * @param result a vector to store the result in
  3442. * @returns the current Vector4.
  3443. */
  3444. scaleToRef(scale: number, result: Vector4): Vector4;
  3445. /**
  3446. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3447. * @param scale defines the scale factor
  3448. * @param result defines the Vector4 object where to store the result
  3449. * @returns the unmodified current Vector4
  3450. */
  3451. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3452. /**
  3453. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3454. * @param otherVector the vector to compare against
  3455. * @returns true if they are equal
  3456. */
  3457. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3458. /**
  3459. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3460. * @param otherVector vector to compare against
  3461. * @param epsilon (Default: very small number)
  3462. * @returns true if they are equal
  3463. */
  3464. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3465. /**
  3466. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3467. * @param x x value to compare against
  3468. * @param y y value to compare against
  3469. * @param z z value to compare against
  3470. * @param w w value to compare against
  3471. * @returns true if equal
  3472. */
  3473. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3474. /**
  3475. * Multiplies in place the current Vector4 by the given one.
  3476. * @param otherVector vector to multiple with
  3477. * @returns the updated Vector4.
  3478. */
  3479. multiplyInPlace(otherVector: Vector4): Vector4;
  3480. /**
  3481. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3482. * @param otherVector vector to multiple with
  3483. * @returns resulting new vector
  3484. */
  3485. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3488. * @param otherVector vector to multiple with
  3489. * @param result vector to store the result
  3490. * @returns the current Vector4.
  3491. */
  3492. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3493. /**
  3494. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3495. * @param x x value multiply with
  3496. * @param y y value multiply with
  3497. * @param z z value multiply with
  3498. * @param w w value multiply with
  3499. * @returns resulting new vector
  3500. */
  3501. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3502. /**
  3503. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3504. * @param otherVector vector to devide with
  3505. * @returns resulting new vector
  3506. */
  3507. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3508. /**
  3509. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3510. * @param otherVector vector to devide with
  3511. * @param result vector to store the result
  3512. * @returns the current Vector4.
  3513. */
  3514. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3515. /**
  3516. * Divides the current Vector3 coordinates by the given ones.
  3517. * @param otherVector vector to devide with
  3518. * @returns the updated Vector3.
  3519. */
  3520. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3521. /**
  3522. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3523. * @param other defines the second operand
  3524. * @returns the current updated Vector4
  3525. */
  3526. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3527. /**
  3528. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3529. * @param other defines the second operand
  3530. * @returns the current updated Vector4
  3531. */
  3532. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Gets a new Vector4 from current Vector4 floored values
  3535. * @returns a new Vector4
  3536. */
  3537. floor(): Vector4;
  3538. /**
  3539. * Gets a new Vector4 from current Vector3 floored values
  3540. * @returns a new Vector4
  3541. */
  3542. fract(): Vector4;
  3543. /**
  3544. * Returns the Vector4 length (float).
  3545. * @returns the length
  3546. */
  3547. length(): number;
  3548. /**
  3549. * Returns the Vector4 squared length (float).
  3550. * @returns the length squared
  3551. */
  3552. lengthSquared(): number;
  3553. /**
  3554. * Normalizes in place the Vector4.
  3555. * @returns the updated Vector4.
  3556. */
  3557. normalize(): Vector4;
  3558. /**
  3559. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3560. * @returns this converted to a new vector3
  3561. */
  3562. toVector3(): Vector3;
  3563. /**
  3564. * Returns a new Vector4 copied from the current one.
  3565. * @returns the new cloned vector
  3566. */
  3567. clone(): Vector4;
  3568. /**
  3569. * Updates the current Vector4 with the given one coordinates.
  3570. * @param source the source vector to copy from
  3571. * @returns the updated Vector4.
  3572. */
  3573. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3574. /**
  3575. * Updates the current Vector4 coordinates with the given floats.
  3576. * @param x float to copy from
  3577. * @param y float to copy from
  3578. * @param z float to copy from
  3579. * @param w float to copy from
  3580. * @returns the updated Vector4.
  3581. */
  3582. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3583. /**
  3584. * Updates the current Vector4 coordinates with the given floats.
  3585. * @param x float to set from
  3586. * @param y float to set from
  3587. * @param z float to set from
  3588. * @param w float to set from
  3589. * @returns the updated Vector4.
  3590. */
  3591. set(x: number, y: number, z: number, w: number): Vector4;
  3592. /**
  3593. * Copies the given float to the current Vector3 coordinates
  3594. * @param v defines the x, y, z and w coordinates of the operand
  3595. * @returns the current updated Vector3
  3596. */
  3597. setAll(v: number): Vector4;
  3598. /**
  3599. * Returns a new Vector4 set from the starting index of the given array.
  3600. * @param array the array to pull values from
  3601. * @param offset the offset into the array to start at
  3602. * @returns the new vector
  3603. */
  3604. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3605. /**
  3606. * Updates the given vector "result" from the starting index of the given array.
  3607. * @param array the array to pull values from
  3608. * @param offset the offset into the array to start at
  3609. * @param result the vector to store the result in
  3610. */
  3611. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3612. /**
  3613. * Updates the given vector "result" from the starting index of the given Float32Array.
  3614. * @param array the array to pull values from
  3615. * @param offset the offset into the array to start at
  3616. * @param result the vector to store the result in
  3617. */
  3618. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3619. /**
  3620. * Updates the given vector "result" coordinates from the given floats.
  3621. * @param x float to set from
  3622. * @param y float to set from
  3623. * @param z float to set from
  3624. * @param w float to set from
  3625. * @param result the vector to the floats in
  3626. */
  3627. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3628. /**
  3629. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3630. * @returns the new vector
  3631. */
  3632. static Zero(): Vector4;
  3633. /**
  3634. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3635. * @returns the new vector
  3636. */
  3637. static One(): Vector4;
  3638. /**
  3639. * Returns a new normalized Vector4 from the given one.
  3640. * @param vector the vector to normalize
  3641. * @returns the vector
  3642. */
  3643. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Updates the given vector "result" from the normalization of the given one.
  3646. * @param vector the vector to normalize
  3647. * @param result the vector to store the result in
  3648. */
  3649. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3650. /**
  3651. * Returns a vector with the minimum values from the left and right vectors
  3652. * @param left left vector to minimize
  3653. * @param right right vector to minimize
  3654. * @returns a new vector with the minimum of the left and right vector values
  3655. */
  3656. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3657. /**
  3658. * Returns a vector with the maximum values from the left and right vectors
  3659. * @param left left vector to maximize
  3660. * @param right right vector to maximize
  3661. * @returns a new vector with the maximum of the left and right vector values
  3662. */
  3663. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3664. /**
  3665. * Returns the distance (float) between the vectors "value1" and "value2".
  3666. * @param value1 value to calulate the distance between
  3667. * @param value2 value to calulate the distance between
  3668. * @return the distance between the two vectors
  3669. */
  3670. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3671. /**
  3672. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3673. * @param value1 value to calulate the distance between
  3674. * @param value2 value to calulate the distance between
  3675. * @return the distance between the two vectors squared
  3676. */
  3677. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3678. /**
  3679. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3680. * @param value1 value to calulate the center between
  3681. * @param value2 value to calulate the center between
  3682. * @return the center between the two vectors
  3683. */
  3684. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3685. /**
  3686. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3687. * This methods computes transformed normalized direction vectors only.
  3688. * @param vector the vector to transform
  3689. * @param transformation the transformation matrix to apply
  3690. * @returns the new vector
  3691. */
  3692. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3693. /**
  3694. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3695. * This methods computes transformed normalized direction vectors only.
  3696. * @param vector the vector to transform
  3697. * @param transformation the transformation matrix to apply
  3698. * @param result the vector to store the result in
  3699. */
  3700. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3701. /**
  3702. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3703. * This methods computes transformed normalized direction vectors only.
  3704. * @param x value to transform
  3705. * @param y value to transform
  3706. * @param z value to transform
  3707. * @param w value to transform
  3708. * @param transformation the transformation matrix to apply
  3709. * @param result the vector to store the results in
  3710. */
  3711. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3712. /**
  3713. * Creates a new Vector4 from a Vector3
  3714. * @param source defines the source data
  3715. * @param w defines the 4th component (default is 0)
  3716. * @returns a new Vector4
  3717. */
  3718. static FromVector3(source: Vector3, w?: number): Vector4;
  3719. }
  3720. /**
  3721. * Class used to store quaternion data
  3722. * @see https://en.wikipedia.org/wiki/Quaternion
  3723. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3724. */
  3725. export class Quaternion {
  3726. /** @hidden */
  3727. _x: number;
  3728. /** @hidden */
  3729. _y: number;
  3730. /** @hidden */
  3731. _z: number;
  3732. /** @hidden */
  3733. _w: number;
  3734. /** @hidden */
  3735. _isDirty: boolean;
  3736. /** Gets or sets the x coordinate */
  3737. get x(): number;
  3738. set x(value: number);
  3739. /** Gets or sets the y coordinate */
  3740. get y(): number;
  3741. set y(value: number);
  3742. /** Gets or sets the z coordinate */
  3743. get z(): number;
  3744. set z(value: number);
  3745. /** Gets or sets the w coordinate */
  3746. get w(): number;
  3747. set w(value: number);
  3748. /**
  3749. * Creates a new Quaternion from the given floats
  3750. * @param x defines the first component (0 by default)
  3751. * @param y defines the second component (0 by default)
  3752. * @param z defines the third component (0 by default)
  3753. * @param w defines the fourth component (1.0 by default)
  3754. */
  3755. constructor(x?: number, y?: number, z?: number, w?: number);
  3756. /**
  3757. * Gets a string representation for the current quaternion
  3758. * @returns a string with the Quaternion coordinates
  3759. */
  3760. toString(): string;
  3761. /**
  3762. * Gets the class name of the quaternion
  3763. * @returns the string "Quaternion"
  3764. */
  3765. getClassName(): string;
  3766. /**
  3767. * Gets a hash code for this quaternion
  3768. * @returns the quaternion hash code
  3769. */
  3770. getHashCode(): number;
  3771. /**
  3772. * Copy the quaternion to an array
  3773. * @returns a new array populated with 4 elements from the quaternion coordinates
  3774. */
  3775. asArray(): number[];
  3776. /**
  3777. * Check if two quaternions are equals
  3778. * @param otherQuaternion defines the second operand
  3779. * @return true if the current quaternion and the given one coordinates are strictly equals
  3780. */
  3781. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3782. /**
  3783. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3784. * @param otherQuaternion defines the other quaternion
  3785. * @param epsilon defines the minimal distance to consider equality
  3786. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3787. */
  3788. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3789. /**
  3790. * Clone the current quaternion
  3791. * @returns a new quaternion copied from the current one
  3792. */
  3793. clone(): Quaternion;
  3794. /**
  3795. * Copy a quaternion to the current one
  3796. * @param other defines the other quaternion
  3797. * @returns the updated current quaternion
  3798. */
  3799. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3800. /**
  3801. * Updates the current quaternion with the given float coordinates
  3802. * @param x defines the x coordinate
  3803. * @param y defines the y coordinate
  3804. * @param z defines the z coordinate
  3805. * @param w defines the w coordinate
  3806. * @returns the updated current quaternion
  3807. */
  3808. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3809. /**
  3810. * Updates the current quaternion from the given float coordinates
  3811. * @param x defines the x coordinate
  3812. * @param y defines the y coordinate
  3813. * @param z defines the z coordinate
  3814. * @param w defines the w coordinate
  3815. * @returns the updated current quaternion
  3816. */
  3817. set(x: number, y: number, z: number, w: number): Quaternion;
  3818. /**
  3819. * Adds two quaternions
  3820. * @param other defines the second operand
  3821. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3822. */
  3823. add(other: DeepImmutable<Quaternion>): Quaternion;
  3824. /**
  3825. * Add a quaternion to the current one
  3826. * @param other defines the quaternion to add
  3827. * @returns the current quaternion
  3828. */
  3829. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3830. /**
  3831. * Subtract two quaternions
  3832. * @param other defines the second operand
  3833. * @returns a new quaternion as the subtraction result of the given one from the current one
  3834. */
  3835. subtract(other: Quaternion): Quaternion;
  3836. /**
  3837. * Multiplies the current quaternion by a scale factor
  3838. * @param value defines the scale factor
  3839. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3840. */
  3841. scale(value: number): Quaternion;
  3842. /**
  3843. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3844. * @param scale defines the scale factor
  3845. * @param result defines the Quaternion object where to store the result
  3846. * @returns the unmodified current quaternion
  3847. */
  3848. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3849. /**
  3850. * Multiplies in place the current quaternion by a scale factor
  3851. * @param value defines the scale factor
  3852. * @returns the current modified quaternion
  3853. */
  3854. scaleInPlace(value: number): Quaternion;
  3855. /**
  3856. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3857. * @param scale defines the scale factor
  3858. * @param result defines the Quaternion object where to store the result
  3859. * @returns the unmodified current quaternion
  3860. */
  3861. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3862. /**
  3863. * Multiplies two quaternions
  3864. * @param q1 defines the second operand
  3865. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3866. */
  3867. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3868. /**
  3869. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3870. * @param q1 defines the second operand
  3871. * @param result defines the target quaternion
  3872. * @returns the current quaternion
  3873. */
  3874. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3875. /**
  3876. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3877. * @param q1 defines the second operand
  3878. * @returns the currentupdated quaternion
  3879. */
  3880. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3881. /**
  3882. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3883. * @param ref defines the target quaternion
  3884. * @returns the current quaternion
  3885. */
  3886. conjugateToRef(ref: Quaternion): Quaternion;
  3887. /**
  3888. * Conjugates in place (1-q) the current quaternion
  3889. * @returns the current updated quaternion
  3890. */
  3891. conjugateInPlace(): Quaternion;
  3892. /**
  3893. * Conjugates in place (1-q) the current quaternion
  3894. * @returns a new quaternion
  3895. */
  3896. conjugate(): Quaternion;
  3897. /**
  3898. * Gets length of current quaternion
  3899. * @returns the quaternion length (float)
  3900. */
  3901. length(): number;
  3902. /**
  3903. * Normalize in place the current quaternion
  3904. * @returns the current updated quaternion
  3905. */
  3906. normalize(): Quaternion;
  3907. /**
  3908. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3909. * @param order is a reserved parameter and is ignored for now
  3910. * @returns a new Vector3 containing the Euler angles
  3911. */
  3912. toEulerAngles(order?: string): Vector3;
  3913. /**
  3914. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3915. * @param result defines the vector which will be filled with the Euler angles
  3916. * @returns the current unchanged quaternion
  3917. */
  3918. toEulerAnglesToRef(result: Vector3): Quaternion;
  3919. /**
  3920. * Updates the given rotation matrix with the current quaternion values
  3921. * @param result defines the target matrix
  3922. * @returns the current unchanged quaternion
  3923. */
  3924. toRotationMatrix(result: Matrix): Quaternion;
  3925. /**
  3926. * Updates the current quaternion from the given rotation matrix values
  3927. * @param matrix defines the source matrix
  3928. * @returns the current updated quaternion
  3929. */
  3930. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3931. /**
  3932. * Creates a new quaternion from a rotation matrix
  3933. * @param matrix defines the source matrix
  3934. * @returns a new quaternion created from the given rotation matrix values
  3935. */
  3936. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3937. /**
  3938. * Updates the given quaternion with the given rotation matrix values
  3939. * @param matrix defines the source matrix
  3940. * @param result defines the target quaternion
  3941. */
  3942. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3943. /**
  3944. * Returns the dot product (float) between the quaternions "left" and "right"
  3945. * @param left defines the left operand
  3946. * @param right defines the right operand
  3947. * @returns the dot product
  3948. */
  3949. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3950. /**
  3951. * Checks if the two quaternions are close to each other
  3952. * @param quat0 defines the first quaternion to check
  3953. * @param quat1 defines the second quaternion to check
  3954. * @returns true if the two quaternions are close to each other
  3955. */
  3956. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3957. /**
  3958. * Creates an empty quaternion
  3959. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3960. */
  3961. static Zero(): Quaternion;
  3962. /**
  3963. * Inverse a given quaternion
  3964. * @param q defines the source quaternion
  3965. * @returns a new quaternion as the inverted current quaternion
  3966. */
  3967. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3968. /**
  3969. * Inverse a given quaternion
  3970. * @param q defines the source quaternion
  3971. * @param result the quaternion the result will be stored in
  3972. * @returns the result quaternion
  3973. */
  3974. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3975. /**
  3976. * Creates an identity quaternion
  3977. * @returns the identity quaternion
  3978. */
  3979. static Identity(): Quaternion;
  3980. /**
  3981. * Gets a boolean indicating if the given quaternion is identity
  3982. * @param quaternion defines the quaternion to check
  3983. * @returns true if the quaternion is identity
  3984. */
  3985. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3986. /**
  3987. * Creates a quaternion from a rotation around an axis
  3988. * @param axis defines the axis to use
  3989. * @param angle defines the angle to use
  3990. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3991. */
  3992. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3993. /**
  3994. * Creates a rotation around an axis and stores it into the given quaternion
  3995. * @param axis defines the axis to use
  3996. * @param angle defines the angle to use
  3997. * @param result defines the target quaternion
  3998. * @returns the target quaternion
  3999. */
  4000. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4001. /**
  4002. * Creates a new quaternion from data stored into an array
  4003. * @param array defines the data source
  4004. * @param offset defines the offset in the source array where the data starts
  4005. * @returns a new quaternion
  4006. */
  4007. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4008. /**
  4009. * Updates the given quaternion "result" from the starting index of the given array.
  4010. * @param array the array to pull values from
  4011. * @param offset the offset into the array to start at
  4012. * @param result the quaternion to store the result in
  4013. */
  4014. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4015. /**
  4016. * Create a quaternion from Euler rotation angles
  4017. * @param x Pitch
  4018. * @param y Yaw
  4019. * @param z Roll
  4020. * @returns the new Quaternion
  4021. */
  4022. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4023. /**
  4024. * Updates a quaternion from Euler rotation angles
  4025. * @param x Pitch
  4026. * @param y Yaw
  4027. * @param z Roll
  4028. * @param result the quaternion to store the result
  4029. * @returns the updated quaternion
  4030. */
  4031. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4032. /**
  4033. * Create a quaternion from Euler rotation vector
  4034. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4035. * @returns the new Quaternion
  4036. */
  4037. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4038. /**
  4039. * Updates a quaternion from Euler rotation vector
  4040. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4041. * @param result the quaternion to store the result
  4042. * @returns the updated quaternion
  4043. */
  4044. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4045. /**
  4046. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4047. * @param yaw defines the rotation around Y axis
  4048. * @param pitch defines the rotation around X axis
  4049. * @param roll defines the rotation around Z axis
  4050. * @returns the new quaternion
  4051. */
  4052. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4053. /**
  4054. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4055. * @param yaw defines the rotation around Y axis
  4056. * @param pitch defines the rotation around X axis
  4057. * @param roll defines the rotation around Z axis
  4058. * @param result defines the target quaternion
  4059. */
  4060. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4061. /**
  4062. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4063. * @param alpha defines the rotation around first axis
  4064. * @param beta defines the rotation around second axis
  4065. * @param gamma defines the rotation around third axis
  4066. * @returns the new quaternion
  4067. */
  4068. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4069. /**
  4070. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4071. * @param alpha defines the rotation around first axis
  4072. * @param beta defines the rotation around second axis
  4073. * @param gamma defines the rotation around third axis
  4074. * @param result defines the target quaternion
  4075. */
  4076. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4077. /**
  4078. * 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)
  4079. * @param axis1 defines the first axis
  4080. * @param axis2 defines the second axis
  4081. * @param axis3 defines the third axis
  4082. * @returns the new quaternion
  4083. */
  4084. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4085. /**
  4086. * 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
  4087. * @param axis1 defines the first axis
  4088. * @param axis2 defines the second axis
  4089. * @param axis3 defines the third axis
  4090. * @param ref defines the target quaternion
  4091. */
  4092. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4093. /**
  4094. * Interpolates between two quaternions
  4095. * @param left defines first quaternion
  4096. * @param right defines second quaternion
  4097. * @param amount defines the gradient to use
  4098. * @returns the new interpolated quaternion
  4099. */
  4100. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4101. /**
  4102. * Interpolates between two quaternions and stores it into a target quaternion
  4103. * @param left defines first quaternion
  4104. * @param right defines second quaternion
  4105. * @param amount defines the gradient to use
  4106. * @param result defines the target quaternion
  4107. */
  4108. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4109. /**
  4110. * Interpolate between two quaternions using Hermite interpolation
  4111. * @param value1 defines first quaternion
  4112. * @param tangent1 defines the incoming tangent
  4113. * @param value2 defines second quaternion
  4114. * @param tangent2 defines the outgoing tangent
  4115. * @param amount defines the target quaternion
  4116. * @returns the new interpolated quaternion
  4117. */
  4118. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4119. }
  4120. /**
  4121. * Class used to store matrix data (4x4)
  4122. */
  4123. export class Matrix {
  4124. /**
  4125. * Gets the precision of matrix computations
  4126. */
  4127. static get Use64Bits(): boolean;
  4128. private static _updateFlagSeed;
  4129. private static _identityReadOnly;
  4130. private _isIdentity;
  4131. private _isIdentityDirty;
  4132. private _isIdentity3x2;
  4133. private _isIdentity3x2Dirty;
  4134. /**
  4135. * Gets the update flag of the matrix which is an unique number for the matrix.
  4136. * It will be incremented every time the matrix data change.
  4137. * You can use it to speed the comparison between two versions of the same matrix.
  4138. */
  4139. updateFlag: number;
  4140. private readonly _m;
  4141. /**
  4142. * Gets the internal data of the matrix
  4143. */
  4144. get m(): DeepImmutable<Float32Array | Array<number>>;
  4145. /** @hidden */
  4146. _markAsUpdated(): void;
  4147. /** @hidden */
  4148. private _updateIdentityStatus;
  4149. /**
  4150. * Creates an empty matrix (filled with zeros)
  4151. */
  4152. constructor();
  4153. /**
  4154. * Check if the current matrix is identity
  4155. * @returns true is the matrix is the identity matrix
  4156. */
  4157. isIdentity(): boolean;
  4158. /**
  4159. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4160. * @returns true is the matrix is the identity matrix
  4161. */
  4162. isIdentityAs3x2(): boolean;
  4163. /**
  4164. * Gets the determinant of the matrix
  4165. * @returns the matrix determinant
  4166. */
  4167. determinant(): number;
  4168. /**
  4169. * Returns the matrix as a Float32Array or Array<number>
  4170. * @returns the matrix underlying array
  4171. */
  4172. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4173. /**
  4174. * Returns the matrix as a Float32Array or Array<number>
  4175. * @returns the matrix underlying array.
  4176. */
  4177. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4178. /**
  4179. * Inverts the current matrix in place
  4180. * @returns the current inverted matrix
  4181. */
  4182. invert(): Matrix;
  4183. /**
  4184. * Sets all the matrix elements to zero
  4185. * @returns the current matrix
  4186. */
  4187. reset(): Matrix;
  4188. /**
  4189. * Adds the current matrix with a second one
  4190. * @param other defines the matrix to add
  4191. * @returns a new matrix as the addition of the current matrix and the given one
  4192. */
  4193. add(other: DeepImmutable<Matrix>): Matrix;
  4194. /**
  4195. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4196. * @param other defines the matrix to add
  4197. * @param result defines the target matrix
  4198. * @returns the current matrix
  4199. */
  4200. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4201. /**
  4202. * Adds in place the given matrix to the current matrix
  4203. * @param other defines the second operand
  4204. * @returns the current updated matrix
  4205. */
  4206. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4207. /**
  4208. * Sets the given matrix to the current inverted Matrix
  4209. * @param other defines the target matrix
  4210. * @returns the unmodified current matrix
  4211. */
  4212. invertToRef(other: Matrix): Matrix;
  4213. /**
  4214. * add a value at the specified position in the current Matrix
  4215. * @param index the index of the value within the matrix. between 0 and 15.
  4216. * @param value the value to be added
  4217. * @returns the current updated matrix
  4218. */
  4219. addAtIndex(index: number, value: number): Matrix;
  4220. /**
  4221. * mutiply the specified position in the current Matrix by a value
  4222. * @param index the index of the value within the matrix. between 0 and 15.
  4223. * @param value the value to be added
  4224. * @returns the current updated matrix
  4225. */
  4226. multiplyAtIndex(index: number, value: number): Matrix;
  4227. /**
  4228. * Inserts the translation vector (using 3 floats) in the current matrix
  4229. * @param x defines the 1st component of the translation
  4230. * @param y defines the 2nd component of the translation
  4231. * @param z defines the 3rd component of the translation
  4232. * @returns the current updated matrix
  4233. */
  4234. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4235. /**
  4236. * Adds the translation vector (using 3 floats) in the current matrix
  4237. * @param x defines the 1st component of the translation
  4238. * @param y defines the 2nd component of the translation
  4239. * @param z defines the 3rd component of the translation
  4240. * @returns the current updated matrix
  4241. */
  4242. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4243. /**
  4244. * Inserts the translation vector in the current matrix
  4245. * @param vector3 defines the translation to insert
  4246. * @returns the current updated matrix
  4247. */
  4248. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4249. /**
  4250. * Gets the translation value of the current matrix
  4251. * @returns a new Vector3 as the extracted translation from the matrix
  4252. */
  4253. getTranslation(): Vector3;
  4254. /**
  4255. * Fill a Vector3 with the extracted translation from the matrix
  4256. * @param result defines the Vector3 where to store the translation
  4257. * @returns the current matrix
  4258. */
  4259. getTranslationToRef(result: Vector3): Matrix;
  4260. /**
  4261. * Remove rotation and scaling part from the matrix
  4262. * @returns the updated matrix
  4263. */
  4264. removeRotationAndScaling(): Matrix;
  4265. /**
  4266. * Multiply two matrices
  4267. * @param other defines the second operand
  4268. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4269. */
  4270. multiply(other: DeepImmutable<Matrix>): Matrix;
  4271. /**
  4272. * Copy the current matrix from the given one
  4273. * @param other defines the source matrix
  4274. * @returns the current updated matrix
  4275. */
  4276. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4277. /**
  4278. * Populates the given array from the starting index with the current matrix values
  4279. * @param array defines the target array
  4280. * @param offset defines the offset in the target array where to start storing values
  4281. * @returns the current matrix
  4282. */
  4283. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4284. /**
  4285. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4286. * @param other defines the second operand
  4287. * @param result defines the matrix where to store the multiplication
  4288. * @returns the current matrix
  4289. */
  4290. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4291. /**
  4292. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4293. * @param other defines the second operand
  4294. * @param result defines the array where to store the multiplication
  4295. * @param offset defines the offset in the target array where to start storing values
  4296. * @returns the current matrix
  4297. */
  4298. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4299. /**
  4300. * Check equality between this matrix and a second one
  4301. * @param value defines the second matrix to compare
  4302. * @returns true is the current matrix and the given one values are strictly equal
  4303. */
  4304. equals(value: DeepImmutable<Matrix>): boolean;
  4305. /**
  4306. * Clone the current matrix
  4307. * @returns a new matrix from the current matrix
  4308. */
  4309. clone(): Matrix;
  4310. /**
  4311. * Returns the name of the current matrix class
  4312. * @returns the string "Matrix"
  4313. */
  4314. getClassName(): string;
  4315. /**
  4316. * Gets the hash code of the current matrix
  4317. * @returns the hash code
  4318. */
  4319. getHashCode(): number;
  4320. /**
  4321. * Decomposes the current Matrix into a translation, rotation and scaling components
  4322. * @param scale defines the scale vector3 given as a reference to update
  4323. * @param rotation defines the rotation quaternion given as a reference to update
  4324. * @param translation defines the translation vector3 given as a reference to update
  4325. * @returns true if operation was successful
  4326. */
  4327. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4328. /**
  4329. * Gets specific row of the matrix
  4330. * @param index defines the number of the row to get
  4331. * @returns the index-th row of the current matrix as a new Vector4
  4332. */
  4333. getRow(index: number): Nullable<Vector4>;
  4334. /**
  4335. * Sets the index-th row of the current matrix to the vector4 values
  4336. * @param index defines the number of the row to set
  4337. * @param row defines the target vector4
  4338. * @returns the updated current matrix
  4339. */
  4340. setRow(index: number, row: Vector4): Matrix;
  4341. /**
  4342. * Compute the transpose of the matrix
  4343. * @returns the new transposed matrix
  4344. */
  4345. transpose(): Matrix;
  4346. /**
  4347. * Compute the transpose of the matrix and store it in a given matrix
  4348. * @param result defines the target matrix
  4349. * @returns the current matrix
  4350. */
  4351. transposeToRef(result: Matrix): Matrix;
  4352. /**
  4353. * Sets the index-th row of the current matrix with the given 4 x float values
  4354. * @param index defines the row index
  4355. * @param x defines the x component to set
  4356. * @param y defines the y component to set
  4357. * @param z defines the z component to set
  4358. * @param w defines the w component to set
  4359. * @returns the updated current matrix
  4360. */
  4361. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4362. /**
  4363. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4364. * @param scale defines the scale factor
  4365. * @returns a new matrix
  4366. */
  4367. scale(scale: number): Matrix;
  4368. /**
  4369. * Scale the current matrix values by a factor to a given result matrix
  4370. * @param scale defines the scale factor
  4371. * @param result defines the matrix to store the result
  4372. * @returns the current matrix
  4373. */
  4374. scaleToRef(scale: number, result: Matrix): Matrix;
  4375. /**
  4376. * Scale the current matrix values by a factor and add the result to a given matrix
  4377. * @param scale defines the scale factor
  4378. * @param result defines the Matrix to store the result
  4379. * @returns the current matrix
  4380. */
  4381. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4382. /**
  4383. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4384. * @param ref matrix to store the result
  4385. */
  4386. toNormalMatrix(ref: Matrix): void;
  4387. /**
  4388. * Gets only rotation part of the current matrix
  4389. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4390. */
  4391. getRotationMatrix(): Matrix;
  4392. /**
  4393. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4394. * @param result defines the target matrix to store data to
  4395. * @returns the current matrix
  4396. */
  4397. getRotationMatrixToRef(result: Matrix): Matrix;
  4398. /**
  4399. * Toggles model matrix from being right handed to left handed in place and vice versa
  4400. */
  4401. toggleModelMatrixHandInPlace(): void;
  4402. /**
  4403. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4404. */
  4405. toggleProjectionMatrixHandInPlace(): void;
  4406. /**
  4407. * Creates a matrix from an array
  4408. * @param array defines the source array
  4409. * @param offset defines an offset in the source array
  4410. * @returns a new Matrix set from the starting index of the given array
  4411. */
  4412. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4413. /**
  4414. * Copy the content of an array into a given matrix
  4415. * @param array defines the source array
  4416. * @param offset defines an offset in the source array
  4417. * @param result defines the target matrix
  4418. */
  4419. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4420. /**
  4421. * Stores an array into a matrix after having multiplied each component by a given factor
  4422. * @param array defines the source array
  4423. * @param offset defines the offset in the source array
  4424. * @param scale defines the scaling factor
  4425. * @param result defines the target matrix
  4426. */
  4427. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4428. /**
  4429. * Gets an identity matrix that must not be updated
  4430. */
  4431. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4432. /**
  4433. * Stores a list of values (16) inside a given matrix
  4434. * @param initialM11 defines 1st value of 1st row
  4435. * @param initialM12 defines 2nd value of 1st row
  4436. * @param initialM13 defines 3rd value of 1st row
  4437. * @param initialM14 defines 4th value of 1st row
  4438. * @param initialM21 defines 1st value of 2nd row
  4439. * @param initialM22 defines 2nd value of 2nd row
  4440. * @param initialM23 defines 3rd value of 2nd row
  4441. * @param initialM24 defines 4th value of 2nd row
  4442. * @param initialM31 defines 1st value of 3rd row
  4443. * @param initialM32 defines 2nd value of 3rd row
  4444. * @param initialM33 defines 3rd value of 3rd row
  4445. * @param initialM34 defines 4th value of 3rd row
  4446. * @param initialM41 defines 1st value of 4th row
  4447. * @param initialM42 defines 2nd value of 4th row
  4448. * @param initialM43 defines 3rd value of 4th row
  4449. * @param initialM44 defines 4th value of 4th row
  4450. * @param result defines the target matrix
  4451. */
  4452. 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;
  4453. /**
  4454. * Creates new matrix from a list of values (16)
  4455. * @param initialM11 defines 1st value of 1st row
  4456. * @param initialM12 defines 2nd value of 1st row
  4457. * @param initialM13 defines 3rd value of 1st row
  4458. * @param initialM14 defines 4th value of 1st row
  4459. * @param initialM21 defines 1st value of 2nd row
  4460. * @param initialM22 defines 2nd value of 2nd row
  4461. * @param initialM23 defines 3rd value of 2nd row
  4462. * @param initialM24 defines 4th value of 2nd row
  4463. * @param initialM31 defines 1st value of 3rd row
  4464. * @param initialM32 defines 2nd value of 3rd row
  4465. * @param initialM33 defines 3rd value of 3rd row
  4466. * @param initialM34 defines 4th value of 3rd row
  4467. * @param initialM41 defines 1st value of 4th row
  4468. * @param initialM42 defines 2nd value of 4th row
  4469. * @param initialM43 defines 3rd value of 4th row
  4470. * @param initialM44 defines 4th value of 4th row
  4471. * @returns the new matrix
  4472. */
  4473. 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;
  4474. /**
  4475. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4476. * @param scale defines the scale vector3
  4477. * @param rotation defines the rotation quaternion
  4478. * @param translation defines the translation vector3
  4479. * @returns a new matrix
  4480. */
  4481. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4482. /**
  4483. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4484. * @param scale defines the scale vector3
  4485. * @param rotation defines the rotation quaternion
  4486. * @param translation defines the translation vector3
  4487. * @param result defines the target matrix
  4488. */
  4489. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4490. /**
  4491. * Creates a new identity matrix
  4492. * @returns a new identity matrix
  4493. */
  4494. static Identity(): Matrix;
  4495. /**
  4496. * Creates a new identity matrix and stores the result in a given matrix
  4497. * @param result defines the target matrix
  4498. */
  4499. static IdentityToRef(result: Matrix): void;
  4500. /**
  4501. * Creates a new zero matrix
  4502. * @returns a new zero matrix
  4503. */
  4504. static Zero(): Matrix;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the X axis
  4507. * @param angle defines the angle (in radians) to use
  4508. * @return the new matrix
  4509. */
  4510. static RotationX(angle: number): Matrix;
  4511. /**
  4512. * Creates a new matrix as the invert of a given matrix
  4513. * @param source defines the source matrix
  4514. * @returns the new matrix
  4515. */
  4516. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4517. /**
  4518. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4519. * @param angle defines the angle (in radians) to use
  4520. * @param result defines the target matrix
  4521. */
  4522. static RotationXToRef(angle: number, result: Matrix): void;
  4523. /**
  4524. * Creates a new rotation matrix for "angle" radians around the Y axis
  4525. * @param angle defines the angle (in radians) to use
  4526. * @return the new matrix
  4527. */
  4528. static RotationY(angle: number): Matrix;
  4529. /**
  4530. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4531. * @param angle defines the angle (in radians) to use
  4532. * @param result defines the target matrix
  4533. */
  4534. static RotationYToRef(angle: number, result: Matrix): void;
  4535. /**
  4536. * Creates a new rotation matrix for "angle" radians around the Z axis
  4537. * @param angle defines the angle (in radians) to use
  4538. * @return the new matrix
  4539. */
  4540. static RotationZ(angle: number): Matrix;
  4541. /**
  4542. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4543. * @param angle defines the angle (in radians) to use
  4544. * @param result defines the target matrix
  4545. */
  4546. static RotationZToRef(angle: number, result: Matrix): void;
  4547. /**
  4548. * Creates a new rotation matrix for "angle" radians around the given axis
  4549. * @param axis defines the axis to use
  4550. * @param angle defines the angle (in radians) to use
  4551. * @return the new matrix
  4552. */
  4553. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4554. /**
  4555. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4556. * @param axis defines the axis to use
  4557. * @param angle defines the angle (in radians) to use
  4558. * @param result defines the target matrix
  4559. */
  4560. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4561. /**
  4562. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4563. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4564. * @param from defines the vector to align
  4565. * @param to defines the vector to align to
  4566. * @param result defines the target matrix
  4567. */
  4568. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4569. /**
  4570. * Creates a rotation matrix
  4571. * @param yaw defines the yaw angle in radians (Y axis)
  4572. * @param pitch defines the pitch angle in radians (X axis)
  4573. * @param roll defines the roll angle in radians (Z axis)
  4574. * @returns the new rotation matrix
  4575. */
  4576. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4577. /**
  4578. * Creates a rotation matrix and stores it in a given matrix
  4579. * @param yaw defines the yaw angle in radians (Y axis)
  4580. * @param pitch defines the pitch angle in radians (X axis)
  4581. * @param roll defines the roll angle in radians (Z axis)
  4582. * @param result defines the target matrix
  4583. */
  4584. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4585. /**
  4586. * Creates a scaling matrix
  4587. * @param x defines the scale factor on X axis
  4588. * @param y defines the scale factor on Y axis
  4589. * @param z defines the scale factor on Z axis
  4590. * @returns the new matrix
  4591. */
  4592. static Scaling(x: number, y: number, z: number): Matrix;
  4593. /**
  4594. * Creates a scaling matrix and stores it in a given matrix
  4595. * @param x defines the scale factor on X axis
  4596. * @param y defines the scale factor on Y axis
  4597. * @param z defines the scale factor on Z axis
  4598. * @param result defines the target matrix
  4599. */
  4600. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4601. /**
  4602. * Creates a translation matrix
  4603. * @param x defines the translation on X axis
  4604. * @param y defines the translation on Y axis
  4605. * @param z defines the translationon Z axis
  4606. * @returns the new matrix
  4607. */
  4608. static Translation(x: number, y: number, z: number): Matrix;
  4609. /**
  4610. * Creates a translation matrix and stores it in a given matrix
  4611. * @param x defines the translation on X axis
  4612. * @param y defines the translation on Y axis
  4613. * @param z defines the translationon Z axis
  4614. * @param result defines the target matrix
  4615. */
  4616. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4617. /**
  4618. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4619. * @param startValue defines the start value
  4620. * @param endValue defines the end value
  4621. * @param gradient defines the gradient factor
  4622. * @returns the new matrix
  4623. */
  4624. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4625. /**
  4626. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4627. * @param startValue defines the start value
  4628. * @param endValue defines the end value
  4629. * @param gradient defines the gradient factor
  4630. * @param result defines the Matrix object where to store data
  4631. */
  4632. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4633. /**
  4634. * Builds a new matrix whose values are computed by:
  4635. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4636. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4637. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4638. * @param startValue defines the first matrix
  4639. * @param endValue defines the second matrix
  4640. * @param gradient defines the gradient between the two matrices
  4641. * @returns the new matrix
  4642. */
  4643. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4644. /**
  4645. * Update a matrix to values which are computed by:
  4646. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4647. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4648. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4649. * @param startValue defines the first matrix
  4650. * @param endValue defines the second matrix
  4651. * @param gradient defines the gradient between the two matrices
  4652. * @param result defines the target matrix
  4653. */
  4654. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4655. /**
  4656. * 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"
  4657. * This function works in left handed mode
  4658. * @param eye defines the final position of the entity
  4659. * @param target defines where the entity should look at
  4660. * @param up defines the up vector for the entity
  4661. * @returns the new matrix
  4662. */
  4663. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4664. /**
  4665. * 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".
  4666. * This function works in left handed mode
  4667. * @param eye defines the final position of the entity
  4668. * @param target defines where the entity should look at
  4669. * @param up defines the up vector for the entity
  4670. * @param result defines the target matrix
  4671. */
  4672. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4673. /**
  4674. * 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"
  4675. * This function works in right handed mode
  4676. * @param eye defines the final position of the entity
  4677. * @param target defines where the entity should look at
  4678. * @param up defines the up vector for the entity
  4679. * @returns the new matrix
  4680. */
  4681. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4682. /**
  4683. * 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".
  4684. * This function works in right handed mode
  4685. * @param eye defines the final position of the entity
  4686. * @param target defines where the entity should look at
  4687. * @param up defines the up vector for the entity
  4688. * @param result defines the target matrix
  4689. */
  4690. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4691. /**
  4692. * Create a left-handed orthographic projection matrix
  4693. * @param width defines the viewport width
  4694. * @param height defines the viewport height
  4695. * @param znear defines the near clip plane
  4696. * @param zfar defines the far clip plane
  4697. * @returns a new matrix as a left-handed orthographic projection matrix
  4698. */
  4699. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4700. /**
  4701. * Store a left-handed orthographic projection to a given matrix
  4702. * @param width defines the viewport width
  4703. * @param height defines the viewport height
  4704. * @param znear defines the near clip plane
  4705. * @param zfar defines the far clip plane
  4706. * @param result defines the target matrix
  4707. */
  4708. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4709. /**
  4710. * Create a left-handed orthographic projection matrix
  4711. * @param left defines the viewport left coordinate
  4712. * @param right defines the viewport right coordinate
  4713. * @param bottom defines the viewport bottom coordinate
  4714. * @param top defines the viewport top coordinate
  4715. * @param znear defines the near clip plane
  4716. * @param zfar defines the far clip plane
  4717. * @returns a new matrix as a left-handed orthographic projection matrix
  4718. */
  4719. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4720. /**
  4721. * Stores a left-handed orthographic projection into a given matrix
  4722. * @param left defines the viewport left coordinate
  4723. * @param right defines the viewport right coordinate
  4724. * @param bottom defines the viewport bottom coordinate
  4725. * @param top defines the viewport top coordinate
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @param result defines the target matrix
  4729. */
  4730. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4731. /**
  4732. * Creates a right-handed orthographic projection matrix
  4733. * @param left defines the viewport left coordinate
  4734. * @param right defines the viewport right coordinate
  4735. * @param bottom defines the viewport bottom coordinate
  4736. * @param top defines the viewport top coordinate
  4737. * @param znear defines the near clip plane
  4738. * @param zfar defines the far clip plane
  4739. * @returns a new matrix as a right-handed orthographic projection matrix
  4740. */
  4741. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4742. /**
  4743. * Stores a right-handed orthographic projection into a given matrix
  4744. * @param left defines the viewport left coordinate
  4745. * @param right defines the viewport right coordinate
  4746. * @param bottom defines the viewport bottom coordinate
  4747. * @param top defines the viewport top coordinate
  4748. * @param znear defines the near clip plane
  4749. * @param zfar defines the far clip plane
  4750. * @param result defines the target matrix
  4751. */
  4752. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4753. /**
  4754. * Creates a left-handed perspective projection matrix
  4755. * @param width defines the viewport width
  4756. * @param height defines the viewport height
  4757. * @param znear defines the near clip plane
  4758. * @param zfar defines the far clip plane
  4759. * @returns a new matrix as a left-handed perspective projection matrix
  4760. */
  4761. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4762. /**
  4763. * Creates a left-handed perspective projection matrix
  4764. * @param fov defines the horizontal field of view
  4765. * @param aspect defines the aspect ratio
  4766. * @param znear defines the near clip plane
  4767. * @param zfar defines the far clip plane
  4768. * @returns a new matrix as a left-handed perspective projection matrix
  4769. */
  4770. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4771. /**
  4772. * Stores a left-handed perspective projection into a given matrix
  4773. * @param fov defines the horizontal field of view
  4774. * @param aspect defines the aspect ratio
  4775. * @param znear defines the near clip plane
  4776. * @param zfar defines the far clip plane
  4777. * @param result defines the target matrix
  4778. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4779. */
  4780. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4781. /**
  4782. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4783. * @param fov defines the horizontal field of view
  4784. * @param aspect defines the aspect ratio
  4785. * @param znear defines the near clip plane
  4786. * @param zfar not used as infinity is used as far clip
  4787. * @param result defines the target matrix
  4788. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4789. */
  4790. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4791. /**
  4792. * Creates a right-handed perspective projection matrix
  4793. * @param fov defines the horizontal field of view
  4794. * @param aspect defines the aspect ratio
  4795. * @param znear defines the near clip plane
  4796. * @param zfar defines the far clip plane
  4797. * @returns a new matrix as a right-handed perspective projection matrix
  4798. */
  4799. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4800. /**
  4801. * Stores a right-handed perspective projection into a given matrix
  4802. * @param fov defines the horizontal field of view
  4803. * @param aspect defines the aspect ratio
  4804. * @param znear defines the near clip plane
  4805. * @param zfar defines the far clip plane
  4806. * @param result defines the target matrix
  4807. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4808. */
  4809. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4810. /**
  4811. * Stores a right-handed perspective projection into a given matrix
  4812. * @param fov defines the horizontal field of view
  4813. * @param aspect defines the aspect ratio
  4814. * @param znear defines the near clip plane
  4815. * @param zfar not used as infinity is used as far clip
  4816. * @param result defines the target matrix
  4817. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4818. */
  4819. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4820. /**
  4821. * Stores a perspective projection for WebVR info a given matrix
  4822. * @param fov defines the field of view
  4823. * @param znear defines the near clip plane
  4824. * @param zfar defines the far clip plane
  4825. * @param result defines the target matrix
  4826. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4827. */
  4828. static PerspectiveFovWebVRToRef(fov: {
  4829. upDegrees: number;
  4830. downDegrees: number;
  4831. leftDegrees: number;
  4832. rightDegrees: number;
  4833. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4834. /**
  4835. * Computes a complete transformation matrix
  4836. * @param viewport defines the viewport to use
  4837. * @param world defines the world matrix
  4838. * @param view defines the view matrix
  4839. * @param projection defines the projection matrix
  4840. * @param zmin defines the near clip plane
  4841. * @param zmax defines the far clip plane
  4842. * @returns the transformation matrix
  4843. */
  4844. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4845. /**
  4846. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4847. * @param matrix defines the matrix to use
  4848. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4849. */
  4850. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4851. /**
  4852. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4853. * @param matrix defines the matrix to use
  4854. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4855. */
  4856. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4857. /**
  4858. * Compute the transpose of a given matrix
  4859. * @param matrix defines the matrix to transpose
  4860. * @returns the new matrix
  4861. */
  4862. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4863. /**
  4864. * Compute the transpose of a matrix and store it in a target matrix
  4865. * @param matrix defines the matrix to transpose
  4866. * @param result defines the target matrix
  4867. */
  4868. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4869. /**
  4870. * Computes a reflection matrix from a plane
  4871. * @param plane defines the reflection plane
  4872. * @returns a new matrix
  4873. */
  4874. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4875. /**
  4876. * Computes a reflection matrix from a plane
  4877. * @param plane defines the reflection plane
  4878. * @param result defines the target matrix
  4879. */
  4880. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4881. /**
  4882. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4883. * @param xaxis defines the value of the 1st axis
  4884. * @param yaxis defines the value of the 2nd axis
  4885. * @param zaxis defines the value of the 3rd axis
  4886. * @param result defines the target matrix
  4887. */
  4888. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4889. /**
  4890. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4891. * @param quat defines the quaternion to use
  4892. * @param result defines the target matrix
  4893. */
  4894. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4895. }
  4896. /**
  4897. * @hidden
  4898. */
  4899. export class TmpVectors {
  4900. static Vector2: Vector2[];
  4901. static Vector3: Vector3[];
  4902. static Vector4: Vector4[];
  4903. static Quaternion: Quaternion[];
  4904. static Matrix: Matrix[];
  4905. }
  4906. }
  4907. declare module "babylonjs/Maths/math.path" {
  4908. import { DeepImmutable, Nullable } from "babylonjs/types";
  4909. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4910. /**
  4911. * Defines potential orientation for back face culling
  4912. */
  4913. export enum Orientation {
  4914. /**
  4915. * Clockwise
  4916. */
  4917. CW = 0,
  4918. /** Counter clockwise */
  4919. CCW = 1
  4920. }
  4921. /** Class used to represent a Bezier curve */
  4922. export class BezierCurve {
  4923. /**
  4924. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4925. * @param t defines the time
  4926. * @param x1 defines the left coordinate on X axis
  4927. * @param y1 defines the left coordinate on Y axis
  4928. * @param x2 defines the right coordinate on X axis
  4929. * @param y2 defines the right coordinate on Y axis
  4930. * @returns the interpolated value
  4931. */
  4932. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4933. }
  4934. /**
  4935. * Defines angle representation
  4936. */
  4937. export class Angle {
  4938. private _radians;
  4939. /**
  4940. * Creates an Angle object of "radians" radians (float).
  4941. * @param radians the angle in radians
  4942. */
  4943. constructor(radians: number);
  4944. /**
  4945. * Get value in degrees
  4946. * @returns the Angle value in degrees (float)
  4947. */
  4948. degrees(): number;
  4949. /**
  4950. * Get value in radians
  4951. * @returns the Angle value in radians (float)
  4952. */
  4953. radians(): number;
  4954. /**
  4955. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4956. * @param a defines first point as the origin
  4957. * @param b defines point
  4958. * @returns a new Angle
  4959. */
  4960. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4961. /**
  4962. * Gets a new Angle object from the given float in radians
  4963. * @param radians defines the angle value in radians
  4964. * @returns a new Angle
  4965. */
  4966. static FromRadians(radians: number): Angle;
  4967. /**
  4968. * Gets a new Angle object from the given float in degrees
  4969. * @param degrees defines the angle value in degrees
  4970. * @returns a new Angle
  4971. */
  4972. static FromDegrees(degrees: number): Angle;
  4973. }
  4974. /**
  4975. * This represents an arc in a 2d space.
  4976. */
  4977. export class Arc2 {
  4978. /** Defines the start point of the arc */
  4979. startPoint: Vector2;
  4980. /** Defines the mid point of the arc */
  4981. midPoint: Vector2;
  4982. /** Defines the end point of the arc */
  4983. endPoint: Vector2;
  4984. /**
  4985. * Defines the center point of the arc.
  4986. */
  4987. centerPoint: Vector2;
  4988. /**
  4989. * Defines the radius of the arc.
  4990. */
  4991. radius: number;
  4992. /**
  4993. * Defines the angle of the arc (from mid point to end point).
  4994. */
  4995. angle: Angle;
  4996. /**
  4997. * Defines the start angle of the arc (from start point to middle point).
  4998. */
  4999. startAngle: Angle;
  5000. /**
  5001. * Defines the orientation of the arc (clock wise/counter clock wise).
  5002. */
  5003. orientation: Orientation;
  5004. /**
  5005. * Creates an Arc object from the three given points : start, middle and end.
  5006. * @param startPoint Defines the start point of the arc
  5007. * @param midPoint Defines the midlle point of the arc
  5008. * @param endPoint Defines the end point of the arc
  5009. */
  5010. constructor(
  5011. /** Defines the start point of the arc */
  5012. startPoint: Vector2,
  5013. /** Defines the mid point of the arc */
  5014. midPoint: Vector2,
  5015. /** Defines the end point of the arc */
  5016. endPoint: Vector2);
  5017. }
  5018. /**
  5019. * Represents a 2D path made up of multiple 2D points
  5020. */
  5021. export class Path2 {
  5022. private _points;
  5023. private _length;
  5024. /**
  5025. * If the path start and end point are the same
  5026. */
  5027. closed: boolean;
  5028. /**
  5029. * Creates a Path2 object from the starting 2D coordinates x and y.
  5030. * @param x the starting points x value
  5031. * @param y the starting points y value
  5032. */
  5033. constructor(x: number, y: number);
  5034. /**
  5035. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5036. * @param x the added points x value
  5037. * @param y the added points y value
  5038. * @returns the updated Path2.
  5039. */
  5040. addLineTo(x: number, y: number): Path2;
  5041. /**
  5042. * 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.
  5043. * @param midX middle point x value
  5044. * @param midY middle point y value
  5045. * @param endX end point x value
  5046. * @param endY end point y value
  5047. * @param numberOfSegments (default: 36)
  5048. * @returns the updated Path2.
  5049. */
  5050. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5051. /**
  5052. * Closes the Path2.
  5053. * @returns the Path2.
  5054. */
  5055. close(): Path2;
  5056. /**
  5057. * Gets the sum of the distance between each sequential point in the path
  5058. * @returns the Path2 total length (float).
  5059. */
  5060. length(): number;
  5061. /**
  5062. * Gets the points which construct the path
  5063. * @returns the Path2 internal array of points.
  5064. */
  5065. getPoints(): Vector2[];
  5066. /**
  5067. * Retreives the point at the distance aways from the starting point
  5068. * @param normalizedLengthPosition the length along the path to retreive the point from
  5069. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5070. */
  5071. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5072. /**
  5073. * Creates a new path starting from an x and y position
  5074. * @param x starting x value
  5075. * @param y starting y value
  5076. * @returns a new Path2 starting at the coordinates (x, y).
  5077. */
  5078. static StartingAt(x: number, y: number): Path2;
  5079. }
  5080. /**
  5081. * Represents a 3D path made up of multiple 3D points
  5082. */
  5083. export class Path3D {
  5084. /**
  5085. * an array of Vector3, the curve axis of the Path3D
  5086. */
  5087. path: Vector3[];
  5088. private _curve;
  5089. private _distances;
  5090. private _tangents;
  5091. private _normals;
  5092. private _binormals;
  5093. private _raw;
  5094. private _alignTangentsWithPath;
  5095. private readonly _pointAtData;
  5096. /**
  5097. * new Path3D(path, normal, raw)
  5098. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5099. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5100. * @param path an array of Vector3, the curve axis of the Path3D
  5101. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5102. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5103. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5104. */
  5105. constructor(
  5106. /**
  5107. * an array of Vector3, the curve axis of the Path3D
  5108. */
  5109. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5110. /**
  5111. * Returns the Path3D array of successive Vector3 designing its curve.
  5112. * @returns the Path3D array of successive Vector3 designing its curve.
  5113. */
  5114. getCurve(): Vector3[];
  5115. /**
  5116. * Returns the Path3D array of successive Vector3 designing its curve.
  5117. * @returns the Path3D array of successive Vector3 designing its curve.
  5118. */
  5119. getPoints(): Vector3[];
  5120. /**
  5121. * @returns the computed length (float) of the path.
  5122. */
  5123. length(): number;
  5124. /**
  5125. * Returns an array populated with tangent vectors on each Path3D curve point.
  5126. * @returns an array populated with tangent vectors on each Path3D curve point.
  5127. */
  5128. getTangents(): Vector3[];
  5129. /**
  5130. * Returns an array populated with normal vectors on each Path3D curve point.
  5131. * @returns an array populated with normal vectors on each Path3D curve point.
  5132. */
  5133. getNormals(): Vector3[];
  5134. /**
  5135. * Returns an array populated with binormal vectors on each Path3D curve point.
  5136. * @returns an array populated with binormal vectors on each Path3D curve point.
  5137. */
  5138. getBinormals(): Vector3[];
  5139. /**
  5140. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5141. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5142. */
  5143. getDistances(): number[];
  5144. /**
  5145. * Returns an interpolated point along this path
  5146. * @param position the position of the point along this path, from 0.0 to 1.0
  5147. * @returns a new Vector3 as the point
  5148. */
  5149. getPointAt(position: number): Vector3;
  5150. /**
  5151. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5152. * @param position the position of the point along this path, from 0.0 to 1.0
  5153. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5154. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5155. */
  5156. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5157. /**
  5158. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5159. * @param position the position of the point along this path, from 0.0 to 1.0
  5160. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5161. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5162. */
  5163. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5164. /**
  5165. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5166. * @param position the position of the point along this path, from 0.0 to 1.0
  5167. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5168. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5169. */
  5170. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5171. /**
  5172. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5173. * @param position the position of the point along this path, from 0.0 to 1.0
  5174. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5175. */
  5176. getDistanceAt(position: number): number;
  5177. /**
  5178. * Returns the array index of the previous point of an interpolated point along this path
  5179. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5180. * @returns the array index
  5181. */
  5182. getPreviousPointIndexAt(position: number): number;
  5183. /**
  5184. * 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)
  5185. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5186. * @returns the sub position
  5187. */
  5188. getSubPositionAt(position: number): number;
  5189. /**
  5190. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5191. * @param target the vector of which to get the closest position to
  5192. * @returns the position of the closest virtual point on this path to the target vector
  5193. */
  5194. getClosestPositionTo(target: Vector3): number;
  5195. /**
  5196. * Returns a sub path (slice) of this path
  5197. * @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
  5198. * @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
  5199. * @returns a sub path (slice) of this path
  5200. */
  5201. slice(start?: number, end?: number): Path3D;
  5202. /**
  5203. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5204. * @param path path which all values are copied into the curves points
  5205. * @param firstNormal which should be projected onto the curve
  5206. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5207. * @returns the same object updated.
  5208. */
  5209. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5210. private _compute;
  5211. private _getFirstNonNullVector;
  5212. private _getLastNonNullVector;
  5213. private _normalVector;
  5214. /**
  5215. * Updates the point at data for an interpolated point along this curve
  5216. * @param position the position of the point along this curve, from 0.0 to 1.0
  5217. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5218. * @returns the (updated) point at data
  5219. */
  5220. private _updatePointAtData;
  5221. /**
  5222. * Updates the point at data from the specified parameters
  5223. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5224. * @param point the interpolated point
  5225. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5226. */
  5227. private _setPointAtData;
  5228. /**
  5229. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5230. */
  5231. private _updateInterpolationMatrix;
  5232. }
  5233. /**
  5234. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5235. * A Curve3 is designed from a series of successive Vector3.
  5236. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5237. */
  5238. export class Curve3 {
  5239. private _points;
  5240. private _length;
  5241. /**
  5242. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5243. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5244. * @param v1 (Vector3) the control point
  5245. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5246. * @param nbPoints (integer) the wanted number of points in the curve
  5247. * @returns the created Curve3
  5248. */
  5249. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5250. /**
  5251. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5252. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5253. * @param v1 (Vector3) the first control point
  5254. * @param v2 (Vector3) the second control point
  5255. * @param v3 (Vector3) the end point of the Cubic Bezier
  5256. * @param nbPoints (integer) the wanted number of points in the curve
  5257. * @returns the created Curve3
  5258. */
  5259. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5260. /**
  5261. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5262. * @param p1 (Vector3) the origin point of the Hermite Spline
  5263. * @param t1 (Vector3) the tangent vector at the origin point
  5264. * @param p2 (Vector3) the end point of the Hermite Spline
  5265. * @param t2 (Vector3) the tangent vector at the end point
  5266. * @param nbPoints (integer) the wanted number of points in the curve
  5267. * @returns the created Curve3
  5268. */
  5269. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5270. /**
  5271. * Returns a Curve3 object along a CatmullRom Spline curve :
  5272. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5273. * @param nbPoints (integer) the wanted number of points between each curve control points
  5274. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5275. * @returns the created Curve3
  5276. */
  5277. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5278. /**
  5279. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5280. * A Curve3 is designed from a series of successive Vector3.
  5281. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5282. * @param points points which make up the curve
  5283. */
  5284. constructor(points: Vector3[]);
  5285. /**
  5286. * @returns the Curve3 stored array of successive Vector3
  5287. */
  5288. getPoints(): Vector3[];
  5289. /**
  5290. * @returns the computed length (float) of the curve.
  5291. */
  5292. length(): number;
  5293. /**
  5294. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5295. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5296. * curveA and curveB keep unchanged.
  5297. * @param curve the curve to continue from this curve
  5298. * @returns the newly constructed curve
  5299. */
  5300. continue(curve: DeepImmutable<Curve3>): Curve3;
  5301. private _computeLength;
  5302. }
  5303. }
  5304. declare module "babylonjs/Animations/easing" {
  5305. /**
  5306. * This represents the main contract an easing function should follow.
  5307. * Easing functions are used throughout the animation system.
  5308. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5309. */
  5310. export interface IEasingFunction {
  5311. /**
  5312. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5313. * of the easing function.
  5314. * The link below provides some of the most common examples of easing functions.
  5315. * @see https://easings.net/
  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. * Base class used for every default easing function.
  5323. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5324. */
  5325. export class EasingFunction implements IEasingFunction {
  5326. /**
  5327. * Interpolation follows the mathematical formula associated with the easing function.
  5328. */
  5329. static readonly EASINGMODE_EASEIN: number;
  5330. /**
  5331. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5332. */
  5333. static readonly EASINGMODE_EASEOUT: number;
  5334. /**
  5335. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5336. */
  5337. static readonly EASINGMODE_EASEINOUT: number;
  5338. private _easingMode;
  5339. /**
  5340. * Sets the easing mode of the current function.
  5341. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5342. */
  5343. setEasingMode(easingMode: number): void;
  5344. /**
  5345. * Gets the current easing mode.
  5346. * @returns the easing mode
  5347. */
  5348. getEasingMode(): number;
  5349. /**
  5350. * @hidden
  5351. */
  5352. easeInCore(gradient: number): number;
  5353. /**
  5354. * Given an input gradient between 0 and 1, this returns the corresponding value
  5355. * of the easing function.
  5356. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5357. * @returns the corresponding value on the curve defined by the easing function
  5358. */
  5359. ease(gradient: number): number;
  5360. }
  5361. /**
  5362. * Easing function with a circle shape (see link below).
  5363. * @see https://easings.net/#easeInCirc
  5364. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5365. */
  5366. export class CircleEase extends EasingFunction implements IEasingFunction {
  5367. /** @hidden */
  5368. easeInCore(gradient: number): number;
  5369. }
  5370. /**
  5371. * Easing function with a ease back shape (see link below).
  5372. * @see https://easings.net/#easeInBack
  5373. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5374. */
  5375. export class BackEase extends EasingFunction implements IEasingFunction {
  5376. /** Defines the amplitude of the function */
  5377. amplitude: number;
  5378. /**
  5379. * Instantiates a back ease easing
  5380. * @see https://easings.net/#easeInBack
  5381. * @param amplitude Defines the amplitude of the function
  5382. */
  5383. constructor(
  5384. /** Defines the amplitude of the function */
  5385. amplitude?: number);
  5386. /** @hidden */
  5387. easeInCore(gradient: number): number;
  5388. }
  5389. /**
  5390. * Easing function with a bouncing shape (see link below).
  5391. * @see https://easings.net/#easeInBounce
  5392. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5393. */
  5394. export class BounceEase extends EasingFunction implements IEasingFunction {
  5395. /** Defines the number of bounces */
  5396. bounces: number;
  5397. /** Defines the amplitude of the bounce */
  5398. bounciness: number;
  5399. /**
  5400. * Instantiates a bounce easing
  5401. * @see https://easings.net/#easeInBounce
  5402. * @param bounces Defines the number of bounces
  5403. * @param bounciness Defines the amplitude of the bounce
  5404. */
  5405. constructor(
  5406. /** Defines the number of bounces */
  5407. bounces?: number,
  5408. /** Defines the amplitude of the bounce */
  5409. bounciness?: number);
  5410. /** @hidden */
  5411. easeInCore(gradient: number): number;
  5412. }
  5413. /**
  5414. * Easing function with a power of 3 shape (see link below).
  5415. * @see https://easings.net/#easeInCubic
  5416. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5417. */
  5418. export class CubicEase extends EasingFunction implements IEasingFunction {
  5419. /** @hidden */
  5420. easeInCore(gradient: number): number;
  5421. }
  5422. /**
  5423. * Easing function with an elastic shape (see link below).
  5424. * @see https://easings.net/#easeInElastic
  5425. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5426. */
  5427. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5428. /** Defines the number of oscillations*/
  5429. oscillations: number;
  5430. /** Defines the amplitude of the oscillations*/
  5431. springiness: number;
  5432. /**
  5433. * Instantiates an elastic easing function
  5434. * @see https://easings.net/#easeInElastic
  5435. * @param oscillations Defines the number of oscillations
  5436. * @param springiness Defines the amplitude of the oscillations
  5437. */
  5438. constructor(
  5439. /** Defines the number of oscillations*/
  5440. oscillations?: number,
  5441. /** Defines the amplitude of the oscillations*/
  5442. springiness?: number);
  5443. /** @hidden */
  5444. easeInCore(gradient: number): number;
  5445. }
  5446. /**
  5447. * Easing function with an exponential shape (see link below).
  5448. * @see https://easings.net/#easeInExpo
  5449. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5450. */
  5451. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5452. /** Defines the exponent of the function */
  5453. exponent: number;
  5454. /**
  5455. * Instantiates an exponential easing function
  5456. * @see https://easings.net/#easeInExpo
  5457. * @param exponent Defines the exponent of the function
  5458. */
  5459. constructor(
  5460. /** Defines the exponent of the function */
  5461. exponent?: number);
  5462. /** @hidden */
  5463. easeInCore(gradient: number): number;
  5464. }
  5465. /**
  5466. * Easing function with a power shape (see link below).
  5467. * @see https://easings.net/#easeInQuad
  5468. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5469. */
  5470. export class PowerEase extends EasingFunction implements IEasingFunction {
  5471. /** Defines the power of the function */
  5472. power: number;
  5473. /**
  5474. * Instantiates an power base easing function
  5475. * @see https://easings.net/#easeInQuad
  5476. * @param power Defines the power of the function
  5477. */
  5478. constructor(
  5479. /** Defines the power of the function */
  5480. power?: number);
  5481. /** @hidden */
  5482. easeInCore(gradient: number): number;
  5483. }
  5484. /**
  5485. * Easing function with a power of 2 shape (see link below).
  5486. * @see https://easings.net/#easeInQuad
  5487. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5488. */
  5489. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5490. /** @hidden */
  5491. easeInCore(gradient: number): number;
  5492. }
  5493. /**
  5494. * Easing function with a power of 4 shape (see link below).
  5495. * @see https://easings.net/#easeInQuart
  5496. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5497. */
  5498. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5499. /** @hidden */
  5500. easeInCore(gradient: number): number;
  5501. }
  5502. /**
  5503. * Easing function with a power of 5 shape (see link below).
  5504. * @see https://easings.net/#easeInQuint
  5505. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5506. */
  5507. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5508. /** @hidden */
  5509. easeInCore(gradient: number): number;
  5510. }
  5511. /**
  5512. * Easing function with a sin shape (see link below).
  5513. * @see https://easings.net/#easeInSine
  5514. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5515. */
  5516. export class SineEase extends EasingFunction implements IEasingFunction {
  5517. /** @hidden */
  5518. easeInCore(gradient: number): number;
  5519. }
  5520. /**
  5521. * Easing function with a bezier shape (see link below).
  5522. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5523. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5524. */
  5525. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5526. /** Defines the x component of the start tangent in the bezier curve */
  5527. x1: number;
  5528. /** Defines the y component of the start tangent in the bezier curve */
  5529. y1: number;
  5530. /** Defines the x component of the end tangent in the bezier curve */
  5531. x2: number;
  5532. /** Defines the y component of the end tangent in the bezier curve */
  5533. y2: number;
  5534. /**
  5535. * Instantiates a bezier function
  5536. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5537. * @param x1 Defines the x component of the start tangent in the bezier curve
  5538. * @param y1 Defines the y component of the start tangent in the bezier curve
  5539. * @param x2 Defines the x component of the end tangent in the bezier curve
  5540. * @param y2 Defines the y component of the end tangent in the bezier curve
  5541. */
  5542. constructor(
  5543. /** Defines the x component of the start tangent in the bezier curve */
  5544. x1?: number,
  5545. /** Defines the y component of the start tangent in the bezier curve */
  5546. y1?: number,
  5547. /** Defines the x component of the end tangent in the bezier curve */
  5548. x2?: number,
  5549. /** Defines the y component of the end tangent in the bezier curve */
  5550. y2?: number);
  5551. /** @hidden */
  5552. easeInCore(gradient: number): number;
  5553. }
  5554. }
  5555. declare module "babylonjs/Maths/math.color" {
  5556. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5557. /**
  5558. * Class used to hold a RBG color
  5559. */
  5560. export class Color3 {
  5561. /**
  5562. * Defines the red component (between 0 and 1, default is 0)
  5563. */
  5564. r: number;
  5565. /**
  5566. * Defines the green component (between 0 and 1, default is 0)
  5567. */
  5568. g: number;
  5569. /**
  5570. * Defines the blue component (between 0 and 1, default is 0)
  5571. */
  5572. b: number;
  5573. /**
  5574. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5575. * @param r defines the red component (between 0 and 1, default is 0)
  5576. * @param g defines the green component (between 0 and 1, default is 0)
  5577. * @param b defines the blue component (between 0 and 1, default is 0)
  5578. */
  5579. constructor(
  5580. /**
  5581. * Defines the red component (between 0 and 1, default is 0)
  5582. */
  5583. r?: number,
  5584. /**
  5585. * Defines the green component (between 0 and 1, default is 0)
  5586. */
  5587. g?: number,
  5588. /**
  5589. * Defines the blue component (between 0 and 1, default is 0)
  5590. */
  5591. b?: number);
  5592. /**
  5593. * Creates a string with the Color3 current values
  5594. * @returns the string representation of the Color3 object
  5595. */
  5596. toString(): string;
  5597. /**
  5598. * Returns the string "Color3"
  5599. * @returns "Color3"
  5600. */
  5601. getClassName(): string;
  5602. /**
  5603. * Compute the Color3 hash code
  5604. * @returns an unique number that can be used to hash Color3 objects
  5605. */
  5606. getHashCode(): number;
  5607. /**
  5608. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5609. * @param array defines the array where to store the r,g,b components
  5610. * @param index defines an optional index in the target array to define where to start storing values
  5611. * @returns the current Color3 object
  5612. */
  5613. toArray(array: FloatArray, index?: number): Color3;
  5614. /**
  5615. * Update the current color with values stored in an array from the starting index of the given array
  5616. * @param array defines the source array
  5617. * @param offset defines an offset in the source array
  5618. * @returns the current Color3 object
  5619. */
  5620. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5621. /**
  5622. * Returns a new Color4 object from the current Color3 and the given alpha
  5623. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5624. * @returns a new Color4 object
  5625. */
  5626. toColor4(alpha?: number): Color4;
  5627. /**
  5628. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5629. * @returns the new array
  5630. */
  5631. asArray(): number[];
  5632. /**
  5633. * Returns the luminance value
  5634. * @returns a float value
  5635. */
  5636. toLuminance(): number;
  5637. /**
  5638. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5639. * @param otherColor defines the second operand
  5640. * @returns the new Color3 object
  5641. */
  5642. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5643. /**
  5644. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5645. * @param otherColor defines the second operand
  5646. * @param result defines the Color3 object where to store the result
  5647. * @returns the current Color3
  5648. */
  5649. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5650. /**
  5651. * Determines equality between Color3 objects
  5652. * @param otherColor defines the second operand
  5653. * @returns true if the rgb values are equal to the given ones
  5654. */
  5655. equals(otherColor: DeepImmutable<Color3>): boolean;
  5656. /**
  5657. * Determines equality between the current Color3 object and a set of r,b,g values
  5658. * @param r defines the red component to check
  5659. * @param g defines the green component to check
  5660. * @param b defines the blue component to check
  5661. * @returns true if the rgb values are equal to the given ones
  5662. */
  5663. equalsFloats(r: number, g: number, b: number): boolean;
  5664. /**
  5665. * Multiplies in place each rgb value by scale
  5666. * @param scale defines the scaling factor
  5667. * @returns the updated Color3
  5668. */
  5669. scale(scale: number): Color3;
  5670. /**
  5671. * Multiplies the rgb values by scale and stores the result into "result"
  5672. * @param scale defines the scaling factor
  5673. * @param result defines the Color3 object where to store the result
  5674. * @returns the unmodified current Color3
  5675. */
  5676. scaleToRef(scale: number, result: Color3): Color3;
  5677. /**
  5678. * Scale the current Color3 values by a factor and add the result to a given Color3
  5679. * @param scale defines the scale factor
  5680. * @param result defines color to store the result into
  5681. * @returns the unmodified current Color3
  5682. */
  5683. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5684. /**
  5685. * Clamps the rgb values by the min and max values and stores the result into "result"
  5686. * @param min defines minimum clamping value (default is 0)
  5687. * @param max defines maximum clamping value (default is 1)
  5688. * @param result defines color to store the result into
  5689. * @returns the original Color3
  5690. */
  5691. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5692. /**
  5693. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5694. * @param otherColor defines the second operand
  5695. * @returns the new Color3
  5696. */
  5697. add(otherColor: DeepImmutable<Color3>): Color3;
  5698. /**
  5699. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5700. * @param otherColor defines the second operand
  5701. * @param result defines Color3 object to store the result into
  5702. * @returns the unmodified current Color3
  5703. */
  5704. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5705. /**
  5706. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5707. * @param otherColor defines the second operand
  5708. * @returns the new Color3
  5709. */
  5710. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5711. /**
  5712. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5713. * @param otherColor defines the second operand
  5714. * @param result defines Color3 object to store the result into
  5715. * @returns the unmodified current Color3
  5716. */
  5717. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5718. /**
  5719. * Copy the current object
  5720. * @returns a new Color3 copied the current one
  5721. */
  5722. clone(): Color3;
  5723. /**
  5724. * Copies the rgb values from the source in the current Color3
  5725. * @param source defines the source Color3 object
  5726. * @returns the updated Color3 object
  5727. */
  5728. copyFrom(source: DeepImmutable<Color3>): Color3;
  5729. /**
  5730. * Updates the Color3 rgb values from the given floats
  5731. * @param r defines the red component to read from
  5732. * @param g defines the green component to read from
  5733. * @param b defines the blue component to read from
  5734. * @returns the current Color3 object
  5735. */
  5736. copyFromFloats(r: number, g: number, b: number): Color3;
  5737. /**
  5738. * Updates the Color3 rgb values from the given floats
  5739. * @param r defines the red component to read from
  5740. * @param g defines the green component to read from
  5741. * @param b defines the blue component to read from
  5742. * @returns the current Color3 object
  5743. */
  5744. set(r: number, g: number, b: number): Color3;
  5745. /**
  5746. * Compute the Color3 hexadecimal code as a string
  5747. * @returns a string containing the hexadecimal representation of the Color3 object
  5748. */
  5749. toHexString(): string;
  5750. /**
  5751. * Computes a new Color3 converted from the current one to linear space
  5752. * @returns a new Color3 object
  5753. */
  5754. toLinearSpace(): Color3;
  5755. /**
  5756. * Converts current color in rgb space to HSV values
  5757. * @returns a new color3 representing the HSV values
  5758. */
  5759. toHSV(): Color3;
  5760. /**
  5761. * Converts current color in rgb space to HSV values
  5762. * @param result defines the Color3 where to store the HSV values
  5763. */
  5764. toHSVToRef(result: Color3): void;
  5765. /**
  5766. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5767. * @param convertedColor defines the Color3 object where to store the linear space version
  5768. * @returns the unmodified Color3
  5769. */
  5770. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5771. /**
  5772. * Computes a new Color3 converted from the current one to gamma space
  5773. * @returns a new Color3 object
  5774. */
  5775. toGammaSpace(): Color3;
  5776. /**
  5777. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5778. * @param convertedColor defines the Color3 object where to store the gamma space version
  5779. * @returns the unmodified Color3
  5780. */
  5781. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5782. private static _BlackReadOnly;
  5783. /**
  5784. * Convert Hue, saturation and value to a Color3 (RGB)
  5785. * @param hue defines the hue
  5786. * @param saturation defines the saturation
  5787. * @param value defines the value
  5788. * @param result defines the Color3 where to store the RGB values
  5789. */
  5790. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5791. /**
  5792. * Creates a new Color3 from the string containing valid hexadecimal values
  5793. * @param hex defines a string containing valid hexadecimal values
  5794. * @returns a new Color3 object
  5795. */
  5796. static FromHexString(hex: string): Color3;
  5797. /**
  5798. * Creates a new Color3 from the starting index of the given array
  5799. * @param array defines the source array
  5800. * @param offset defines an offset in the source array
  5801. * @returns a new Color3 object
  5802. */
  5803. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5804. /**
  5805. * Creates a new Color3 from the starting index element of the given array
  5806. * @param array defines the source array to read from
  5807. * @param offset defines the offset in the source array
  5808. * @param result defines the target Color3 object
  5809. */
  5810. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5811. /**
  5812. * Creates a new Color3 from integer values (< 256)
  5813. * @param r defines the red component to read from (value between 0 and 255)
  5814. * @param g defines the green component to read from (value between 0 and 255)
  5815. * @param b defines the blue component to read from (value between 0 and 255)
  5816. * @returns a new Color3 object
  5817. */
  5818. static FromInts(r: number, g: number, b: number): Color3;
  5819. /**
  5820. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5821. * @param start defines the start Color3 value
  5822. * @param end defines the end Color3 value
  5823. * @param amount defines the gradient value between start and end
  5824. * @returns a new Color3 object
  5825. */
  5826. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5827. /**
  5828. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5829. * @param left defines the start value
  5830. * @param right defines the end value
  5831. * @param amount defines the gradient factor
  5832. * @param result defines the Color3 object where to store the result
  5833. */
  5834. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5835. /**
  5836. * Returns a Color3 value containing a red color
  5837. * @returns a new Color3 object
  5838. */
  5839. static Red(): Color3;
  5840. /**
  5841. * Returns a Color3 value containing a green color
  5842. * @returns a new Color3 object
  5843. */
  5844. static Green(): Color3;
  5845. /**
  5846. * Returns a Color3 value containing a blue color
  5847. * @returns a new Color3 object
  5848. */
  5849. static Blue(): Color3;
  5850. /**
  5851. * Returns a Color3 value containing a black color
  5852. * @returns a new Color3 object
  5853. */
  5854. static Black(): Color3;
  5855. /**
  5856. * Gets a Color3 value containing a black color that must not be updated
  5857. */
  5858. static get BlackReadOnly(): DeepImmutable<Color3>;
  5859. /**
  5860. * Returns a Color3 value containing a white color
  5861. * @returns a new Color3 object
  5862. */
  5863. static White(): Color3;
  5864. /**
  5865. * Returns a Color3 value containing a purple color
  5866. * @returns a new Color3 object
  5867. */
  5868. static Purple(): Color3;
  5869. /**
  5870. * Returns a Color3 value containing a magenta color
  5871. * @returns a new Color3 object
  5872. */
  5873. static Magenta(): Color3;
  5874. /**
  5875. * Returns a Color3 value containing a yellow color
  5876. * @returns a new Color3 object
  5877. */
  5878. static Yellow(): Color3;
  5879. /**
  5880. * Returns a Color3 value containing a gray color
  5881. * @returns a new Color3 object
  5882. */
  5883. static Gray(): Color3;
  5884. /**
  5885. * Returns a Color3 value containing a teal color
  5886. * @returns a new Color3 object
  5887. */
  5888. static Teal(): Color3;
  5889. /**
  5890. * Returns a Color3 value containing a random color
  5891. * @returns a new Color3 object
  5892. */
  5893. static Random(): Color3;
  5894. }
  5895. /**
  5896. * Class used to hold a RBGA color
  5897. */
  5898. export class Color4 {
  5899. /**
  5900. * Defines the red component (between 0 and 1, default is 0)
  5901. */
  5902. r: number;
  5903. /**
  5904. * Defines the green component (between 0 and 1, default is 0)
  5905. */
  5906. g: number;
  5907. /**
  5908. * Defines the blue component (between 0 and 1, default is 0)
  5909. */
  5910. b: number;
  5911. /**
  5912. * Defines the alpha component (between 0 and 1, default is 1)
  5913. */
  5914. a: number;
  5915. /**
  5916. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5917. * @param r defines the red component (between 0 and 1, default is 0)
  5918. * @param g defines the green component (between 0 and 1, default is 0)
  5919. * @param b defines the blue component (between 0 and 1, default is 0)
  5920. * @param a defines the alpha component (between 0 and 1, default is 1)
  5921. */
  5922. constructor(
  5923. /**
  5924. * Defines the red component (between 0 and 1, default is 0)
  5925. */
  5926. r?: number,
  5927. /**
  5928. * Defines the green component (between 0 and 1, default is 0)
  5929. */
  5930. g?: number,
  5931. /**
  5932. * Defines the blue component (between 0 and 1, default is 0)
  5933. */
  5934. b?: number,
  5935. /**
  5936. * Defines the alpha component (between 0 and 1, default is 1)
  5937. */
  5938. a?: number);
  5939. /**
  5940. * Adds in place the given Color4 values to the current Color4 object
  5941. * @param right defines the second operand
  5942. * @returns the current updated Color4 object
  5943. */
  5944. addInPlace(right: DeepImmutable<Color4>): Color4;
  5945. /**
  5946. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5947. * @returns the new array
  5948. */
  5949. asArray(): number[];
  5950. /**
  5951. * Stores from the starting index in the given array the Color4 successive values
  5952. * @param array defines the array where to store the r,g,b components
  5953. * @param index defines an optional index in the target array to define where to start storing values
  5954. * @returns the current Color4 object
  5955. */
  5956. toArray(array: number[], index?: number): Color4;
  5957. /**
  5958. * Update the current color with values stored in an array from the starting index of the given array
  5959. * @param array defines the source array
  5960. * @param offset defines an offset in the source array
  5961. * @returns the current Color4 object
  5962. */
  5963. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5964. /**
  5965. * Determines equality between Color4 objects
  5966. * @param otherColor defines the second operand
  5967. * @returns true if the rgba values are equal to the given ones
  5968. */
  5969. equals(otherColor: DeepImmutable<Color4>): boolean;
  5970. /**
  5971. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5972. * @param right defines the second operand
  5973. * @returns a new Color4 object
  5974. */
  5975. add(right: DeepImmutable<Color4>): Color4;
  5976. /**
  5977. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5978. * @param right defines the second operand
  5979. * @returns a new Color4 object
  5980. */
  5981. subtract(right: DeepImmutable<Color4>): Color4;
  5982. /**
  5983. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5984. * @param right defines the second operand
  5985. * @param result defines the Color4 object where to store the result
  5986. * @returns the current Color4 object
  5987. */
  5988. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5989. /**
  5990. * Creates a new Color4 with the current Color4 values multiplied by scale
  5991. * @param scale defines the scaling factor to apply
  5992. * @returns a new Color4 object
  5993. */
  5994. scale(scale: number): Color4;
  5995. /**
  5996. * Multiplies the current Color4 values by scale and stores the result in "result"
  5997. * @param scale defines the scaling factor to apply
  5998. * @param result defines the Color4 object where to store the result
  5999. * @returns the current unmodified Color4
  6000. */
  6001. scaleToRef(scale: number, result: Color4): Color4;
  6002. /**
  6003. * Scale the current Color4 values by a factor and add the result to a given Color4
  6004. * @param scale defines the scale factor
  6005. * @param result defines the Color4 object where to store the result
  6006. * @returns the unmodified current Color4
  6007. */
  6008. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6009. /**
  6010. * Clamps the rgb values by the min and max values and stores the result into "result"
  6011. * @param min defines minimum clamping value (default is 0)
  6012. * @param max defines maximum clamping value (default is 1)
  6013. * @param result defines color to store the result into.
  6014. * @returns the cuurent Color4
  6015. */
  6016. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6017. /**
  6018. * Multipy an Color4 value by another and return a new Color4 object
  6019. * @param color defines the Color4 value to multiply by
  6020. * @returns a new Color4 object
  6021. */
  6022. multiply(color: Color4): Color4;
  6023. /**
  6024. * Multipy a Color4 value by another and push the result in a reference value
  6025. * @param color defines the Color4 value to multiply by
  6026. * @param result defines the Color4 to fill the result in
  6027. * @returns the result Color4
  6028. */
  6029. multiplyToRef(color: Color4, result: Color4): Color4;
  6030. /**
  6031. * Creates a string with the Color4 current values
  6032. * @returns the string representation of the Color4 object
  6033. */
  6034. toString(): string;
  6035. /**
  6036. * Returns the string "Color4"
  6037. * @returns "Color4"
  6038. */
  6039. getClassName(): string;
  6040. /**
  6041. * Compute the Color4 hash code
  6042. * @returns an unique number that can be used to hash Color4 objects
  6043. */
  6044. getHashCode(): number;
  6045. /**
  6046. * Creates a new Color4 copied from the current one
  6047. * @returns a new Color4 object
  6048. */
  6049. clone(): Color4;
  6050. /**
  6051. * Copies the given Color4 values into the current one
  6052. * @param source defines the source Color4 object
  6053. * @returns the current updated Color4 object
  6054. */
  6055. copyFrom(source: Color4): Color4;
  6056. /**
  6057. * Copies the given float values into the current one
  6058. * @param r defines the red component to read from
  6059. * @param g defines the green component to read from
  6060. * @param b defines the blue component to read from
  6061. * @param a defines the alpha component to read from
  6062. * @returns the current updated Color4 object
  6063. */
  6064. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6065. /**
  6066. * Copies the given float values into the current one
  6067. * @param r defines the red component to read from
  6068. * @param g defines the green component to read from
  6069. * @param b defines the blue component to read from
  6070. * @param a defines the alpha component to read from
  6071. * @returns the current updated Color4 object
  6072. */
  6073. set(r: number, g: number, b: number, a: number): Color4;
  6074. /**
  6075. * Compute the Color4 hexadecimal code as a string
  6076. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6077. * @returns a string containing the hexadecimal representation of the Color4 object
  6078. */
  6079. toHexString(returnAsColor3?: boolean): string;
  6080. /**
  6081. * Computes a new Color4 converted from the current one to linear space
  6082. * @returns a new Color4 object
  6083. */
  6084. toLinearSpace(): Color4;
  6085. /**
  6086. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6087. * @param convertedColor defines the Color4 object where to store the linear space version
  6088. * @returns the unmodified Color4
  6089. */
  6090. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6091. /**
  6092. * Computes a new Color4 converted from the current one to gamma space
  6093. * @returns a new Color4 object
  6094. */
  6095. toGammaSpace(): Color4;
  6096. /**
  6097. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6098. * @param convertedColor defines the Color4 object where to store the gamma space version
  6099. * @returns the unmodified Color4
  6100. */
  6101. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6102. /**
  6103. * Creates a new Color4 from the string containing valid hexadecimal values
  6104. * @param hex defines a string containing valid hexadecimal values
  6105. * @returns a new Color4 object
  6106. */
  6107. static FromHexString(hex: string): Color4;
  6108. /**
  6109. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6110. * @param left defines the start value
  6111. * @param right defines the end value
  6112. * @param amount defines the gradient factor
  6113. * @returns a new Color4 object
  6114. */
  6115. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6116. /**
  6117. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6118. * @param left defines the start value
  6119. * @param right defines the end value
  6120. * @param amount defines the gradient factor
  6121. * @param result defines the Color4 object where to store data
  6122. */
  6123. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6124. /**
  6125. * Creates a new Color4 from a Color3 and an alpha value
  6126. * @param color3 defines the source Color3 to read from
  6127. * @param alpha defines the alpha component (1.0 by default)
  6128. * @returns a new Color4 object
  6129. */
  6130. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6131. /**
  6132. * Creates a new Color4 from the starting index element of the given array
  6133. * @param array defines the source array to read from
  6134. * @param offset defines the offset in the source array
  6135. * @returns a new Color4 object
  6136. */
  6137. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6138. /**
  6139. * Creates a new Color4 from the starting index element of the given array
  6140. * @param array defines the source array to read from
  6141. * @param offset defines the offset in the source array
  6142. * @param result defines the target Color4 object
  6143. */
  6144. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6145. /**
  6146. * Creates a new Color3 from integer values (< 256)
  6147. * @param r defines the red component to read from (value between 0 and 255)
  6148. * @param g defines the green component to read from (value between 0 and 255)
  6149. * @param b defines the blue component to read from (value between 0 and 255)
  6150. * @param a defines the alpha component to read from (value between 0 and 255)
  6151. * @returns a new Color3 object
  6152. */
  6153. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6154. /**
  6155. * Check the content of a given array and convert it to an array containing RGBA data
  6156. * If the original array was already containing count * 4 values then it is returned directly
  6157. * @param colors defines the array to check
  6158. * @param count defines the number of RGBA data to expect
  6159. * @returns an array containing count * 4 values (RGBA)
  6160. */
  6161. static CheckColors4(colors: number[], count: number): number[];
  6162. }
  6163. /**
  6164. * @hidden
  6165. */
  6166. export class TmpColors {
  6167. static Color3: Color3[];
  6168. static Color4: Color4[];
  6169. }
  6170. }
  6171. declare module "babylonjs/Animations/animationKey" {
  6172. /**
  6173. * Defines an interface which represents an animation key frame
  6174. */
  6175. export interface IAnimationKey {
  6176. /**
  6177. * Frame of the key frame
  6178. */
  6179. frame: number;
  6180. /**
  6181. * Value at the specifies key frame
  6182. */
  6183. value: any;
  6184. /**
  6185. * The input tangent for the cubic hermite spline
  6186. */
  6187. inTangent?: any;
  6188. /**
  6189. * The output tangent for the cubic hermite spline
  6190. */
  6191. outTangent?: any;
  6192. /**
  6193. * The animation interpolation type
  6194. */
  6195. interpolation?: AnimationKeyInterpolation;
  6196. }
  6197. /**
  6198. * Enum for the animation key frame interpolation type
  6199. */
  6200. export enum AnimationKeyInterpolation {
  6201. /**
  6202. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6203. */
  6204. STEP = 1
  6205. }
  6206. }
  6207. declare module "babylonjs/Animations/animationRange" {
  6208. /**
  6209. * Represents the range of an animation
  6210. */
  6211. export class AnimationRange {
  6212. /**The name of the animation range**/
  6213. name: string;
  6214. /**The starting frame of the animation */
  6215. from: number;
  6216. /**The ending frame of the animation*/
  6217. to: number;
  6218. /**
  6219. * Initializes the range of an animation
  6220. * @param name The name of the animation range
  6221. * @param from The starting frame of the animation
  6222. * @param to The ending frame of the animation
  6223. */
  6224. constructor(
  6225. /**The name of the animation range**/
  6226. name: string,
  6227. /**The starting frame of the animation */
  6228. from: number,
  6229. /**The ending frame of the animation*/
  6230. to: number);
  6231. /**
  6232. * Makes a copy of the animation range
  6233. * @returns A copy of the animation range
  6234. */
  6235. clone(): AnimationRange;
  6236. }
  6237. }
  6238. declare module "babylonjs/Animations/animationEvent" {
  6239. /**
  6240. * Composed of a frame, and an action function
  6241. */
  6242. export class AnimationEvent {
  6243. /** The frame for which the event is triggered **/
  6244. frame: number;
  6245. /** The event to perform when triggered **/
  6246. action: (currentFrame: number) => void;
  6247. /** Specifies if the event should be triggered only once**/
  6248. onlyOnce?: boolean | undefined;
  6249. /**
  6250. * Specifies if the animation event is done
  6251. */
  6252. isDone: boolean;
  6253. /**
  6254. * Initializes the animation event
  6255. * @param frame The frame for which the event is triggered
  6256. * @param action The event to perform when triggered
  6257. * @param onlyOnce Specifies if the event should be triggered only once
  6258. */
  6259. constructor(
  6260. /** The frame for which the event is triggered **/
  6261. frame: number,
  6262. /** The event to perform when triggered **/
  6263. action: (currentFrame: number) => void,
  6264. /** Specifies if the event should be triggered only once**/
  6265. onlyOnce?: boolean | undefined);
  6266. /** @hidden */
  6267. _clone(): AnimationEvent;
  6268. }
  6269. }
  6270. declare module "babylonjs/Behaviors/behavior" {
  6271. import { Nullable } from "babylonjs/types";
  6272. /**
  6273. * Interface used to define a behavior
  6274. */
  6275. export interface Behavior<T> {
  6276. /** gets or sets behavior's name */
  6277. name: string;
  6278. /**
  6279. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6280. */
  6281. init(): void;
  6282. /**
  6283. * Called when the behavior is attached to a target
  6284. * @param target defines the target where the behavior is attached to
  6285. */
  6286. attach(target: T): void;
  6287. /**
  6288. * Called when the behavior is detached from its target
  6289. */
  6290. detach(): void;
  6291. }
  6292. /**
  6293. * Interface implemented by classes supporting behaviors
  6294. */
  6295. export interface IBehaviorAware<T> {
  6296. /**
  6297. * Attach a behavior
  6298. * @param behavior defines the behavior to attach
  6299. * @returns the current host
  6300. */
  6301. addBehavior(behavior: Behavior<T>): T;
  6302. /**
  6303. * Remove a behavior from the current object
  6304. * @param behavior defines the behavior to detach
  6305. * @returns the current host
  6306. */
  6307. removeBehavior(behavior: Behavior<T>): T;
  6308. /**
  6309. * Gets a behavior using its name to search
  6310. * @param name defines the name to search
  6311. * @returns the behavior or null if not found
  6312. */
  6313. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6314. }
  6315. }
  6316. declare module "babylonjs/Misc/smartArray" {
  6317. /**
  6318. * Defines an array and its length.
  6319. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6320. */
  6321. export interface ISmartArrayLike<T> {
  6322. /**
  6323. * The data of the array.
  6324. */
  6325. data: Array<T>;
  6326. /**
  6327. * The active length of the array.
  6328. */
  6329. length: number;
  6330. }
  6331. /**
  6332. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6333. */
  6334. export class SmartArray<T> implements ISmartArrayLike<T> {
  6335. /**
  6336. * The full set of data from the array.
  6337. */
  6338. data: Array<T>;
  6339. /**
  6340. * The active length of the array.
  6341. */
  6342. length: number;
  6343. protected _id: number;
  6344. /**
  6345. * Instantiates a Smart Array.
  6346. * @param capacity defines the default capacity of the array.
  6347. */
  6348. constructor(capacity: number);
  6349. /**
  6350. * Pushes a value at the end of the active data.
  6351. * @param value defines the object to push in the array.
  6352. */
  6353. push(value: T): void;
  6354. /**
  6355. * Iterates over the active data and apply the lambda to them.
  6356. * @param func defines the action to apply on each value.
  6357. */
  6358. forEach(func: (content: T) => void): void;
  6359. /**
  6360. * Sorts the full sets of data.
  6361. * @param compareFn defines the comparison function to apply.
  6362. */
  6363. sort(compareFn: (a: T, b: T) => number): void;
  6364. /**
  6365. * Resets the active data to an empty array.
  6366. */
  6367. reset(): void;
  6368. /**
  6369. * Releases all the data from the array as well as the array.
  6370. */
  6371. dispose(): void;
  6372. /**
  6373. * Concats the active data with a given array.
  6374. * @param array defines the data to concatenate with.
  6375. */
  6376. concat(array: any): void;
  6377. /**
  6378. * Returns the position of a value in the active data.
  6379. * @param value defines the value to find the index for
  6380. * @returns the index if found in the active data otherwise -1
  6381. */
  6382. indexOf(value: T): number;
  6383. /**
  6384. * Returns whether an element is part of the active data.
  6385. * @param value defines the value to look for
  6386. * @returns true if found in the active data otherwise false
  6387. */
  6388. contains(value: T): boolean;
  6389. private static _GlobalId;
  6390. }
  6391. /**
  6392. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6393. * The data in this array can only be present once
  6394. */
  6395. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6396. private _duplicateId;
  6397. /**
  6398. * Pushes a value at the end of the active data.
  6399. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6400. * @param value defines the object to push in the array.
  6401. */
  6402. push(value: T): void;
  6403. /**
  6404. * Pushes a value at the end of the active data.
  6405. * If the data is already present, it won t be added again
  6406. * @param value defines the object to push in the array.
  6407. * @returns true if added false if it was already present
  6408. */
  6409. pushNoDuplicate(value: T): boolean;
  6410. /**
  6411. * Resets the active data to an empty array.
  6412. */
  6413. reset(): void;
  6414. /**
  6415. * Concats the active data with a given array.
  6416. * This ensures no dupplicate will be present in the result.
  6417. * @param array defines the data to concatenate with.
  6418. */
  6419. concatWithNoDuplicate(array: any): void;
  6420. }
  6421. }
  6422. declare module "babylonjs/Cameras/cameraInputsManager" {
  6423. import { Nullable } from "babylonjs/types";
  6424. import { Camera } from "babylonjs/Cameras/camera";
  6425. /**
  6426. * @ignore
  6427. * This is a list of all the different input types that are available in the application.
  6428. * Fo instance: ArcRotateCameraGamepadInput...
  6429. */
  6430. export var CameraInputTypes: {};
  6431. /**
  6432. * This is the contract to implement in order to create a new input class.
  6433. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6434. */
  6435. export interface ICameraInput<TCamera extends Camera> {
  6436. /**
  6437. * Defines the camera the input is attached to.
  6438. */
  6439. camera: Nullable<TCamera>;
  6440. /**
  6441. * Gets the class name of the current intput.
  6442. * @returns the class name
  6443. */
  6444. getClassName(): string;
  6445. /**
  6446. * Get the friendly name associated with the input class.
  6447. * @returns the input friendly name
  6448. */
  6449. getSimpleName(): string;
  6450. /**
  6451. * Attach the input controls to a specific dom element to get the input from.
  6452. * @param element Defines the element the controls should be listened from
  6453. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6454. */
  6455. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6456. /**
  6457. * Detach the current controls from the specified dom element.
  6458. * @param element Defines the element to stop listening the inputs from
  6459. */
  6460. detachControl(element: Nullable<HTMLElement>): void;
  6461. /**
  6462. * Update the current camera state depending on the inputs that have been used this frame.
  6463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6464. */
  6465. checkInputs?: () => void;
  6466. }
  6467. /**
  6468. * Represents a map of input types to input instance or input index to input instance.
  6469. */
  6470. export interface CameraInputsMap<TCamera extends Camera> {
  6471. /**
  6472. * Accessor to the input by input type.
  6473. */
  6474. [name: string]: ICameraInput<TCamera>;
  6475. /**
  6476. * Accessor to the input by input index.
  6477. */
  6478. [idx: number]: ICameraInput<TCamera>;
  6479. }
  6480. /**
  6481. * This represents the input manager used within a camera.
  6482. * It helps dealing with all the different kind of input attached to a camera.
  6483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6484. */
  6485. export class CameraInputsManager<TCamera extends Camera> {
  6486. /**
  6487. * Defines the list of inputs attahed to the camera.
  6488. */
  6489. attached: CameraInputsMap<TCamera>;
  6490. /**
  6491. * Defines the dom element the camera is collecting inputs from.
  6492. * This is null if the controls have not been attached.
  6493. */
  6494. attachedElement: Nullable<HTMLElement>;
  6495. /**
  6496. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6497. */
  6498. noPreventDefault: boolean;
  6499. /**
  6500. * Defined the camera the input manager belongs to.
  6501. */
  6502. camera: TCamera;
  6503. /**
  6504. * Update the current camera state depending on the inputs that have been used this frame.
  6505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6506. */
  6507. checkInputs: () => void;
  6508. /**
  6509. * Instantiate a new Camera Input Manager.
  6510. * @param camera Defines the camera the input manager blongs to
  6511. */
  6512. constructor(camera: TCamera);
  6513. /**
  6514. * Add an input method to a camera
  6515. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6516. * @param input camera input method
  6517. */
  6518. add(input: ICameraInput<TCamera>): void;
  6519. /**
  6520. * Remove a specific input method from a camera
  6521. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6522. * @param inputToRemove camera input method
  6523. */
  6524. remove(inputToRemove: ICameraInput<TCamera>): void;
  6525. /**
  6526. * Remove a specific input type from a camera
  6527. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6528. * @param inputType the type of the input to remove
  6529. */
  6530. removeByType(inputType: string): void;
  6531. private _addCheckInputs;
  6532. /**
  6533. * Attach the input controls to the currently attached dom element to listen the events from.
  6534. * @param input Defines the input to attach
  6535. */
  6536. attachInput(input: ICameraInput<TCamera>): void;
  6537. /**
  6538. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6539. * @param element Defines the dom element to collect the events from
  6540. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6541. */
  6542. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6543. /**
  6544. * Detach the current manager inputs controls from a specific dom element.
  6545. * @param element Defines the dom element to collect the events from
  6546. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6547. */
  6548. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6549. /**
  6550. * Rebuild the dynamic inputCheck function from the current list of
  6551. * defined inputs in the manager.
  6552. */
  6553. rebuildInputCheck(): void;
  6554. /**
  6555. * Remove all attached input methods from a camera
  6556. */
  6557. clear(): void;
  6558. /**
  6559. * Serialize the current input manager attached to a camera.
  6560. * This ensures than once parsed,
  6561. * the input associated to the camera will be identical to the current ones
  6562. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6563. */
  6564. serialize(serializedCamera: any): void;
  6565. /**
  6566. * Parses an input manager serialized JSON to restore the previous list of inputs
  6567. * and states associated to a camera.
  6568. * @param parsedCamera Defines the JSON to parse
  6569. */
  6570. parse(parsedCamera: any): void;
  6571. }
  6572. }
  6573. declare module "babylonjs/Meshes/buffer" {
  6574. import { Nullable, DataArray } from "babylonjs/types";
  6575. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6576. /**
  6577. * Class used to store data that will be store in GPU memory
  6578. */
  6579. export class Buffer {
  6580. private _engine;
  6581. private _buffer;
  6582. /** @hidden */
  6583. _data: Nullable<DataArray>;
  6584. private _updatable;
  6585. private _instanced;
  6586. private _divisor;
  6587. /**
  6588. * Gets the byte stride.
  6589. */
  6590. readonly byteStride: number;
  6591. /**
  6592. * Constructor
  6593. * @param engine the engine
  6594. * @param data the data to use for this buffer
  6595. * @param updatable whether the data is updatable
  6596. * @param stride the stride (optional)
  6597. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6598. * @param instanced whether the buffer is instanced (optional)
  6599. * @param useBytes set to true if the stride in in bytes (optional)
  6600. * @param divisor sets an optional divisor for instances (1 by default)
  6601. */
  6602. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6603. /**
  6604. * Create a new VertexBuffer based on the current buffer
  6605. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6606. * @param offset defines offset in the buffer (0 by default)
  6607. * @param size defines the size in floats of attributes (position is 3 for instance)
  6608. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6609. * @param instanced defines if the vertex buffer contains indexed data
  6610. * @param useBytes defines if the offset and stride are in bytes *
  6611. * @param divisor sets an optional divisor for instances (1 by default)
  6612. * @returns the new vertex buffer
  6613. */
  6614. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6615. /**
  6616. * Gets a boolean indicating if the Buffer is updatable?
  6617. * @returns true if the buffer is updatable
  6618. */
  6619. isUpdatable(): boolean;
  6620. /**
  6621. * Gets current buffer's data
  6622. * @returns a DataArray or null
  6623. */
  6624. getData(): Nullable<DataArray>;
  6625. /**
  6626. * Gets underlying native buffer
  6627. * @returns underlying native buffer
  6628. */
  6629. getBuffer(): Nullable<DataBuffer>;
  6630. /**
  6631. * Gets the stride in float32 units (i.e. byte stride / 4).
  6632. * May not be an integer if the byte stride is not divisible by 4.
  6633. * @returns the stride in float32 units
  6634. * @deprecated Please use byteStride instead.
  6635. */
  6636. getStrideSize(): number;
  6637. /**
  6638. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6639. * @param data defines the data to store
  6640. */
  6641. create(data?: Nullable<DataArray>): void;
  6642. /** @hidden */
  6643. _rebuild(): void;
  6644. /**
  6645. * Update current buffer data
  6646. * @param data defines the data to store
  6647. */
  6648. update(data: DataArray): void;
  6649. /**
  6650. * Updates the data directly.
  6651. * @param data the new data
  6652. * @param offset the new offset
  6653. * @param vertexCount the vertex count (optional)
  6654. * @param useBytes set to true if the offset is in bytes
  6655. */
  6656. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6657. /**
  6658. * Release all resources
  6659. */
  6660. dispose(): void;
  6661. }
  6662. /**
  6663. * Specialized buffer used to store vertex data
  6664. */
  6665. export class VertexBuffer {
  6666. /** @hidden */
  6667. _buffer: Buffer;
  6668. private _kind;
  6669. private _size;
  6670. private _ownsBuffer;
  6671. private _instanced;
  6672. private _instanceDivisor;
  6673. /**
  6674. * The byte type.
  6675. */
  6676. static readonly BYTE: number;
  6677. /**
  6678. * The unsigned byte type.
  6679. */
  6680. static readonly UNSIGNED_BYTE: number;
  6681. /**
  6682. * The short type.
  6683. */
  6684. static readonly SHORT: number;
  6685. /**
  6686. * The unsigned short type.
  6687. */
  6688. static readonly UNSIGNED_SHORT: number;
  6689. /**
  6690. * The integer type.
  6691. */
  6692. static readonly INT: number;
  6693. /**
  6694. * The unsigned integer type.
  6695. */
  6696. static readonly UNSIGNED_INT: number;
  6697. /**
  6698. * The float type.
  6699. */
  6700. static readonly FLOAT: number;
  6701. /**
  6702. * Gets or sets the instance divisor when in instanced mode
  6703. */
  6704. get instanceDivisor(): number;
  6705. set instanceDivisor(value: number);
  6706. /**
  6707. * Gets the byte stride.
  6708. */
  6709. readonly byteStride: number;
  6710. /**
  6711. * Gets the byte offset.
  6712. */
  6713. readonly byteOffset: number;
  6714. /**
  6715. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6716. */
  6717. readonly normalized: boolean;
  6718. /**
  6719. * Gets the data type of each component in the array.
  6720. */
  6721. readonly type: number;
  6722. /**
  6723. * Constructor
  6724. * @param engine the engine
  6725. * @param data the data to use for this vertex buffer
  6726. * @param kind the vertex buffer kind
  6727. * @param updatable whether the data is updatable
  6728. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6729. * @param stride the stride (optional)
  6730. * @param instanced whether the buffer is instanced (optional)
  6731. * @param offset the offset of the data (optional)
  6732. * @param size the number of components (optional)
  6733. * @param type the type of the component (optional)
  6734. * @param normalized whether the data contains normalized data (optional)
  6735. * @param useBytes set to true if stride and offset are in bytes (optional)
  6736. * @param divisor defines the instance divisor to use (1 by default)
  6737. */
  6738. 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);
  6739. /** @hidden */
  6740. _rebuild(): void;
  6741. /**
  6742. * Returns the kind of the VertexBuffer (string)
  6743. * @returns a string
  6744. */
  6745. getKind(): string;
  6746. /**
  6747. * Gets a boolean indicating if the VertexBuffer is updatable?
  6748. * @returns true if the buffer is updatable
  6749. */
  6750. isUpdatable(): boolean;
  6751. /**
  6752. * Gets current buffer's data
  6753. * @returns a DataArray or null
  6754. */
  6755. getData(): Nullable<DataArray>;
  6756. /**
  6757. * Gets underlying native buffer
  6758. * @returns underlying native buffer
  6759. */
  6760. getBuffer(): Nullable<DataBuffer>;
  6761. /**
  6762. * Gets the stride in float32 units (i.e. byte stride / 4).
  6763. * May not be an integer if the byte stride is not divisible by 4.
  6764. * @returns the stride in float32 units
  6765. * @deprecated Please use byteStride instead.
  6766. */
  6767. getStrideSize(): number;
  6768. /**
  6769. * Returns the offset as a multiple of the type byte length.
  6770. * @returns the offset in bytes
  6771. * @deprecated Please use byteOffset instead.
  6772. */
  6773. getOffset(): number;
  6774. /**
  6775. * Returns the number of components per vertex attribute (integer)
  6776. * @returns the size in float
  6777. */
  6778. getSize(): number;
  6779. /**
  6780. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6781. * @returns true if this buffer is instanced
  6782. */
  6783. getIsInstanced(): boolean;
  6784. /**
  6785. * Returns the instancing divisor, zero for non-instanced (integer).
  6786. * @returns a number
  6787. */
  6788. getInstanceDivisor(): number;
  6789. /**
  6790. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6791. * @param data defines the data to store
  6792. */
  6793. create(data?: DataArray): void;
  6794. /**
  6795. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6796. * This function will create a new buffer if the current one is not updatable
  6797. * @param data defines the data to store
  6798. */
  6799. update(data: DataArray): void;
  6800. /**
  6801. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6802. * Returns the directly updated WebGLBuffer.
  6803. * @param data the new data
  6804. * @param offset the new offset
  6805. * @param useBytes set to true if the offset is in bytes
  6806. */
  6807. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6808. /**
  6809. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6810. */
  6811. dispose(): void;
  6812. /**
  6813. * Enumerates each value of this vertex buffer as numbers.
  6814. * @param count the number of values to enumerate
  6815. * @param callback the callback function called for each value
  6816. */
  6817. forEach(count: number, callback: (value: number, index: number) => void): void;
  6818. /**
  6819. * Positions
  6820. */
  6821. static readonly PositionKind: string;
  6822. /**
  6823. * Normals
  6824. */
  6825. static readonly NormalKind: string;
  6826. /**
  6827. * Tangents
  6828. */
  6829. static readonly TangentKind: string;
  6830. /**
  6831. * Texture coordinates
  6832. */
  6833. static readonly UVKind: string;
  6834. /**
  6835. * Texture coordinates 2
  6836. */
  6837. static readonly UV2Kind: string;
  6838. /**
  6839. * Texture coordinates 3
  6840. */
  6841. static readonly UV3Kind: string;
  6842. /**
  6843. * Texture coordinates 4
  6844. */
  6845. static readonly UV4Kind: string;
  6846. /**
  6847. * Texture coordinates 5
  6848. */
  6849. static readonly UV5Kind: string;
  6850. /**
  6851. * Texture coordinates 6
  6852. */
  6853. static readonly UV6Kind: string;
  6854. /**
  6855. * Colors
  6856. */
  6857. static readonly ColorKind: string;
  6858. /**
  6859. * Matrix indices (for bones)
  6860. */
  6861. static readonly MatricesIndicesKind: string;
  6862. /**
  6863. * Matrix weights (for bones)
  6864. */
  6865. static readonly MatricesWeightsKind: string;
  6866. /**
  6867. * Additional matrix indices (for bones)
  6868. */
  6869. static readonly MatricesIndicesExtraKind: string;
  6870. /**
  6871. * Additional matrix weights (for bones)
  6872. */
  6873. static readonly MatricesWeightsExtraKind: string;
  6874. /**
  6875. * Deduces the stride given a kind.
  6876. * @param kind The kind string to deduce
  6877. * @returns The deduced stride
  6878. */
  6879. static DeduceStride(kind: string): number;
  6880. /**
  6881. * Gets the byte length of the given type.
  6882. * @param type the type
  6883. * @returns the number of bytes
  6884. */
  6885. static GetTypeByteLength(type: number): number;
  6886. /**
  6887. * Enumerates each value of the given parameters as numbers.
  6888. * @param data the data to enumerate
  6889. * @param byteOffset the byte offset of the data
  6890. * @param byteStride the byte stride of the data
  6891. * @param componentCount the number of components per element
  6892. * @param componentType the type of the component
  6893. * @param count the number of values to enumerate
  6894. * @param normalized whether the data is normalized
  6895. * @param callback the callback function called for each value
  6896. */
  6897. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6898. private static _GetFloatValue;
  6899. }
  6900. }
  6901. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6902. import { Vector3 } from "babylonjs/Maths/math.vector";
  6903. import { Mesh } from "babylonjs/Meshes/mesh";
  6904. /**
  6905. * The options Interface for creating a Capsule Mesh
  6906. */
  6907. export interface ICreateCapsuleOptions {
  6908. /** The Orientation of the capsule. Default : Vector3.Up() */
  6909. orientation?: Vector3;
  6910. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6911. subdivisions: number;
  6912. /** Number of cylindrical segments on the capsule. */
  6913. tessellation: number;
  6914. /** Height or Length of the capsule. */
  6915. height: number;
  6916. /** Radius of the capsule. */
  6917. radius: number;
  6918. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6919. capSubdivisions: number;
  6920. /** Overwrite for the top radius. */
  6921. radiusTop?: number;
  6922. /** Overwrite for the bottom radius. */
  6923. radiusBottom?: number;
  6924. /** Overwrite for the top capSubdivisions. */
  6925. topCapSubdivisions?: number;
  6926. /** Overwrite for the bottom capSubdivisions. */
  6927. bottomCapSubdivisions?: number;
  6928. }
  6929. /**
  6930. * Class containing static functions to help procedurally build meshes
  6931. */
  6932. export class CapsuleBuilder {
  6933. /**
  6934. * Creates a capsule or a pill mesh
  6935. * @param name defines the name of the mesh
  6936. * @param options The constructors options.
  6937. * @param scene The scene the mesh is scoped to.
  6938. * @returns Capsule Mesh
  6939. */
  6940. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6941. }
  6942. }
  6943. declare module "babylonjs/Collisions/intersectionInfo" {
  6944. import { Nullable } from "babylonjs/types";
  6945. /**
  6946. * @hidden
  6947. */
  6948. export class IntersectionInfo {
  6949. bu: Nullable<number>;
  6950. bv: Nullable<number>;
  6951. distance: number;
  6952. faceId: number;
  6953. subMeshId: number;
  6954. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6955. }
  6956. }
  6957. declare module "babylonjs/Culling/boundingSphere" {
  6958. import { DeepImmutable } from "babylonjs/types";
  6959. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6960. import { Plane } from "babylonjs/Maths/math.plane";
  6961. /**
  6962. * Class used to store bounding sphere information
  6963. */
  6964. export class BoundingSphere {
  6965. /**
  6966. * Gets the center of the bounding sphere in local space
  6967. */
  6968. readonly center: Vector3;
  6969. /**
  6970. * Radius of the bounding sphere in local space
  6971. */
  6972. radius: number;
  6973. /**
  6974. * Gets the center of the bounding sphere in world space
  6975. */
  6976. readonly centerWorld: Vector3;
  6977. /**
  6978. * Radius of the bounding sphere in world space
  6979. */
  6980. radiusWorld: number;
  6981. /**
  6982. * Gets the minimum vector in local space
  6983. */
  6984. readonly minimum: Vector3;
  6985. /**
  6986. * Gets the maximum vector in local space
  6987. */
  6988. readonly maximum: Vector3;
  6989. private _worldMatrix;
  6990. private static readonly TmpVector3;
  6991. /**
  6992. * Creates a new bounding sphere
  6993. * @param min defines the minimum vector (in local space)
  6994. * @param max defines the maximum vector (in local space)
  6995. * @param worldMatrix defines the new world matrix
  6996. */
  6997. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6998. /**
  6999. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7000. * @param min defines the new minimum vector (in local space)
  7001. * @param max defines the new maximum vector (in local space)
  7002. * @param worldMatrix defines the new world matrix
  7003. */
  7004. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7005. /**
  7006. * Scale the current bounding sphere by applying a scale factor
  7007. * @param factor defines the scale factor to apply
  7008. * @returns the current bounding box
  7009. */
  7010. scale(factor: number): BoundingSphere;
  7011. /**
  7012. * Gets the world matrix of the bounding box
  7013. * @returns a matrix
  7014. */
  7015. getWorldMatrix(): DeepImmutable<Matrix>;
  7016. /** @hidden */
  7017. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7018. /**
  7019. * Tests if the bounding sphere is intersecting the frustum planes
  7020. * @param frustumPlanes defines the frustum planes to test
  7021. * @returns true if there is an intersection
  7022. */
  7023. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7024. /**
  7025. * Tests if the bounding sphere center is in between the frustum planes.
  7026. * Used for optimistic fast inclusion.
  7027. * @param frustumPlanes defines the frustum planes to test
  7028. * @returns true if the sphere center is in between the frustum planes
  7029. */
  7030. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7031. /**
  7032. * Tests if a point is inside the bounding sphere
  7033. * @param point defines the point to test
  7034. * @returns true if the point is inside the bounding sphere
  7035. */
  7036. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7037. /**
  7038. * Checks if two sphere intersct
  7039. * @param sphere0 sphere 0
  7040. * @param sphere1 sphere 1
  7041. * @returns true if the speres intersect
  7042. */
  7043. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7044. }
  7045. }
  7046. declare module "babylonjs/Culling/boundingBox" {
  7047. import { DeepImmutable } from "babylonjs/types";
  7048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7049. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7050. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7051. import { Plane } from "babylonjs/Maths/math.plane";
  7052. /**
  7053. * Class used to store bounding box information
  7054. */
  7055. export class BoundingBox implements ICullable {
  7056. /**
  7057. * Gets the 8 vectors representing the bounding box in local space
  7058. */
  7059. readonly vectors: Vector3[];
  7060. /**
  7061. * Gets the center of the bounding box in local space
  7062. */
  7063. readonly center: Vector3;
  7064. /**
  7065. * Gets the center of the bounding box in world space
  7066. */
  7067. readonly centerWorld: Vector3;
  7068. /**
  7069. * Gets the extend size in local space
  7070. */
  7071. readonly extendSize: Vector3;
  7072. /**
  7073. * Gets the extend size in world space
  7074. */
  7075. readonly extendSizeWorld: Vector3;
  7076. /**
  7077. * Gets the OBB (object bounding box) directions
  7078. */
  7079. readonly directions: Vector3[];
  7080. /**
  7081. * Gets the 8 vectors representing the bounding box in world space
  7082. */
  7083. readonly vectorsWorld: Vector3[];
  7084. /**
  7085. * Gets the minimum vector in world space
  7086. */
  7087. readonly minimumWorld: Vector3;
  7088. /**
  7089. * Gets the maximum vector in world space
  7090. */
  7091. readonly maximumWorld: Vector3;
  7092. /**
  7093. * Gets the minimum vector in local space
  7094. */
  7095. readonly minimum: Vector3;
  7096. /**
  7097. * Gets the maximum vector in local space
  7098. */
  7099. readonly maximum: Vector3;
  7100. private _worldMatrix;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * @hidden
  7104. */
  7105. _tag: number;
  7106. /**
  7107. * Creates a new bounding box
  7108. * @param min defines the minimum vector (in local space)
  7109. * @param max defines the maximum vector (in local space)
  7110. * @param worldMatrix defines the new world matrix
  7111. */
  7112. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7113. /**
  7114. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7115. * @param min defines the new minimum vector (in local space)
  7116. * @param max defines the new maximum vector (in local space)
  7117. * @param worldMatrix defines the new world matrix
  7118. */
  7119. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7120. /**
  7121. * Scale the current bounding box by applying a scale factor
  7122. * @param factor defines the scale factor to apply
  7123. * @returns the current bounding box
  7124. */
  7125. scale(factor: number): BoundingBox;
  7126. /**
  7127. * Gets the world matrix of the bounding box
  7128. * @returns a matrix
  7129. */
  7130. getWorldMatrix(): DeepImmutable<Matrix>;
  7131. /** @hidden */
  7132. _update(world: DeepImmutable<Matrix>): void;
  7133. /**
  7134. * Tests if the bounding box is intersecting the frustum planes
  7135. * @param frustumPlanes defines the frustum planes to test
  7136. * @returns true if there is an intersection
  7137. */
  7138. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7139. /**
  7140. * Tests if the bounding box is entirely inside the frustum planes
  7141. * @param frustumPlanes defines the frustum planes to test
  7142. * @returns true if there is an inclusion
  7143. */
  7144. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7145. /**
  7146. * Tests if a point is inside the bounding box
  7147. * @param point defines the point to test
  7148. * @returns true if the point is inside the bounding box
  7149. */
  7150. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7151. /**
  7152. * Tests if the bounding box intersects with a bounding sphere
  7153. * @param sphere defines the sphere to test
  7154. * @returns true if there is an intersection
  7155. */
  7156. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7157. /**
  7158. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7159. * @param min defines the min vector to use
  7160. * @param max defines the max vector to use
  7161. * @returns true if there is an intersection
  7162. */
  7163. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7164. /**
  7165. * Tests if two bounding boxes are intersections
  7166. * @param box0 defines the first box to test
  7167. * @param box1 defines the second box to test
  7168. * @returns true if there is an intersection
  7169. */
  7170. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7171. /**
  7172. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7173. * @param minPoint defines the minimum vector of the bounding box
  7174. * @param maxPoint defines the maximum vector of the bounding box
  7175. * @param sphereCenter defines the sphere center
  7176. * @param sphereRadius defines the sphere radius
  7177. * @returns true if there is an intersection
  7178. */
  7179. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7180. /**
  7181. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7182. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7183. * @param frustumPlanes defines the frustum planes to test
  7184. * @return true if there is an inclusion
  7185. */
  7186. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7187. /**
  7188. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7189. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7190. * @param frustumPlanes defines the frustum planes to test
  7191. * @return true if there is an intersection
  7192. */
  7193. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7194. }
  7195. }
  7196. declare module "babylonjs/Collisions/collider" {
  7197. import { Nullable, IndicesArray } from "babylonjs/types";
  7198. import { Vector3 } from "babylonjs/Maths/math.vector";
  7199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7200. import { Plane } from "babylonjs/Maths/math.plane";
  7201. /** @hidden */
  7202. export class Collider {
  7203. /** Define if a collision was found */
  7204. collisionFound: boolean;
  7205. /**
  7206. * Define last intersection point in local space
  7207. */
  7208. intersectionPoint: Vector3;
  7209. /**
  7210. * Define last collided mesh
  7211. */
  7212. collidedMesh: Nullable<AbstractMesh>;
  7213. private _collisionPoint;
  7214. private _planeIntersectionPoint;
  7215. private _tempVector;
  7216. private _tempVector2;
  7217. private _tempVector3;
  7218. private _tempVector4;
  7219. private _edge;
  7220. private _baseToVertex;
  7221. private _destinationPoint;
  7222. private _slidePlaneNormal;
  7223. private _displacementVector;
  7224. /** @hidden */
  7225. _radius: Vector3;
  7226. /** @hidden */
  7227. _retry: number;
  7228. private _velocity;
  7229. private _basePoint;
  7230. private _epsilon;
  7231. /** @hidden */
  7232. _velocityWorldLength: number;
  7233. /** @hidden */
  7234. _basePointWorld: Vector3;
  7235. private _velocityWorld;
  7236. private _normalizedVelocity;
  7237. /** @hidden */
  7238. _initialVelocity: Vector3;
  7239. /** @hidden */
  7240. _initialPosition: Vector3;
  7241. private _nearestDistance;
  7242. private _collisionMask;
  7243. get collisionMask(): number;
  7244. set collisionMask(mask: number);
  7245. /**
  7246. * Gets the plane normal used to compute the sliding response (in local space)
  7247. */
  7248. get slidePlaneNormal(): Vector3;
  7249. /** @hidden */
  7250. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7251. /** @hidden */
  7252. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7253. /** @hidden */
  7254. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7255. /** @hidden */
  7256. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7257. /** @hidden */
  7258. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7259. /** @hidden */
  7260. _getResponse(pos: Vector3, vel: Vector3): void;
  7261. }
  7262. }
  7263. declare module "babylonjs/Culling/boundingInfo" {
  7264. import { DeepImmutable } from "babylonjs/types";
  7265. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7266. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7267. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7268. import { Plane } from "babylonjs/Maths/math.plane";
  7269. import { Collider } from "babylonjs/Collisions/collider";
  7270. /**
  7271. * Interface for cullable objects
  7272. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7273. */
  7274. export interface ICullable {
  7275. /**
  7276. * Checks if the object or part of the object is in the frustum
  7277. * @param frustumPlanes Camera near/planes
  7278. * @returns true if the object is in frustum otherwise false
  7279. */
  7280. isInFrustum(frustumPlanes: Plane[]): boolean;
  7281. /**
  7282. * Checks if a cullable object (mesh...) is in the camera frustum
  7283. * Unlike isInFrustum this cheks the full bounding box
  7284. * @param frustumPlanes Camera near/planes
  7285. * @returns true if the object is in frustum otherwise false
  7286. */
  7287. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7288. }
  7289. /**
  7290. * Info for a bounding data of a mesh
  7291. */
  7292. export class BoundingInfo implements ICullable {
  7293. /**
  7294. * Bounding box for the mesh
  7295. */
  7296. readonly boundingBox: BoundingBox;
  7297. /**
  7298. * Bounding sphere for the mesh
  7299. */
  7300. readonly boundingSphere: BoundingSphere;
  7301. private _isLocked;
  7302. private static readonly TmpVector3;
  7303. /**
  7304. * Constructs bounding info
  7305. * @param minimum min vector of the bounding box/sphere
  7306. * @param maximum max vector of the bounding box/sphere
  7307. * @param worldMatrix defines the new world matrix
  7308. */
  7309. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7310. /**
  7311. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7312. * @param min defines the new minimum vector (in local space)
  7313. * @param max defines the new maximum vector (in local space)
  7314. * @param worldMatrix defines the new world matrix
  7315. */
  7316. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7317. /**
  7318. * min vector of the bounding box/sphere
  7319. */
  7320. get minimum(): Vector3;
  7321. /**
  7322. * max vector of the bounding box/sphere
  7323. */
  7324. get maximum(): Vector3;
  7325. /**
  7326. * If the info is locked and won't be updated to avoid perf overhead
  7327. */
  7328. get isLocked(): boolean;
  7329. set isLocked(value: boolean);
  7330. /**
  7331. * Updates the bounding sphere and box
  7332. * @param world world matrix to be used to update
  7333. */
  7334. update(world: DeepImmutable<Matrix>): void;
  7335. /**
  7336. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7337. * @param center New center of the bounding info
  7338. * @param extend New extend of the bounding info
  7339. * @returns the current bounding info
  7340. */
  7341. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7342. /**
  7343. * Scale the current bounding info by applying a scale factor
  7344. * @param factor defines the scale factor to apply
  7345. * @returns the current bounding info
  7346. */
  7347. scale(factor: number): BoundingInfo;
  7348. /**
  7349. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7350. * @param frustumPlanes defines the frustum to test
  7351. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7352. * @returns true if the bounding info is in the frustum planes
  7353. */
  7354. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7355. /**
  7356. * Gets the world distance between the min and max points of the bounding box
  7357. */
  7358. get diagonalLength(): number;
  7359. /**
  7360. * Checks if a cullable object (mesh...) is in the camera frustum
  7361. * Unlike isInFrustum this cheks the full bounding box
  7362. * @param frustumPlanes Camera near/planes
  7363. * @returns true if the object is in frustum otherwise false
  7364. */
  7365. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7366. /** @hidden */
  7367. _checkCollision(collider: Collider): boolean;
  7368. /**
  7369. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7370. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7371. * @param point the point to check intersection with
  7372. * @returns if the point intersects
  7373. */
  7374. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7375. /**
  7376. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7377. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7378. * @param boundingInfo the bounding info to check intersection with
  7379. * @param precise if the intersection should be done using OBB
  7380. * @returns if the bounding info intersects
  7381. */
  7382. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7383. }
  7384. }
  7385. declare module "babylonjs/Maths/math.functions" {
  7386. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7387. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7388. /**
  7389. * Extracts minimum and maximum values from a list of indexed positions
  7390. * @param positions defines the positions to use
  7391. * @param indices defines the indices to the positions
  7392. * @param indexStart defines the start index
  7393. * @param indexCount defines the end index
  7394. * @param bias defines bias value to add to the result
  7395. * @return minimum and maximum values
  7396. */
  7397. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7398. minimum: Vector3;
  7399. maximum: Vector3;
  7400. };
  7401. /**
  7402. * Extracts minimum and maximum values from a list of positions
  7403. * @param positions defines the positions to use
  7404. * @param start defines the start index in the positions array
  7405. * @param count defines the number of positions to handle
  7406. * @param bias defines bias value to add to the result
  7407. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7408. * @return minimum and maximum values
  7409. */
  7410. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7411. minimum: Vector3;
  7412. maximum: Vector3;
  7413. };
  7414. }
  7415. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7416. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7417. /** @hidden */
  7418. export class WebGLDataBuffer extends DataBuffer {
  7419. private _buffer;
  7420. constructor(resource: WebGLBuffer);
  7421. get underlyingResource(): any;
  7422. }
  7423. }
  7424. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7425. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7426. import { Nullable } from "babylonjs/types";
  7427. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7428. /** @hidden */
  7429. export class WebGLPipelineContext implements IPipelineContext {
  7430. engine: ThinEngine;
  7431. program: Nullable<WebGLProgram>;
  7432. context?: WebGLRenderingContext;
  7433. vertexShader?: WebGLShader;
  7434. fragmentShader?: WebGLShader;
  7435. isParallelCompiled: boolean;
  7436. onCompiled?: () => void;
  7437. transformFeedback?: WebGLTransformFeedback | null;
  7438. vertexCompilationError: Nullable<string>;
  7439. fragmentCompilationError: Nullable<string>;
  7440. programLinkError: Nullable<string>;
  7441. programValidationError: Nullable<string>;
  7442. get isAsync(): boolean;
  7443. get isReady(): boolean;
  7444. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7445. _getVertexShaderCode(): string | null;
  7446. _getFragmentShaderCode(): string | null;
  7447. }
  7448. }
  7449. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7450. import { FloatArray, Nullable } from "babylonjs/types";
  7451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7452. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7453. module "babylonjs/Engines/thinEngine" {
  7454. interface ThinEngine {
  7455. /**
  7456. * Create an uniform buffer
  7457. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7458. * @param elements defines the content of the uniform buffer
  7459. * @returns the webGL uniform buffer
  7460. */
  7461. createUniformBuffer(elements: FloatArray): DataBuffer;
  7462. /**
  7463. * Create a dynamic uniform buffer
  7464. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7465. * @param elements defines the content of the uniform buffer
  7466. * @returns the webGL uniform buffer
  7467. */
  7468. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7469. /**
  7470. * Update an existing uniform buffer
  7471. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7472. * @param uniformBuffer defines the target uniform buffer
  7473. * @param elements defines the content to update
  7474. * @param offset defines the offset in the uniform buffer where update should start
  7475. * @param count defines the size of the data to update
  7476. */
  7477. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7478. /**
  7479. * Bind an uniform buffer to the current webGL context
  7480. * @param buffer defines the buffer to bind
  7481. */
  7482. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7483. /**
  7484. * Bind a buffer to the current webGL context at a given location
  7485. * @param buffer defines the buffer to bind
  7486. * @param location defines the index where to bind the buffer
  7487. */
  7488. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7489. /**
  7490. * Bind a specific block at a given index in a specific shader program
  7491. * @param pipelineContext defines the pipeline context to use
  7492. * @param blockName defines the block name
  7493. * @param index defines the index where to bind the block
  7494. */
  7495. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7496. }
  7497. }
  7498. }
  7499. declare module "babylonjs/Materials/uniformBuffer" {
  7500. import { Nullable, FloatArray } from "babylonjs/types";
  7501. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7502. import { Engine } from "babylonjs/Engines/engine";
  7503. import { Effect } from "babylonjs/Materials/effect";
  7504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7505. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7506. import { Color3 } from "babylonjs/Maths/math.color";
  7507. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7508. /**
  7509. * Uniform buffer objects.
  7510. *
  7511. * Handles blocks of uniform on the GPU.
  7512. *
  7513. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7514. *
  7515. * For more information, please refer to :
  7516. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7517. */
  7518. export class UniformBuffer {
  7519. private _engine;
  7520. private _buffer;
  7521. private _data;
  7522. private _bufferData;
  7523. private _dynamic?;
  7524. private _uniformLocations;
  7525. private _uniformSizes;
  7526. private _uniformLocationPointer;
  7527. private _needSync;
  7528. private _noUBO;
  7529. private _currentEffect;
  7530. /** @hidden */
  7531. _alreadyBound: boolean;
  7532. private static _MAX_UNIFORM_SIZE;
  7533. private static _tempBuffer;
  7534. /**
  7535. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7536. * This is dynamic to allow compat with webgl 1 and 2.
  7537. * You will need to pass the name of the uniform as well as the value.
  7538. */
  7539. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7540. /**
  7541. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7542. * This is dynamic to allow compat with webgl 1 and 2.
  7543. * You will need to pass the name of the uniform as well as the value.
  7544. */
  7545. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7546. /**
  7547. * Lambda to Update a single float in a uniform buffer.
  7548. * This is dynamic to allow compat with webgl 1 and 2.
  7549. * You will need to pass the name of the uniform as well as the value.
  7550. */
  7551. updateFloat: (name: string, x: number) => void;
  7552. /**
  7553. * Lambda to Update a vec2 of float in a uniform buffer.
  7554. * This is dynamic to allow compat with webgl 1 and 2.
  7555. * You will need to pass the name of the uniform as well as the value.
  7556. */
  7557. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7558. /**
  7559. * Lambda to Update a vec3 of float in a uniform buffer.
  7560. * This is dynamic to allow compat with webgl 1 and 2.
  7561. * You will need to pass the name of the uniform as well as the value.
  7562. */
  7563. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7564. /**
  7565. * Lambda to Update a vec4 of float in a uniform buffer.
  7566. * This is dynamic to allow compat with webgl 1 and 2.
  7567. * You will need to pass the name of the uniform as well as the value.
  7568. */
  7569. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7570. /**
  7571. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7572. * This is dynamic to allow compat with webgl 1 and 2.
  7573. * You will need to pass the name of the uniform as well as the value.
  7574. */
  7575. updateMatrix: (name: string, mat: Matrix) => void;
  7576. /**
  7577. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7578. * This is dynamic to allow compat with webgl 1 and 2.
  7579. * You will need to pass the name of the uniform as well as the value.
  7580. */
  7581. updateVector3: (name: string, vector: Vector3) => void;
  7582. /**
  7583. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7584. * This is dynamic to allow compat with webgl 1 and 2.
  7585. * You will need to pass the name of the uniform as well as the value.
  7586. */
  7587. updateVector4: (name: string, vector: Vector4) => void;
  7588. /**
  7589. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7590. * This is dynamic to allow compat with webgl 1 and 2.
  7591. * You will need to pass the name of the uniform as well as the value.
  7592. */
  7593. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7594. /**
  7595. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7596. * This is dynamic to allow compat with webgl 1 and 2.
  7597. * You will need to pass the name of the uniform as well as the value.
  7598. */
  7599. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7600. /**
  7601. * Instantiates a new Uniform buffer objects.
  7602. *
  7603. * Handles blocks of uniform on the GPU.
  7604. *
  7605. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7606. *
  7607. * For more information, please refer to :
  7608. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7609. * @param engine Define the engine the buffer is associated with
  7610. * @param data Define the data contained in the buffer
  7611. * @param dynamic Define if the buffer is updatable
  7612. */
  7613. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7614. /**
  7615. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7616. * or just falling back on setUniformXXX calls.
  7617. */
  7618. get useUbo(): boolean;
  7619. /**
  7620. * Indicates if the WebGL underlying uniform buffer is in sync
  7621. * with the javascript cache data.
  7622. */
  7623. get isSync(): boolean;
  7624. /**
  7625. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7626. * Also, a dynamic UniformBuffer will disable cache verification and always
  7627. * update the underlying WebGL uniform buffer to the GPU.
  7628. * @returns if Dynamic, otherwise false
  7629. */
  7630. isDynamic(): boolean;
  7631. /**
  7632. * The data cache on JS side.
  7633. * @returns the underlying data as a float array
  7634. */
  7635. getData(): Float32Array;
  7636. /**
  7637. * The underlying WebGL Uniform buffer.
  7638. * @returns the webgl buffer
  7639. */
  7640. getBuffer(): Nullable<DataBuffer>;
  7641. /**
  7642. * std140 layout specifies how to align data within an UBO structure.
  7643. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7644. * for specs.
  7645. */
  7646. private _fillAlignment;
  7647. /**
  7648. * Adds an uniform in the buffer.
  7649. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7650. * for the layout to be correct !
  7651. * @param name Name of the uniform, as used in the uniform block in the shader.
  7652. * @param size Data size, or data directly.
  7653. */
  7654. addUniform(name: string, size: number | number[]): void;
  7655. /**
  7656. * Adds a Matrix 4x4 to the uniform buffer.
  7657. * @param name Name of the uniform, as used in the uniform block in the shader.
  7658. * @param mat A 4x4 matrix.
  7659. */
  7660. addMatrix(name: string, mat: Matrix): void;
  7661. /**
  7662. * Adds a vec2 to the uniform buffer.
  7663. * @param name Name of the uniform, as used in the uniform block in the shader.
  7664. * @param x Define the x component value of the vec2
  7665. * @param y Define the y component value of the vec2
  7666. */
  7667. addFloat2(name: string, x: number, y: number): void;
  7668. /**
  7669. * Adds a vec3 to the uniform buffer.
  7670. * @param name Name of the uniform, as used in the uniform block in the shader.
  7671. * @param x Define the x component value of the vec3
  7672. * @param y Define the y component value of the vec3
  7673. * @param z Define the z component value of the vec3
  7674. */
  7675. addFloat3(name: string, x: number, y: number, z: number): void;
  7676. /**
  7677. * Adds a vec3 to the uniform buffer.
  7678. * @param name Name of the uniform, as used in the uniform block in the shader.
  7679. * @param color Define the vec3 from a Color
  7680. */
  7681. addColor3(name: string, color: Color3): void;
  7682. /**
  7683. * Adds a vec4 to the uniform buffer.
  7684. * @param name Name of the uniform, as used in the uniform block in the shader.
  7685. * @param color Define the rgb components from a Color
  7686. * @param alpha Define the a component of the vec4
  7687. */
  7688. addColor4(name: string, color: Color3, alpha: number): void;
  7689. /**
  7690. * Adds a vec3 to the uniform buffer.
  7691. * @param name Name of the uniform, as used in the uniform block in the shader.
  7692. * @param vector Define the vec3 components from a Vector
  7693. */
  7694. addVector3(name: string, vector: Vector3): void;
  7695. /**
  7696. * Adds a Matrix 3x3 to the uniform buffer.
  7697. * @param name Name of the uniform, as used in the uniform block in the shader.
  7698. */
  7699. addMatrix3x3(name: string): void;
  7700. /**
  7701. * Adds a Matrix 2x2 to the uniform buffer.
  7702. * @param name Name of the uniform, as used in the uniform block in the shader.
  7703. */
  7704. addMatrix2x2(name: string): void;
  7705. /**
  7706. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7707. */
  7708. create(): void;
  7709. /** @hidden */
  7710. _rebuild(): void;
  7711. /**
  7712. * Updates the WebGL Uniform Buffer on the GPU.
  7713. * If the `dynamic` flag is set to true, no cache comparison is done.
  7714. * Otherwise, the buffer will be updated only if the cache differs.
  7715. */
  7716. update(): void;
  7717. /**
  7718. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7719. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7720. * @param data Define the flattened data
  7721. * @param size Define the size of the data.
  7722. */
  7723. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7724. private _valueCache;
  7725. private _cacheMatrix;
  7726. private _updateMatrix3x3ForUniform;
  7727. private _updateMatrix3x3ForEffect;
  7728. private _updateMatrix2x2ForEffect;
  7729. private _updateMatrix2x2ForUniform;
  7730. private _updateFloatForEffect;
  7731. private _updateFloatForUniform;
  7732. private _updateFloat2ForEffect;
  7733. private _updateFloat2ForUniform;
  7734. private _updateFloat3ForEffect;
  7735. private _updateFloat3ForUniform;
  7736. private _updateFloat4ForEffect;
  7737. private _updateFloat4ForUniform;
  7738. private _updateMatrixForEffect;
  7739. private _updateMatrixForUniform;
  7740. private _updateVector3ForEffect;
  7741. private _updateVector3ForUniform;
  7742. private _updateVector4ForEffect;
  7743. private _updateVector4ForUniform;
  7744. private _updateColor3ForEffect;
  7745. private _updateColor3ForUniform;
  7746. private _updateColor4ForEffect;
  7747. private _updateColor4ForUniform;
  7748. /**
  7749. * Sets a sampler uniform on the effect.
  7750. * @param name Define the name of the sampler.
  7751. * @param texture Define the texture to set in the sampler
  7752. */
  7753. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7754. /**
  7755. * Directly updates the value of the uniform in the cache AND on the GPU.
  7756. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7757. * @param data Define the flattened data
  7758. */
  7759. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7760. /**
  7761. * Binds this uniform buffer to an effect.
  7762. * @param effect Define the effect to bind the buffer to
  7763. * @param name Name of the uniform block in the shader.
  7764. */
  7765. bindToEffect(effect: Effect, name: string): void;
  7766. /**
  7767. * Disposes the uniform buffer.
  7768. */
  7769. dispose(): void;
  7770. }
  7771. }
  7772. declare module "babylonjs/Misc/iInspectable" {
  7773. /**
  7774. * Enum that determines the text-wrapping mode to use.
  7775. */
  7776. export enum InspectableType {
  7777. /**
  7778. * Checkbox for booleans
  7779. */
  7780. Checkbox = 0,
  7781. /**
  7782. * Sliders for numbers
  7783. */
  7784. Slider = 1,
  7785. /**
  7786. * Vector3
  7787. */
  7788. Vector3 = 2,
  7789. /**
  7790. * Quaternions
  7791. */
  7792. Quaternion = 3,
  7793. /**
  7794. * Color3
  7795. */
  7796. Color3 = 4,
  7797. /**
  7798. * String
  7799. */
  7800. String = 5
  7801. }
  7802. /**
  7803. * Interface used to define custom inspectable properties.
  7804. * This interface is used by the inspector to display custom property grids
  7805. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7806. */
  7807. export interface IInspectable {
  7808. /**
  7809. * Gets the label to display
  7810. */
  7811. label: string;
  7812. /**
  7813. * Gets the name of the property to edit
  7814. */
  7815. propertyName: string;
  7816. /**
  7817. * Gets the type of the editor to use
  7818. */
  7819. type: InspectableType;
  7820. /**
  7821. * Gets the minimum value of the property when using in "slider" mode
  7822. */
  7823. min?: number;
  7824. /**
  7825. * Gets the maximum value of the property when using in "slider" mode
  7826. */
  7827. max?: number;
  7828. /**
  7829. * Gets the setp to use when using in "slider" mode
  7830. */
  7831. step?: number;
  7832. }
  7833. }
  7834. declare module "babylonjs/Misc/timingTools" {
  7835. /**
  7836. * Class used to provide helper for timing
  7837. */
  7838. export class TimingTools {
  7839. /**
  7840. * Polyfill for setImmediate
  7841. * @param action defines the action to execute after the current execution block
  7842. */
  7843. static SetImmediate(action: () => void): void;
  7844. }
  7845. }
  7846. declare module "babylonjs/Misc/instantiationTools" {
  7847. /**
  7848. * Class used to enable instatition of objects by class name
  7849. */
  7850. export class InstantiationTools {
  7851. /**
  7852. * Use this object to register external classes like custom textures or material
  7853. * to allow the laoders to instantiate them
  7854. */
  7855. static RegisteredExternalClasses: {
  7856. [key: string]: Object;
  7857. };
  7858. /**
  7859. * Tries to instantiate a new object from a given class name
  7860. * @param className defines the class name to instantiate
  7861. * @returns the new object or null if the system was not able to do the instantiation
  7862. */
  7863. static Instantiate(className: string): any;
  7864. }
  7865. }
  7866. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7867. /**
  7868. * Define options used to create a depth texture
  7869. */
  7870. export class DepthTextureCreationOptions {
  7871. /** Specifies whether or not a stencil should be allocated in the texture */
  7872. generateStencil?: boolean;
  7873. /** Specifies whether or not bilinear filtering is enable on the texture */
  7874. bilinearFiltering?: boolean;
  7875. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7876. comparisonFunction?: number;
  7877. /** Specifies if the created texture is a cube texture */
  7878. isCube?: boolean;
  7879. }
  7880. }
  7881. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7882. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7883. import { Nullable } from "babylonjs/types";
  7884. import { Scene } from "babylonjs/scene";
  7885. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7886. module "babylonjs/Engines/thinEngine" {
  7887. interface ThinEngine {
  7888. /**
  7889. * Creates a depth stencil cube texture.
  7890. * This is only available in WebGL 2.
  7891. * @param size The size of face edge in the cube texture.
  7892. * @param options The options defining the cube texture.
  7893. * @returns The cube texture
  7894. */
  7895. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7896. /**
  7897. * Creates a cube texture
  7898. * @param rootUrl defines the url where the files to load is located
  7899. * @param scene defines the current scene
  7900. * @param files defines the list of files to load (1 per face)
  7901. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7902. * @param onLoad defines an optional callback raised when the texture is loaded
  7903. * @param onError defines an optional callback raised if there is an issue to load the texture
  7904. * @param format defines the format of the data
  7905. * @param forcedExtension defines the extension to use to pick the right loader
  7906. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7907. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7908. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7909. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7910. * @param loaderOptions options to be passed to the loader
  7911. * @returns the cube texture as an InternalTexture
  7912. */
  7913. 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>, loaderOptions: any): InternalTexture;
  7914. /**
  7915. * Creates a cube texture
  7916. * @param rootUrl defines the url where the files to load is located
  7917. * @param scene defines the current scene
  7918. * @param files defines the list of files to load (1 per face)
  7919. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7920. * @param onLoad defines an optional callback raised when the texture is loaded
  7921. * @param onError defines an optional callback raised if there is an issue to load the texture
  7922. * @param format defines the format of the data
  7923. * @param forcedExtension defines the extension to use to pick the right loader
  7924. * @returns the cube texture as an InternalTexture
  7925. */
  7926. 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;
  7927. /**
  7928. * Creates a cube texture
  7929. * @param rootUrl defines the url where the files to load is located
  7930. * @param scene defines the current scene
  7931. * @param files defines the list of files to load (1 per face)
  7932. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7933. * @param onLoad defines an optional callback raised when the texture is loaded
  7934. * @param onError defines an optional callback raised if there is an issue to load the texture
  7935. * @param format defines the format of the data
  7936. * @param forcedExtension defines the extension to use to pick the right loader
  7937. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7938. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7939. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7940. * @returns the cube texture as an InternalTexture
  7941. */
  7942. 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;
  7943. /** @hidden */
  7944. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7945. /** @hidden */
  7946. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7947. /** @hidden */
  7948. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7949. /** @hidden */
  7950. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7951. /**
  7952. * @hidden
  7953. */
  7954. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7955. }
  7956. }
  7957. }
  7958. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7959. import { Nullable } from "babylonjs/types";
  7960. import { Scene } from "babylonjs/scene";
  7961. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7962. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7963. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7964. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7965. import { Observable } from "babylonjs/Misc/observable";
  7966. /**
  7967. * Class for creating a cube texture
  7968. */
  7969. export class CubeTexture extends BaseTexture {
  7970. private _delayedOnLoad;
  7971. /**
  7972. * Observable triggered once the texture has been loaded.
  7973. */
  7974. onLoadObservable: Observable<CubeTexture>;
  7975. /**
  7976. * The url of the texture
  7977. */
  7978. url: string;
  7979. /**
  7980. * Gets or sets the center of the bounding box associated with the cube texture.
  7981. * It must define where the camera used to render the texture was set
  7982. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7983. */
  7984. boundingBoxPosition: Vector3;
  7985. private _boundingBoxSize;
  7986. /**
  7987. * Gets or sets the size of the bounding box associated with the cube texture
  7988. * When defined, the cubemap will switch to local mode
  7989. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7990. * @example https://www.babylonjs-playground.com/#RNASML
  7991. */
  7992. set boundingBoxSize(value: Vector3);
  7993. /**
  7994. * Returns the bounding box size
  7995. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7996. */
  7997. get boundingBoxSize(): Vector3;
  7998. protected _rotationY: number;
  7999. /**
  8000. * Sets texture matrix rotation angle around Y axis in radians.
  8001. */
  8002. set rotationY(value: number);
  8003. /**
  8004. * Gets texture matrix rotation angle around Y axis radians.
  8005. */
  8006. get rotationY(): number;
  8007. /**
  8008. * Are mip maps generated for this texture or not.
  8009. */
  8010. get noMipmap(): boolean;
  8011. private _noMipmap;
  8012. private _files;
  8013. protected _forcedExtension: Nullable<string>;
  8014. private _extensions;
  8015. private _textureMatrix;
  8016. private _format;
  8017. private _createPolynomials;
  8018. private _loaderOptions;
  8019. /**
  8020. * Creates a cube texture from an array of image urls
  8021. * @param files defines an array of image urls
  8022. * @param scene defines the hosting scene
  8023. * @param noMipmap specifies if mip maps are not used
  8024. * @returns a cube texture
  8025. */
  8026. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8027. /**
  8028. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8029. * @param url defines the url of the prefiltered texture
  8030. * @param scene defines the scene the texture is attached to
  8031. * @param forcedExtension defines the extension of the file if different from the url
  8032. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8033. * @return the prefiltered texture
  8034. */
  8035. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8036. /**
  8037. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8038. * as prefiltered data.
  8039. * @param rootUrl defines the url of the texture or the root name of the six images
  8040. * @param null defines the scene or engine the texture is attached to
  8041. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8042. * @param noMipmap defines if mipmaps should be created or not
  8043. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8044. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8045. * @param onError defines a callback triggered in case of error during load
  8046. * @param format defines the internal format to use for the texture once loaded
  8047. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8048. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8049. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8050. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8051. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8052. * @param loaderOptions options to be passed to the loader
  8053. * @return the cube texture
  8054. */
  8055. 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, loaderOptions?: any);
  8056. /**
  8057. * Get the current class name of the texture useful for serialization or dynamic coding.
  8058. * @returns "CubeTexture"
  8059. */
  8060. getClassName(): string;
  8061. /**
  8062. * Update the url (and optional buffer) of this texture if url was null during construction.
  8063. * @param url the url of the texture
  8064. * @param forcedExtension defines the extension to use
  8065. * @param onLoad callback called when the texture is loaded (defaults to null)
  8066. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8067. */
  8068. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8069. /**
  8070. * Delays loading of the cube texture
  8071. * @param forcedExtension defines the extension to use
  8072. */
  8073. delayLoad(forcedExtension?: string): void;
  8074. /**
  8075. * Returns the reflection texture matrix
  8076. * @returns the reflection texture matrix
  8077. */
  8078. getReflectionTextureMatrix(): Matrix;
  8079. /**
  8080. * Sets the reflection texture matrix
  8081. * @param value Reflection texture matrix
  8082. */
  8083. setReflectionTextureMatrix(value: Matrix): void;
  8084. /**
  8085. * Parses text to create a cube texture
  8086. * @param parsedTexture define the serialized text to read from
  8087. * @param scene defines the hosting scene
  8088. * @param rootUrl defines the root url of the cube texture
  8089. * @returns a cube texture
  8090. */
  8091. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8092. /**
  8093. * Makes a clone, or deep copy, of the cube texture
  8094. * @returns a new cube texture
  8095. */
  8096. clone(): CubeTexture;
  8097. }
  8098. }
  8099. declare module "babylonjs/Materials/materialDefines" {
  8100. /**
  8101. * Manages the defines for the Material
  8102. */
  8103. export class MaterialDefines {
  8104. /** @hidden */
  8105. protected _keys: string[];
  8106. private _isDirty;
  8107. /** @hidden */
  8108. _renderId: number;
  8109. /** @hidden */
  8110. _areLightsDirty: boolean;
  8111. /** @hidden */
  8112. _areLightsDisposed: boolean;
  8113. /** @hidden */
  8114. _areAttributesDirty: boolean;
  8115. /** @hidden */
  8116. _areTexturesDirty: boolean;
  8117. /** @hidden */
  8118. _areFresnelDirty: boolean;
  8119. /** @hidden */
  8120. _areMiscDirty: boolean;
  8121. /** @hidden */
  8122. _arePrePassDirty: boolean;
  8123. /** @hidden */
  8124. _areImageProcessingDirty: boolean;
  8125. /** @hidden */
  8126. _normals: boolean;
  8127. /** @hidden */
  8128. _uvs: boolean;
  8129. /** @hidden */
  8130. _needNormals: boolean;
  8131. /** @hidden */
  8132. _needUVs: boolean;
  8133. [id: string]: any;
  8134. /**
  8135. * Specifies if the material needs to be re-calculated
  8136. */
  8137. get isDirty(): boolean;
  8138. /**
  8139. * Marks the material to indicate that it has been re-calculated
  8140. */
  8141. markAsProcessed(): void;
  8142. /**
  8143. * Marks the material to indicate that it needs to be re-calculated
  8144. */
  8145. markAsUnprocessed(): void;
  8146. /**
  8147. * Marks the material to indicate all of its defines need to be re-calculated
  8148. */
  8149. markAllAsDirty(): void;
  8150. /**
  8151. * Marks the material to indicate that image processing needs to be re-calculated
  8152. */
  8153. markAsImageProcessingDirty(): void;
  8154. /**
  8155. * Marks the material to indicate the lights need to be re-calculated
  8156. * @param disposed Defines whether the light is dirty due to dispose or not
  8157. */
  8158. markAsLightDirty(disposed?: boolean): void;
  8159. /**
  8160. * Marks the attribute state as changed
  8161. */
  8162. markAsAttributesDirty(): void;
  8163. /**
  8164. * Marks the texture state as changed
  8165. */
  8166. markAsTexturesDirty(): void;
  8167. /**
  8168. * Marks the fresnel state as changed
  8169. */
  8170. markAsFresnelDirty(): void;
  8171. /**
  8172. * Marks the misc state as changed
  8173. */
  8174. markAsMiscDirty(): void;
  8175. /**
  8176. * Marks the prepass state as changed
  8177. */
  8178. markAsPrePassDirty(): void;
  8179. /**
  8180. * Rebuilds the material defines
  8181. */
  8182. rebuild(): void;
  8183. /**
  8184. * Specifies if two material defines are equal
  8185. * @param other - A material define instance to compare to
  8186. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8187. */
  8188. isEqual(other: MaterialDefines): boolean;
  8189. /**
  8190. * Clones this instance's defines to another instance
  8191. * @param other - material defines to clone values to
  8192. */
  8193. cloneTo(other: MaterialDefines): void;
  8194. /**
  8195. * Resets the material define values
  8196. */
  8197. reset(): void;
  8198. /**
  8199. * Converts the material define values to a string
  8200. * @returns - String of material define information
  8201. */
  8202. toString(): string;
  8203. }
  8204. }
  8205. declare module "babylonjs/Materials/colorCurves" {
  8206. import { Effect } from "babylonjs/Materials/effect";
  8207. /**
  8208. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8209. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8210. * 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;
  8211. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8212. */
  8213. export class ColorCurves {
  8214. private _dirty;
  8215. private _tempColor;
  8216. private _globalCurve;
  8217. private _highlightsCurve;
  8218. private _midtonesCurve;
  8219. private _shadowsCurve;
  8220. private _positiveCurve;
  8221. private _negativeCurve;
  8222. private _globalHue;
  8223. private _globalDensity;
  8224. private _globalSaturation;
  8225. private _globalExposure;
  8226. /**
  8227. * Gets the global Hue value.
  8228. * 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).
  8229. */
  8230. get globalHue(): number;
  8231. /**
  8232. * Sets the global Hue value.
  8233. * 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).
  8234. */
  8235. set globalHue(value: number);
  8236. /**
  8237. * Gets the global Density value.
  8238. * 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.
  8239. * Values less than zero provide a filter of opposite hue.
  8240. */
  8241. get globalDensity(): number;
  8242. /**
  8243. * Sets the global Density value.
  8244. * 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.
  8245. * Values less than zero provide a filter of opposite hue.
  8246. */
  8247. set globalDensity(value: number);
  8248. /**
  8249. * Gets the global Saturation value.
  8250. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8251. */
  8252. get globalSaturation(): number;
  8253. /**
  8254. * Sets the global Saturation value.
  8255. * 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.
  8256. */
  8257. set globalSaturation(value: number);
  8258. /**
  8259. * Gets the global Exposure value.
  8260. * 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.
  8261. */
  8262. get globalExposure(): number;
  8263. /**
  8264. * Sets the global Exposure value.
  8265. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8266. */
  8267. set globalExposure(value: number);
  8268. private _highlightsHue;
  8269. private _highlightsDensity;
  8270. private _highlightsSaturation;
  8271. private _highlightsExposure;
  8272. /**
  8273. * Gets the highlights Hue value.
  8274. * 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).
  8275. */
  8276. get highlightsHue(): number;
  8277. /**
  8278. * Sets the highlights Hue value.
  8279. * 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).
  8280. */
  8281. set highlightsHue(value: number);
  8282. /**
  8283. * Gets the highlights Density value.
  8284. * 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.
  8285. * Values less than zero provide a filter of opposite hue.
  8286. */
  8287. get highlightsDensity(): number;
  8288. /**
  8289. * Sets the highlights Density value.
  8290. * 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.
  8291. * Values less than zero provide a filter of opposite hue.
  8292. */
  8293. set highlightsDensity(value: number);
  8294. /**
  8295. * Gets the highlights Saturation value.
  8296. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8297. */
  8298. get highlightsSaturation(): number;
  8299. /**
  8300. * Sets the highlights Saturation value.
  8301. * 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.
  8302. */
  8303. set highlightsSaturation(value: number);
  8304. /**
  8305. * Gets the highlights Exposure value.
  8306. * 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.
  8307. */
  8308. get highlightsExposure(): number;
  8309. /**
  8310. * Sets the highlights Exposure value.
  8311. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8312. */
  8313. set highlightsExposure(value: number);
  8314. private _midtonesHue;
  8315. private _midtonesDensity;
  8316. private _midtonesSaturation;
  8317. private _midtonesExposure;
  8318. /**
  8319. * Gets the midtones Hue value.
  8320. * 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).
  8321. */
  8322. get midtonesHue(): number;
  8323. /**
  8324. * Sets the midtones Hue value.
  8325. * 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).
  8326. */
  8327. set midtonesHue(value: number);
  8328. /**
  8329. * Gets the midtones Density value.
  8330. * 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.
  8331. * Values less than zero provide a filter of opposite hue.
  8332. */
  8333. get midtonesDensity(): number;
  8334. /**
  8335. * Sets the midtones Density value.
  8336. * 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.
  8337. * Values less than zero provide a filter of opposite hue.
  8338. */
  8339. set midtonesDensity(value: number);
  8340. /**
  8341. * Gets the midtones Saturation value.
  8342. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8343. */
  8344. get midtonesSaturation(): number;
  8345. /**
  8346. * Sets the midtones Saturation value.
  8347. * 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.
  8348. */
  8349. set midtonesSaturation(value: number);
  8350. /**
  8351. * Gets the midtones Exposure value.
  8352. * 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.
  8353. */
  8354. get midtonesExposure(): number;
  8355. /**
  8356. * Sets the midtones Exposure value.
  8357. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8358. */
  8359. set midtonesExposure(value: number);
  8360. private _shadowsHue;
  8361. private _shadowsDensity;
  8362. private _shadowsSaturation;
  8363. private _shadowsExposure;
  8364. /**
  8365. * Gets the shadows Hue value.
  8366. * 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).
  8367. */
  8368. get shadowsHue(): number;
  8369. /**
  8370. * Sets the shadows Hue value.
  8371. * 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).
  8372. */
  8373. set shadowsHue(value: number);
  8374. /**
  8375. * Gets the shadows Density value.
  8376. * 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.
  8377. * Values less than zero provide a filter of opposite hue.
  8378. */
  8379. get shadowsDensity(): number;
  8380. /**
  8381. * Sets the shadows Density value.
  8382. * 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.
  8383. * Values less than zero provide a filter of opposite hue.
  8384. */
  8385. set shadowsDensity(value: number);
  8386. /**
  8387. * Gets the shadows Saturation value.
  8388. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8389. */
  8390. get shadowsSaturation(): number;
  8391. /**
  8392. * Sets the shadows Saturation value.
  8393. * 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.
  8394. */
  8395. set shadowsSaturation(value: number);
  8396. /**
  8397. * Gets the shadows Exposure value.
  8398. * 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.
  8399. */
  8400. get shadowsExposure(): number;
  8401. /**
  8402. * Sets the shadows Exposure value.
  8403. * 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.
  8404. */
  8405. set shadowsExposure(value: number);
  8406. /**
  8407. * Returns the class name
  8408. * @returns The class name
  8409. */
  8410. getClassName(): string;
  8411. /**
  8412. * Binds the color curves to the shader.
  8413. * @param colorCurves The color curve to bind
  8414. * @param effect The effect to bind to
  8415. * @param positiveUniform The positive uniform shader parameter
  8416. * @param neutralUniform The neutral uniform shader parameter
  8417. * @param negativeUniform The negative uniform shader parameter
  8418. */
  8419. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8420. /**
  8421. * Prepare the list of uniforms associated with the ColorCurves effects.
  8422. * @param uniformsList The list of uniforms used in the effect
  8423. */
  8424. static PrepareUniforms(uniformsList: string[]): void;
  8425. /**
  8426. * Returns color grading data based on a hue, density, saturation and exposure value.
  8427. * @param filterHue The hue of the color filter.
  8428. * @param filterDensity The density of the color filter.
  8429. * @param saturation The saturation.
  8430. * @param exposure The exposure.
  8431. * @param result The result data container.
  8432. */
  8433. private getColorGradingDataToRef;
  8434. /**
  8435. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8436. * @param value The input slider value in range [-100,100].
  8437. * @returns Adjusted value.
  8438. */
  8439. private static applyColorGradingSliderNonlinear;
  8440. /**
  8441. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8442. * @param hue The hue (H) input.
  8443. * @param saturation The saturation (S) input.
  8444. * @param brightness The brightness (B) input.
  8445. * @result An RGBA color represented as Vector4.
  8446. */
  8447. private static fromHSBToRef;
  8448. /**
  8449. * Returns a value clamped between min and max
  8450. * @param value The value to clamp
  8451. * @param min The minimum of value
  8452. * @param max The maximum of value
  8453. * @returns The clamped value.
  8454. */
  8455. private static clamp;
  8456. /**
  8457. * Clones the current color curve instance.
  8458. * @return The cloned curves
  8459. */
  8460. clone(): ColorCurves;
  8461. /**
  8462. * Serializes the current color curve instance to a json representation.
  8463. * @return a JSON representation
  8464. */
  8465. serialize(): any;
  8466. /**
  8467. * Parses the color curve from a json representation.
  8468. * @param source the JSON source to parse
  8469. * @return The parsed curves
  8470. */
  8471. static Parse(source: any): ColorCurves;
  8472. }
  8473. }
  8474. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8475. import { Observable } from "babylonjs/Misc/observable";
  8476. import { Nullable } from "babylonjs/types";
  8477. import { Color4 } from "babylonjs/Maths/math.color";
  8478. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8479. import { Effect } from "babylonjs/Materials/effect";
  8480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8481. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8482. /**
  8483. * Interface to follow in your material defines to integrate easily the
  8484. * Image proccessing functions.
  8485. * @hidden
  8486. */
  8487. export interface IImageProcessingConfigurationDefines {
  8488. IMAGEPROCESSING: boolean;
  8489. VIGNETTE: boolean;
  8490. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8491. VIGNETTEBLENDMODEOPAQUE: boolean;
  8492. TONEMAPPING: boolean;
  8493. TONEMAPPING_ACES: boolean;
  8494. CONTRAST: boolean;
  8495. EXPOSURE: boolean;
  8496. COLORCURVES: boolean;
  8497. COLORGRADING: boolean;
  8498. COLORGRADING3D: boolean;
  8499. SAMPLER3DGREENDEPTH: boolean;
  8500. SAMPLER3DBGRMAP: boolean;
  8501. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8502. }
  8503. /**
  8504. * @hidden
  8505. */
  8506. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8507. IMAGEPROCESSING: boolean;
  8508. VIGNETTE: boolean;
  8509. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8510. VIGNETTEBLENDMODEOPAQUE: boolean;
  8511. TONEMAPPING: boolean;
  8512. TONEMAPPING_ACES: boolean;
  8513. CONTRAST: boolean;
  8514. COLORCURVES: boolean;
  8515. COLORGRADING: boolean;
  8516. COLORGRADING3D: boolean;
  8517. SAMPLER3DGREENDEPTH: boolean;
  8518. SAMPLER3DBGRMAP: boolean;
  8519. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8520. EXPOSURE: boolean;
  8521. constructor();
  8522. }
  8523. /**
  8524. * This groups together the common properties used for image processing either in direct forward pass
  8525. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8526. * or not.
  8527. */
  8528. export class ImageProcessingConfiguration {
  8529. /**
  8530. * Default tone mapping applied in BabylonJS.
  8531. */
  8532. static readonly TONEMAPPING_STANDARD: number;
  8533. /**
  8534. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8535. * to other engines rendering to increase portability.
  8536. */
  8537. static readonly TONEMAPPING_ACES: number;
  8538. /**
  8539. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8540. */
  8541. colorCurves: Nullable<ColorCurves>;
  8542. private _colorCurvesEnabled;
  8543. /**
  8544. * Gets wether the color curves effect is enabled.
  8545. */
  8546. get colorCurvesEnabled(): boolean;
  8547. /**
  8548. * Sets wether the color curves effect is enabled.
  8549. */
  8550. set colorCurvesEnabled(value: boolean);
  8551. private _colorGradingTexture;
  8552. /**
  8553. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8554. */
  8555. get colorGradingTexture(): Nullable<BaseTexture>;
  8556. /**
  8557. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8558. */
  8559. set colorGradingTexture(value: Nullable<BaseTexture>);
  8560. private _colorGradingEnabled;
  8561. /**
  8562. * Gets wether the color grading effect is enabled.
  8563. */
  8564. get colorGradingEnabled(): boolean;
  8565. /**
  8566. * Sets wether the color grading effect is enabled.
  8567. */
  8568. set colorGradingEnabled(value: boolean);
  8569. private _colorGradingWithGreenDepth;
  8570. /**
  8571. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8572. */
  8573. get colorGradingWithGreenDepth(): boolean;
  8574. /**
  8575. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8576. */
  8577. set colorGradingWithGreenDepth(value: boolean);
  8578. private _colorGradingBGR;
  8579. /**
  8580. * Gets wether the color grading texture contains BGR values.
  8581. */
  8582. get colorGradingBGR(): boolean;
  8583. /**
  8584. * Sets wether the color grading texture contains BGR values.
  8585. */
  8586. set colorGradingBGR(value: boolean);
  8587. /** @hidden */
  8588. _exposure: number;
  8589. /**
  8590. * Gets the Exposure used in the effect.
  8591. */
  8592. get exposure(): number;
  8593. /**
  8594. * Sets the Exposure used in the effect.
  8595. */
  8596. set exposure(value: number);
  8597. private _toneMappingEnabled;
  8598. /**
  8599. * Gets wether the tone mapping effect is enabled.
  8600. */
  8601. get toneMappingEnabled(): boolean;
  8602. /**
  8603. * Sets wether the tone mapping effect is enabled.
  8604. */
  8605. set toneMappingEnabled(value: boolean);
  8606. private _toneMappingType;
  8607. /**
  8608. * Gets the type of tone mapping effect.
  8609. */
  8610. get toneMappingType(): number;
  8611. /**
  8612. * Sets the type of tone mapping effect used in BabylonJS.
  8613. */
  8614. set toneMappingType(value: number);
  8615. protected _contrast: number;
  8616. /**
  8617. * Gets the contrast used in the effect.
  8618. */
  8619. get contrast(): number;
  8620. /**
  8621. * Sets the contrast used in the effect.
  8622. */
  8623. set contrast(value: number);
  8624. /**
  8625. * Vignette stretch size.
  8626. */
  8627. vignetteStretch: number;
  8628. /**
  8629. * Vignette centre X Offset.
  8630. */
  8631. vignetteCentreX: number;
  8632. /**
  8633. * Vignette centre Y Offset.
  8634. */
  8635. vignetteCentreY: number;
  8636. /**
  8637. * Vignette weight or intensity of the vignette effect.
  8638. */
  8639. vignetteWeight: number;
  8640. /**
  8641. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8642. * if vignetteEnabled is set to true.
  8643. */
  8644. vignetteColor: Color4;
  8645. /**
  8646. * Camera field of view used by the Vignette effect.
  8647. */
  8648. vignetteCameraFov: number;
  8649. private _vignetteBlendMode;
  8650. /**
  8651. * Gets the vignette blend mode allowing different kind of effect.
  8652. */
  8653. get vignetteBlendMode(): number;
  8654. /**
  8655. * Sets the vignette blend mode allowing different kind of effect.
  8656. */
  8657. set vignetteBlendMode(value: number);
  8658. private _vignetteEnabled;
  8659. /**
  8660. * Gets wether the vignette effect is enabled.
  8661. */
  8662. get vignetteEnabled(): boolean;
  8663. /**
  8664. * Sets wether the vignette effect is enabled.
  8665. */
  8666. set vignetteEnabled(value: boolean);
  8667. private _applyByPostProcess;
  8668. /**
  8669. * Gets wether the image processing is applied through a post process or not.
  8670. */
  8671. get applyByPostProcess(): boolean;
  8672. /**
  8673. * Sets wether the image processing is applied through a post process or not.
  8674. */
  8675. set applyByPostProcess(value: boolean);
  8676. private _isEnabled;
  8677. /**
  8678. * Gets wether the image processing is enabled or not.
  8679. */
  8680. get isEnabled(): boolean;
  8681. /**
  8682. * Sets wether the image processing is enabled or not.
  8683. */
  8684. set isEnabled(value: boolean);
  8685. /**
  8686. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8687. */
  8688. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8689. /**
  8690. * Method called each time the image processing information changes requires to recompile the effect.
  8691. */
  8692. protected _updateParameters(): void;
  8693. /**
  8694. * Gets the current class name.
  8695. * @return "ImageProcessingConfiguration"
  8696. */
  8697. getClassName(): string;
  8698. /**
  8699. * Prepare the list of uniforms associated with the Image Processing effects.
  8700. * @param uniforms The list of uniforms used in the effect
  8701. * @param defines the list of defines currently in use
  8702. */
  8703. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8704. /**
  8705. * Prepare the list of samplers associated with the Image Processing effects.
  8706. * @param samplersList The list of uniforms used in the effect
  8707. * @param defines the list of defines currently in use
  8708. */
  8709. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8710. /**
  8711. * Prepare the list of defines associated to the shader.
  8712. * @param defines the list of defines to complete
  8713. * @param forPostProcess Define if we are currently in post process mode or not
  8714. */
  8715. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8716. /**
  8717. * Returns true if all the image processing information are ready.
  8718. * @returns True if ready, otherwise, false
  8719. */
  8720. isReady(): boolean;
  8721. /**
  8722. * Binds the image processing to the shader.
  8723. * @param effect The effect to bind to
  8724. * @param overrideAspectRatio Override the aspect ratio of the effect
  8725. */
  8726. bind(effect: Effect, overrideAspectRatio?: number): void;
  8727. /**
  8728. * Clones the current image processing instance.
  8729. * @return The cloned image processing
  8730. */
  8731. clone(): ImageProcessingConfiguration;
  8732. /**
  8733. * Serializes the current image processing instance to a json representation.
  8734. * @return a JSON representation
  8735. */
  8736. serialize(): any;
  8737. /**
  8738. * Parses the image processing from a json representation.
  8739. * @param source the JSON source to parse
  8740. * @return The parsed image processing
  8741. */
  8742. static Parse(source: any): ImageProcessingConfiguration;
  8743. private static _VIGNETTEMODE_MULTIPLY;
  8744. private static _VIGNETTEMODE_OPAQUE;
  8745. /**
  8746. * Used to apply the vignette as a mix with the pixel color.
  8747. */
  8748. static get VIGNETTEMODE_MULTIPLY(): number;
  8749. /**
  8750. * Used to apply the vignette as a replacement of the pixel color.
  8751. */
  8752. static get VIGNETTEMODE_OPAQUE(): number;
  8753. }
  8754. }
  8755. declare module "babylonjs/Shaders/postprocess.vertex" {
  8756. /** @hidden */
  8757. export var postprocessVertexShader: {
  8758. name: string;
  8759. shader: string;
  8760. };
  8761. }
  8762. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8763. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8764. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8765. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8766. /**
  8767. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8768. */
  8769. export type RenderTargetTextureSize = number | {
  8770. width: number;
  8771. height: number;
  8772. layers?: number;
  8773. };
  8774. module "babylonjs/Engines/thinEngine" {
  8775. interface ThinEngine {
  8776. /**
  8777. * Creates a new render target texture
  8778. * @param size defines the size of the texture
  8779. * @param options defines the options used to create the texture
  8780. * @returns a new render target texture stored in an InternalTexture
  8781. */
  8782. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8783. /**
  8784. * Creates a depth stencil texture.
  8785. * This is only available in WebGL 2 or with the depth texture extension available.
  8786. * @param size The size of face edge in the texture.
  8787. * @param options The options defining the texture.
  8788. * @returns The texture
  8789. */
  8790. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8791. /** @hidden */
  8792. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8793. }
  8794. }
  8795. }
  8796. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8797. /**
  8798. * Defines the kind of connection point for node based material
  8799. */
  8800. export enum NodeMaterialBlockConnectionPointTypes {
  8801. /** Float */
  8802. Float = 1,
  8803. /** Int */
  8804. Int = 2,
  8805. /** Vector2 */
  8806. Vector2 = 4,
  8807. /** Vector3 */
  8808. Vector3 = 8,
  8809. /** Vector4 */
  8810. Vector4 = 16,
  8811. /** Color3 */
  8812. Color3 = 32,
  8813. /** Color4 */
  8814. Color4 = 64,
  8815. /** Matrix */
  8816. Matrix = 128,
  8817. /** Custom object */
  8818. Object = 256,
  8819. /** Detect type based on connection */
  8820. AutoDetect = 1024,
  8821. /** Output type that will be defined by input type */
  8822. BasedOnInput = 2048
  8823. }
  8824. }
  8825. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8826. /**
  8827. * Enum used to define the target of a block
  8828. */
  8829. export enum NodeMaterialBlockTargets {
  8830. /** Vertex shader */
  8831. Vertex = 1,
  8832. /** Fragment shader */
  8833. Fragment = 2,
  8834. /** Neutral */
  8835. Neutral = 4,
  8836. /** Vertex and Fragment */
  8837. VertexAndFragment = 3
  8838. }
  8839. }
  8840. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8841. /**
  8842. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8843. */
  8844. export enum NodeMaterialBlockConnectionPointMode {
  8845. /** Value is an uniform */
  8846. Uniform = 0,
  8847. /** Value is a mesh attribute */
  8848. Attribute = 1,
  8849. /** Value is a varying between vertex and fragment shaders */
  8850. Varying = 2,
  8851. /** Mode is undefined */
  8852. Undefined = 3
  8853. }
  8854. }
  8855. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8856. /**
  8857. * Enum used to define system values e.g. values automatically provided by the system
  8858. */
  8859. export enum NodeMaterialSystemValues {
  8860. /** World */
  8861. World = 1,
  8862. /** View */
  8863. View = 2,
  8864. /** Projection */
  8865. Projection = 3,
  8866. /** ViewProjection */
  8867. ViewProjection = 4,
  8868. /** WorldView */
  8869. WorldView = 5,
  8870. /** WorldViewProjection */
  8871. WorldViewProjection = 6,
  8872. /** CameraPosition */
  8873. CameraPosition = 7,
  8874. /** Fog Color */
  8875. FogColor = 8,
  8876. /** Delta time */
  8877. DeltaTime = 9
  8878. }
  8879. }
  8880. declare module "babylonjs/Maths/math.axis" {
  8881. import { Vector3 } from "babylonjs/Maths/math.vector";
  8882. /** Defines supported spaces */
  8883. export enum Space {
  8884. /** Local (object) space */
  8885. LOCAL = 0,
  8886. /** World space */
  8887. WORLD = 1,
  8888. /** Bone space */
  8889. BONE = 2
  8890. }
  8891. /** Defines the 3 main axes */
  8892. export class Axis {
  8893. /** X axis */
  8894. static X: Vector3;
  8895. /** Y axis */
  8896. static Y: Vector3;
  8897. /** Z axis */
  8898. static Z: Vector3;
  8899. }
  8900. }
  8901. declare module "babylonjs/Maths/math.frustum" {
  8902. import { Matrix } from "babylonjs/Maths/math.vector";
  8903. import { DeepImmutable } from "babylonjs/types";
  8904. import { Plane } from "babylonjs/Maths/math.plane";
  8905. /**
  8906. * Represents a camera frustum
  8907. */
  8908. export class Frustum {
  8909. /**
  8910. * Gets the planes representing the frustum
  8911. * @param transform matrix to be applied to the returned planes
  8912. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8913. */
  8914. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8915. /**
  8916. * Gets the near frustum plane transformed by the transform matrix
  8917. * @param transform transformation matrix to be applied to the resulting frustum plane
  8918. * @param frustumPlane the resuling frustum plane
  8919. */
  8920. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8921. /**
  8922. * Gets the far frustum plane transformed by the transform matrix
  8923. * @param transform transformation matrix to be applied to the resulting frustum plane
  8924. * @param frustumPlane the resuling frustum plane
  8925. */
  8926. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8927. /**
  8928. * Gets the left frustum plane transformed by the transform matrix
  8929. * @param transform transformation matrix to be applied to the resulting frustum plane
  8930. * @param frustumPlane the resuling frustum plane
  8931. */
  8932. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8933. /**
  8934. * Gets the right frustum plane transformed by the transform matrix
  8935. * @param transform transformation matrix to be applied to the resulting frustum plane
  8936. * @param frustumPlane the resuling frustum plane
  8937. */
  8938. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8939. /**
  8940. * Gets the top frustum plane transformed by the transform matrix
  8941. * @param transform transformation matrix to be applied to the resulting frustum plane
  8942. * @param frustumPlane the resuling frustum plane
  8943. */
  8944. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8945. /**
  8946. * Gets the bottom frustum plane transformed by the transform matrix
  8947. * @param transform transformation matrix to be applied to the resulting frustum plane
  8948. * @param frustumPlane the resuling frustum plane
  8949. */
  8950. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8951. /**
  8952. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8953. * @param transform transformation matrix to be applied to the resulting frustum planes
  8954. * @param frustumPlanes the resuling frustum planes
  8955. */
  8956. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8957. }
  8958. }
  8959. declare module "babylonjs/Maths/math.size" {
  8960. /**
  8961. * Interface for the size containing width and height
  8962. */
  8963. export interface ISize {
  8964. /**
  8965. * Width
  8966. */
  8967. width: number;
  8968. /**
  8969. * Heighht
  8970. */
  8971. height: number;
  8972. }
  8973. /**
  8974. * Size containing widht and height
  8975. */
  8976. export class Size implements ISize {
  8977. /**
  8978. * Width
  8979. */
  8980. width: number;
  8981. /**
  8982. * Height
  8983. */
  8984. height: number;
  8985. /**
  8986. * Creates a Size object from the given width and height (floats).
  8987. * @param width width of the new size
  8988. * @param height height of the new size
  8989. */
  8990. constructor(width: number, height: number);
  8991. /**
  8992. * Returns a string with the Size width and height
  8993. * @returns a string with the Size width and height
  8994. */
  8995. toString(): string;
  8996. /**
  8997. * "Size"
  8998. * @returns the string "Size"
  8999. */
  9000. getClassName(): string;
  9001. /**
  9002. * Returns the Size hash code.
  9003. * @returns a hash code for a unique width and height
  9004. */
  9005. getHashCode(): number;
  9006. /**
  9007. * Updates the current size from the given one.
  9008. * @param src the given size
  9009. */
  9010. copyFrom(src: Size): void;
  9011. /**
  9012. * Updates in place the current Size from the given floats.
  9013. * @param width width of the new size
  9014. * @param height height of the new size
  9015. * @returns the updated Size.
  9016. */
  9017. copyFromFloats(width: number, height: number): Size;
  9018. /**
  9019. * Updates in place the current Size from the given floats.
  9020. * @param width width to set
  9021. * @param height height to set
  9022. * @returns the updated Size.
  9023. */
  9024. set(width: number, height: number): Size;
  9025. /**
  9026. * Multiplies the width and height by numbers
  9027. * @param w factor to multiple the width by
  9028. * @param h factor to multiple the height by
  9029. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9030. */
  9031. multiplyByFloats(w: number, h: number): Size;
  9032. /**
  9033. * Clones the size
  9034. * @returns a new Size copied from the given one.
  9035. */
  9036. clone(): Size;
  9037. /**
  9038. * True if the current Size and the given one width and height are strictly equal.
  9039. * @param other the other size to compare against
  9040. * @returns True if the current Size and the given one width and height are strictly equal.
  9041. */
  9042. equals(other: Size): boolean;
  9043. /**
  9044. * The surface of the Size : width * height (float).
  9045. */
  9046. get surface(): number;
  9047. /**
  9048. * Create a new size of zero
  9049. * @returns a new Size set to (0.0, 0.0)
  9050. */
  9051. static Zero(): Size;
  9052. /**
  9053. * Sums the width and height of two sizes
  9054. * @param otherSize size to add to this size
  9055. * @returns a new Size set as the addition result of the current Size and the given one.
  9056. */
  9057. add(otherSize: Size): Size;
  9058. /**
  9059. * Subtracts the width and height of two
  9060. * @param otherSize size to subtract to this size
  9061. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9062. */
  9063. subtract(otherSize: Size): Size;
  9064. /**
  9065. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9066. * @param start starting size to lerp between
  9067. * @param end end size to lerp between
  9068. * @param amount amount to lerp between the start and end values
  9069. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9070. */
  9071. static Lerp(start: Size, end: Size, amount: number): Size;
  9072. }
  9073. }
  9074. declare module "babylonjs/Maths/math.vertexFormat" {
  9075. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9076. /**
  9077. * Contains position and normal vectors for a vertex
  9078. */
  9079. export class PositionNormalVertex {
  9080. /** the position of the vertex (defaut: 0,0,0) */
  9081. position: Vector3;
  9082. /** the normal of the vertex (defaut: 0,1,0) */
  9083. normal: Vector3;
  9084. /**
  9085. * Creates a PositionNormalVertex
  9086. * @param position the position of the vertex (defaut: 0,0,0)
  9087. * @param normal the normal of the vertex (defaut: 0,1,0)
  9088. */
  9089. constructor(
  9090. /** the position of the vertex (defaut: 0,0,0) */
  9091. position?: Vector3,
  9092. /** the normal of the vertex (defaut: 0,1,0) */
  9093. normal?: Vector3);
  9094. /**
  9095. * Clones the PositionNormalVertex
  9096. * @returns the cloned PositionNormalVertex
  9097. */
  9098. clone(): PositionNormalVertex;
  9099. }
  9100. /**
  9101. * Contains position, normal and uv vectors for a vertex
  9102. */
  9103. export class PositionNormalTextureVertex {
  9104. /** the position of the vertex (defaut: 0,0,0) */
  9105. position: Vector3;
  9106. /** the normal of the vertex (defaut: 0,1,0) */
  9107. normal: Vector3;
  9108. /** the uv of the vertex (default: 0,0) */
  9109. uv: Vector2;
  9110. /**
  9111. * Creates a PositionNormalTextureVertex
  9112. * @param position the position of the vertex (defaut: 0,0,0)
  9113. * @param normal the normal of the vertex (defaut: 0,1,0)
  9114. * @param uv the uv of the vertex (default: 0,0)
  9115. */
  9116. constructor(
  9117. /** the position of the vertex (defaut: 0,0,0) */
  9118. position?: Vector3,
  9119. /** the normal of the vertex (defaut: 0,1,0) */
  9120. normal?: Vector3,
  9121. /** the uv of the vertex (default: 0,0) */
  9122. uv?: Vector2);
  9123. /**
  9124. * Clones the PositionNormalTextureVertex
  9125. * @returns the cloned PositionNormalTextureVertex
  9126. */
  9127. clone(): PositionNormalTextureVertex;
  9128. }
  9129. }
  9130. declare module "babylonjs/Maths/math" {
  9131. export * from "babylonjs/Maths/math.axis";
  9132. export * from "babylonjs/Maths/math.color";
  9133. export * from "babylonjs/Maths/math.constants";
  9134. export * from "babylonjs/Maths/math.frustum";
  9135. export * from "babylonjs/Maths/math.path";
  9136. export * from "babylonjs/Maths/math.plane";
  9137. export * from "babylonjs/Maths/math.size";
  9138. export * from "babylonjs/Maths/math.vector";
  9139. export * from "babylonjs/Maths/math.vertexFormat";
  9140. export * from "babylonjs/Maths/math.viewport";
  9141. }
  9142. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9143. /**
  9144. * Enum defining the type of animations supported by InputBlock
  9145. */
  9146. export enum AnimatedInputBlockTypes {
  9147. /** No animation */
  9148. None = 0,
  9149. /** Time based animation. Will only work for floats */
  9150. Time = 1
  9151. }
  9152. }
  9153. declare module "babylonjs/Lights/shadowLight" {
  9154. import { Camera } from "babylonjs/Cameras/camera";
  9155. import { Scene } from "babylonjs/scene";
  9156. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9158. import { Light } from "babylonjs/Lights/light";
  9159. /**
  9160. * Interface describing all the common properties and methods a shadow light needs to implement.
  9161. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9162. * as well as binding the different shadow properties to the effects.
  9163. */
  9164. export interface IShadowLight extends Light {
  9165. /**
  9166. * The light id in the scene (used in scene.findLighById for instance)
  9167. */
  9168. id: string;
  9169. /**
  9170. * The position the shdow will be casted from.
  9171. */
  9172. position: Vector3;
  9173. /**
  9174. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9175. */
  9176. direction: Vector3;
  9177. /**
  9178. * The transformed position. Position of the light in world space taking parenting in account.
  9179. */
  9180. transformedPosition: Vector3;
  9181. /**
  9182. * The transformed direction. Direction of the light in world space taking parenting in account.
  9183. */
  9184. transformedDirection: Vector3;
  9185. /**
  9186. * The friendly name of the light in the scene.
  9187. */
  9188. name: string;
  9189. /**
  9190. * Defines the shadow projection clipping minimum z value.
  9191. */
  9192. shadowMinZ: number;
  9193. /**
  9194. * Defines the shadow projection clipping maximum z value.
  9195. */
  9196. shadowMaxZ: number;
  9197. /**
  9198. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9199. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9200. */
  9201. computeTransformedInformation(): boolean;
  9202. /**
  9203. * Gets the scene the light belongs to.
  9204. * @returns The scene
  9205. */
  9206. getScene(): Scene;
  9207. /**
  9208. * Callback defining a custom Projection Matrix Builder.
  9209. * This can be used to override the default projection matrix computation.
  9210. */
  9211. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9212. /**
  9213. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9214. * @param matrix The materix to updated with the projection information
  9215. * @param viewMatrix The transform matrix of the light
  9216. * @param renderList The list of mesh to render in the map
  9217. * @returns The current light
  9218. */
  9219. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9220. /**
  9221. * Gets the current depth scale used in ESM.
  9222. * @returns The scale
  9223. */
  9224. getDepthScale(): number;
  9225. /**
  9226. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9227. * @returns true if a cube texture needs to be use
  9228. */
  9229. needCube(): boolean;
  9230. /**
  9231. * Detects if the projection matrix requires to be recomputed this frame.
  9232. * @returns true if it requires to be recomputed otherwise, false.
  9233. */
  9234. needProjectionMatrixCompute(): boolean;
  9235. /**
  9236. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9237. */
  9238. forceProjectionMatrixCompute(): void;
  9239. /**
  9240. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9241. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9242. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9243. */
  9244. getShadowDirection(faceIndex?: number): Vector3;
  9245. /**
  9246. * Gets the minZ used for shadow according to both the scene and the light.
  9247. * @param activeCamera The camera we are returning the min for
  9248. * @returns the depth min z
  9249. */
  9250. getDepthMinZ(activeCamera: Camera): number;
  9251. /**
  9252. * Gets the maxZ used for shadow according to both the scene and the light.
  9253. * @param activeCamera The camera we are returning the max for
  9254. * @returns the depth max z
  9255. */
  9256. getDepthMaxZ(activeCamera: Camera): number;
  9257. }
  9258. /**
  9259. * Base implementation IShadowLight
  9260. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9261. */
  9262. export abstract class ShadowLight extends Light implements IShadowLight {
  9263. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9264. protected _position: Vector3;
  9265. protected _setPosition(value: Vector3): void;
  9266. /**
  9267. * Sets the position the shadow will be casted from. Also use as the light position for both
  9268. * point and spot lights.
  9269. */
  9270. get position(): Vector3;
  9271. /**
  9272. * Sets the position the shadow will be casted from. Also use as the light position for both
  9273. * point and spot lights.
  9274. */
  9275. set position(value: Vector3);
  9276. protected _direction: Vector3;
  9277. protected _setDirection(value: Vector3): void;
  9278. /**
  9279. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9280. * Also use as the light direction on spot and directional lights.
  9281. */
  9282. get direction(): Vector3;
  9283. /**
  9284. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9285. * Also use as the light direction on spot and directional lights.
  9286. */
  9287. set direction(value: Vector3);
  9288. protected _shadowMinZ: number;
  9289. /**
  9290. * Gets the shadow projection clipping minimum z value.
  9291. */
  9292. get shadowMinZ(): number;
  9293. /**
  9294. * Sets the shadow projection clipping minimum z value.
  9295. */
  9296. set shadowMinZ(value: number);
  9297. protected _shadowMaxZ: number;
  9298. /**
  9299. * Sets the shadow projection clipping maximum z value.
  9300. */
  9301. get shadowMaxZ(): number;
  9302. /**
  9303. * Gets the shadow projection clipping maximum z value.
  9304. */
  9305. set shadowMaxZ(value: number);
  9306. /**
  9307. * Callback defining a custom Projection Matrix Builder.
  9308. * This can be used to override the default projection matrix computation.
  9309. */
  9310. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9311. /**
  9312. * The transformed position. Position of the light in world space taking parenting in account.
  9313. */
  9314. transformedPosition: Vector3;
  9315. /**
  9316. * The transformed direction. Direction of the light in world space taking parenting in account.
  9317. */
  9318. transformedDirection: Vector3;
  9319. private _needProjectionMatrixCompute;
  9320. /**
  9321. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9322. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9323. */
  9324. computeTransformedInformation(): boolean;
  9325. /**
  9326. * Return the depth scale used for the shadow map.
  9327. * @returns the depth scale.
  9328. */
  9329. getDepthScale(): number;
  9330. /**
  9331. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9332. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9333. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9334. */
  9335. getShadowDirection(faceIndex?: number): Vector3;
  9336. /**
  9337. * Returns the ShadowLight absolute position in the World.
  9338. * @returns the position vector in world space
  9339. */
  9340. getAbsolutePosition(): Vector3;
  9341. /**
  9342. * Sets the ShadowLight direction toward the passed target.
  9343. * @param target The point to target in local space
  9344. * @returns the updated ShadowLight direction
  9345. */
  9346. setDirectionToTarget(target: Vector3): Vector3;
  9347. /**
  9348. * Returns the light rotation in euler definition.
  9349. * @returns the x y z rotation in local space.
  9350. */
  9351. getRotation(): Vector3;
  9352. /**
  9353. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9354. * @returns true if a cube texture needs to be use
  9355. */
  9356. needCube(): boolean;
  9357. /**
  9358. * Detects if the projection matrix requires to be recomputed this frame.
  9359. * @returns true if it requires to be recomputed otherwise, false.
  9360. */
  9361. needProjectionMatrixCompute(): boolean;
  9362. /**
  9363. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9364. */
  9365. forceProjectionMatrixCompute(): void;
  9366. /** @hidden */
  9367. _initCache(): void;
  9368. /** @hidden */
  9369. _isSynchronized(): boolean;
  9370. /**
  9371. * Computes the world matrix of the node
  9372. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9373. * @returns the world matrix
  9374. */
  9375. computeWorldMatrix(force?: boolean): Matrix;
  9376. /**
  9377. * Gets the minZ used for shadow according to both the scene and the light.
  9378. * @param activeCamera The camera we are returning the min for
  9379. * @returns the depth min z
  9380. */
  9381. getDepthMinZ(activeCamera: Camera): number;
  9382. /**
  9383. * Gets the maxZ used for shadow according to both the scene and the light.
  9384. * @param activeCamera The camera we are returning the max for
  9385. * @returns the depth max z
  9386. */
  9387. getDepthMaxZ(activeCamera: Camera): number;
  9388. /**
  9389. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9390. * @param matrix The materix to updated with the projection information
  9391. * @param viewMatrix The transform matrix of the light
  9392. * @param renderList The list of mesh to render in the map
  9393. * @returns The current light
  9394. */
  9395. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9396. }
  9397. }
  9398. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9399. /** @hidden */
  9400. export var packingFunctions: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9406. /** @hidden */
  9407. export var bayerDitherFunctions: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9413. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9414. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9415. /** @hidden */
  9416. export var shadowMapFragmentDeclaration: {
  9417. name: string;
  9418. shader: string;
  9419. };
  9420. }
  9421. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9422. /** @hidden */
  9423. export var clipPlaneFragmentDeclaration: {
  9424. name: string;
  9425. shader: string;
  9426. };
  9427. }
  9428. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9429. /** @hidden */
  9430. export var clipPlaneFragment: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9436. /** @hidden */
  9437. export var shadowMapFragment: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9443. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9444. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9445. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9446. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9447. /** @hidden */
  9448. export var shadowMapPixelShader: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9454. /** @hidden */
  9455. export var bonesDeclaration: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9461. /** @hidden */
  9462. export var morphTargetsVertexGlobalDeclaration: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9468. /** @hidden */
  9469. export var morphTargetsVertexDeclaration: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9475. /** @hidden */
  9476. export var instancesDeclaration: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9482. /** @hidden */
  9483. export var helperFunctions: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9489. /** @hidden */
  9490. export var shadowMapVertexDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9496. /** @hidden */
  9497. export var clipPlaneVertexDeclaration: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9503. /** @hidden */
  9504. export var morphTargetsVertex: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9510. /** @hidden */
  9511. export var instancesVertex: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9517. /** @hidden */
  9518. export var bonesVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9524. /** @hidden */
  9525. export var shadowMapVertexNormalBias: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9531. /** @hidden */
  9532. export var shadowMapVertexMetric: {
  9533. name: string;
  9534. shader: string;
  9535. };
  9536. }
  9537. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9538. /** @hidden */
  9539. export var clipPlaneVertex: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9545. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9548. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9549. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9550. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9551. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9552. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9553. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9554. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9555. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9556. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9557. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9558. /** @hidden */
  9559. export var shadowMapVertexShader: {
  9560. name: string;
  9561. shader: string;
  9562. };
  9563. }
  9564. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9565. /** @hidden */
  9566. export var depthBoxBlurPixelShader: {
  9567. name: string;
  9568. shader: string;
  9569. };
  9570. }
  9571. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9572. /** @hidden */
  9573. export var shadowMapFragmentSoftTransparentShadow: {
  9574. name: string;
  9575. shader: string;
  9576. };
  9577. }
  9578. declare module "babylonjs/Materials/effectFallbacks" {
  9579. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9580. import { Effect } from "babylonjs/Materials/effect";
  9581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9582. /**
  9583. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9584. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9585. */
  9586. export class EffectFallbacks implements IEffectFallbacks {
  9587. private _defines;
  9588. private _currentRank;
  9589. private _maxRank;
  9590. private _mesh;
  9591. /**
  9592. * Removes the fallback from the bound mesh.
  9593. */
  9594. unBindMesh(): void;
  9595. /**
  9596. * Adds a fallback on the specified property.
  9597. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9598. * @param define The name of the define in the shader
  9599. */
  9600. addFallback(rank: number, define: string): void;
  9601. /**
  9602. * Sets the mesh to use CPU skinning when needing to fallback.
  9603. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9604. * @param mesh The mesh to use the fallbacks.
  9605. */
  9606. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9607. /**
  9608. * Checks to see if more fallbacks are still availible.
  9609. */
  9610. get hasMoreFallbacks(): boolean;
  9611. /**
  9612. * Removes the defines that should be removed when falling back.
  9613. * @param currentDefines defines the current define statements for the shader.
  9614. * @param effect defines the current effect we try to compile
  9615. * @returns The resulting defines with defines of the current rank removed.
  9616. */
  9617. reduce(currentDefines: string, effect: Effect): string;
  9618. }
  9619. }
  9620. declare module "babylonjs/Actions/action" {
  9621. import { Observable } from "babylonjs/Misc/observable";
  9622. import { Condition } from "babylonjs/Actions/condition";
  9623. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9624. import { Nullable } from "babylonjs/types";
  9625. import { Scene } from "babylonjs/scene";
  9626. import { ActionManager } from "babylonjs/Actions/actionManager";
  9627. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9628. import { Node } from "babylonjs/node";
  9629. /**
  9630. * Interface used to define Action
  9631. */
  9632. export interface IAction {
  9633. /**
  9634. * Trigger for the action
  9635. */
  9636. trigger: number;
  9637. /** Options of the trigger */
  9638. triggerOptions: any;
  9639. /**
  9640. * Gets the trigger parameters
  9641. * @returns the trigger parameters
  9642. */
  9643. getTriggerParameter(): any;
  9644. /**
  9645. * Internal only - executes current action event
  9646. * @hidden
  9647. */
  9648. _executeCurrent(evt?: ActionEvent): void;
  9649. /**
  9650. * Serialize placeholder for child classes
  9651. * @param parent of child
  9652. * @returns the serialized object
  9653. */
  9654. serialize(parent: any): any;
  9655. /**
  9656. * Internal only
  9657. * @hidden
  9658. */
  9659. _prepare(): void;
  9660. /**
  9661. * Internal only - manager for action
  9662. * @hidden
  9663. */
  9664. _actionManager: Nullable<AbstractActionManager>;
  9665. /**
  9666. * Adds action to chain of actions, may be a DoNothingAction
  9667. * @param action defines the next action to execute
  9668. * @returns The action passed in
  9669. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9670. */
  9671. then(action: IAction): IAction;
  9672. }
  9673. /**
  9674. * The action to be carried out following a trigger
  9675. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9676. */
  9677. export class Action implements IAction {
  9678. /** the trigger, with or without parameters, for the action */
  9679. triggerOptions: any;
  9680. /**
  9681. * Trigger for the action
  9682. */
  9683. trigger: number;
  9684. /**
  9685. * Internal only - manager for action
  9686. * @hidden
  9687. */
  9688. _actionManager: ActionManager;
  9689. private _nextActiveAction;
  9690. private _child;
  9691. private _condition?;
  9692. private _triggerParameter;
  9693. /**
  9694. * An event triggered prior to action being executed.
  9695. */
  9696. onBeforeExecuteObservable: Observable<Action>;
  9697. /**
  9698. * Creates a new Action
  9699. * @param triggerOptions the trigger, with or without parameters, for the action
  9700. * @param condition an optional determinant of action
  9701. */
  9702. constructor(
  9703. /** the trigger, with or without parameters, for the action */
  9704. triggerOptions: any, condition?: Condition);
  9705. /**
  9706. * Internal only
  9707. * @hidden
  9708. */
  9709. _prepare(): void;
  9710. /**
  9711. * Gets the trigger parameters
  9712. * @returns the trigger parameters
  9713. */
  9714. getTriggerParameter(): any;
  9715. /**
  9716. * Internal only - executes current action event
  9717. * @hidden
  9718. */
  9719. _executeCurrent(evt?: ActionEvent): void;
  9720. /**
  9721. * Execute placeholder for child classes
  9722. * @param evt optional action event
  9723. */
  9724. execute(evt?: ActionEvent): void;
  9725. /**
  9726. * Skips to next active action
  9727. */
  9728. skipToNextActiveAction(): void;
  9729. /**
  9730. * Adds action to chain of actions, may be a DoNothingAction
  9731. * @param action defines the next action to execute
  9732. * @returns The action passed in
  9733. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9734. */
  9735. then(action: Action): Action;
  9736. /**
  9737. * Internal only
  9738. * @hidden
  9739. */
  9740. _getProperty(propertyPath: string): string;
  9741. /**
  9742. * Internal only
  9743. * @hidden
  9744. */
  9745. _getEffectiveTarget(target: any, propertyPath: string): any;
  9746. /**
  9747. * Serialize placeholder for child classes
  9748. * @param parent of child
  9749. * @returns the serialized object
  9750. */
  9751. serialize(parent: any): any;
  9752. /**
  9753. * Internal only called by serialize
  9754. * @hidden
  9755. */
  9756. protected _serialize(serializedAction: any, parent?: any): any;
  9757. /**
  9758. * Internal only
  9759. * @hidden
  9760. */
  9761. static _SerializeValueAsString: (value: any) => string;
  9762. /**
  9763. * Internal only
  9764. * @hidden
  9765. */
  9766. static _GetTargetProperty: (target: Scene | Node) => {
  9767. name: string;
  9768. targetType: string;
  9769. value: string;
  9770. };
  9771. }
  9772. }
  9773. declare module "babylonjs/Actions/condition" {
  9774. import { ActionManager } from "babylonjs/Actions/actionManager";
  9775. /**
  9776. * A Condition applied to an Action
  9777. */
  9778. export class Condition {
  9779. /**
  9780. * Internal only - manager for action
  9781. * @hidden
  9782. */
  9783. _actionManager: ActionManager;
  9784. /**
  9785. * Internal only
  9786. * @hidden
  9787. */
  9788. _evaluationId: number;
  9789. /**
  9790. * Internal only
  9791. * @hidden
  9792. */
  9793. _currentResult: boolean;
  9794. /**
  9795. * Creates a new Condition
  9796. * @param actionManager the manager of the action the condition is applied to
  9797. */
  9798. constructor(actionManager: ActionManager);
  9799. /**
  9800. * Check if the current condition is valid
  9801. * @returns a boolean
  9802. */
  9803. isValid(): boolean;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. _getProperty(propertyPath: string): string;
  9809. /**
  9810. * Internal only
  9811. * @hidden
  9812. */
  9813. _getEffectiveTarget(target: any, propertyPath: string): any;
  9814. /**
  9815. * Serialize placeholder for child classes
  9816. * @returns the serialized object
  9817. */
  9818. serialize(): any;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. protected _serialize(serializedCondition: any): any;
  9824. }
  9825. /**
  9826. * Defines specific conditional operators as extensions of Condition
  9827. */
  9828. export class ValueCondition extends Condition {
  9829. /** path to specify the property of the target the conditional operator uses */
  9830. propertyPath: string;
  9831. /** the value compared by the conditional operator against the current value of the property */
  9832. value: any;
  9833. /** the conditional operator, default ValueCondition.IsEqual */
  9834. operator: number;
  9835. /**
  9836. * Internal only
  9837. * @hidden
  9838. */
  9839. private static _IsEqual;
  9840. /**
  9841. * Internal only
  9842. * @hidden
  9843. */
  9844. private static _IsDifferent;
  9845. /**
  9846. * Internal only
  9847. * @hidden
  9848. */
  9849. private static _IsGreater;
  9850. /**
  9851. * Internal only
  9852. * @hidden
  9853. */
  9854. private static _IsLesser;
  9855. /**
  9856. * returns the number for IsEqual
  9857. */
  9858. static get IsEqual(): number;
  9859. /**
  9860. * Returns the number for IsDifferent
  9861. */
  9862. static get IsDifferent(): number;
  9863. /**
  9864. * Returns the number for IsGreater
  9865. */
  9866. static get IsGreater(): number;
  9867. /**
  9868. * Returns the number for IsLesser
  9869. */
  9870. static get IsLesser(): number;
  9871. /**
  9872. * Internal only The action manager for the condition
  9873. * @hidden
  9874. */
  9875. _actionManager: ActionManager;
  9876. /**
  9877. * Internal only
  9878. * @hidden
  9879. */
  9880. private _target;
  9881. /**
  9882. * Internal only
  9883. * @hidden
  9884. */
  9885. private _effectiveTarget;
  9886. /**
  9887. * Internal only
  9888. * @hidden
  9889. */
  9890. private _property;
  9891. /**
  9892. * Creates a new ValueCondition
  9893. * @param actionManager manager for the action the condition applies to
  9894. * @param target for the action
  9895. * @param propertyPath path to specify the property of the target the conditional operator uses
  9896. * @param value the value compared by the conditional operator against the current value of the property
  9897. * @param operator the conditional operator, default ValueCondition.IsEqual
  9898. */
  9899. constructor(actionManager: ActionManager, target: any,
  9900. /** path to specify the property of the target the conditional operator uses */
  9901. propertyPath: string,
  9902. /** the value compared by the conditional operator against the current value of the property */
  9903. value: any,
  9904. /** the conditional operator, default ValueCondition.IsEqual */
  9905. operator?: number);
  9906. /**
  9907. * Compares the given value with the property value for the specified conditional operator
  9908. * @returns the result of the comparison
  9909. */
  9910. isValid(): boolean;
  9911. /**
  9912. * Serialize the ValueCondition into a JSON compatible object
  9913. * @returns serialization object
  9914. */
  9915. serialize(): any;
  9916. /**
  9917. * Gets the name of the conditional operator for the ValueCondition
  9918. * @param operator the conditional operator
  9919. * @returns the name
  9920. */
  9921. static GetOperatorName(operator: number): string;
  9922. }
  9923. /**
  9924. * Defines a predicate condition as an extension of Condition
  9925. */
  9926. export class PredicateCondition extends Condition {
  9927. /** defines the predicate function used to validate the condition */
  9928. predicate: () => boolean;
  9929. /**
  9930. * Internal only - manager for action
  9931. * @hidden
  9932. */
  9933. _actionManager: ActionManager;
  9934. /**
  9935. * Creates a new PredicateCondition
  9936. * @param actionManager manager for the action the condition applies to
  9937. * @param predicate defines the predicate function used to validate the condition
  9938. */
  9939. constructor(actionManager: ActionManager,
  9940. /** defines the predicate function used to validate the condition */
  9941. predicate: () => boolean);
  9942. /**
  9943. * @returns the validity of the predicate condition
  9944. */
  9945. isValid(): boolean;
  9946. }
  9947. /**
  9948. * Defines a state condition as an extension of Condition
  9949. */
  9950. export class StateCondition extends Condition {
  9951. /** Value to compare with target state */
  9952. value: string;
  9953. /**
  9954. * Internal only - manager for action
  9955. * @hidden
  9956. */
  9957. _actionManager: ActionManager;
  9958. /**
  9959. * Internal only
  9960. * @hidden
  9961. */
  9962. private _target;
  9963. /**
  9964. * Creates a new StateCondition
  9965. * @param actionManager manager for the action the condition applies to
  9966. * @param target of the condition
  9967. * @param value to compare with target state
  9968. */
  9969. constructor(actionManager: ActionManager, target: any,
  9970. /** Value to compare with target state */
  9971. value: string);
  9972. /**
  9973. * Gets a boolean indicating if the current condition is met
  9974. * @returns the validity of the state
  9975. */
  9976. isValid(): boolean;
  9977. /**
  9978. * Serialize the StateCondition into a JSON compatible object
  9979. * @returns serialization object
  9980. */
  9981. serialize(): any;
  9982. }
  9983. }
  9984. declare module "babylonjs/Actions/directActions" {
  9985. import { Action } from "babylonjs/Actions/action";
  9986. import { Condition } from "babylonjs/Actions/condition";
  9987. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9988. /**
  9989. * This defines an action responsible to toggle a boolean once triggered.
  9990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9991. */
  9992. export class SwitchBooleanAction extends Action {
  9993. /**
  9994. * The path to the boolean property in the target object
  9995. */
  9996. propertyPath: string;
  9997. private _target;
  9998. private _effectiveTarget;
  9999. private _property;
  10000. /**
  10001. * Instantiate the action
  10002. * @param triggerOptions defines the trigger options
  10003. * @param target defines the object containing the boolean
  10004. * @param propertyPath defines the path to the boolean property in the target object
  10005. * @param condition defines the trigger related conditions
  10006. */
  10007. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10008. /** @hidden */
  10009. _prepare(): void;
  10010. /**
  10011. * Execute the action toggle the boolean value.
  10012. */
  10013. execute(): void;
  10014. /**
  10015. * Serializes the actions and its related information.
  10016. * @param parent defines the object to serialize in
  10017. * @returns the serialized object
  10018. */
  10019. serialize(parent: any): any;
  10020. }
  10021. /**
  10022. * This defines an action responsible to set a the state field of the target
  10023. * to a desired value once triggered.
  10024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class SetStateAction extends Action {
  10027. /**
  10028. * The value to store in the state field.
  10029. */
  10030. value: string;
  10031. private _target;
  10032. /**
  10033. * Instantiate the action
  10034. * @param triggerOptions defines the trigger options
  10035. * @param target defines the object containing the state property
  10036. * @param value defines the value to store in the state field
  10037. * @param condition defines the trigger related conditions
  10038. */
  10039. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10040. /**
  10041. * Execute the action and store the value on the target state property.
  10042. */
  10043. execute(): void;
  10044. /**
  10045. * Serializes the actions and its related information.
  10046. * @param parent defines the object to serialize in
  10047. * @returns the serialized object
  10048. */
  10049. serialize(parent: any): any;
  10050. }
  10051. /**
  10052. * This defines an action responsible to set a property of the target
  10053. * to a desired value once triggered.
  10054. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10055. */
  10056. export class SetValueAction extends Action {
  10057. /**
  10058. * The path of the property to set in the target.
  10059. */
  10060. propertyPath: string;
  10061. /**
  10062. * The value to set in the property
  10063. */
  10064. value: any;
  10065. private _target;
  10066. private _effectiveTarget;
  10067. private _property;
  10068. /**
  10069. * Instantiate the action
  10070. * @param triggerOptions defines the trigger options
  10071. * @param target defines the object containing the property
  10072. * @param propertyPath defines the path of the property to set in the target
  10073. * @param value defines the value to set in the property
  10074. * @param condition defines the trigger related conditions
  10075. */
  10076. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10077. /** @hidden */
  10078. _prepare(): void;
  10079. /**
  10080. * Execute the action and set the targetted property to the desired value.
  10081. */
  10082. execute(): void;
  10083. /**
  10084. * Serializes the actions and its related information.
  10085. * @param parent defines the object to serialize in
  10086. * @returns the serialized object
  10087. */
  10088. serialize(parent: any): any;
  10089. }
  10090. /**
  10091. * This defines an action responsible to increment the target value
  10092. * to a desired value once triggered.
  10093. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10094. */
  10095. export class IncrementValueAction extends Action {
  10096. /**
  10097. * The path of the property to increment in the target.
  10098. */
  10099. propertyPath: string;
  10100. /**
  10101. * The value we should increment the property by.
  10102. */
  10103. value: any;
  10104. private _target;
  10105. private _effectiveTarget;
  10106. private _property;
  10107. /**
  10108. * Instantiate the action
  10109. * @param triggerOptions defines the trigger options
  10110. * @param target defines the object containing the property
  10111. * @param propertyPath defines the path of the property to increment in the target
  10112. * @param value defines the value value we should increment the property by
  10113. * @param condition defines the trigger related conditions
  10114. */
  10115. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10116. /** @hidden */
  10117. _prepare(): void;
  10118. /**
  10119. * Execute the action and increment the target of the value amount.
  10120. */
  10121. execute(): void;
  10122. /**
  10123. * Serializes the actions and its related information.
  10124. * @param parent defines the object to serialize in
  10125. * @returns the serialized object
  10126. */
  10127. serialize(parent: any): any;
  10128. }
  10129. /**
  10130. * This defines an action responsible to start an animation once triggered.
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10132. */
  10133. export class PlayAnimationAction extends Action {
  10134. /**
  10135. * Where the animation should start (animation frame)
  10136. */
  10137. from: number;
  10138. /**
  10139. * Where the animation should stop (animation frame)
  10140. */
  10141. to: number;
  10142. /**
  10143. * Define if the animation should loop or stop after the first play.
  10144. */
  10145. loop?: boolean;
  10146. private _target;
  10147. /**
  10148. * Instantiate the action
  10149. * @param triggerOptions defines the trigger options
  10150. * @param target defines the target animation or animation name
  10151. * @param from defines from where the animation should start (animation frame)
  10152. * @param end defines where the animation should stop (animation frame)
  10153. * @param loop defines if the animation should loop or stop after the first play
  10154. * @param condition defines the trigger related conditions
  10155. */
  10156. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10157. /** @hidden */
  10158. _prepare(): void;
  10159. /**
  10160. * Execute the action and play the animation.
  10161. */
  10162. execute(): void;
  10163. /**
  10164. * Serializes the actions and its related information.
  10165. * @param parent defines the object to serialize in
  10166. * @returns the serialized object
  10167. */
  10168. serialize(parent: any): any;
  10169. }
  10170. /**
  10171. * This defines an action responsible to stop an animation once triggered.
  10172. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10173. */
  10174. export class StopAnimationAction extends Action {
  10175. private _target;
  10176. /**
  10177. * Instantiate the action
  10178. * @param triggerOptions defines the trigger options
  10179. * @param target defines the target animation or animation name
  10180. * @param condition defines the trigger related conditions
  10181. */
  10182. constructor(triggerOptions: any, target: any, condition?: Condition);
  10183. /** @hidden */
  10184. _prepare(): void;
  10185. /**
  10186. * Execute the action and stop the animation.
  10187. */
  10188. execute(): void;
  10189. /**
  10190. * Serializes the actions and its related information.
  10191. * @param parent defines the object to serialize in
  10192. * @returns the serialized object
  10193. */
  10194. serialize(parent: any): any;
  10195. }
  10196. /**
  10197. * This defines an action responsible that does nothing once triggered.
  10198. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10199. */
  10200. export class DoNothingAction extends Action {
  10201. /**
  10202. * Instantiate the action
  10203. * @param triggerOptions defines the trigger options
  10204. * @param condition defines the trigger related conditions
  10205. */
  10206. constructor(triggerOptions?: any, condition?: Condition);
  10207. /**
  10208. * Execute the action and do nothing.
  10209. */
  10210. execute(): void;
  10211. /**
  10212. * Serializes the actions and its related information.
  10213. * @param parent defines the object to serialize in
  10214. * @returns the serialized object
  10215. */
  10216. serialize(parent: any): any;
  10217. }
  10218. /**
  10219. * This defines an action responsible to trigger several actions once triggered.
  10220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10221. */
  10222. export class CombineAction extends Action {
  10223. /**
  10224. * The list of aggregated animations to run.
  10225. */
  10226. children: Action[];
  10227. /**
  10228. * Instantiate the action
  10229. * @param triggerOptions defines the trigger options
  10230. * @param children defines the list of aggregated animations to run
  10231. * @param condition defines the trigger related conditions
  10232. */
  10233. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10234. /** @hidden */
  10235. _prepare(): void;
  10236. /**
  10237. * Execute the action and executes all the aggregated actions.
  10238. */
  10239. execute(evt: ActionEvent): void;
  10240. /**
  10241. * Serializes the actions and its related information.
  10242. * @param parent defines the object to serialize in
  10243. * @returns the serialized object
  10244. */
  10245. serialize(parent: any): any;
  10246. }
  10247. /**
  10248. * This defines an action responsible to run code (external event) once triggered.
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10250. */
  10251. export class ExecuteCodeAction extends Action {
  10252. /**
  10253. * The callback function to run.
  10254. */
  10255. func: (evt: ActionEvent) => void;
  10256. /**
  10257. * Instantiate the action
  10258. * @param triggerOptions defines the trigger options
  10259. * @param func defines the callback function to run
  10260. * @param condition defines the trigger related conditions
  10261. */
  10262. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10263. /**
  10264. * Execute the action and run the attached code.
  10265. */
  10266. execute(evt: ActionEvent): void;
  10267. }
  10268. /**
  10269. * This defines an action responsible to set the parent property of the target once triggered.
  10270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10271. */
  10272. export class SetParentAction extends Action {
  10273. private _parent;
  10274. private _target;
  10275. /**
  10276. * Instantiate the action
  10277. * @param triggerOptions defines the trigger options
  10278. * @param target defines the target containing the parent property
  10279. * @param parent defines from where the animation should start (animation frame)
  10280. * @param condition defines the trigger related conditions
  10281. */
  10282. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10283. /** @hidden */
  10284. _prepare(): void;
  10285. /**
  10286. * Execute the action and set the parent property.
  10287. */
  10288. execute(): void;
  10289. /**
  10290. * Serializes the actions and its related information.
  10291. * @param parent defines the object to serialize in
  10292. * @returns the serialized object
  10293. */
  10294. serialize(parent: any): any;
  10295. }
  10296. }
  10297. declare module "babylonjs/Actions/actionManager" {
  10298. import { Nullable } from "babylonjs/types";
  10299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10300. import { Scene } from "babylonjs/scene";
  10301. import { IAction } from "babylonjs/Actions/action";
  10302. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10303. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10304. /**
  10305. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10306. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10307. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10308. */
  10309. export class ActionManager extends AbstractActionManager {
  10310. /**
  10311. * Nothing
  10312. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10313. */
  10314. static readonly NothingTrigger: number;
  10315. /**
  10316. * On pick
  10317. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10318. */
  10319. static readonly OnPickTrigger: number;
  10320. /**
  10321. * On left pick
  10322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10323. */
  10324. static readonly OnLeftPickTrigger: number;
  10325. /**
  10326. * On right pick
  10327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10328. */
  10329. static readonly OnRightPickTrigger: number;
  10330. /**
  10331. * On center pick
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnCenterPickTrigger: number;
  10335. /**
  10336. * On pick down
  10337. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10338. */
  10339. static readonly OnPickDownTrigger: number;
  10340. /**
  10341. * On double pick
  10342. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10343. */
  10344. static readonly OnDoublePickTrigger: number;
  10345. /**
  10346. * On pick up
  10347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10348. */
  10349. static readonly OnPickUpTrigger: number;
  10350. /**
  10351. * On pick out.
  10352. * This trigger will only be raised if you also declared a OnPickDown
  10353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10354. */
  10355. static readonly OnPickOutTrigger: number;
  10356. /**
  10357. * On long press
  10358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10359. */
  10360. static readonly OnLongPressTrigger: number;
  10361. /**
  10362. * On pointer over
  10363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10364. */
  10365. static readonly OnPointerOverTrigger: number;
  10366. /**
  10367. * On pointer out
  10368. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10369. */
  10370. static readonly OnPointerOutTrigger: number;
  10371. /**
  10372. * On every frame
  10373. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10374. */
  10375. static readonly OnEveryFrameTrigger: number;
  10376. /**
  10377. * On intersection enter
  10378. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10379. */
  10380. static readonly OnIntersectionEnterTrigger: number;
  10381. /**
  10382. * On intersection exit
  10383. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10384. */
  10385. static readonly OnIntersectionExitTrigger: number;
  10386. /**
  10387. * On key down
  10388. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10389. */
  10390. static readonly OnKeyDownTrigger: number;
  10391. /**
  10392. * On key up
  10393. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10394. */
  10395. static readonly OnKeyUpTrigger: number;
  10396. private _scene;
  10397. /**
  10398. * Creates a new action manager
  10399. * @param scene defines the hosting scene
  10400. */
  10401. constructor(scene: Scene);
  10402. /**
  10403. * Releases all associated resources
  10404. */
  10405. dispose(): void;
  10406. /**
  10407. * Gets hosting scene
  10408. * @returns the hosting scene
  10409. */
  10410. getScene(): Scene;
  10411. /**
  10412. * Does this action manager handles actions of any of the given triggers
  10413. * @param triggers defines the triggers to be tested
  10414. * @return a boolean indicating whether one (or more) of the triggers is handled
  10415. */
  10416. hasSpecificTriggers(triggers: number[]): boolean;
  10417. /**
  10418. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10419. * speed.
  10420. * @param triggerA defines the trigger to be tested
  10421. * @param triggerB defines the trigger to be tested
  10422. * @return a boolean indicating whether one (or more) of the triggers is handled
  10423. */
  10424. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10425. /**
  10426. * Does this action manager handles actions of a given trigger
  10427. * @param trigger defines the trigger to be tested
  10428. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10429. * @return whether the trigger is handled
  10430. */
  10431. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10432. /**
  10433. * Does this action manager has pointer triggers
  10434. */
  10435. get hasPointerTriggers(): boolean;
  10436. /**
  10437. * Does this action manager has pick triggers
  10438. */
  10439. get hasPickTriggers(): boolean;
  10440. /**
  10441. * Registers an action to this action manager
  10442. * @param action defines the action to be registered
  10443. * @return the action amended (prepared) after registration
  10444. */
  10445. registerAction(action: IAction): Nullable<IAction>;
  10446. /**
  10447. * Unregisters an action to this action manager
  10448. * @param action defines the action to be unregistered
  10449. * @return a boolean indicating whether the action has been unregistered
  10450. */
  10451. unregisterAction(action: IAction): Boolean;
  10452. /**
  10453. * Process a specific trigger
  10454. * @param trigger defines the trigger to process
  10455. * @param evt defines the event details to be processed
  10456. */
  10457. processTrigger(trigger: number, evt?: IActionEvent): void;
  10458. /** @hidden */
  10459. _getEffectiveTarget(target: any, propertyPath: string): any;
  10460. /** @hidden */
  10461. _getProperty(propertyPath: string): string;
  10462. /**
  10463. * Serialize this manager to a JSON object
  10464. * @param name defines the property name to store this manager
  10465. * @returns a JSON representation of this manager
  10466. */
  10467. serialize(name: string): any;
  10468. /**
  10469. * Creates a new ActionManager from a JSON data
  10470. * @param parsedActions defines the JSON data to read from
  10471. * @param object defines the hosting mesh
  10472. * @param scene defines the hosting scene
  10473. */
  10474. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10475. /**
  10476. * Get a trigger name by index
  10477. * @param trigger defines the trigger index
  10478. * @returns a trigger name
  10479. */
  10480. static GetTriggerName(trigger: number): string;
  10481. }
  10482. }
  10483. declare module "babylonjs/Sprites/sprite" {
  10484. import { Vector3 } from "babylonjs/Maths/math.vector";
  10485. import { Nullable } from "babylonjs/types";
  10486. import { ActionManager } from "babylonjs/Actions/actionManager";
  10487. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10488. import { Color4 } from "babylonjs/Maths/math.color";
  10489. import { Observable } from "babylonjs/Misc/observable";
  10490. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10491. import { Animation } from "babylonjs/Animations/animation";
  10492. /**
  10493. * Class used to represent a sprite
  10494. * @see https://doc.babylonjs.com/babylon101/sprites
  10495. */
  10496. export class Sprite implements IAnimatable {
  10497. /** defines the name */
  10498. name: string;
  10499. /** Gets or sets the current world position */
  10500. position: Vector3;
  10501. /** Gets or sets the main color */
  10502. color: Color4;
  10503. /** Gets or sets the width */
  10504. width: number;
  10505. /** Gets or sets the height */
  10506. height: number;
  10507. /** Gets or sets rotation angle */
  10508. angle: number;
  10509. /** Gets or sets the cell index in the sprite sheet */
  10510. cellIndex: number;
  10511. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10512. cellRef: string;
  10513. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10514. invertU: boolean;
  10515. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10516. invertV: boolean;
  10517. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10518. disposeWhenFinishedAnimating: boolean;
  10519. /** Gets the list of attached animations */
  10520. animations: Nullable<Array<Animation>>;
  10521. /** Gets or sets a boolean indicating if the sprite can be picked */
  10522. isPickable: boolean;
  10523. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10524. useAlphaForPicking: boolean;
  10525. /** @hidden */
  10526. _xOffset: number;
  10527. /** @hidden */
  10528. _yOffset: number;
  10529. /** @hidden */
  10530. _xSize: number;
  10531. /** @hidden */
  10532. _ySize: number;
  10533. /**
  10534. * Gets or sets the associated action manager
  10535. */
  10536. actionManager: Nullable<ActionManager>;
  10537. /**
  10538. * An event triggered when the control has been disposed
  10539. */
  10540. onDisposeObservable: Observable<Sprite>;
  10541. private _animationStarted;
  10542. private _loopAnimation;
  10543. private _fromIndex;
  10544. private _toIndex;
  10545. private _delay;
  10546. private _direction;
  10547. private _manager;
  10548. private _time;
  10549. private _onAnimationEnd;
  10550. /**
  10551. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10552. */
  10553. isVisible: boolean;
  10554. /**
  10555. * Gets or sets the sprite size
  10556. */
  10557. get size(): number;
  10558. set size(value: number);
  10559. /**
  10560. * Returns a boolean indicating if the animation is started
  10561. */
  10562. get animationStarted(): boolean;
  10563. /**
  10564. * Gets or sets the unique id of the sprite
  10565. */
  10566. uniqueId: number;
  10567. /**
  10568. * Gets the manager of this sprite
  10569. */
  10570. get manager(): ISpriteManager;
  10571. /**
  10572. * Creates a new Sprite
  10573. * @param name defines the name
  10574. * @param manager defines the manager
  10575. */
  10576. constructor(
  10577. /** defines the name */
  10578. name: string, manager: ISpriteManager);
  10579. /**
  10580. * Returns the string "Sprite"
  10581. * @returns "Sprite"
  10582. */
  10583. getClassName(): string;
  10584. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10585. get fromIndex(): number;
  10586. set fromIndex(value: number);
  10587. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10588. get toIndex(): number;
  10589. set toIndex(value: number);
  10590. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10591. get loopAnimation(): boolean;
  10592. set loopAnimation(value: boolean);
  10593. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10594. get delay(): number;
  10595. set delay(value: number);
  10596. /**
  10597. * Starts an animation
  10598. * @param from defines the initial key
  10599. * @param to defines the end key
  10600. * @param loop defines if the animation must loop
  10601. * @param delay defines the start delay (in ms)
  10602. * @param onAnimationEnd defines a callback to call when animation ends
  10603. */
  10604. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10605. /** Stops current animation (if any) */
  10606. stopAnimation(): void;
  10607. /** @hidden */
  10608. _animate(deltaTime: number): void;
  10609. /** Release associated resources */
  10610. dispose(): void;
  10611. /**
  10612. * Serializes the sprite to a JSON object
  10613. * @returns the JSON object
  10614. */
  10615. serialize(): any;
  10616. /**
  10617. * Parses a JSON object to create a new sprite
  10618. * @param parsedSprite The JSON object to parse
  10619. * @param manager defines the hosting manager
  10620. * @returns the new sprite
  10621. */
  10622. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10623. }
  10624. }
  10625. declare module "babylonjs/Collisions/pickingInfo" {
  10626. import { Nullable } from "babylonjs/types";
  10627. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10629. import { Sprite } from "babylonjs/Sprites/sprite";
  10630. import { Ray } from "babylonjs/Culling/ray";
  10631. /**
  10632. * Information about the result of picking within a scene
  10633. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10634. */
  10635. export class PickingInfo {
  10636. /** @hidden */
  10637. _pickingUnavailable: boolean;
  10638. /**
  10639. * If the pick collided with an object
  10640. */
  10641. hit: boolean;
  10642. /**
  10643. * Distance away where the pick collided
  10644. */
  10645. distance: number;
  10646. /**
  10647. * The location of pick collision
  10648. */
  10649. pickedPoint: Nullable<Vector3>;
  10650. /**
  10651. * The mesh corresponding the the pick collision
  10652. */
  10653. pickedMesh: Nullable<AbstractMesh>;
  10654. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10655. bu: number;
  10656. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10657. bv: number;
  10658. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10659. faceId: number;
  10660. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10661. subMeshFaceId: number;
  10662. /** Id of the the submesh that was picked */
  10663. subMeshId: number;
  10664. /** If a sprite was picked, this will be the sprite the pick collided with */
  10665. pickedSprite: Nullable<Sprite>;
  10666. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10667. thinInstanceIndex: number;
  10668. /**
  10669. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10670. */
  10671. originMesh: Nullable<AbstractMesh>;
  10672. /**
  10673. * The ray that was used to perform the picking.
  10674. */
  10675. ray: Nullable<Ray>;
  10676. /**
  10677. * Gets the normal correspodning to the face the pick collided with
  10678. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10679. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10680. * @returns The normal correspodning to the face the pick collided with
  10681. */
  10682. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10683. /**
  10684. * Gets the texture coordinates of where the pick occured
  10685. * @returns the vector containing the coordnates of the texture
  10686. */
  10687. getTextureCoordinates(): Nullable<Vector2>;
  10688. }
  10689. }
  10690. declare module "babylonjs/Culling/ray" {
  10691. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10692. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10694. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10695. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10696. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10697. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10698. import { Plane } from "babylonjs/Maths/math.plane";
  10699. /**
  10700. * Class representing a ray with position and direction
  10701. */
  10702. export class Ray {
  10703. /** origin point */
  10704. origin: Vector3;
  10705. /** direction */
  10706. direction: Vector3;
  10707. /** length of the ray */
  10708. length: number;
  10709. private static readonly _TmpVector3;
  10710. private _tmpRay;
  10711. /**
  10712. * Creates a new ray
  10713. * @param origin origin point
  10714. * @param direction direction
  10715. * @param length length of the ray
  10716. */
  10717. constructor(
  10718. /** origin point */
  10719. origin: Vector3,
  10720. /** direction */
  10721. direction: Vector3,
  10722. /** length of the ray */
  10723. length?: number);
  10724. /**
  10725. * Checks if the ray intersects a box
  10726. * This does not account for the ray lenght by design to improve perfs.
  10727. * @param minimum bound of the box
  10728. * @param maximum bound of the box
  10729. * @param intersectionTreshold extra extend to be added to the box in all direction
  10730. * @returns if the box was hit
  10731. */
  10732. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10733. /**
  10734. * Checks if the ray intersects a box
  10735. * This does not account for the ray lenght by design to improve perfs.
  10736. * @param box the bounding box to check
  10737. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10738. * @returns if the box was hit
  10739. */
  10740. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10741. /**
  10742. * If the ray hits a sphere
  10743. * @param sphere the bounding sphere to check
  10744. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10745. * @returns true if it hits the sphere
  10746. */
  10747. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10748. /**
  10749. * If the ray hits a triange
  10750. * @param vertex0 triangle vertex
  10751. * @param vertex1 triangle vertex
  10752. * @param vertex2 triangle vertex
  10753. * @returns intersection information if hit
  10754. */
  10755. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10756. /**
  10757. * Checks if ray intersects a plane
  10758. * @param plane the plane to check
  10759. * @returns the distance away it was hit
  10760. */
  10761. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10762. /**
  10763. * Calculate the intercept of a ray on a given axis
  10764. * @param axis to check 'x' | 'y' | 'z'
  10765. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10766. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10767. */
  10768. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10769. /**
  10770. * Checks if ray intersects a mesh
  10771. * @param mesh the mesh to check
  10772. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10773. * @returns picking info of the intersecton
  10774. */
  10775. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10776. /**
  10777. * Checks if ray intersects a mesh
  10778. * @param meshes the meshes to check
  10779. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10780. * @param results array to store result in
  10781. * @returns Array of picking infos
  10782. */
  10783. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10784. private _comparePickingInfo;
  10785. private static smallnum;
  10786. private static rayl;
  10787. /**
  10788. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10789. * @param sega the first point of the segment to test the intersection against
  10790. * @param segb the second point of the segment to test the intersection against
  10791. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10792. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10793. */
  10794. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10795. /**
  10796. * Update the ray from viewport position
  10797. * @param x position
  10798. * @param y y position
  10799. * @param viewportWidth viewport width
  10800. * @param viewportHeight viewport height
  10801. * @param world world matrix
  10802. * @param view view matrix
  10803. * @param projection projection matrix
  10804. * @returns this ray updated
  10805. */
  10806. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10807. /**
  10808. * Creates a ray with origin and direction of 0,0,0
  10809. * @returns the new ray
  10810. */
  10811. static Zero(): Ray;
  10812. /**
  10813. * Creates a new ray from screen space and viewport
  10814. * @param x position
  10815. * @param y y position
  10816. * @param viewportWidth viewport width
  10817. * @param viewportHeight viewport height
  10818. * @param world world matrix
  10819. * @param view view matrix
  10820. * @param projection projection matrix
  10821. * @returns new ray
  10822. */
  10823. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10824. /**
  10825. * 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
  10826. * transformed to the given world matrix.
  10827. * @param origin The origin point
  10828. * @param end The end point
  10829. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10830. * @returns the new ray
  10831. */
  10832. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10833. /**
  10834. * Transforms a ray by a matrix
  10835. * @param ray ray to transform
  10836. * @param matrix matrix to apply
  10837. * @returns the resulting new ray
  10838. */
  10839. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10840. /**
  10841. * Transforms a ray by a matrix
  10842. * @param ray ray to transform
  10843. * @param matrix matrix to apply
  10844. * @param result ray to store result in
  10845. */
  10846. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10847. /**
  10848. * Unproject a ray from screen space to object space
  10849. * @param sourceX defines the screen space x coordinate to use
  10850. * @param sourceY defines the screen space y coordinate to use
  10851. * @param viewportWidth defines the current width of the viewport
  10852. * @param viewportHeight defines the current height of the viewport
  10853. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10854. * @param view defines the view matrix to use
  10855. * @param projection defines the projection matrix to use
  10856. */
  10857. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10858. }
  10859. /**
  10860. * Type used to define predicate used to select faces when a mesh intersection is detected
  10861. */
  10862. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10863. module "babylonjs/scene" {
  10864. interface Scene {
  10865. /** @hidden */
  10866. _tempPickingRay: Nullable<Ray>;
  10867. /** @hidden */
  10868. _cachedRayForTransform: Ray;
  10869. /** @hidden */
  10870. _pickWithRayInverseMatrix: Matrix;
  10871. /** @hidden */
  10872. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10873. /** @hidden */
  10874. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10875. /** @hidden */
  10876. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10877. }
  10878. }
  10879. }
  10880. declare module "babylonjs/sceneComponent" {
  10881. import { Scene } from "babylonjs/scene";
  10882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10883. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10884. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10885. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10886. import { Nullable } from "babylonjs/types";
  10887. import { Camera } from "babylonjs/Cameras/camera";
  10888. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10889. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10890. import { AbstractScene } from "babylonjs/abstractScene";
  10891. import { Mesh } from "babylonjs/Meshes/mesh";
  10892. /**
  10893. * Groups all the scene component constants in one place to ease maintenance.
  10894. * @hidden
  10895. */
  10896. export class SceneComponentConstants {
  10897. static readonly NAME_EFFECTLAYER: string;
  10898. static readonly NAME_LAYER: string;
  10899. static readonly NAME_LENSFLARESYSTEM: string;
  10900. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10901. static readonly NAME_PARTICLESYSTEM: string;
  10902. static readonly NAME_GAMEPAD: string;
  10903. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10904. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10905. static readonly NAME_PREPASSRENDERER: string;
  10906. static readonly NAME_DEPTHRENDERER: string;
  10907. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10908. static readonly NAME_SPRITE: string;
  10909. static readonly NAME_SUBSURFACE: string;
  10910. static readonly NAME_OUTLINERENDERER: string;
  10911. static readonly NAME_PROCEDURALTEXTURE: string;
  10912. static readonly NAME_SHADOWGENERATOR: string;
  10913. static readonly NAME_OCTREE: string;
  10914. static readonly NAME_PHYSICSENGINE: string;
  10915. static readonly NAME_AUDIO: string;
  10916. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10917. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10918. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10919. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10920. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10921. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10922. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10923. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10924. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10925. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10926. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10927. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10928. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10929. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10930. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10931. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10932. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10933. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10934. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10935. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10936. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10937. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10938. static readonly STEP_AFTERRENDER_AUDIO: number;
  10939. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10940. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10941. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10942. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10943. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10944. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10945. static readonly STEP_POINTERMOVE_SPRITE: number;
  10946. static readonly STEP_POINTERDOWN_SPRITE: number;
  10947. static readonly STEP_POINTERUP_SPRITE: number;
  10948. }
  10949. /**
  10950. * This represents a scene component.
  10951. *
  10952. * This is used to decouple the dependency the scene is having on the different workloads like
  10953. * layers, post processes...
  10954. */
  10955. export interface ISceneComponent {
  10956. /**
  10957. * The name of the component. Each component must have a unique name.
  10958. */
  10959. name: string;
  10960. /**
  10961. * The scene the component belongs to.
  10962. */
  10963. scene: Scene;
  10964. /**
  10965. * Register the component to one instance of a scene.
  10966. */
  10967. register(): void;
  10968. /**
  10969. * Rebuilds the elements related to this component in case of
  10970. * context lost for instance.
  10971. */
  10972. rebuild(): void;
  10973. /**
  10974. * Disposes the component and the associated ressources.
  10975. */
  10976. dispose(): void;
  10977. }
  10978. /**
  10979. * This represents a SERIALIZABLE scene component.
  10980. *
  10981. * This extends Scene Component to add Serialization methods on top.
  10982. */
  10983. export interface ISceneSerializableComponent extends ISceneComponent {
  10984. /**
  10985. * Adds all the elements from the container to the scene
  10986. * @param container the container holding the elements
  10987. */
  10988. addFromContainer(container: AbstractScene): void;
  10989. /**
  10990. * Removes all the elements in the container from the scene
  10991. * @param container contains the elements to remove
  10992. * @param dispose if the removed element should be disposed (default: false)
  10993. */
  10994. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10995. /**
  10996. * Serializes the component data to the specified json object
  10997. * @param serializationObject The object to serialize to
  10998. */
  10999. serialize(serializationObject: any): void;
  11000. }
  11001. /**
  11002. * Strong typing of a Mesh related stage step action
  11003. */
  11004. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11005. /**
  11006. * Strong typing of a Evaluate Sub Mesh related stage step action
  11007. */
  11008. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11009. /**
  11010. * Strong typing of a Active Mesh related stage step action
  11011. */
  11012. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11013. /**
  11014. * Strong typing of a Camera related stage step action
  11015. */
  11016. export type CameraStageAction = (camera: Camera) => void;
  11017. /**
  11018. * Strong typing of a Camera Frame buffer related stage step action
  11019. */
  11020. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11021. /**
  11022. * Strong typing of a Render Target related stage step action
  11023. */
  11024. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11025. /**
  11026. * Strong typing of a RenderingGroup related stage step action
  11027. */
  11028. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11029. /**
  11030. * Strong typing of a Mesh Render related stage step action
  11031. */
  11032. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11033. /**
  11034. * Strong typing of a simple stage step action
  11035. */
  11036. export type SimpleStageAction = () => void;
  11037. /**
  11038. * Strong typing of a render target action.
  11039. */
  11040. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11041. /**
  11042. * Strong typing of a pointer move action.
  11043. */
  11044. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11045. /**
  11046. * Strong typing of a pointer up/down action.
  11047. */
  11048. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11049. /**
  11050. * Representation of a stage in the scene (Basically a list of ordered steps)
  11051. * @hidden
  11052. */
  11053. export class Stage<T extends Function> extends Array<{
  11054. index: number;
  11055. component: ISceneComponent;
  11056. action: T;
  11057. }> {
  11058. /**
  11059. * Hide ctor from the rest of the world.
  11060. * @param items The items to add.
  11061. */
  11062. private constructor();
  11063. /**
  11064. * Creates a new Stage.
  11065. * @returns A new instance of a Stage
  11066. */
  11067. static Create<T extends Function>(): Stage<T>;
  11068. /**
  11069. * Registers a step in an ordered way in the targeted stage.
  11070. * @param index Defines the position to register the step in
  11071. * @param component Defines the component attached to the step
  11072. * @param action Defines the action to launch during the step
  11073. */
  11074. registerStep(index: number, component: ISceneComponent, action: T): void;
  11075. /**
  11076. * Clears all the steps from the stage.
  11077. */
  11078. clear(): void;
  11079. }
  11080. }
  11081. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11082. import { Nullable } from "babylonjs/types";
  11083. import { Observable } from "babylonjs/Misc/observable";
  11084. import { Scene } from "babylonjs/scene";
  11085. import { Sprite } from "babylonjs/Sprites/sprite";
  11086. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11087. import { Ray } from "babylonjs/Culling/ray";
  11088. import { Camera } from "babylonjs/Cameras/camera";
  11089. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11090. import { ISceneComponent } from "babylonjs/sceneComponent";
  11091. module "babylonjs/scene" {
  11092. interface Scene {
  11093. /** @hidden */
  11094. _pointerOverSprite: Nullable<Sprite>;
  11095. /** @hidden */
  11096. _pickedDownSprite: Nullable<Sprite>;
  11097. /** @hidden */
  11098. _tempSpritePickingRay: Nullable<Ray>;
  11099. /**
  11100. * All of the sprite managers added to this scene
  11101. * @see https://doc.babylonjs.com/babylon101/sprites
  11102. */
  11103. spriteManagers: Array<ISpriteManager>;
  11104. /**
  11105. * An event triggered when sprites rendering is about to start
  11106. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11107. */
  11108. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11109. /**
  11110. * An event triggered when sprites rendering is done
  11111. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11112. */
  11113. onAfterSpritesRenderingObservable: Observable<Scene>;
  11114. /** @hidden */
  11115. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11116. /** Launch a ray to try to pick a sprite in the scene
  11117. * @param x position on screen
  11118. * @param y position on screen
  11119. * @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
  11120. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11121. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11122. * @returns a PickingInfo
  11123. */
  11124. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11125. /** Use the given ray to pick a sprite in the scene
  11126. * @param ray The ray (in world space) to use to pick meshes
  11127. * @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
  11128. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11129. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11130. * @returns a PickingInfo
  11131. */
  11132. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11133. /** @hidden */
  11134. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11135. /** Launch a ray to try to pick sprites in the scene
  11136. * @param x position on screen
  11137. * @param y position on screen
  11138. * @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
  11139. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11140. * @returns a PickingInfo array
  11141. */
  11142. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11143. /** Use the given ray to pick sprites in the scene
  11144. * @param ray The ray (in world space) to use to pick meshes
  11145. * @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
  11146. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11147. * @returns a PickingInfo array
  11148. */
  11149. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11150. /**
  11151. * Force the sprite under the pointer
  11152. * @param sprite defines the sprite to use
  11153. */
  11154. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11155. /**
  11156. * Gets the sprite under the pointer
  11157. * @returns a Sprite or null if no sprite is under the pointer
  11158. */
  11159. getPointerOverSprite(): Nullable<Sprite>;
  11160. }
  11161. }
  11162. /**
  11163. * Defines the sprite scene component responsible to manage sprites
  11164. * in a given scene.
  11165. */
  11166. export class SpriteSceneComponent implements ISceneComponent {
  11167. /**
  11168. * The component name helpfull to identify the component in the list of scene components.
  11169. */
  11170. readonly name: string;
  11171. /**
  11172. * The scene the component belongs to.
  11173. */
  11174. scene: Scene;
  11175. /** @hidden */
  11176. private _spritePredicate;
  11177. /**
  11178. * Creates a new instance of the component for the given scene
  11179. * @param scene Defines the scene to register the component in
  11180. */
  11181. constructor(scene: Scene);
  11182. /**
  11183. * Registers the component in a given scene
  11184. */
  11185. register(): void;
  11186. /**
  11187. * Rebuilds the elements related to this component in case of
  11188. * context lost for instance.
  11189. */
  11190. rebuild(): void;
  11191. /**
  11192. * Disposes the component and the associated ressources.
  11193. */
  11194. dispose(): void;
  11195. private _pickSpriteButKeepRay;
  11196. private _pointerMove;
  11197. private _pointerDown;
  11198. private _pointerUp;
  11199. }
  11200. }
  11201. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11202. /** @hidden */
  11203. export var fogFragmentDeclaration: {
  11204. name: string;
  11205. shader: string;
  11206. };
  11207. }
  11208. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11209. /** @hidden */
  11210. export var fogFragment: {
  11211. name: string;
  11212. shader: string;
  11213. };
  11214. }
  11215. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  11216. /** @hidden */
  11217. export var imageProcessingCompatibility: {
  11218. name: string;
  11219. shader: string;
  11220. };
  11221. }
  11222. declare module "babylonjs/Shaders/sprites.fragment" {
  11223. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11224. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11225. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  11226. /** @hidden */
  11227. export var spritesPixelShader: {
  11228. name: string;
  11229. shader: string;
  11230. };
  11231. }
  11232. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11233. /** @hidden */
  11234. export var fogVertexDeclaration: {
  11235. name: string;
  11236. shader: string;
  11237. };
  11238. }
  11239. declare module "babylonjs/Shaders/sprites.vertex" {
  11240. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11241. /** @hidden */
  11242. export var spritesVertexShader: {
  11243. name: string;
  11244. shader: string;
  11245. };
  11246. }
  11247. declare module "babylonjs/Sprites/spriteManager" {
  11248. import { IDisposable, Scene } from "babylonjs/scene";
  11249. import { Nullable } from "babylonjs/types";
  11250. import { Observable } from "babylonjs/Misc/observable";
  11251. import { Sprite } from "babylonjs/Sprites/sprite";
  11252. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11253. import { Camera } from "babylonjs/Cameras/camera";
  11254. import { Texture } from "babylonjs/Materials/Textures/texture";
  11255. import "babylonjs/Shaders/sprites.fragment";
  11256. import "babylonjs/Shaders/sprites.vertex";
  11257. import { Ray } from "babylonjs/Culling/ray";
  11258. /**
  11259. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11260. */
  11261. export interface ISpriteManager extends IDisposable {
  11262. /**
  11263. * Gets manager's name
  11264. */
  11265. name: string;
  11266. /**
  11267. * Restricts the camera to viewing objects with the same layerMask.
  11268. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11269. */
  11270. layerMask: number;
  11271. /**
  11272. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11273. */
  11274. isPickable: boolean;
  11275. /**
  11276. * Gets the hosting scene
  11277. */
  11278. scene: Scene;
  11279. /**
  11280. * Specifies the rendering group id for this mesh (0 by default)
  11281. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11282. */
  11283. renderingGroupId: number;
  11284. /**
  11285. * Defines the list of sprites managed by the manager.
  11286. */
  11287. sprites: Array<Sprite>;
  11288. /**
  11289. * Gets or sets the spritesheet texture
  11290. */
  11291. texture: Texture;
  11292. /** Defines the default width of a cell in the spritesheet */
  11293. cellWidth: number;
  11294. /** Defines the default height of a cell in the spritesheet */
  11295. cellHeight: number;
  11296. /**
  11297. * Tests the intersection of a sprite with a specific ray.
  11298. * @param ray The ray we are sending to test the collision
  11299. * @param camera The camera space we are sending rays in
  11300. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11301. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11302. * @returns picking info or null.
  11303. */
  11304. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11305. /**
  11306. * Intersects the sprites with a ray
  11307. * @param ray defines the ray to intersect with
  11308. * @param camera defines the current active camera
  11309. * @param predicate defines a predicate used to select candidate sprites
  11310. * @returns null if no hit or a PickingInfo array
  11311. */
  11312. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11313. /**
  11314. * Renders the list of sprites on screen.
  11315. */
  11316. render(): void;
  11317. }
  11318. /**
  11319. * Class used to manage multiple sprites on the same spritesheet
  11320. * @see https://doc.babylonjs.com/babylon101/sprites
  11321. */
  11322. export class SpriteManager implements ISpriteManager {
  11323. /** defines the manager's name */
  11324. name: string;
  11325. /** Define the Url to load snippets */
  11326. static SnippetUrl: string;
  11327. /** Snippet ID if the manager was created from the snippet server */
  11328. snippetId: string;
  11329. /** Gets the list of sprites */
  11330. sprites: Sprite[];
  11331. /** Gets or sets the rendering group id (0 by default) */
  11332. renderingGroupId: number;
  11333. /** Gets or sets camera layer mask */
  11334. layerMask: number;
  11335. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11336. fogEnabled: boolean;
  11337. /** Gets or sets a boolean indicating if the sprites are pickable */
  11338. isPickable: boolean;
  11339. /** Defines the default width of a cell in the spritesheet */
  11340. cellWidth: number;
  11341. /** Defines the default height of a cell in the spritesheet */
  11342. cellHeight: number;
  11343. /** Associative array from JSON sprite data file */
  11344. private _cellData;
  11345. /** Array of sprite names from JSON sprite data file */
  11346. private _spriteMap;
  11347. /** True when packed cell data from JSON file is ready*/
  11348. private _packedAndReady;
  11349. private _textureContent;
  11350. private _useInstancing;
  11351. /**
  11352. * An event triggered when the manager is disposed.
  11353. */
  11354. onDisposeObservable: Observable<SpriteManager>;
  11355. private _onDisposeObserver;
  11356. /**
  11357. * Callback called when the manager is disposed
  11358. */
  11359. set onDispose(callback: () => void);
  11360. private _capacity;
  11361. private _fromPacked;
  11362. private _spriteTexture;
  11363. private _epsilon;
  11364. private _scene;
  11365. private _vertexData;
  11366. private _buffer;
  11367. private _vertexBuffers;
  11368. private _spriteBuffer;
  11369. private _indexBuffer;
  11370. private _effectBase;
  11371. private _effectFog;
  11372. private _vertexBufferSize;
  11373. /**
  11374. * Gets or sets the unique id of the sprite
  11375. */
  11376. uniqueId: number;
  11377. /**
  11378. * Gets the array of sprites
  11379. */
  11380. get children(): Sprite[];
  11381. /**
  11382. * Gets the hosting scene
  11383. */
  11384. get scene(): Scene;
  11385. /**
  11386. * Gets the capacity of the manager
  11387. */
  11388. get capacity(): number;
  11389. /**
  11390. * Gets or sets the spritesheet texture
  11391. */
  11392. get texture(): Texture;
  11393. set texture(value: Texture);
  11394. private _blendMode;
  11395. /**
  11396. * Blend mode use to render the particle, it can be any of
  11397. * the static Constants.ALPHA_x properties provided in this class.
  11398. * Default value is Constants.ALPHA_COMBINE
  11399. */
  11400. get blendMode(): number;
  11401. set blendMode(blendMode: number);
  11402. /** Disables writing to the depth buffer when rendering the sprites.
  11403. * It can be handy to disable depth writing when using textures without alpha channel
  11404. * and setting some specific blend modes.
  11405. */
  11406. disableDepthWrite: boolean;
  11407. /**
  11408. * Creates a new sprite manager
  11409. * @param name defines the manager's name
  11410. * @param imgUrl defines the sprite sheet url
  11411. * @param capacity defines the maximum allowed number of sprites
  11412. * @param cellSize defines the size of a sprite cell
  11413. * @param scene defines the hosting scene
  11414. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11415. * @param samplingMode defines the smapling mode to use with spritesheet
  11416. * @param fromPacked set to false; do not alter
  11417. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11418. */
  11419. constructor(
  11420. /** defines the manager's name */
  11421. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11422. /**
  11423. * Returns the string "SpriteManager"
  11424. * @returns "SpriteManager"
  11425. */
  11426. getClassName(): string;
  11427. private _makePacked;
  11428. private _appendSpriteVertex;
  11429. private _checkTextureAlpha;
  11430. /**
  11431. * Intersects the sprites with a ray
  11432. * @param ray defines the ray to intersect with
  11433. * @param camera defines the current active camera
  11434. * @param predicate defines a predicate used to select candidate sprites
  11435. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11436. * @returns null if no hit or a PickingInfo
  11437. */
  11438. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11439. /**
  11440. * Intersects the sprites with a ray
  11441. * @param ray defines the ray to intersect with
  11442. * @param camera defines the current active camera
  11443. * @param predicate defines a predicate used to select candidate sprites
  11444. * @returns null if no hit or a PickingInfo array
  11445. */
  11446. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11447. /**
  11448. * Render all child sprites
  11449. */
  11450. render(): void;
  11451. /**
  11452. * Release associated resources
  11453. */
  11454. dispose(): void;
  11455. /**
  11456. * Serializes the sprite manager to a JSON object
  11457. * @param serializeTexture defines if the texture must be serialized as well
  11458. * @returns the JSON object
  11459. */
  11460. serialize(serializeTexture?: boolean): any;
  11461. /**
  11462. * Parses a JSON object to create a new sprite manager.
  11463. * @param parsedManager The JSON object to parse
  11464. * @param scene The scene to create the sprite managerin
  11465. * @param rootUrl The root url to use to load external dependencies like texture
  11466. * @returns the new sprite manager
  11467. */
  11468. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11469. /**
  11470. * Creates a sprite manager from a snippet saved in a remote file
  11471. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11472. * @param url defines the url to load from
  11473. * @param scene defines the hosting scene
  11474. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11475. * @returns a promise that will resolve to the new sprite manager
  11476. */
  11477. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11478. /**
  11479. * Creates a sprite manager from a snippet saved by the sprite editor
  11480. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11481. * @param scene defines the hosting scene
  11482. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11483. * @returns a promise that will resolve to the new sprite manager
  11484. */
  11485. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11486. }
  11487. }
  11488. declare module "babylonjs/Misc/gradients" {
  11489. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11490. /** Interface used by value gradients (color, factor, ...) */
  11491. export interface IValueGradient {
  11492. /**
  11493. * Gets or sets the gradient value (between 0 and 1)
  11494. */
  11495. gradient: number;
  11496. }
  11497. /** Class used to store color4 gradient */
  11498. export class ColorGradient implements IValueGradient {
  11499. /**
  11500. * Gets or sets the gradient value (between 0 and 1)
  11501. */
  11502. gradient: number;
  11503. /**
  11504. * Gets or sets first associated color
  11505. */
  11506. color1: Color4;
  11507. /**
  11508. * Gets or sets second associated color
  11509. */
  11510. color2?: Color4 | undefined;
  11511. /**
  11512. * Creates a new color4 gradient
  11513. * @param gradient gets or sets the gradient value (between 0 and 1)
  11514. * @param color1 gets or sets first associated color
  11515. * @param color2 gets or sets first second color
  11516. */
  11517. constructor(
  11518. /**
  11519. * Gets or sets the gradient value (between 0 and 1)
  11520. */
  11521. gradient: number,
  11522. /**
  11523. * Gets or sets first associated color
  11524. */
  11525. color1: Color4,
  11526. /**
  11527. * Gets or sets second associated color
  11528. */
  11529. color2?: Color4 | undefined);
  11530. /**
  11531. * Will get a color picked randomly between color1 and color2.
  11532. * If color2 is undefined then color1 will be used
  11533. * @param result defines the target Color4 to store the result in
  11534. */
  11535. getColorToRef(result: Color4): void;
  11536. }
  11537. /** Class used to store color 3 gradient */
  11538. export class Color3Gradient implements IValueGradient {
  11539. /**
  11540. * Gets or sets the gradient value (between 0 and 1)
  11541. */
  11542. gradient: number;
  11543. /**
  11544. * Gets or sets the associated color
  11545. */
  11546. color: Color3;
  11547. /**
  11548. * Creates a new color3 gradient
  11549. * @param gradient gets or sets the gradient value (between 0 and 1)
  11550. * @param color gets or sets associated color
  11551. */
  11552. constructor(
  11553. /**
  11554. * Gets or sets the gradient value (between 0 and 1)
  11555. */
  11556. gradient: number,
  11557. /**
  11558. * Gets or sets the associated color
  11559. */
  11560. color: Color3);
  11561. }
  11562. /** Class used to store factor gradient */
  11563. export class FactorGradient implements IValueGradient {
  11564. /**
  11565. * Gets or sets the gradient value (between 0 and 1)
  11566. */
  11567. gradient: number;
  11568. /**
  11569. * Gets or sets first associated factor
  11570. */
  11571. factor1: number;
  11572. /**
  11573. * Gets or sets second associated factor
  11574. */
  11575. factor2?: number | undefined;
  11576. /**
  11577. * Creates a new factor gradient
  11578. * @param gradient gets or sets the gradient value (between 0 and 1)
  11579. * @param factor1 gets or sets first associated factor
  11580. * @param factor2 gets or sets second associated factor
  11581. */
  11582. constructor(
  11583. /**
  11584. * Gets or sets the gradient value (between 0 and 1)
  11585. */
  11586. gradient: number,
  11587. /**
  11588. * Gets or sets first associated factor
  11589. */
  11590. factor1: number,
  11591. /**
  11592. * Gets or sets second associated factor
  11593. */
  11594. factor2?: number | undefined);
  11595. /**
  11596. * Will get a number picked randomly between factor1 and factor2.
  11597. * If factor2 is undefined then factor1 will be used
  11598. * @returns the picked number
  11599. */
  11600. getFactor(): number;
  11601. }
  11602. /**
  11603. * Helper used to simplify some generic gradient tasks
  11604. */
  11605. export class GradientHelper {
  11606. /**
  11607. * Gets the current gradient from an array of IValueGradient
  11608. * @param ratio defines the current ratio to get
  11609. * @param gradients defines the array of IValueGradient
  11610. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11611. */
  11612. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11613. }
  11614. }
  11615. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11616. import { Nullable } from "babylonjs/types";
  11617. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11618. import { Scene } from "babylonjs/scene";
  11619. module "babylonjs/Engines/thinEngine" {
  11620. interface ThinEngine {
  11621. /**
  11622. * Creates a raw texture
  11623. * @param data defines the data to store in the texture
  11624. * @param width defines the width of the texture
  11625. * @param height defines the height of the texture
  11626. * @param format defines the format of the data
  11627. * @param generateMipMaps defines if the engine should generate the mip levels
  11628. * @param invertY defines if data must be stored with Y axis inverted
  11629. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11630. * @param compression defines the compression used (null by default)
  11631. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11632. * @returns the raw texture inside an InternalTexture
  11633. */
  11634. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11635. /**
  11636. * Update a raw texture
  11637. * @param texture defines the texture to update
  11638. * @param data defines the data to store in the texture
  11639. * @param format defines the format of the data
  11640. * @param invertY defines if data must be stored with Y axis inverted
  11641. */
  11642. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11643. /**
  11644. * Update a raw texture
  11645. * @param texture defines the texture to update
  11646. * @param data defines the data to store in the texture
  11647. * @param format defines the format of the data
  11648. * @param invertY defines if data must be stored with Y axis inverted
  11649. * @param compression defines the compression used (null by default)
  11650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11651. */
  11652. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11653. /**
  11654. * Creates a new raw cube texture
  11655. * @param data defines the array of data to use to create each face
  11656. * @param size defines the size of the textures
  11657. * @param format defines the format of the data
  11658. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11659. * @param generateMipMaps defines if the engine should generate the mip levels
  11660. * @param invertY defines if data must be stored with Y axis inverted
  11661. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11662. * @param compression defines the compression used (null by default)
  11663. * @returns the cube texture as an InternalTexture
  11664. */
  11665. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11666. /**
  11667. * Update a raw cube texture
  11668. * @param texture defines the texture to udpdate
  11669. * @param data defines the data to store
  11670. * @param format defines the data format
  11671. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11672. * @param invertY defines if data must be stored with Y axis inverted
  11673. */
  11674. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11675. /**
  11676. * Update a raw cube texture
  11677. * @param texture defines the texture to udpdate
  11678. * @param data defines the data to store
  11679. * @param format defines the data format
  11680. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11681. * @param invertY defines if data must be stored with Y axis inverted
  11682. * @param compression defines the compression used (null by default)
  11683. */
  11684. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11685. /**
  11686. * Update a raw cube texture
  11687. * @param texture defines the texture to udpdate
  11688. * @param data defines the data to store
  11689. * @param format defines the data format
  11690. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11691. * @param invertY defines if data must be stored with Y axis inverted
  11692. * @param compression defines the compression used (null by default)
  11693. * @param level defines which level of the texture to update
  11694. */
  11695. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11696. /**
  11697. * Creates a new raw cube texture from a specified url
  11698. * @param url defines the url where the data is located
  11699. * @param scene defines the current scene
  11700. * @param size defines the size of the textures
  11701. * @param format defines the format of the data
  11702. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11703. * @param noMipmap defines if the engine should avoid generating the mip levels
  11704. * @param callback defines a callback used to extract texture data from loaded data
  11705. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11706. * @param onLoad defines a callback called when texture is loaded
  11707. * @param onError defines a callback called if there is an error
  11708. * @returns the cube texture as an InternalTexture
  11709. */
  11710. 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;
  11711. /**
  11712. * Creates a new raw cube texture from a specified url
  11713. * @param url defines the url where the data is located
  11714. * @param scene defines the current scene
  11715. * @param size defines the size of the textures
  11716. * @param format defines the format of the data
  11717. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11718. * @param noMipmap defines if the engine should avoid generating the mip levels
  11719. * @param callback defines a callback used to extract texture data from loaded data
  11720. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11721. * @param onLoad defines a callback called when texture is loaded
  11722. * @param onError defines a callback called if there is an error
  11723. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11724. * @param invertY defines if data must be stored with Y axis inverted
  11725. * @returns the cube texture as an InternalTexture
  11726. */
  11727. 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;
  11728. /**
  11729. * Creates a new raw 3D texture
  11730. * @param data defines the data used to create the texture
  11731. * @param width defines the width of the texture
  11732. * @param height defines the height of the texture
  11733. * @param depth defines the depth of the texture
  11734. * @param format defines the format of the texture
  11735. * @param generateMipMaps defines if the engine must generate mip levels
  11736. * @param invertY defines if data must be stored with Y axis inverted
  11737. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11738. * @param compression defines the compressed used (can be null)
  11739. * @param textureType defines the compressed used (can be null)
  11740. * @returns a new raw 3D texture (stored in an InternalTexture)
  11741. */
  11742. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11743. /**
  11744. * Update a raw 3D texture
  11745. * @param texture defines the texture to update
  11746. * @param data defines the data to store
  11747. * @param format defines the data format
  11748. * @param invertY defines if data must be stored with Y axis inverted
  11749. */
  11750. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11751. /**
  11752. * Update a raw 3D texture
  11753. * @param texture defines the texture to update
  11754. * @param data defines the data to store
  11755. * @param format defines the data format
  11756. * @param invertY defines if data must be stored with Y axis inverted
  11757. * @param compression defines the used compression (can be null)
  11758. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11759. */
  11760. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11761. /**
  11762. * Creates a new raw 2D array texture
  11763. * @param data defines the data used to create the texture
  11764. * @param width defines the width of the texture
  11765. * @param height defines the height of the texture
  11766. * @param depth defines the number of layers of the texture
  11767. * @param format defines the format of the texture
  11768. * @param generateMipMaps defines if the engine must generate mip levels
  11769. * @param invertY defines if data must be stored with Y axis inverted
  11770. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11771. * @param compression defines the compressed used (can be null)
  11772. * @param textureType defines the compressed used (can be null)
  11773. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11774. */
  11775. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11776. /**
  11777. * Update a raw 2D array texture
  11778. * @param texture defines the texture to update
  11779. * @param data defines the data to store
  11780. * @param format defines the data format
  11781. * @param invertY defines if data must be stored with Y axis inverted
  11782. */
  11783. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11784. /**
  11785. * Update a raw 2D array texture
  11786. * @param texture defines the texture to update
  11787. * @param data defines the data to store
  11788. * @param format defines the data format
  11789. * @param invertY defines if data must be stored with Y axis inverted
  11790. * @param compression defines the used compression (can be null)
  11791. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11792. */
  11793. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11794. }
  11795. }
  11796. }
  11797. declare module "babylonjs/Materials/Textures/rawTexture" {
  11798. import { Texture } from "babylonjs/Materials/Textures/texture";
  11799. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11800. import { Nullable } from "babylonjs/types";
  11801. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11802. import { Scene } from "babylonjs/scene";
  11803. /**
  11804. * Raw texture can help creating a texture directly from an array of data.
  11805. * This can be super useful if you either get the data from an uncompressed source or
  11806. * if you wish to create your texture pixel by pixel.
  11807. */
  11808. export class RawTexture extends Texture {
  11809. /**
  11810. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11811. */
  11812. format: number;
  11813. /**
  11814. * Instantiates a new RawTexture.
  11815. * Raw texture can help creating a texture directly from an array of data.
  11816. * This can be super useful if you either get the data from an uncompressed source or
  11817. * if you wish to create your texture pixel by pixel.
  11818. * @param data define the array of data to use to create the texture
  11819. * @param width define the width of the texture
  11820. * @param height define the height of the texture
  11821. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11822. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11823. * @param generateMipMaps define whether mip maps should be generated or not
  11824. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11825. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11826. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11827. */
  11828. constructor(data: ArrayBufferView, width: number, height: number,
  11829. /**
  11830. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11831. */
  11832. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11833. /**
  11834. * Updates the texture underlying data.
  11835. * @param data Define the new data of the texture
  11836. */
  11837. update(data: ArrayBufferView): void;
  11838. /**
  11839. * Creates a luminance texture from some data.
  11840. * @param data Define the texture data
  11841. * @param width Define the width of the texture
  11842. * @param height Define the height of the texture
  11843. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11844. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11845. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11846. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11847. * @returns the luminance texture
  11848. */
  11849. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11850. /**
  11851. * Creates a luminance alpha texture from some data.
  11852. * @param data Define the texture data
  11853. * @param width Define the width of the texture
  11854. * @param height Define the height of the texture
  11855. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11856. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11857. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11858. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11859. * @returns the luminance alpha texture
  11860. */
  11861. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11862. /**
  11863. * Creates an alpha texture from some data.
  11864. * @param data Define the texture data
  11865. * @param width Define the width of the texture
  11866. * @param height Define the height of the texture
  11867. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11868. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11869. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11870. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11871. * @returns the alpha texture
  11872. */
  11873. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11874. /**
  11875. * Creates a RGB texture from some data.
  11876. * @param data Define the texture data
  11877. * @param width Define the width of the texture
  11878. * @param height Define the height of the texture
  11879. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11880. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11881. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11882. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11883. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11884. * @returns the RGB alpha texture
  11885. */
  11886. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11887. /**
  11888. * Creates a RGBA texture from some data.
  11889. * @param data Define the texture data
  11890. * @param width Define the width of the texture
  11891. * @param height Define the height of the texture
  11892. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11893. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11894. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11895. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11896. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11897. * @returns the RGBA texture
  11898. */
  11899. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11900. /**
  11901. * Creates a R texture from some data.
  11902. * @param data Define the texture data
  11903. * @param width Define the width of the texture
  11904. * @param height Define the height of the texture
  11905. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11906. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11907. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11908. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11909. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11910. * @returns the R texture
  11911. */
  11912. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11913. }
  11914. }
  11915. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11916. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11917. import { IndicesArray, DataArray } from "babylonjs/types";
  11918. module "babylonjs/Engines/thinEngine" {
  11919. interface ThinEngine {
  11920. /**
  11921. * Update a dynamic index buffer
  11922. * @param indexBuffer defines the target index buffer
  11923. * @param indices defines the data to update
  11924. * @param offset defines the offset in the target index buffer where update should start
  11925. */
  11926. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11927. /**
  11928. * Updates a dynamic vertex buffer.
  11929. * @param vertexBuffer the vertex buffer to update
  11930. * @param data the data used to update the vertex buffer
  11931. * @param byteOffset the byte offset of the data
  11932. * @param byteLength the byte length of the data
  11933. */
  11934. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11935. }
  11936. }
  11937. }
  11938. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11939. import { Scene } from "babylonjs/scene";
  11940. import { ISceneComponent } from "babylonjs/sceneComponent";
  11941. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11942. module "babylonjs/abstractScene" {
  11943. interface AbstractScene {
  11944. /**
  11945. * The list of procedural textures added to the scene
  11946. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11947. */
  11948. proceduralTextures: Array<ProceduralTexture>;
  11949. }
  11950. }
  11951. /**
  11952. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11953. * in a given scene.
  11954. */
  11955. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11956. /**
  11957. * The component name helpfull to identify the component in the list of scene components.
  11958. */
  11959. readonly name: string;
  11960. /**
  11961. * The scene the component belongs to.
  11962. */
  11963. scene: Scene;
  11964. /**
  11965. * Creates a new instance of the component for the given scene
  11966. * @param scene Defines the scene to register the component in
  11967. */
  11968. constructor(scene: Scene);
  11969. /**
  11970. * Registers the component in a given scene
  11971. */
  11972. register(): void;
  11973. /**
  11974. * Rebuilds the elements related to this component in case of
  11975. * context lost for instance.
  11976. */
  11977. rebuild(): void;
  11978. /**
  11979. * Disposes the component and the associated ressources.
  11980. */
  11981. dispose(): void;
  11982. private _beforeClear;
  11983. }
  11984. }
  11985. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11986. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11987. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11988. module "babylonjs/Engines/thinEngine" {
  11989. interface ThinEngine {
  11990. /**
  11991. * Creates a new render target cube texture
  11992. * @param size defines the size of the texture
  11993. * @param options defines the options used to create the texture
  11994. * @returns a new render target cube texture stored in an InternalTexture
  11995. */
  11996. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11997. }
  11998. }
  11999. }
  12000. declare module "babylonjs/Shaders/procedural.vertex" {
  12001. /** @hidden */
  12002. export var proceduralVertexShader: {
  12003. name: string;
  12004. shader: string;
  12005. };
  12006. }
  12007. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  12008. import { Observable } from "babylonjs/Misc/observable";
  12009. import { Nullable } from "babylonjs/types";
  12010. import { Scene } from "babylonjs/scene";
  12011. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12012. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12013. import { Effect } from "babylonjs/Materials/effect";
  12014. import { Texture } from "babylonjs/Materials/Textures/texture";
  12015. import "babylonjs/Engines/Extensions/engine.renderTarget";
  12016. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  12017. import "babylonjs/Shaders/procedural.vertex";
  12018. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12019. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  12020. /**
  12021. * 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.
  12022. * This is the base class of any Procedural texture and contains most of the shareable code.
  12023. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12024. */
  12025. export class ProceduralTexture extends Texture {
  12026. /**
  12027. * Define if the texture is enabled or not (disabled texture will not render)
  12028. */
  12029. isEnabled: boolean;
  12030. /**
  12031. * Define if the texture must be cleared before rendering (default is true)
  12032. */
  12033. autoClear: boolean;
  12034. /**
  12035. * Callback called when the texture is generated
  12036. */
  12037. onGenerated: () => void;
  12038. /**
  12039. * Event raised when the texture is generated
  12040. */
  12041. onGeneratedObservable: Observable<ProceduralTexture>;
  12042. /**
  12043. * Event raised before the texture is generated
  12044. */
  12045. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12046. /**
  12047. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12048. */
  12049. nodeMaterialSource: Nullable<NodeMaterial>;
  12050. /** @hidden */
  12051. _generateMipMaps: boolean;
  12052. /** @hidden **/
  12053. _effect: Effect;
  12054. /** @hidden */
  12055. _textures: {
  12056. [key: string]: Texture;
  12057. };
  12058. /** @hidden */
  12059. protected _fallbackTexture: Nullable<Texture>;
  12060. private _size;
  12061. private _currentRefreshId;
  12062. private _frameId;
  12063. private _refreshRate;
  12064. private _vertexBuffers;
  12065. private _indexBuffer;
  12066. private _uniforms;
  12067. private _samplers;
  12068. private _fragment;
  12069. private _floats;
  12070. private _ints;
  12071. private _floatsArrays;
  12072. private _colors3;
  12073. private _colors4;
  12074. private _vectors2;
  12075. private _vectors3;
  12076. private _matrices;
  12077. private _fallbackTextureUsed;
  12078. private _fullEngine;
  12079. private _cachedDefines;
  12080. private _contentUpdateId;
  12081. private _contentData;
  12082. /**
  12083. * Instantiates a new procedural texture.
  12084. * 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.
  12085. * This is the base class of any Procedural texture and contains most of the shareable code.
  12086. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12087. * @param name Define the name of the texture
  12088. * @param size Define the size of the texture to create
  12089. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12090. * @param scene Define the scene the texture belongs to
  12091. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12092. * @param generateMipMaps Define if the texture should creates mip maps or not
  12093. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12094. * @param textureType The FBO internal texture type
  12095. */
  12096. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12097. /**
  12098. * The effect that is created when initializing the post process.
  12099. * @returns The created effect corresponding the the postprocess.
  12100. */
  12101. getEffect(): Effect;
  12102. /**
  12103. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12104. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12105. */
  12106. getContent(): Nullable<ArrayBufferView>;
  12107. private _createIndexBuffer;
  12108. /** @hidden */
  12109. _rebuild(): void;
  12110. /**
  12111. * Resets the texture in order to recreate its associated resources.
  12112. * This can be called in case of context loss
  12113. */
  12114. reset(): void;
  12115. protected _getDefines(): string;
  12116. /**
  12117. * Is the texture ready to be used ? (rendered at least once)
  12118. * @returns true if ready, otherwise, false.
  12119. */
  12120. isReady(): boolean;
  12121. /**
  12122. * Resets the refresh counter of the texture and start bak from scratch.
  12123. * Could be useful to regenerate the texture if it is setup to render only once.
  12124. */
  12125. resetRefreshCounter(): void;
  12126. /**
  12127. * Set the fragment shader to use in order to render the texture.
  12128. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12129. */
  12130. setFragment(fragment: any): void;
  12131. /**
  12132. * Define the refresh rate of the texture or the rendering frequency.
  12133. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12134. */
  12135. get refreshRate(): number;
  12136. set refreshRate(value: number);
  12137. /** @hidden */
  12138. _shouldRender(): boolean;
  12139. /**
  12140. * Get the size the texture is rendering at.
  12141. * @returns the size (on cube texture it is always squared)
  12142. */
  12143. getRenderSize(): RenderTargetTextureSize;
  12144. /**
  12145. * Resize the texture to new value.
  12146. * @param size Define the new size the texture should have
  12147. * @param generateMipMaps Define whether the new texture should create mip maps
  12148. */
  12149. resize(size: number, generateMipMaps: boolean): void;
  12150. private _checkUniform;
  12151. /**
  12152. * Set a texture in the shader program used to render.
  12153. * @param name Define the name of the uniform samplers as defined in the shader
  12154. * @param texture Define the texture to bind to this sampler
  12155. * @return the texture itself allowing "fluent" like uniform updates
  12156. */
  12157. setTexture(name: string, texture: Texture): ProceduralTexture;
  12158. /**
  12159. * Set a float in the shader.
  12160. * @param name Define the name of the uniform as defined in the shader
  12161. * @param value Define the value to give to the uniform
  12162. * @return the texture itself allowing "fluent" like uniform updates
  12163. */
  12164. setFloat(name: string, value: number): ProceduralTexture;
  12165. /**
  12166. * Set a int in the shader.
  12167. * @param name Define the name of the uniform as defined in the shader
  12168. * @param value Define the value to give to the uniform
  12169. * @return the texture itself allowing "fluent" like uniform updates
  12170. */
  12171. setInt(name: string, value: number): ProceduralTexture;
  12172. /**
  12173. * Set an array of floats in the shader.
  12174. * @param name Define the name of the uniform as defined in the shader
  12175. * @param value Define the value to give to the uniform
  12176. * @return the texture itself allowing "fluent" like uniform updates
  12177. */
  12178. setFloats(name: string, value: number[]): ProceduralTexture;
  12179. /**
  12180. * Set a vec3 in the shader from a Color3.
  12181. * @param name Define the name of the uniform as defined in the shader
  12182. * @param value Define the value to give to the uniform
  12183. * @return the texture itself allowing "fluent" like uniform updates
  12184. */
  12185. setColor3(name: string, value: Color3): ProceduralTexture;
  12186. /**
  12187. * Set a vec4 in the shader from a Color4.
  12188. * @param name Define the name of the uniform as defined in the shader
  12189. * @param value Define the value to give to the uniform
  12190. * @return the texture itself allowing "fluent" like uniform updates
  12191. */
  12192. setColor4(name: string, value: Color4): ProceduralTexture;
  12193. /**
  12194. * Set a vec2 in the shader from a Vector2.
  12195. * @param name Define the name of the uniform as defined in the shader
  12196. * @param value Define the value to give to the uniform
  12197. * @return the texture itself allowing "fluent" like uniform updates
  12198. */
  12199. setVector2(name: string, value: Vector2): ProceduralTexture;
  12200. /**
  12201. * Set a vec3 in the shader from a Vector3.
  12202. * @param name Define the name of the uniform as defined in the shader
  12203. * @param value Define the value to give to the uniform
  12204. * @return the texture itself allowing "fluent" like uniform updates
  12205. */
  12206. setVector3(name: string, value: Vector3): ProceduralTexture;
  12207. /**
  12208. * Set a mat4 in the shader from a MAtrix.
  12209. * @param name Define the name of the uniform as defined in the shader
  12210. * @param value Define the value to give to the uniform
  12211. * @return the texture itself allowing "fluent" like uniform updates
  12212. */
  12213. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12214. /**
  12215. * Render the texture to its associated render target.
  12216. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12217. */
  12218. render(useCameraPostProcess?: boolean): void;
  12219. /**
  12220. * Clone the texture.
  12221. * @returns the cloned texture
  12222. */
  12223. clone(): ProceduralTexture;
  12224. /**
  12225. * Dispose the texture and release its asoociated resources.
  12226. */
  12227. dispose(): void;
  12228. }
  12229. }
  12230. declare module "babylonjs/Particles/baseParticleSystem" {
  12231. import { Nullable } from "babylonjs/types";
  12232. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12234. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12235. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12236. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12238. import { Color4 } from "babylonjs/Maths/math.color";
  12239. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12240. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12241. import { Animation } from "babylonjs/Animations/animation";
  12242. import { Scene } from "babylonjs/scene";
  12243. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12244. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12245. /**
  12246. * This represents the base class for particle system in Babylon.
  12247. * 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.
  12248. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12249. * @example https://doc.babylonjs.com/babylon101/particles
  12250. */
  12251. export class BaseParticleSystem {
  12252. /**
  12253. * Source color is added to the destination color without alpha affecting the result
  12254. */
  12255. static BLENDMODE_ONEONE: number;
  12256. /**
  12257. * Blend current color and particle color using particle’s alpha
  12258. */
  12259. static BLENDMODE_STANDARD: number;
  12260. /**
  12261. * Add current color and particle color multiplied by particle’s alpha
  12262. */
  12263. static BLENDMODE_ADD: number;
  12264. /**
  12265. * Multiply current color with particle color
  12266. */
  12267. static BLENDMODE_MULTIPLY: number;
  12268. /**
  12269. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12270. */
  12271. static BLENDMODE_MULTIPLYADD: number;
  12272. /**
  12273. * List of animations used by the particle system.
  12274. */
  12275. animations: Animation[];
  12276. /**
  12277. * Gets or sets the unique id of the particle system
  12278. */
  12279. uniqueId: number;
  12280. /**
  12281. * The id of the Particle system.
  12282. */
  12283. id: string;
  12284. /**
  12285. * The friendly name of the Particle system.
  12286. */
  12287. name: string;
  12288. /**
  12289. * Snippet ID if the particle system was created from the snippet server
  12290. */
  12291. snippetId: string;
  12292. /**
  12293. * The rendering group used by the Particle system to chose when to render.
  12294. */
  12295. renderingGroupId: number;
  12296. /**
  12297. * The emitter represents the Mesh or position we are attaching the particle system to.
  12298. */
  12299. emitter: Nullable<AbstractMesh | Vector3>;
  12300. /**
  12301. * The maximum number of particles to emit per frame
  12302. */
  12303. emitRate: number;
  12304. /**
  12305. * If you want to launch only a few particles at once, that can be done, as well.
  12306. */
  12307. manualEmitCount: number;
  12308. /**
  12309. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12310. */
  12311. updateSpeed: number;
  12312. /**
  12313. * The amount of time the particle system is running (depends of the overall update speed).
  12314. */
  12315. targetStopDuration: number;
  12316. /**
  12317. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12318. */
  12319. disposeOnStop: boolean;
  12320. /**
  12321. * Minimum power of emitting particles.
  12322. */
  12323. minEmitPower: number;
  12324. /**
  12325. * Maximum power of emitting particles.
  12326. */
  12327. maxEmitPower: number;
  12328. /**
  12329. * Minimum life time of emitting particles.
  12330. */
  12331. minLifeTime: number;
  12332. /**
  12333. * Maximum life time of emitting particles.
  12334. */
  12335. maxLifeTime: number;
  12336. /**
  12337. * Minimum Size of emitting particles.
  12338. */
  12339. minSize: number;
  12340. /**
  12341. * Maximum Size of emitting particles.
  12342. */
  12343. maxSize: number;
  12344. /**
  12345. * Minimum scale of emitting particles on X axis.
  12346. */
  12347. minScaleX: number;
  12348. /**
  12349. * Maximum scale of emitting particles on X axis.
  12350. */
  12351. maxScaleX: number;
  12352. /**
  12353. * Minimum scale of emitting particles on Y axis.
  12354. */
  12355. minScaleY: number;
  12356. /**
  12357. * Maximum scale of emitting particles on Y axis.
  12358. */
  12359. maxScaleY: number;
  12360. /**
  12361. * Gets or sets the minimal initial rotation in radians.
  12362. */
  12363. minInitialRotation: number;
  12364. /**
  12365. * Gets or sets the maximal initial rotation in radians.
  12366. */
  12367. maxInitialRotation: number;
  12368. /**
  12369. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12370. */
  12371. minAngularSpeed: number;
  12372. /**
  12373. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12374. */
  12375. maxAngularSpeed: number;
  12376. /**
  12377. * The texture used to render each particle. (this can be a spritesheet)
  12378. */
  12379. particleTexture: Nullable<BaseTexture>;
  12380. /**
  12381. * The layer mask we are rendering the particles through.
  12382. */
  12383. layerMask: number;
  12384. /**
  12385. * This can help using your own shader to render the particle system.
  12386. * The according effect will be created
  12387. */
  12388. customShader: any;
  12389. /**
  12390. * By default particle system starts as soon as they are created. This prevents the
  12391. * automatic start to happen and let you decide when to start emitting particles.
  12392. */
  12393. preventAutoStart: boolean;
  12394. private _noiseTexture;
  12395. /**
  12396. * Gets or sets a texture used to add random noise to particle positions
  12397. */
  12398. get noiseTexture(): Nullable<ProceduralTexture>;
  12399. set noiseTexture(value: Nullable<ProceduralTexture>);
  12400. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12401. noiseStrength: Vector3;
  12402. /**
  12403. * Callback triggered when the particle animation is ending.
  12404. */
  12405. onAnimationEnd: Nullable<() => void>;
  12406. /**
  12407. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12408. */
  12409. blendMode: number;
  12410. /**
  12411. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12412. * to override the particles.
  12413. */
  12414. forceDepthWrite: boolean;
  12415. /** 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 */
  12416. preWarmCycles: number;
  12417. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12418. preWarmStepOffset: number;
  12419. /**
  12420. * 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)
  12421. */
  12422. spriteCellChangeSpeed: number;
  12423. /**
  12424. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12425. */
  12426. startSpriteCellID: number;
  12427. /**
  12428. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12429. */
  12430. endSpriteCellID: number;
  12431. /**
  12432. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12433. */
  12434. spriteCellWidth: number;
  12435. /**
  12436. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12437. */
  12438. spriteCellHeight: number;
  12439. /**
  12440. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12441. */
  12442. spriteRandomStartCell: boolean;
  12443. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12444. translationPivot: Vector2;
  12445. /** @hidden */
  12446. protected _isAnimationSheetEnabled: boolean;
  12447. /**
  12448. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12449. */
  12450. beginAnimationOnStart: boolean;
  12451. /**
  12452. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12453. */
  12454. beginAnimationFrom: number;
  12455. /**
  12456. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12457. */
  12458. beginAnimationTo: number;
  12459. /**
  12460. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12461. */
  12462. beginAnimationLoop: boolean;
  12463. /**
  12464. * Gets or sets a world offset applied to all particles
  12465. */
  12466. worldOffset: Vector3;
  12467. /**
  12468. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12469. */
  12470. get isAnimationSheetEnabled(): boolean;
  12471. set isAnimationSheetEnabled(value: boolean);
  12472. /**
  12473. * Get hosting scene
  12474. * @returns the scene
  12475. */
  12476. getScene(): Nullable<Scene>;
  12477. /**
  12478. * You can use gravity if you want to give an orientation to your particles.
  12479. */
  12480. gravity: Vector3;
  12481. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12482. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12483. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12484. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12485. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12486. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12487. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12488. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12489. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12490. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12491. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12492. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12493. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12494. /**
  12495. * Defines the delay in milliseconds before starting the system (0 by default)
  12496. */
  12497. startDelay: number;
  12498. /**
  12499. * Gets the current list of drag gradients.
  12500. * You must use addDragGradient and removeDragGradient to udpate this list
  12501. * @returns the list of drag gradients
  12502. */
  12503. getDragGradients(): Nullable<Array<FactorGradient>>;
  12504. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12505. limitVelocityDamping: number;
  12506. /**
  12507. * Gets the current list of limit velocity gradients.
  12508. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12509. * @returns the list of limit velocity gradients
  12510. */
  12511. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12512. /**
  12513. * Gets the current list of color gradients.
  12514. * You must use addColorGradient and removeColorGradient to udpate this list
  12515. * @returns the list of color gradients
  12516. */
  12517. getColorGradients(): Nullable<Array<ColorGradient>>;
  12518. /**
  12519. * Gets the current list of size gradients.
  12520. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12521. * @returns the list of size gradients
  12522. */
  12523. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12524. /**
  12525. * Gets the current list of color remap gradients.
  12526. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12527. * @returns the list of color remap gradients
  12528. */
  12529. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12530. /**
  12531. * Gets the current list of alpha remap gradients.
  12532. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12533. * @returns the list of alpha remap gradients
  12534. */
  12535. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12536. /**
  12537. * Gets the current list of life time gradients.
  12538. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12539. * @returns the list of life time gradients
  12540. */
  12541. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12542. /**
  12543. * Gets the current list of angular speed gradients.
  12544. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12545. * @returns the list of angular speed gradients
  12546. */
  12547. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12548. /**
  12549. * Gets the current list of velocity gradients.
  12550. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12551. * @returns the list of velocity gradients
  12552. */
  12553. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12554. /**
  12555. * Gets the current list of start size gradients.
  12556. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12557. * @returns the list of start size gradients
  12558. */
  12559. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12560. /**
  12561. * Gets the current list of emit rate gradients.
  12562. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12563. * @returns the list of emit rate gradients
  12564. */
  12565. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12566. /**
  12567. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12568. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12569. */
  12570. get direction1(): Vector3;
  12571. set direction1(value: Vector3);
  12572. /**
  12573. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12574. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12575. */
  12576. get direction2(): Vector3;
  12577. set direction2(value: Vector3);
  12578. /**
  12579. * 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.
  12580. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12581. */
  12582. get minEmitBox(): Vector3;
  12583. set minEmitBox(value: Vector3);
  12584. /**
  12585. * 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.
  12586. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12587. */
  12588. get maxEmitBox(): Vector3;
  12589. set maxEmitBox(value: Vector3);
  12590. /**
  12591. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12592. */
  12593. color1: Color4;
  12594. /**
  12595. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12596. */
  12597. color2: Color4;
  12598. /**
  12599. * Color the particle will have at the end of its lifetime
  12600. */
  12601. colorDead: Color4;
  12602. /**
  12603. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12604. */
  12605. textureMask: Color4;
  12606. /**
  12607. * The particle emitter type defines the emitter used by the particle system.
  12608. * It can be for example box, sphere, or cone...
  12609. */
  12610. particleEmitterType: IParticleEmitterType;
  12611. /** @hidden */
  12612. _isSubEmitter: boolean;
  12613. /**
  12614. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12615. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12616. */
  12617. billboardMode: number;
  12618. protected _isBillboardBased: boolean;
  12619. /**
  12620. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12621. */
  12622. get isBillboardBased(): boolean;
  12623. set isBillboardBased(value: boolean);
  12624. /**
  12625. * The scene the particle system belongs to.
  12626. */
  12627. protected _scene: Nullable<Scene>;
  12628. /**
  12629. * The engine the particle system belongs to.
  12630. */
  12631. protected _engine: ThinEngine;
  12632. /**
  12633. * Local cache of defines for image processing.
  12634. */
  12635. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12636. /**
  12637. * Default configuration related to image processing available in the standard Material.
  12638. */
  12639. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12640. /**
  12641. * Gets the image processing configuration used either in this material.
  12642. */
  12643. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12644. /**
  12645. * Sets the Default image processing configuration used either in the this material.
  12646. *
  12647. * If sets to null, the scene one is in use.
  12648. */
  12649. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12650. /**
  12651. * Attaches a new image processing configuration to the Standard Material.
  12652. * @param configuration
  12653. */
  12654. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12655. /** @hidden */
  12656. protected _reset(): void;
  12657. /** @hidden */
  12658. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12659. /**
  12660. * Instantiates a particle system.
  12661. * 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.
  12662. * @param name The name of the particle system
  12663. */
  12664. constructor(name: string);
  12665. /**
  12666. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12667. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12668. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12669. * @returns the emitter
  12670. */
  12671. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12672. /**
  12673. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12674. * @param radius The radius of the hemisphere to emit from
  12675. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12676. * @returns the emitter
  12677. */
  12678. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12679. /**
  12680. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12681. * @param radius The radius of the sphere to emit from
  12682. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12683. * @returns the emitter
  12684. */
  12685. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12686. /**
  12687. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12688. * @param radius The radius of the sphere to emit from
  12689. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12690. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12691. * @returns the emitter
  12692. */
  12693. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12694. /**
  12695. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12696. * @param radius The radius of the emission cylinder
  12697. * @param height The height of the emission cylinder
  12698. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12699. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12700. * @returns the emitter
  12701. */
  12702. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12703. /**
  12704. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12705. * @param radius The radius of the cylinder to emit from
  12706. * @param height The height of the emission cylinder
  12707. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12708. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12709. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12710. * @returns the emitter
  12711. */
  12712. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12713. /**
  12714. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12715. * @param radius The radius of the cone to emit from
  12716. * @param angle The base angle of the cone
  12717. * @returns the emitter
  12718. */
  12719. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12720. /**
  12721. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12722. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12723. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12724. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12725. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12726. * @returns the emitter
  12727. */
  12728. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12729. }
  12730. }
  12731. declare module "babylonjs/Particles/subEmitter" {
  12732. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12733. import { Scene } from "babylonjs/scene";
  12734. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12735. /**
  12736. * Type of sub emitter
  12737. */
  12738. export enum SubEmitterType {
  12739. /**
  12740. * Attached to the particle over it's lifetime
  12741. */
  12742. ATTACHED = 0,
  12743. /**
  12744. * Created when the particle dies
  12745. */
  12746. END = 1
  12747. }
  12748. /**
  12749. * Sub emitter class used to emit particles from an existing particle
  12750. */
  12751. export class SubEmitter {
  12752. /**
  12753. * the particle system to be used by the sub emitter
  12754. */
  12755. particleSystem: ParticleSystem;
  12756. /**
  12757. * Type of the submitter (Default: END)
  12758. */
  12759. type: SubEmitterType;
  12760. /**
  12761. * 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)
  12762. * Note: This only is supported when using an emitter of type Mesh
  12763. */
  12764. inheritDirection: boolean;
  12765. /**
  12766. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12767. */
  12768. inheritedVelocityAmount: number;
  12769. /**
  12770. * Creates a sub emitter
  12771. * @param particleSystem the particle system to be used by the sub emitter
  12772. */
  12773. constructor(
  12774. /**
  12775. * the particle system to be used by the sub emitter
  12776. */
  12777. particleSystem: ParticleSystem);
  12778. /**
  12779. * Clones the sub emitter
  12780. * @returns the cloned sub emitter
  12781. */
  12782. clone(): SubEmitter;
  12783. /**
  12784. * Serialize current object to a JSON object
  12785. * @returns the serialized object
  12786. */
  12787. serialize(): any;
  12788. /** @hidden */
  12789. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12790. /**
  12791. * Creates a new SubEmitter from a serialized JSON version
  12792. * @param serializationObject defines the JSON object to read from
  12793. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12794. * @param rootUrl defines the rootUrl for data loading
  12795. * @returns a new SubEmitter
  12796. */
  12797. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12798. /** Release associated resources */
  12799. dispose(): void;
  12800. }
  12801. }
  12802. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12803. /** @hidden */
  12804. export var imageProcessingDeclaration: {
  12805. name: string;
  12806. shader: string;
  12807. };
  12808. }
  12809. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12810. /** @hidden */
  12811. export var imageProcessingFunctions: {
  12812. name: string;
  12813. shader: string;
  12814. };
  12815. }
  12816. declare module "babylonjs/Shaders/particles.fragment" {
  12817. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12818. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12819. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12820. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12821. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12822. /** @hidden */
  12823. export var particlesPixelShader: {
  12824. name: string;
  12825. shader: string;
  12826. };
  12827. }
  12828. declare module "babylonjs/Shaders/particles.vertex" {
  12829. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12830. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12831. /** @hidden */
  12832. export var particlesVertexShader: {
  12833. name: string;
  12834. shader: string;
  12835. };
  12836. }
  12837. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12838. import { Nullable } from "babylonjs/types";
  12839. import { Plane } from "babylonjs/Maths/math";
  12840. /**
  12841. * Interface used to define entities containing multiple clip planes
  12842. */
  12843. export interface IClipPlanesHolder {
  12844. /**
  12845. * Gets or sets the active clipplane 1
  12846. */
  12847. clipPlane: Nullable<Plane>;
  12848. /**
  12849. * Gets or sets the active clipplane 2
  12850. */
  12851. clipPlane2: Nullable<Plane>;
  12852. /**
  12853. * Gets or sets the active clipplane 3
  12854. */
  12855. clipPlane3: Nullable<Plane>;
  12856. /**
  12857. * Gets or sets the active clipplane 4
  12858. */
  12859. clipPlane4: Nullable<Plane>;
  12860. /**
  12861. * Gets or sets the active clipplane 5
  12862. */
  12863. clipPlane5: Nullable<Plane>;
  12864. /**
  12865. * Gets or sets the active clipplane 6
  12866. */
  12867. clipPlane6: Nullable<Plane>;
  12868. }
  12869. }
  12870. declare module "babylonjs/Materials/thinMaterialHelper" {
  12871. import { Effect } from "babylonjs/Materials/effect";
  12872. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12873. /**
  12874. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12875. *
  12876. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12877. *
  12878. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12879. */
  12880. export class ThinMaterialHelper {
  12881. /**
  12882. * Binds the clip plane information from the holder to the effect.
  12883. * @param effect The effect we are binding the data to
  12884. * @param holder The entity containing the clip plane information
  12885. */
  12886. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12887. }
  12888. }
  12889. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12890. module "babylonjs/Engines/thinEngine" {
  12891. interface ThinEngine {
  12892. /**
  12893. * Sets alpha constants used by some alpha blending modes
  12894. * @param r defines the red component
  12895. * @param g defines the green component
  12896. * @param b defines the blue component
  12897. * @param a defines the alpha component
  12898. */
  12899. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12900. /**
  12901. * Sets the current alpha mode
  12902. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12903. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12904. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12905. */
  12906. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12907. /**
  12908. * Gets the current alpha mode
  12909. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12910. * @returns the current alpha mode
  12911. */
  12912. getAlphaMode(): number;
  12913. /**
  12914. * Sets the current alpha equation
  12915. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12916. */
  12917. setAlphaEquation(equation: number): void;
  12918. /**
  12919. * Gets the current alpha equation.
  12920. * @returns the current alpha equation
  12921. */
  12922. getAlphaEquation(): number;
  12923. }
  12924. }
  12925. }
  12926. declare module "babylonjs/Particles/particleSystem" {
  12927. import { Nullable } from "babylonjs/types";
  12928. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12929. import { Observable } from "babylonjs/Misc/observable";
  12930. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12931. import { Effect } from "babylonjs/Materials/effect";
  12932. import { IDisposable } from "babylonjs/scene";
  12933. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12934. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12935. import { Particle } from "babylonjs/Particles/particle";
  12936. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12937. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12938. import "babylonjs/Shaders/particles.fragment";
  12939. import "babylonjs/Shaders/particles.vertex";
  12940. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12941. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12942. import "babylonjs/Engines/Extensions/engine.alpha";
  12943. import { Scene } from "babylonjs/scene";
  12944. /**
  12945. * This represents a particle system in Babylon.
  12946. * 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.
  12947. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12948. * @example https://doc.babylonjs.com/babylon101/particles
  12949. */
  12950. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12951. /**
  12952. * Billboard mode will only apply to Y axis
  12953. */
  12954. static readonly BILLBOARDMODE_Y: number;
  12955. /**
  12956. * Billboard mode will apply to all axes
  12957. */
  12958. static readonly BILLBOARDMODE_ALL: number;
  12959. /**
  12960. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12961. */
  12962. static readonly BILLBOARDMODE_STRETCHED: number;
  12963. /**
  12964. * This function can be defined to provide custom update for active particles.
  12965. * This function will be called instead of regular update (age, position, color, etc.).
  12966. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12967. */
  12968. updateFunction: (particles: Particle[]) => void;
  12969. private _emitterWorldMatrix;
  12970. /**
  12971. * This function can be defined to specify initial direction for every new particle.
  12972. * It by default use the emitterType defined function
  12973. */
  12974. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12975. /**
  12976. * This function can be defined to specify initial position for every new particle.
  12977. * It by default use the emitterType defined function
  12978. */
  12979. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12980. /**
  12981. * @hidden
  12982. */
  12983. _inheritedVelocityOffset: Vector3;
  12984. /**
  12985. * An event triggered when the system is disposed
  12986. */
  12987. onDisposeObservable: Observable<IParticleSystem>;
  12988. /**
  12989. * An event triggered when the system is stopped
  12990. */
  12991. onStoppedObservable: Observable<IParticleSystem>;
  12992. private _onDisposeObserver;
  12993. /**
  12994. * Sets a callback that will be triggered when the system is disposed
  12995. */
  12996. set onDispose(callback: () => void);
  12997. private _particles;
  12998. private _epsilon;
  12999. private _capacity;
  13000. private _stockParticles;
  13001. private _newPartsExcess;
  13002. private _vertexData;
  13003. private _vertexBuffer;
  13004. private _vertexBuffers;
  13005. private _spriteBuffer;
  13006. private _indexBuffer;
  13007. private _effect;
  13008. private _customEffect;
  13009. private _cachedDefines;
  13010. private _scaledColorStep;
  13011. private _colorDiff;
  13012. private _scaledDirection;
  13013. private _scaledGravity;
  13014. private _currentRenderId;
  13015. private _alive;
  13016. private _useInstancing;
  13017. private _vertexArrayObject;
  13018. private _started;
  13019. private _stopped;
  13020. private _actualFrame;
  13021. private _scaledUpdateSpeed;
  13022. private _vertexBufferSize;
  13023. /** @hidden */
  13024. _currentEmitRateGradient: Nullable<FactorGradient>;
  13025. /** @hidden */
  13026. _currentEmitRate1: number;
  13027. /** @hidden */
  13028. _currentEmitRate2: number;
  13029. /** @hidden */
  13030. _currentStartSizeGradient: Nullable<FactorGradient>;
  13031. /** @hidden */
  13032. _currentStartSize1: number;
  13033. /** @hidden */
  13034. _currentStartSize2: number;
  13035. private readonly _rawTextureWidth;
  13036. private _rampGradientsTexture;
  13037. private _useRampGradients;
  13038. /** Gets or sets a matrix to use to compute projection */
  13039. defaultProjectionMatrix: Matrix;
  13040. /** Gets or sets a matrix to use to compute view */
  13041. defaultViewMatrix: Matrix;
  13042. /** Gets or sets a boolean indicating that ramp gradients must be used
  13043. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13044. */
  13045. get useRampGradients(): boolean;
  13046. set useRampGradients(value: boolean);
  13047. /**
  13048. * 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.
  13049. * 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: [])
  13050. */
  13051. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13052. private _subEmitters;
  13053. /**
  13054. * @hidden
  13055. * If the particle systems emitter should be disposed when the particle system is disposed
  13056. */
  13057. _disposeEmitterOnDispose: boolean;
  13058. /**
  13059. * The current active Sub-systems, this property is used by the root particle system only.
  13060. */
  13061. activeSubSystems: Array<ParticleSystem>;
  13062. /**
  13063. * Specifies if the particles are updated in emitter local space or world space
  13064. */
  13065. isLocal: boolean;
  13066. private _rootParticleSystem;
  13067. /**
  13068. * Gets the current list of active particles
  13069. */
  13070. get particles(): Particle[];
  13071. /**
  13072. * Gets the number of particles active at the same time.
  13073. * @returns The number of active particles.
  13074. */
  13075. getActiveCount(): number;
  13076. /**
  13077. * Returns the string "ParticleSystem"
  13078. * @returns a string containing the class name
  13079. */
  13080. getClassName(): string;
  13081. /**
  13082. * Gets a boolean indicating that the system is stopping
  13083. * @returns true if the system is currently stopping
  13084. */
  13085. isStopping(): boolean;
  13086. /**
  13087. * Gets the custom effect used to render the particles
  13088. * @param blendMode Blend mode for which the effect should be retrieved
  13089. * @returns The effect
  13090. */
  13091. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13092. /**
  13093. * Sets the custom effect used to render the particles
  13094. * @param effect The effect to set
  13095. * @param blendMode Blend mode for which the effect should be set
  13096. */
  13097. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13098. /** @hidden */
  13099. private _onBeforeDrawParticlesObservable;
  13100. /**
  13101. * Observable that will be called just before the particles are drawn
  13102. */
  13103. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13104. /**
  13105. * Gets the name of the particle vertex shader
  13106. */
  13107. get vertexShaderName(): string;
  13108. /**
  13109. * Instantiates a particle system.
  13110. * 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.
  13111. * @param name The name of the particle system
  13112. * @param capacity The max number of particles alive at the same time
  13113. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13114. * @param customEffect a custom effect used to change the way particles are rendered by default
  13115. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13116. * @param epsilon Offset used to render the particles
  13117. */
  13118. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13119. private _addFactorGradient;
  13120. private _removeFactorGradient;
  13121. /**
  13122. * Adds a new life time gradient
  13123. * @param gradient defines the gradient to use (between 0 and 1)
  13124. * @param factor defines the life time factor 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. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13129. /**
  13130. * Remove a specific life time gradient
  13131. * @param gradient defines the gradient to remove
  13132. * @returns the current particle system
  13133. */
  13134. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13135. /**
  13136. * Adds a new size gradient
  13137. * @param gradient defines the gradient to use (between 0 and 1)
  13138. * @param factor defines the size factor 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. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13143. /**
  13144. * Remove a specific size gradient
  13145. * @param gradient defines the gradient to remove
  13146. * @returns the current particle system
  13147. */
  13148. removeSizeGradient(gradient: number): IParticleSystem;
  13149. /**
  13150. * Adds a new color remap gradient
  13151. * @param gradient defines the gradient to use (between 0 and 1)
  13152. * @param min defines the color remap minimal range
  13153. * @param max defines the color remap maximal range
  13154. * @returns the current particle system
  13155. */
  13156. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13157. /**
  13158. * Remove a specific color remap gradient
  13159. * @param gradient defines the gradient to remove
  13160. * @returns the current particle system
  13161. */
  13162. removeColorRemapGradient(gradient: number): IParticleSystem;
  13163. /**
  13164. * Adds a new alpha remap gradient
  13165. * @param gradient defines the gradient to use (between 0 and 1)
  13166. * @param min defines the alpha remap minimal range
  13167. * @param max defines the alpha remap maximal range
  13168. * @returns the current particle system
  13169. */
  13170. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13171. /**
  13172. * Remove a specific alpha remap gradient
  13173. * @param gradient defines the gradient to remove
  13174. * @returns the current particle system
  13175. */
  13176. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13177. /**
  13178. * Adds a new angular speed gradient
  13179. * @param gradient defines the gradient to use (between 0 and 1)
  13180. * @param factor defines the angular speed to affect to the specified gradient
  13181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13182. * @returns the current particle system
  13183. */
  13184. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13185. /**
  13186. * Remove a specific angular speed gradient
  13187. * @param gradient defines the gradient to remove
  13188. * @returns the current particle system
  13189. */
  13190. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13191. /**
  13192. * Adds a new velocity gradient
  13193. * @param gradient defines the gradient to use (between 0 and 1)
  13194. * @param factor defines the velocity to affect to the specified gradient
  13195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13196. * @returns the current particle system
  13197. */
  13198. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13199. /**
  13200. * Remove a specific velocity gradient
  13201. * @param gradient defines the gradient to remove
  13202. * @returns the current particle system
  13203. */
  13204. removeVelocityGradient(gradient: number): IParticleSystem;
  13205. /**
  13206. * Adds a new limit velocity gradient
  13207. * @param gradient defines the gradient to use (between 0 and 1)
  13208. * @param factor defines the limit velocity value to affect to the specified gradient
  13209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13210. * @returns the current particle system
  13211. */
  13212. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13213. /**
  13214. * Remove a specific limit velocity gradient
  13215. * @param gradient defines the gradient to remove
  13216. * @returns the current particle system
  13217. */
  13218. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13219. /**
  13220. * Adds a new drag gradient
  13221. * @param gradient defines the gradient to use (between 0 and 1)
  13222. * @param factor defines the drag value to affect to the specified gradient
  13223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13224. * @returns the current particle system
  13225. */
  13226. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13227. /**
  13228. * Remove a specific drag gradient
  13229. * @param gradient defines the gradient to remove
  13230. * @returns the current particle system
  13231. */
  13232. removeDragGradient(gradient: number): IParticleSystem;
  13233. /**
  13234. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13235. * @param gradient defines the gradient to use (between 0 and 1)
  13236. * @param factor defines the emit rate value to affect to the specified gradient
  13237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13238. * @returns the current particle system
  13239. */
  13240. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13241. /**
  13242. * Remove a specific emit rate gradient
  13243. * @param gradient defines the gradient to remove
  13244. * @returns the current particle system
  13245. */
  13246. removeEmitRateGradient(gradient: number): IParticleSystem;
  13247. /**
  13248. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13249. * @param gradient defines the gradient to use (between 0 and 1)
  13250. * @param factor defines the start size value to affect to the specified gradient
  13251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13252. * @returns the current particle system
  13253. */
  13254. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13255. /**
  13256. * Remove a specific start size gradient
  13257. * @param gradient defines the gradient to remove
  13258. * @returns the current particle system
  13259. */
  13260. removeStartSizeGradient(gradient: number): IParticleSystem;
  13261. private _createRampGradientTexture;
  13262. /**
  13263. * Gets the current list of ramp gradients.
  13264. * You must use addRampGradient and removeRampGradient to udpate this list
  13265. * @returns the list of ramp gradients
  13266. */
  13267. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13268. /** Force the system to rebuild all gradients that need to be resync */
  13269. forceRefreshGradients(): void;
  13270. private _syncRampGradientTexture;
  13271. /**
  13272. * Adds a new ramp gradient used to remap particle colors
  13273. * @param gradient defines the gradient to use (between 0 and 1)
  13274. * @param color defines the color to affect to the specified gradient
  13275. * @returns the current particle system
  13276. */
  13277. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13278. /**
  13279. * Remove a specific ramp gradient
  13280. * @param gradient defines the gradient to remove
  13281. * @returns the current particle system
  13282. */
  13283. removeRampGradient(gradient: number): ParticleSystem;
  13284. /**
  13285. * Adds a new color gradient
  13286. * @param gradient defines the gradient to use (between 0 and 1)
  13287. * @param color1 defines the color to affect to the specified gradient
  13288. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13289. * @returns this particle system
  13290. */
  13291. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13292. /**
  13293. * Remove a specific color gradient
  13294. * @param gradient defines the gradient to remove
  13295. * @returns this particle system
  13296. */
  13297. removeColorGradient(gradient: number): IParticleSystem;
  13298. private _fetchR;
  13299. protected _reset(): void;
  13300. private _resetEffect;
  13301. private _createVertexBuffers;
  13302. private _createIndexBuffer;
  13303. /**
  13304. * Gets the maximum number of particles active at the same time.
  13305. * @returns The max number of active particles.
  13306. */
  13307. getCapacity(): number;
  13308. /**
  13309. * Gets whether there are still active particles in the system.
  13310. * @returns True if it is alive, otherwise false.
  13311. */
  13312. isAlive(): boolean;
  13313. /**
  13314. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13315. * @returns True if it has been started, otherwise false.
  13316. */
  13317. isStarted(): boolean;
  13318. private _prepareSubEmitterInternalArray;
  13319. /**
  13320. * Starts the particle system and begins to emit
  13321. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13322. */
  13323. start(delay?: number): void;
  13324. /**
  13325. * Stops the particle system.
  13326. * @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.
  13327. */
  13328. stop(stopSubEmitters?: boolean): void;
  13329. /**
  13330. * Remove all active particles
  13331. */
  13332. reset(): void;
  13333. /**
  13334. * @hidden (for internal use only)
  13335. */
  13336. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13337. /**
  13338. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13339. * Its lifetime will start back at 0.
  13340. */
  13341. recycleParticle: (particle: Particle) => void;
  13342. private _stopSubEmitters;
  13343. private _createParticle;
  13344. private _removeFromRoot;
  13345. private _emitFromParticle;
  13346. private _update;
  13347. /** @hidden */
  13348. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13349. /** @hidden */
  13350. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13351. /**
  13352. * Fill the defines array according to the current settings of the particle system
  13353. * @param defines Array to be updated
  13354. * @param blendMode blend mode to take into account when updating the array
  13355. */
  13356. fillDefines(defines: Array<string>, blendMode: number): void;
  13357. /**
  13358. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13359. * @param uniforms Uniforms array to fill
  13360. * @param attributes Attributes array to fill
  13361. * @param samplers Samplers array to fill
  13362. */
  13363. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13364. /** @hidden */
  13365. private _getEffect;
  13366. /**
  13367. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13368. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13369. */
  13370. animate(preWarmOnly?: boolean): void;
  13371. private _appendParticleVertices;
  13372. /**
  13373. * Rebuilds the particle system.
  13374. */
  13375. rebuild(): void;
  13376. /**
  13377. * Is this system ready to be used/rendered
  13378. * @return true if the system is ready
  13379. */
  13380. isReady(): boolean;
  13381. private _render;
  13382. /**
  13383. * Renders the particle system in its current state.
  13384. * @returns the current number of particles
  13385. */
  13386. render(): number;
  13387. /**
  13388. * Disposes the particle system and free the associated resources
  13389. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13390. */
  13391. dispose(disposeTexture?: boolean): void;
  13392. /**
  13393. * Clones the particle system.
  13394. * @param name The name of the cloned object
  13395. * @param newEmitter The new emitter to use
  13396. * @returns the cloned particle system
  13397. */
  13398. clone(name: string, newEmitter: any): ParticleSystem;
  13399. /**
  13400. * Serializes the particle system to a JSON object
  13401. * @param serializeTexture defines if the texture must be serialized as well
  13402. * @returns the JSON object
  13403. */
  13404. serialize(serializeTexture?: boolean): any;
  13405. /** @hidden */
  13406. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13407. /** @hidden */
  13408. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13409. /**
  13410. * Parses a JSON object to create a particle system.
  13411. * @param parsedParticleSystem The JSON object to parse
  13412. * @param sceneOrEngine The scene or the engine to create the particle system in
  13413. * @param rootUrl The root url to use to load external dependencies like texture
  13414. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13415. * @returns the Parsed particle system
  13416. */
  13417. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13418. }
  13419. }
  13420. declare module "babylonjs/Particles/particle" {
  13421. import { Nullable } from "babylonjs/types";
  13422. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13423. import { Color4 } from "babylonjs/Maths/math.color";
  13424. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13425. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13426. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13427. /**
  13428. * A particle represents one of the element emitted by a particle system.
  13429. * This is mainly define by its coordinates, direction, velocity and age.
  13430. */
  13431. export class Particle {
  13432. /**
  13433. * The particle system the particle belongs to.
  13434. */
  13435. particleSystem: ParticleSystem;
  13436. private static _Count;
  13437. /**
  13438. * Unique ID of the particle
  13439. */
  13440. id: number;
  13441. /**
  13442. * The world position of the particle in the scene.
  13443. */
  13444. position: Vector3;
  13445. /**
  13446. * The world direction of the particle in the scene.
  13447. */
  13448. direction: Vector3;
  13449. /**
  13450. * The color of the particle.
  13451. */
  13452. color: Color4;
  13453. /**
  13454. * The color change of the particle per step.
  13455. */
  13456. colorStep: Color4;
  13457. /**
  13458. * Defines how long will the life of the particle be.
  13459. */
  13460. lifeTime: number;
  13461. /**
  13462. * The current age of the particle.
  13463. */
  13464. age: number;
  13465. /**
  13466. * The current size of the particle.
  13467. */
  13468. size: number;
  13469. /**
  13470. * The current scale of the particle.
  13471. */
  13472. scale: Vector2;
  13473. /**
  13474. * The current angle of the particle.
  13475. */
  13476. angle: number;
  13477. /**
  13478. * Defines how fast is the angle changing.
  13479. */
  13480. angularSpeed: number;
  13481. /**
  13482. * Defines the cell index used by the particle to be rendered from a sprite.
  13483. */
  13484. cellIndex: number;
  13485. /**
  13486. * The information required to support color remapping
  13487. */
  13488. remapData: Vector4;
  13489. /** @hidden */
  13490. _randomCellOffset?: number;
  13491. /** @hidden */
  13492. _initialDirection: Nullable<Vector3>;
  13493. /** @hidden */
  13494. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13495. /** @hidden */
  13496. _initialStartSpriteCellID: number;
  13497. /** @hidden */
  13498. _initialEndSpriteCellID: number;
  13499. /** @hidden */
  13500. _currentColorGradient: Nullable<ColorGradient>;
  13501. /** @hidden */
  13502. _currentColor1: Color4;
  13503. /** @hidden */
  13504. _currentColor2: Color4;
  13505. /** @hidden */
  13506. _currentSizeGradient: Nullable<FactorGradient>;
  13507. /** @hidden */
  13508. _currentSize1: number;
  13509. /** @hidden */
  13510. _currentSize2: number;
  13511. /** @hidden */
  13512. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13513. /** @hidden */
  13514. _currentAngularSpeed1: number;
  13515. /** @hidden */
  13516. _currentAngularSpeed2: number;
  13517. /** @hidden */
  13518. _currentVelocityGradient: Nullable<FactorGradient>;
  13519. /** @hidden */
  13520. _currentVelocity1: number;
  13521. /** @hidden */
  13522. _currentVelocity2: number;
  13523. /** @hidden */
  13524. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13525. /** @hidden */
  13526. _currentLimitVelocity1: number;
  13527. /** @hidden */
  13528. _currentLimitVelocity2: number;
  13529. /** @hidden */
  13530. _currentDragGradient: Nullable<FactorGradient>;
  13531. /** @hidden */
  13532. _currentDrag1: number;
  13533. /** @hidden */
  13534. _currentDrag2: number;
  13535. /** @hidden */
  13536. _randomNoiseCoordinates1: Vector3;
  13537. /** @hidden */
  13538. _randomNoiseCoordinates2: Vector3;
  13539. /** @hidden */
  13540. _localPosition?: Vector3;
  13541. /**
  13542. * Creates a new instance Particle
  13543. * @param particleSystem the particle system the particle belongs to
  13544. */
  13545. constructor(
  13546. /**
  13547. * The particle system the particle belongs to.
  13548. */
  13549. particleSystem: ParticleSystem);
  13550. private updateCellInfoFromSystem;
  13551. /**
  13552. * Defines how the sprite cell index is updated for the particle
  13553. */
  13554. updateCellIndex(): void;
  13555. /** @hidden */
  13556. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13557. /** @hidden */
  13558. _inheritParticleInfoToSubEmitters(): void;
  13559. /** @hidden */
  13560. _reset(): void;
  13561. /**
  13562. * Copy the properties of particle to another one.
  13563. * @param other the particle to copy the information to.
  13564. */
  13565. copyTo(other: Particle): void;
  13566. }
  13567. }
  13568. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13569. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13570. import { Effect } from "babylonjs/Materials/effect";
  13571. import { Particle } from "babylonjs/Particles/particle";
  13572. import { Nullable } from "babylonjs/types";
  13573. import { Scene } from "babylonjs/scene";
  13574. /**
  13575. * Particle emitter represents a volume emitting particles.
  13576. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13577. */
  13578. export interface IParticleEmitterType {
  13579. /**
  13580. * Called by the particle System when the direction is computed for the created particle.
  13581. * @param worldMatrix is the world matrix of the particle system
  13582. * @param directionToUpdate is the direction vector to update with the result
  13583. * @param particle is the particle we are computed the direction for
  13584. * @param isLocal defines if the direction should be set in local space
  13585. */
  13586. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13587. /**
  13588. * Called by the particle System when the position is computed for the created particle.
  13589. * @param worldMatrix is the world matrix of the particle system
  13590. * @param positionToUpdate is the position vector to update with the result
  13591. * @param particle is the particle we are computed the position for
  13592. * @param isLocal defines if the position should be set in local space
  13593. */
  13594. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13595. /**
  13596. * Clones the current emitter and returns a copy of it
  13597. * @returns the new emitter
  13598. */
  13599. clone(): IParticleEmitterType;
  13600. /**
  13601. * Called by the GPUParticleSystem to setup the update shader
  13602. * @param effect defines the update shader
  13603. */
  13604. applyToShader(effect: Effect): void;
  13605. /**
  13606. * Returns a string to use to update the GPU particles update shader
  13607. * @returns the effect defines string
  13608. */
  13609. getEffectDefines(): string;
  13610. /**
  13611. * Returns a string representing the class name
  13612. * @returns a string containing the class name
  13613. */
  13614. getClassName(): string;
  13615. /**
  13616. * Serializes the particle system to a JSON object.
  13617. * @returns the JSON object
  13618. */
  13619. serialize(): any;
  13620. /**
  13621. * Parse properties from a JSON object
  13622. * @param serializationObject defines the JSON object
  13623. * @param scene defines the hosting scene
  13624. */
  13625. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13626. }
  13627. }
  13628. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13629. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13630. import { Effect } from "babylonjs/Materials/effect";
  13631. import { Particle } from "babylonjs/Particles/particle";
  13632. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13633. /**
  13634. * Particle emitter emitting particles from the inside of a box.
  13635. * It emits the particles randomly between 2 given directions.
  13636. */
  13637. export class BoxParticleEmitter implements IParticleEmitterType {
  13638. /**
  13639. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13640. */
  13641. direction1: Vector3;
  13642. /**
  13643. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13644. */
  13645. direction2: Vector3;
  13646. /**
  13647. * 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.
  13648. */
  13649. minEmitBox: Vector3;
  13650. /**
  13651. * 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.
  13652. */
  13653. maxEmitBox: Vector3;
  13654. /**
  13655. * Creates a new instance BoxParticleEmitter
  13656. */
  13657. constructor();
  13658. /**
  13659. * Called by the particle System when the direction is computed for the created particle.
  13660. * @param worldMatrix is the world matrix of the particle system
  13661. * @param directionToUpdate is the direction vector to update with the result
  13662. * @param particle is the particle we are computed the direction for
  13663. * @param isLocal defines if the direction should be set in local space
  13664. */
  13665. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13666. /**
  13667. * Called by the particle System when the position is computed for the created particle.
  13668. * @param worldMatrix is the world matrix of the particle system
  13669. * @param positionToUpdate is the position vector to update with the result
  13670. * @param particle is the particle we are computed the position for
  13671. * @param isLocal defines if the position should be set in local space
  13672. */
  13673. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13674. /**
  13675. * Clones the current emitter and returns a copy of it
  13676. * @returns the new emitter
  13677. */
  13678. clone(): BoxParticleEmitter;
  13679. /**
  13680. * Called by the GPUParticleSystem to setup the update shader
  13681. * @param effect defines the update shader
  13682. */
  13683. applyToShader(effect: Effect): void;
  13684. /**
  13685. * Returns a string to use to update the GPU particles update shader
  13686. * @returns a string containng the defines string
  13687. */
  13688. getEffectDefines(): string;
  13689. /**
  13690. * Returns the string "BoxParticleEmitter"
  13691. * @returns a string containing the class name
  13692. */
  13693. getClassName(): string;
  13694. /**
  13695. * Serializes the particle system to a JSON object.
  13696. * @returns the JSON object
  13697. */
  13698. serialize(): any;
  13699. /**
  13700. * Parse properties from a JSON object
  13701. * @param serializationObject defines the JSON object
  13702. */
  13703. parse(serializationObject: any): void;
  13704. }
  13705. }
  13706. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13707. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13708. import { Effect } from "babylonjs/Materials/effect";
  13709. import { Particle } from "babylonjs/Particles/particle";
  13710. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13711. /**
  13712. * Particle emitter emitting particles from the inside of a cone.
  13713. * It emits the particles alongside the cone volume from the base to the particle.
  13714. * The emission direction might be randomized.
  13715. */
  13716. export class ConeParticleEmitter implements IParticleEmitterType {
  13717. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13718. directionRandomizer: number;
  13719. private _radius;
  13720. private _angle;
  13721. private _height;
  13722. /**
  13723. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13724. */
  13725. radiusRange: number;
  13726. /**
  13727. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13728. */
  13729. heightRange: number;
  13730. /**
  13731. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13732. */
  13733. emitFromSpawnPointOnly: boolean;
  13734. /**
  13735. * Gets or sets the radius of the emission cone
  13736. */
  13737. get radius(): number;
  13738. set radius(value: number);
  13739. /**
  13740. * Gets or sets the angle of the emission cone
  13741. */
  13742. get angle(): number;
  13743. set angle(value: number);
  13744. private _buildHeight;
  13745. /**
  13746. * Creates a new instance ConeParticleEmitter
  13747. * @param radius the radius of the emission cone (1 by default)
  13748. * @param angle the cone base angle (PI by default)
  13749. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13750. */
  13751. constructor(radius?: number, angle?: number,
  13752. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13753. directionRandomizer?: number);
  13754. /**
  13755. * Called by the particle System when the direction is computed for the created particle.
  13756. * @param worldMatrix is the world matrix of the particle system
  13757. * @param directionToUpdate is the direction vector to update with the result
  13758. * @param particle is the particle we are computed the direction for
  13759. * @param isLocal defines if the direction should be set in local space
  13760. */
  13761. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13762. /**
  13763. * Called by the particle System when the position is computed for the created particle.
  13764. * @param worldMatrix is the world matrix of the particle system
  13765. * @param positionToUpdate is the position vector to update with the result
  13766. * @param particle is the particle we are computed the position for
  13767. * @param isLocal defines if the position should be set in local space
  13768. */
  13769. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13770. /**
  13771. * Clones the current emitter and returns a copy of it
  13772. * @returns the new emitter
  13773. */
  13774. clone(): ConeParticleEmitter;
  13775. /**
  13776. * Called by the GPUParticleSystem to setup the update shader
  13777. * @param effect defines the update shader
  13778. */
  13779. applyToShader(effect: Effect): void;
  13780. /**
  13781. * Returns a string to use to update the GPU particles update shader
  13782. * @returns a string containng the defines string
  13783. */
  13784. getEffectDefines(): string;
  13785. /**
  13786. * Returns the string "ConeParticleEmitter"
  13787. * @returns a string containing the class name
  13788. */
  13789. getClassName(): string;
  13790. /**
  13791. * Serializes the particle system to a JSON object.
  13792. * @returns the JSON object
  13793. */
  13794. serialize(): any;
  13795. /**
  13796. * Parse properties from a JSON object
  13797. * @param serializationObject defines the JSON object
  13798. */
  13799. parse(serializationObject: any): void;
  13800. }
  13801. }
  13802. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13803. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13804. import { Effect } from "babylonjs/Materials/effect";
  13805. import { Particle } from "babylonjs/Particles/particle";
  13806. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13807. /**
  13808. * Particle emitter emitting particles from the inside of a cylinder.
  13809. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13810. */
  13811. export class CylinderParticleEmitter implements IParticleEmitterType {
  13812. /**
  13813. * The radius of the emission cylinder.
  13814. */
  13815. radius: number;
  13816. /**
  13817. * The height of the emission cylinder.
  13818. */
  13819. height: number;
  13820. /**
  13821. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13822. */
  13823. radiusRange: number;
  13824. /**
  13825. * How much to randomize the particle direction [0-1].
  13826. */
  13827. directionRandomizer: number;
  13828. /**
  13829. * Creates a new instance CylinderParticleEmitter
  13830. * @param radius the radius of the emission cylinder (1 by default)
  13831. * @param height the height of the emission cylinder (1 by default)
  13832. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13833. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13834. */
  13835. constructor(
  13836. /**
  13837. * The radius of the emission cylinder.
  13838. */
  13839. radius?: number,
  13840. /**
  13841. * The height of the emission cylinder.
  13842. */
  13843. height?: number,
  13844. /**
  13845. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13846. */
  13847. radiusRange?: number,
  13848. /**
  13849. * How much to randomize the particle direction [0-1].
  13850. */
  13851. directionRandomizer?: number);
  13852. /**
  13853. * Called by the particle System when the direction is computed for the created particle.
  13854. * @param worldMatrix is the world matrix of the particle system
  13855. * @param directionToUpdate is the direction vector to update with the result
  13856. * @param particle is the particle we are computed the direction for
  13857. * @param isLocal defines if the direction should be set in local space
  13858. */
  13859. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13860. /**
  13861. * Called by the particle System when the position is computed for the created particle.
  13862. * @param worldMatrix is the world matrix of the particle system
  13863. * @param positionToUpdate is the position vector to update with the result
  13864. * @param particle is the particle we are computed the position for
  13865. * @param isLocal defines if the position should be set in local space
  13866. */
  13867. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13868. /**
  13869. * Clones the current emitter and returns a copy of it
  13870. * @returns the new emitter
  13871. */
  13872. clone(): CylinderParticleEmitter;
  13873. /**
  13874. * Called by the GPUParticleSystem to setup the update shader
  13875. * @param effect defines the update shader
  13876. */
  13877. applyToShader(effect: Effect): void;
  13878. /**
  13879. * Returns a string to use to update the GPU particles update shader
  13880. * @returns a string containng the defines string
  13881. */
  13882. getEffectDefines(): string;
  13883. /**
  13884. * Returns the string "CylinderParticleEmitter"
  13885. * @returns a string containing the class name
  13886. */
  13887. getClassName(): string;
  13888. /**
  13889. * Serializes the particle system to a JSON object.
  13890. * @returns the JSON object
  13891. */
  13892. serialize(): any;
  13893. /**
  13894. * Parse properties from a JSON object
  13895. * @param serializationObject defines the JSON object
  13896. */
  13897. parse(serializationObject: any): void;
  13898. }
  13899. /**
  13900. * Particle emitter emitting particles from the inside of a cylinder.
  13901. * It emits the particles randomly between two vectors.
  13902. */
  13903. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13904. /**
  13905. * The min limit of the emission direction.
  13906. */
  13907. direction1: Vector3;
  13908. /**
  13909. * The max limit of the emission direction.
  13910. */
  13911. direction2: Vector3;
  13912. /**
  13913. * Creates a new instance CylinderDirectedParticleEmitter
  13914. * @param radius the radius of the emission cylinder (1 by default)
  13915. * @param height the height of the emission cylinder (1 by default)
  13916. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13917. * @param direction1 the min limit of the emission direction (up vector by default)
  13918. * @param direction2 the max limit of the emission direction (up vector by default)
  13919. */
  13920. constructor(radius?: number, height?: number, radiusRange?: number,
  13921. /**
  13922. * The min limit of the emission direction.
  13923. */
  13924. direction1?: Vector3,
  13925. /**
  13926. * The max limit of the emission direction.
  13927. */
  13928. direction2?: Vector3);
  13929. /**
  13930. * Called by the particle System when the direction is computed for the created particle.
  13931. * @param worldMatrix is the world matrix of the particle system
  13932. * @param directionToUpdate is the direction vector to update with the result
  13933. * @param particle is the particle we are computed the direction for
  13934. */
  13935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13936. /**
  13937. * Clones the current emitter and returns a copy of it
  13938. * @returns the new emitter
  13939. */
  13940. clone(): CylinderDirectedParticleEmitter;
  13941. /**
  13942. * Called by the GPUParticleSystem to setup the update shader
  13943. * @param effect defines the update shader
  13944. */
  13945. applyToShader(effect: Effect): void;
  13946. /**
  13947. * Returns a string to use to update the GPU particles update shader
  13948. * @returns a string containng the defines string
  13949. */
  13950. getEffectDefines(): string;
  13951. /**
  13952. * Returns the string "CylinderDirectedParticleEmitter"
  13953. * @returns a string containing the class name
  13954. */
  13955. getClassName(): string;
  13956. /**
  13957. * Serializes the particle system to a JSON object.
  13958. * @returns the JSON object
  13959. */
  13960. serialize(): any;
  13961. /**
  13962. * Parse properties from a JSON object
  13963. * @param serializationObject defines the JSON object
  13964. */
  13965. parse(serializationObject: any): void;
  13966. }
  13967. }
  13968. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13969. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13970. import { Effect } from "babylonjs/Materials/effect";
  13971. import { Particle } from "babylonjs/Particles/particle";
  13972. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13973. /**
  13974. * Particle emitter emitting particles from the inside of a hemisphere.
  13975. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13976. */
  13977. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13978. /**
  13979. * The radius of the emission hemisphere.
  13980. */
  13981. radius: number;
  13982. /**
  13983. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13984. */
  13985. radiusRange: number;
  13986. /**
  13987. * How much to randomize the particle direction [0-1].
  13988. */
  13989. directionRandomizer: number;
  13990. /**
  13991. * Creates a new instance HemisphericParticleEmitter
  13992. * @param radius the radius of the emission hemisphere (1 by default)
  13993. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13994. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13995. */
  13996. constructor(
  13997. /**
  13998. * The radius of the emission hemisphere.
  13999. */
  14000. radius?: number,
  14001. /**
  14002. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14003. */
  14004. radiusRange?: number,
  14005. /**
  14006. * How much to randomize the particle direction [0-1].
  14007. */
  14008. directionRandomizer?: number);
  14009. /**
  14010. * Called by the particle System when the direction is computed for the created particle.
  14011. * @param worldMatrix is the world matrix of the particle system
  14012. * @param directionToUpdate is the direction vector to update with the result
  14013. * @param particle is the particle we are computed the direction for
  14014. * @param isLocal defines if the direction should be set in local space
  14015. */
  14016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14017. /**
  14018. * Called by the particle System when the position is computed for the created particle.
  14019. * @param worldMatrix is the world matrix of the particle system
  14020. * @param positionToUpdate is the position vector to update with the result
  14021. * @param particle is the particle we are computed the position for
  14022. * @param isLocal defines if the position should be set in local space
  14023. */
  14024. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14025. /**
  14026. * Clones the current emitter and returns a copy of it
  14027. * @returns the new emitter
  14028. */
  14029. clone(): HemisphericParticleEmitter;
  14030. /**
  14031. * Called by the GPUParticleSystem to setup the update shader
  14032. * @param effect defines the update shader
  14033. */
  14034. applyToShader(effect: Effect): void;
  14035. /**
  14036. * Returns a string to use to update the GPU particles update shader
  14037. * @returns a string containng the defines string
  14038. */
  14039. getEffectDefines(): string;
  14040. /**
  14041. * Returns the string "HemisphericParticleEmitter"
  14042. * @returns a string containing the class name
  14043. */
  14044. getClassName(): string;
  14045. /**
  14046. * Serializes the particle system to a JSON object.
  14047. * @returns the JSON object
  14048. */
  14049. serialize(): any;
  14050. /**
  14051. * Parse properties from a JSON object
  14052. * @param serializationObject defines the JSON object
  14053. */
  14054. parse(serializationObject: any): void;
  14055. }
  14056. }
  14057. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14058. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14059. import { Effect } from "babylonjs/Materials/effect";
  14060. import { Particle } from "babylonjs/Particles/particle";
  14061. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14062. /**
  14063. * Particle emitter emitting particles from a point.
  14064. * It emits the particles randomly between 2 given directions.
  14065. */
  14066. export class PointParticleEmitter implements IParticleEmitterType {
  14067. /**
  14068. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14069. */
  14070. direction1: Vector3;
  14071. /**
  14072. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14073. */
  14074. direction2: Vector3;
  14075. /**
  14076. * Creates a new instance PointParticleEmitter
  14077. */
  14078. constructor();
  14079. /**
  14080. * Called by the particle System when the direction is computed for the created particle.
  14081. * @param worldMatrix is the world matrix of the particle system
  14082. * @param directionToUpdate is the direction vector to update with the result
  14083. * @param particle is the particle we are computed the direction for
  14084. * @param isLocal defines if the direction should be set in local space
  14085. */
  14086. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14087. /**
  14088. * Called by the particle System when the position is computed for the created particle.
  14089. * @param worldMatrix is the world matrix of the particle system
  14090. * @param positionToUpdate is the position vector to update with the result
  14091. * @param particle is the particle we are computed the position for
  14092. * @param isLocal defines if the position should be set in local space
  14093. */
  14094. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14095. /**
  14096. * Clones the current emitter and returns a copy of it
  14097. * @returns the new emitter
  14098. */
  14099. clone(): PointParticleEmitter;
  14100. /**
  14101. * Called by the GPUParticleSystem to setup the update shader
  14102. * @param effect defines the update shader
  14103. */
  14104. applyToShader(effect: Effect): void;
  14105. /**
  14106. * Returns a string to use to update the GPU particles update shader
  14107. * @returns a string containng the defines string
  14108. */
  14109. getEffectDefines(): string;
  14110. /**
  14111. * Returns the string "PointParticleEmitter"
  14112. * @returns a string containing the class name
  14113. */
  14114. getClassName(): string;
  14115. /**
  14116. * Serializes the particle system to a JSON object.
  14117. * @returns the JSON object
  14118. */
  14119. serialize(): any;
  14120. /**
  14121. * Parse properties from a JSON object
  14122. * @param serializationObject defines the JSON object
  14123. */
  14124. parse(serializationObject: any): void;
  14125. }
  14126. }
  14127. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14128. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14129. import { Effect } from "babylonjs/Materials/effect";
  14130. import { Particle } from "babylonjs/Particles/particle";
  14131. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14132. /**
  14133. * Particle emitter emitting particles from the inside of a sphere.
  14134. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14135. */
  14136. export class SphereParticleEmitter implements IParticleEmitterType {
  14137. /**
  14138. * The radius of the emission sphere.
  14139. */
  14140. radius: number;
  14141. /**
  14142. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14143. */
  14144. radiusRange: number;
  14145. /**
  14146. * How much to randomize the particle direction [0-1].
  14147. */
  14148. directionRandomizer: number;
  14149. /**
  14150. * Creates a new instance SphereParticleEmitter
  14151. * @param radius the radius of the emission sphere (1 by default)
  14152. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14153. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14154. */
  14155. constructor(
  14156. /**
  14157. * The radius of the emission sphere.
  14158. */
  14159. radius?: number,
  14160. /**
  14161. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14162. */
  14163. radiusRange?: number,
  14164. /**
  14165. * How much to randomize the particle direction [0-1].
  14166. */
  14167. directionRandomizer?: number);
  14168. /**
  14169. * Called by the particle System when the direction is computed for the created particle.
  14170. * @param worldMatrix is the world matrix of the particle system
  14171. * @param directionToUpdate is the direction vector to update with the result
  14172. * @param particle is the particle we are computed the direction for
  14173. * @param isLocal defines if the direction should be set in local space
  14174. */
  14175. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14176. /**
  14177. * Called by the particle System when the position is computed for the created particle.
  14178. * @param worldMatrix is the world matrix of the particle system
  14179. * @param positionToUpdate is the position vector to update with the result
  14180. * @param particle is the particle we are computed the position for
  14181. * @param isLocal defines if the position should be set in local space
  14182. */
  14183. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14184. /**
  14185. * Clones the current emitter and returns a copy of it
  14186. * @returns the new emitter
  14187. */
  14188. clone(): SphereParticleEmitter;
  14189. /**
  14190. * Called by the GPUParticleSystem to setup the update shader
  14191. * @param effect defines the update shader
  14192. */
  14193. applyToShader(effect: Effect): void;
  14194. /**
  14195. * Returns a string to use to update the GPU particles update shader
  14196. * @returns a string containng the defines string
  14197. */
  14198. getEffectDefines(): string;
  14199. /**
  14200. * Returns the string "SphereParticleEmitter"
  14201. * @returns a string containing the class name
  14202. */
  14203. getClassName(): string;
  14204. /**
  14205. * Serializes the particle system to a JSON object.
  14206. * @returns the JSON object
  14207. */
  14208. serialize(): any;
  14209. /**
  14210. * Parse properties from a JSON object
  14211. * @param serializationObject defines the JSON object
  14212. */
  14213. parse(serializationObject: any): void;
  14214. }
  14215. /**
  14216. * Particle emitter emitting particles from the inside of a sphere.
  14217. * It emits the particles randomly between two vectors.
  14218. */
  14219. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14220. /**
  14221. * The min limit of the emission direction.
  14222. */
  14223. direction1: Vector3;
  14224. /**
  14225. * The max limit of the emission direction.
  14226. */
  14227. direction2: Vector3;
  14228. /**
  14229. * Creates a new instance SphereDirectedParticleEmitter
  14230. * @param radius the radius of the emission sphere (1 by default)
  14231. * @param direction1 the min limit of the emission direction (up vector by default)
  14232. * @param direction2 the max limit of the emission direction (up vector by default)
  14233. */
  14234. constructor(radius?: number,
  14235. /**
  14236. * The min limit of the emission direction.
  14237. */
  14238. direction1?: Vector3,
  14239. /**
  14240. * The max limit of the emission direction.
  14241. */
  14242. direction2?: Vector3);
  14243. /**
  14244. * Called by the particle System when the direction is computed for the created particle.
  14245. * @param worldMatrix is the world matrix of the particle system
  14246. * @param directionToUpdate is the direction vector to update with the result
  14247. * @param particle is the particle we are computed the direction for
  14248. */
  14249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14250. /**
  14251. * Clones the current emitter and returns a copy of it
  14252. * @returns the new emitter
  14253. */
  14254. clone(): SphereDirectedParticleEmitter;
  14255. /**
  14256. * Called by the GPUParticleSystem to setup the update shader
  14257. * @param effect defines the update shader
  14258. */
  14259. applyToShader(effect: Effect): void;
  14260. /**
  14261. * Returns a string to use to update the GPU particles update shader
  14262. * @returns a string containng the defines string
  14263. */
  14264. getEffectDefines(): string;
  14265. /**
  14266. * Returns the string "SphereDirectedParticleEmitter"
  14267. * @returns a string containing the class name
  14268. */
  14269. getClassName(): string;
  14270. /**
  14271. * Serializes the particle system to a JSON object.
  14272. * @returns the JSON object
  14273. */
  14274. serialize(): any;
  14275. /**
  14276. * Parse properties from a JSON object
  14277. * @param serializationObject defines the JSON object
  14278. */
  14279. parse(serializationObject: any): void;
  14280. }
  14281. }
  14282. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14283. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14284. import { Effect } from "babylonjs/Materials/effect";
  14285. import { Particle } from "babylonjs/Particles/particle";
  14286. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14287. import { Nullable } from "babylonjs/types";
  14288. /**
  14289. * Particle emitter emitting particles from a custom list of positions.
  14290. */
  14291. export class CustomParticleEmitter implements IParticleEmitterType {
  14292. /**
  14293. * Gets or sets the position generator that will create the inital position of each particle.
  14294. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14295. */
  14296. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14297. /**
  14298. * Gets or sets the destination generator that will create the final destination of each particle.
  14299. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14300. */
  14301. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14302. /**
  14303. * Creates a new instance CustomParticleEmitter
  14304. */
  14305. constructor();
  14306. /**
  14307. * Called by the particle System when the direction is computed for the created particle.
  14308. * @param worldMatrix is the world matrix of the particle system
  14309. * @param directionToUpdate is the direction vector to update with the result
  14310. * @param particle is the particle we are computed the direction for
  14311. * @param isLocal defines if the direction should be set in local space
  14312. */
  14313. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14314. /**
  14315. * Called by the particle System when the position is computed for the created particle.
  14316. * @param worldMatrix is the world matrix of the particle system
  14317. * @param positionToUpdate is the position vector to update with the result
  14318. * @param particle is the particle we are computed the position for
  14319. * @param isLocal defines if the position should be set in local space
  14320. */
  14321. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14322. /**
  14323. * Clones the current emitter and returns a copy of it
  14324. * @returns the new emitter
  14325. */
  14326. clone(): CustomParticleEmitter;
  14327. /**
  14328. * Called by the GPUParticleSystem to setup the update shader
  14329. * @param effect defines the update shader
  14330. */
  14331. applyToShader(effect: Effect): void;
  14332. /**
  14333. * Returns a string to use to update the GPU particles update shader
  14334. * @returns a string containng the defines string
  14335. */
  14336. getEffectDefines(): string;
  14337. /**
  14338. * Returns the string "PointParticleEmitter"
  14339. * @returns a string containing the class name
  14340. */
  14341. getClassName(): string;
  14342. /**
  14343. * Serializes the particle system to a JSON object.
  14344. * @returns the JSON object
  14345. */
  14346. serialize(): any;
  14347. /**
  14348. * Parse properties from a JSON object
  14349. * @param serializationObject defines the JSON object
  14350. */
  14351. parse(serializationObject: any): void;
  14352. }
  14353. }
  14354. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14355. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14356. import { Effect } from "babylonjs/Materials/effect";
  14357. import { Particle } from "babylonjs/Particles/particle";
  14358. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14359. import { Nullable } from "babylonjs/types";
  14360. import { Scene } from "babylonjs/scene";
  14361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14362. /**
  14363. * Particle emitter emitting particles from the inside of a box.
  14364. * It emits the particles randomly between 2 given directions.
  14365. */
  14366. export class MeshParticleEmitter implements IParticleEmitterType {
  14367. private _indices;
  14368. private _positions;
  14369. private _normals;
  14370. private _storedNormal;
  14371. private _mesh;
  14372. /**
  14373. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14374. */
  14375. direction1: Vector3;
  14376. /**
  14377. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14378. */
  14379. direction2: Vector3;
  14380. /**
  14381. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14382. */
  14383. useMeshNormalsForDirection: boolean;
  14384. /** Defines the mesh to use as source */
  14385. get mesh(): Nullable<AbstractMesh>;
  14386. set mesh(value: Nullable<AbstractMesh>);
  14387. /**
  14388. * Creates a new instance MeshParticleEmitter
  14389. * @param mesh defines the mesh to use as source
  14390. */
  14391. constructor(mesh?: Nullable<AbstractMesh>);
  14392. /**
  14393. * Called by the particle System when the direction is computed for the created particle.
  14394. * @param worldMatrix is the world matrix of the particle system
  14395. * @param directionToUpdate is the direction vector to update with the result
  14396. * @param particle is the particle we are computed the direction for
  14397. * @param isLocal defines if the direction should be set in local space
  14398. */
  14399. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14400. /**
  14401. * Called by the particle System when the position is computed for the created particle.
  14402. * @param worldMatrix is the world matrix of the particle system
  14403. * @param positionToUpdate is the position vector to update with the result
  14404. * @param particle is the particle we are computed the position for
  14405. * @param isLocal defines if the position should be set in local space
  14406. */
  14407. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14408. /**
  14409. * Clones the current emitter and returns a copy of it
  14410. * @returns the new emitter
  14411. */
  14412. clone(): MeshParticleEmitter;
  14413. /**
  14414. * Called by the GPUParticleSystem to setup the update shader
  14415. * @param effect defines the update shader
  14416. */
  14417. applyToShader(effect: Effect): void;
  14418. /**
  14419. * Returns a string to use to update the GPU particles update shader
  14420. * @returns a string containng the defines string
  14421. */
  14422. getEffectDefines(): string;
  14423. /**
  14424. * Returns the string "BoxParticleEmitter"
  14425. * @returns a string containing the class name
  14426. */
  14427. getClassName(): string;
  14428. /**
  14429. * Serializes the particle system to a JSON object.
  14430. * @returns the JSON object
  14431. */
  14432. serialize(): any;
  14433. /**
  14434. * Parse properties from a JSON object
  14435. * @param serializationObject defines the JSON object
  14436. * @param scene defines the hosting scene
  14437. */
  14438. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14439. }
  14440. }
  14441. declare module "babylonjs/Particles/EmitterTypes/index" {
  14442. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14443. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14444. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14445. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14446. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14447. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14448. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14449. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14450. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14451. }
  14452. declare module "babylonjs/Particles/IParticleSystem" {
  14453. import { Nullable } from "babylonjs/types";
  14454. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14455. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14456. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14457. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14458. import { Scene } from "babylonjs/scene";
  14459. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14460. import { Effect } from "babylonjs/Materials/effect";
  14461. import { Observable } from "babylonjs/Misc/observable";
  14462. import { Animation } from "babylonjs/Animations/animation";
  14463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14464. /**
  14465. * Interface representing a particle system in Babylon.js.
  14466. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14467. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14468. */
  14469. export interface IParticleSystem {
  14470. /**
  14471. * List of animations used by the particle system.
  14472. */
  14473. animations: Animation[];
  14474. /**
  14475. * The id of the Particle system.
  14476. */
  14477. id: string;
  14478. /**
  14479. * The name of the Particle system.
  14480. */
  14481. name: string;
  14482. /**
  14483. * The emitter represents the Mesh or position we are attaching the particle system to.
  14484. */
  14485. emitter: Nullable<AbstractMesh | Vector3>;
  14486. /**
  14487. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14488. */
  14489. isBillboardBased: boolean;
  14490. /**
  14491. * The rendering group used by the Particle system to chose when to render.
  14492. */
  14493. renderingGroupId: number;
  14494. /**
  14495. * The layer mask we are rendering the particles through.
  14496. */
  14497. layerMask: number;
  14498. /**
  14499. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14500. */
  14501. updateSpeed: number;
  14502. /**
  14503. * The amount of time the particle system is running (depends of the overall update speed).
  14504. */
  14505. targetStopDuration: number;
  14506. /**
  14507. * The texture used to render each particle. (this can be a spritesheet)
  14508. */
  14509. particleTexture: Nullable<BaseTexture>;
  14510. /**
  14511. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14512. */
  14513. blendMode: number;
  14514. /**
  14515. * Minimum life time of emitting particles.
  14516. */
  14517. minLifeTime: number;
  14518. /**
  14519. * Maximum life time of emitting particles.
  14520. */
  14521. maxLifeTime: number;
  14522. /**
  14523. * Minimum Size of emitting particles.
  14524. */
  14525. minSize: number;
  14526. /**
  14527. * Maximum Size of emitting particles.
  14528. */
  14529. maxSize: number;
  14530. /**
  14531. * Minimum scale of emitting particles on X axis.
  14532. */
  14533. minScaleX: number;
  14534. /**
  14535. * Maximum scale of emitting particles on X axis.
  14536. */
  14537. maxScaleX: number;
  14538. /**
  14539. * Minimum scale of emitting particles on Y axis.
  14540. */
  14541. minScaleY: number;
  14542. /**
  14543. * Maximum scale of emitting particles on Y axis.
  14544. */
  14545. maxScaleY: number;
  14546. /**
  14547. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14548. */
  14549. color1: Color4;
  14550. /**
  14551. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14552. */
  14553. color2: Color4;
  14554. /**
  14555. * Color the particle will have at the end of its lifetime.
  14556. */
  14557. colorDead: Color4;
  14558. /**
  14559. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14560. */
  14561. emitRate: number;
  14562. /**
  14563. * You can use gravity if you want to give an orientation to your particles.
  14564. */
  14565. gravity: Vector3;
  14566. /**
  14567. * Minimum power of emitting particles.
  14568. */
  14569. minEmitPower: number;
  14570. /**
  14571. * Maximum power of emitting particles.
  14572. */
  14573. maxEmitPower: number;
  14574. /**
  14575. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14576. */
  14577. minAngularSpeed: number;
  14578. /**
  14579. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14580. */
  14581. maxAngularSpeed: number;
  14582. /**
  14583. * Gets or sets the minimal initial rotation in radians.
  14584. */
  14585. minInitialRotation: number;
  14586. /**
  14587. * Gets or sets the maximal initial rotation in radians.
  14588. */
  14589. maxInitialRotation: number;
  14590. /**
  14591. * The particle emitter type defines the emitter used by the particle system.
  14592. * It can be for example box, sphere, or cone...
  14593. */
  14594. particleEmitterType: Nullable<IParticleEmitterType>;
  14595. /**
  14596. * Defines the delay in milliseconds before starting the system (0 by default)
  14597. */
  14598. startDelay: number;
  14599. /**
  14600. * 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
  14601. */
  14602. preWarmCycles: number;
  14603. /**
  14604. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14605. */
  14606. preWarmStepOffset: number;
  14607. /**
  14608. * 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)
  14609. */
  14610. spriteCellChangeSpeed: number;
  14611. /**
  14612. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14613. */
  14614. startSpriteCellID: number;
  14615. /**
  14616. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14617. */
  14618. endSpriteCellID: number;
  14619. /**
  14620. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14621. */
  14622. spriteCellWidth: number;
  14623. /**
  14624. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14625. */
  14626. spriteCellHeight: number;
  14627. /**
  14628. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14629. */
  14630. spriteRandomStartCell: boolean;
  14631. /**
  14632. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14633. */
  14634. isAnimationSheetEnabled: boolean;
  14635. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14636. translationPivot: Vector2;
  14637. /**
  14638. * Gets or sets a texture used to add random noise to particle positions
  14639. */
  14640. noiseTexture: Nullable<BaseTexture>;
  14641. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14642. noiseStrength: Vector3;
  14643. /**
  14644. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14645. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14646. */
  14647. billboardMode: number;
  14648. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14649. limitVelocityDamping: number;
  14650. /**
  14651. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14652. */
  14653. beginAnimationOnStart: boolean;
  14654. /**
  14655. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14656. */
  14657. beginAnimationFrom: number;
  14658. /**
  14659. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14660. */
  14661. beginAnimationTo: number;
  14662. /**
  14663. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14664. */
  14665. beginAnimationLoop: boolean;
  14666. /**
  14667. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14668. */
  14669. disposeOnStop: boolean;
  14670. /**
  14671. * Specifies if the particles are updated in emitter local space or world space
  14672. */
  14673. isLocal: boolean;
  14674. /** Snippet ID if the particle system was created from the snippet server */
  14675. snippetId: string;
  14676. /** Gets or sets a matrix to use to compute projection */
  14677. defaultProjectionMatrix: Matrix;
  14678. /**
  14679. * Gets the maximum number of particles active at the same time.
  14680. * @returns The max number of active particles.
  14681. */
  14682. getCapacity(): number;
  14683. /**
  14684. * Gets the number of particles active at the same time.
  14685. * @returns The number of active particles.
  14686. */
  14687. getActiveCount(): number;
  14688. /**
  14689. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14690. * @returns True if it has been started, otherwise false.
  14691. */
  14692. isStarted(): boolean;
  14693. /**
  14694. * Animates the particle system for this frame.
  14695. */
  14696. animate(): void;
  14697. /**
  14698. * Renders the particle system in its current state.
  14699. * @returns the current number of particles
  14700. */
  14701. render(): number;
  14702. /**
  14703. * Dispose the particle system and frees its associated resources.
  14704. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14705. */
  14706. dispose(disposeTexture?: boolean): void;
  14707. /**
  14708. * An event triggered when the system is disposed
  14709. */
  14710. onDisposeObservable: Observable<IParticleSystem>;
  14711. /**
  14712. * An event triggered when the system is stopped
  14713. */
  14714. onStoppedObservable: Observable<IParticleSystem>;
  14715. /**
  14716. * Clones the particle system.
  14717. * @param name The name of the cloned object
  14718. * @param newEmitter The new emitter to use
  14719. * @returns the cloned particle system
  14720. */
  14721. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14722. /**
  14723. * Serializes the particle system to a JSON object
  14724. * @param serializeTexture defines if the texture must be serialized as well
  14725. * @returns the JSON object
  14726. */
  14727. serialize(serializeTexture: boolean): any;
  14728. /**
  14729. * Rebuild the particle system
  14730. */
  14731. rebuild(): void;
  14732. /** Force the system to rebuild all gradients that need to be resync */
  14733. forceRefreshGradients(): void;
  14734. /**
  14735. * Starts the particle system and begins to emit
  14736. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14737. */
  14738. start(delay?: number): void;
  14739. /**
  14740. * Stops the particle system.
  14741. */
  14742. stop(): void;
  14743. /**
  14744. * Remove all active particles
  14745. */
  14746. reset(): void;
  14747. /**
  14748. * Gets a boolean indicating that the system is stopping
  14749. * @returns true if the system is currently stopping
  14750. */
  14751. isStopping(): boolean;
  14752. /**
  14753. * Is this system ready to be used/rendered
  14754. * @return true if the system is ready
  14755. */
  14756. isReady(): boolean;
  14757. /**
  14758. * Returns the string "ParticleSystem"
  14759. * @returns a string containing the class name
  14760. */
  14761. getClassName(): string;
  14762. /**
  14763. * Gets the custom effect used to render the particles
  14764. * @param blendMode Blend mode for which the effect should be retrieved
  14765. * @returns The effect
  14766. */
  14767. getCustomEffect(blendMode: number): Nullable<Effect>;
  14768. /**
  14769. * Sets the custom effect used to render the particles
  14770. * @param effect The effect to set
  14771. * @param blendMode Blend mode for which the effect should be set
  14772. */
  14773. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14774. /**
  14775. * Fill the defines array according to the current settings of the particle system
  14776. * @param defines Array to be updated
  14777. * @param blendMode blend mode to take into account when updating the array
  14778. */
  14779. fillDefines(defines: Array<string>, blendMode: number): void;
  14780. /**
  14781. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14782. * @param uniforms Uniforms array to fill
  14783. * @param attributes Attributes array to fill
  14784. * @param samplers Samplers array to fill
  14785. */
  14786. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14787. /**
  14788. * Observable that will be called just before the particles are drawn
  14789. */
  14790. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14791. /**
  14792. * Gets the name of the particle vertex shader
  14793. */
  14794. vertexShaderName: string;
  14795. /**
  14796. * Adds a new color gradient
  14797. * @param gradient defines the gradient to use (between 0 and 1)
  14798. * @param color1 defines the color to affect to the specified gradient
  14799. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14800. * @returns the current particle system
  14801. */
  14802. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14803. /**
  14804. * Remove a specific color gradient
  14805. * @param gradient defines the gradient to remove
  14806. * @returns the current particle system
  14807. */
  14808. removeColorGradient(gradient: number): IParticleSystem;
  14809. /**
  14810. * Adds a new size gradient
  14811. * @param gradient defines the gradient to use (between 0 and 1)
  14812. * @param factor defines the size factor to affect to the specified gradient
  14813. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14814. * @returns the current particle system
  14815. */
  14816. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14817. /**
  14818. * Remove a specific size gradient
  14819. * @param gradient defines the gradient to remove
  14820. * @returns the current particle system
  14821. */
  14822. removeSizeGradient(gradient: number): IParticleSystem;
  14823. /**
  14824. * Gets the current list of color gradients.
  14825. * You must use addColorGradient and removeColorGradient to udpate this list
  14826. * @returns the list of color gradients
  14827. */
  14828. getColorGradients(): Nullable<Array<ColorGradient>>;
  14829. /**
  14830. * Gets the current list of size gradients.
  14831. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14832. * @returns the list of size gradients
  14833. */
  14834. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14835. /**
  14836. * Gets the current list of angular speed gradients.
  14837. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14838. * @returns the list of angular speed gradients
  14839. */
  14840. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14841. /**
  14842. * Adds a new angular speed gradient
  14843. * @param gradient defines the gradient to use (between 0 and 1)
  14844. * @param factor defines the angular speed to affect to the specified gradient
  14845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14846. * @returns the current particle system
  14847. */
  14848. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14849. /**
  14850. * Remove a specific angular speed gradient
  14851. * @param gradient defines the gradient to remove
  14852. * @returns the current particle system
  14853. */
  14854. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14855. /**
  14856. * Gets the current list of velocity gradients.
  14857. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14858. * @returns the list of velocity gradients
  14859. */
  14860. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14861. /**
  14862. * Adds a new velocity gradient
  14863. * @param gradient defines the gradient to use (between 0 and 1)
  14864. * @param factor defines the velocity to affect to the specified gradient
  14865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14866. * @returns the current particle system
  14867. */
  14868. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14869. /**
  14870. * Remove a specific velocity gradient
  14871. * @param gradient defines the gradient to remove
  14872. * @returns the current particle system
  14873. */
  14874. removeVelocityGradient(gradient: number): IParticleSystem;
  14875. /**
  14876. * Gets the current list of limit velocity gradients.
  14877. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14878. * @returns the list of limit velocity gradients
  14879. */
  14880. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14881. /**
  14882. * Adds a new limit velocity gradient
  14883. * @param gradient defines the gradient to use (between 0 and 1)
  14884. * @param factor defines the limit velocity to affect to the specified gradient
  14885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14886. * @returns the current particle system
  14887. */
  14888. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14889. /**
  14890. * Remove a specific limit velocity gradient
  14891. * @param gradient defines the gradient to remove
  14892. * @returns the current particle system
  14893. */
  14894. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14895. /**
  14896. * Adds a new drag gradient
  14897. * @param gradient defines the gradient to use (between 0 and 1)
  14898. * @param factor defines the drag to affect to the specified gradient
  14899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14900. * @returns the current particle system
  14901. */
  14902. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14903. /**
  14904. * Remove a specific drag gradient
  14905. * @param gradient defines the gradient to remove
  14906. * @returns the current particle system
  14907. */
  14908. removeDragGradient(gradient: number): IParticleSystem;
  14909. /**
  14910. * Gets the current list of drag gradients.
  14911. * You must use addDragGradient and removeDragGradient to udpate this list
  14912. * @returns the list of drag gradients
  14913. */
  14914. getDragGradients(): Nullable<Array<FactorGradient>>;
  14915. /**
  14916. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14917. * @param gradient defines the gradient to use (between 0 and 1)
  14918. * @param factor defines the emit rate to affect to the specified gradient
  14919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14920. * @returns the current particle system
  14921. */
  14922. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14923. /**
  14924. * Remove a specific emit rate gradient
  14925. * @param gradient defines the gradient to remove
  14926. * @returns the current particle system
  14927. */
  14928. removeEmitRateGradient(gradient: number): IParticleSystem;
  14929. /**
  14930. * Gets the current list of emit rate gradients.
  14931. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14932. * @returns the list of emit rate gradients
  14933. */
  14934. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14935. /**
  14936. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14937. * @param gradient defines the gradient to use (between 0 and 1)
  14938. * @param factor defines the start size to affect to the specified gradient
  14939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14940. * @returns the current particle system
  14941. */
  14942. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14943. /**
  14944. * Remove a specific start size gradient
  14945. * @param gradient defines the gradient to remove
  14946. * @returns the current particle system
  14947. */
  14948. removeStartSizeGradient(gradient: number): IParticleSystem;
  14949. /**
  14950. * Gets the current list of start size gradients.
  14951. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14952. * @returns the list of start size gradients
  14953. */
  14954. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14955. /**
  14956. * Adds a new life time gradient
  14957. * @param gradient defines the gradient to use (between 0 and 1)
  14958. * @param factor defines the life time factor to affect to the specified gradient
  14959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14960. * @returns the current particle system
  14961. */
  14962. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14963. /**
  14964. * Remove a specific life time gradient
  14965. * @param gradient defines the gradient to remove
  14966. * @returns the current particle system
  14967. */
  14968. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14969. /**
  14970. * Gets the current list of life time gradients.
  14971. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14972. * @returns the list of life time gradients
  14973. */
  14974. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14975. /**
  14976. * Gets the current list of color gradients.
  14977. * You must use addColorGradient and removeColorGradient to udpate this list
  14978. * @returns the list of color gradients
  14979. */
  14980. getColorGradients(): Nullable<Array<ColorGradient>>;
  14981. /**
  14982. * Adds a new ramp gradient used to remap particle colors
  14983. * @param gradient defines the gradient to use (between 0 and 1)
  14984. * @param color defines the color to affect to the specified gradient
  14985. * @returns the current particle system
  14986. */
  14987. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14988. /**
  14989. * Gets the current list of ramp gradients.
  14990. * You must use addRampGradient and removeRampGradient to udpate this list
  14991. * @returns the list of ramp gradients
  14992. */
  14993. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14994. /** Gets or sets a boolean indicating that ramp gradients must be used
  14995. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14996. */
  14997. useRampGradients: boolean;
  14998. /**
  14999. * Adds a new color remap gradient
  15000. * @param gradient defines the gradient to use (between 0 and 1)
  15001. * @param min defines the color remap minimal range
  15002. * @param max defines the color remap maximal range
  15003. * @returns the current particle system
  15004. */
  15005. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15006. /**
  15007. * Gets the current list of color remap gradients.
  15008. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15009. * @returns the list of color remap gradients
  15010. */
  15011. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15012. /**
  15013. * Adds a new alpha remap gradient
  15014. * @param gradient defines the gradient to use (between 0 and 1)
  15015. * @param min defines the alpha remap minimal range
  15016. * @param max defines the alpha remap maximal range
  15017. * @returns the current particle system
  15018. */
  15019. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15020. /**
  15021. * Gets the current list of alpha remap gradients.
  15022. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15023. * @returns the list of alpha remap gradients
  15024. */
  15025. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15026. /**
  15027. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15028. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15029. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15030. * @returns the emitter
  15031. */
  15032. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15033. /**
  15034. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15035. * @param radius The radius of the hemisphere to emit from
  15036. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15037. * @returns the emitter
  15038. */
  15039. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15040. /**
  15041. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15042. * @param radius The radius of the sphere to emit from
  15043. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15044. * @returns the emitter
  15045. */
  15046. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15047. /**
  15048. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15049. * @param radius The radius of the sphere to emit from
  15050. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15051. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15052. * @returns the emitter
  15053. */
  15054. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15055. /**
  15056. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15057. * @param radius The radius of the emission cylinder
  15058. * @param height The height of the emission cylinder
  15059. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15060. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15061. * @returns the emitter
  15062. */
  15063. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15064. /**
  15065. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15066. * @param radius The radius of the cylinder to emit from
  15067. * @param height The height of the emission cylinder
  15068. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15069. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15070. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15071. * @returns the emitter
  15072. */
  15073. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15074. /**
  15075. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15076. * @param radius The radius of the cone to emit from
  15077. * @param angle The base angle of the cone
  15078. * @returns the emitter
  15079. */
  15080. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15081. /**
  15082. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15083. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15084. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15085. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15086. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15087. * @returns the emitter
  15088. */
  15089. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15090. /**
  15091. * Get hosting scene
  15092. * @returns the scene
  15093. */
  15094. getScene(): Nullable<Scene>;
  15095. }
  15096. }
  15097. declare module "babylonjs/Meshes/transformNode" {
  15098. import { DeepImmutable } from "babylonjs/types";
  15099. import { Observable } from "babylonjs/Misc/observable";
  15100. import { Nullable } from "babylonjs/types";
  15101. import { Camera } from "babylonjs/Cameras/camera";
  15102. import { Scene } from "babylonjs/scene";
  15103. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15104. import { Node } from "babylonjs/node";
  15105. import { Bone } from "babylonjs/Bones/bone";
  15106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15107. import { Space } from "babylonjs/Maths/math.axis";
  15108. /**
  15109. * 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.
  15110. * @see https://doc.babylonjs.com/how_to/transformnode
  15111. */
  15112. export class TransformNode extends Node {
  15113. /**
  15114. * Object will not rotate to face the camera
  15115. */
  15116. static BILLBOARDMODE_NONE: number;
  15117. /**
  15118. * Object will rotate to face the camera but only on the x axis
  15119. */
  15120. static BILLBOARDMODE_X: number;
  15121. /**
  15122. * Object will rotate to face the camera but only on the y axis
  15123. */
  15124. static BILLBOARDMODE_Y: number;
  15125. /**
  15126. * Object will rotate to face the camera but only on the z axis
  15127. */
  15128. static BILLBOARDMODE_Z: number;
  15129. /**
  15130. * Object will rotate to face the camera
  15131. */
  15132. static BILLBOARDMODE_ALL: number;
  15133. /**
  15134. * Object will rotate to face the camera's position instead of orientation
  15135. */
  15136. static BILLBOARDMODE_USE_POSITION: number;
  15137. private static _TmpRotation;
  15138. private static _TmpScaling;
  15139. private static _TmpTranslation;
  15140. private _forward;
  15141. private _forwardInverted;
  15142. private _up;
  15143. private _right;
  15144. private _rightInverted;
  15145. private _position;
  15146. private _rotation;
  15147. private _rotationQuaternion;
  15148. protected _scaling: Vector3;
  15149. protected _isDirty: boolean;
  15150. private _transformToBoneReferal;
  15151. private _isAbsoluteSynced;
  15152. private _billboardMode;
  15153. /**
  15154. * Gets or sets the billboard mode. Default is 0.
  15155. *
  15156. * | Value | Type | Description |
  15157. * | --- | --- | --- |
  15158. * | 0 | BILLBOARDMODE_NONE | |
  15159. * | 1 | BILLBOARDMODE_X | |
  15160. * | 2 | BILLBOARDMODE_Y | |
  15161. * | 4 | BILLBOARDMODE_Z | |
  15162. * | 7 | BILLBOARDMODE_ALL | |
  15163. *
  15164. */
  15165. get billboardMode(): number;
  15166. set billboardMode(value: number);
  15167. private _preserveParentRotationForBillboard;
  15168. /**
  15169. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15170. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15171. */
  15172. get preserveParentRotationForBillboard(): boolean;
  15173. set preserveParentRotationForBillboard(value: boolean);
  15174. /**
  15175. * 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
  15176. */
  15177. scalingDeterminant: number;
  15178. private _infiniteDistance;
  15179. /**
  15180. * Gets or sets the distance of the object to max, often used by skybox
  15181. */
  15182. get infiniteDistance(): boolean;
  15183. set infiniteDistance(value: boolean);
  15184. /**
  15185. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15186. * By default the system will update normals to compensate
  15187. */
  15188. ignoreNonUniformScaling: boolean;
  15189. /**
  15190. * 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
  15191. */
  15192. reIntegrateRotationIntoRotationQuaternion: boolean;
  15193. /** @hidden */
  15194. _poseMatrix: Nullable<Matrix>;
  15195. /** @hidden */
  15196. _localMatrix: Matrix;
  15197. private _usePivotMatrix;
  15198. private _absolutePosition;
  15199. private _absoluteScaling;
  15200. private _absoluteRotationQuaternion;
  15201. private _pivotMatrix;
  15202. private _pivotMatrixInverse;
  15203. /** @hidden */
  15204. _postMultiplyPivotMatrix: boolean;
  15205. protected _isWorldMatrixFrozen: boolean;
  15206. /** @hidden */
  15207. _indexInSceneTransformNodesArray: number;
  15208. /**
  15209. * An event triggered after the world matrix is updated
  15210. */
  15211. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15212. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15213. /**
  15214. * Gets a string identifying the name of the class
  15215. * @returns "TransformNode" string
  15216. */
  15217. getClassName(): string;
  15218. /**
  15219. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15220. */
  15221. get position(): Vector3;
  15222. set position(newPosition: Vector3);
  15223. /**
  15224. * 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)).
  15225. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15226. */
  15227. get rotation(): Vector3;
  15228. set rotation(newRotation: Vector3);
  15229. /**
  15230. * 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)).
  15231. */
  15232. get scaling(): Vector3;
  15233. set scaling(newScaling: Vector3);
  15234. /**
  15235. * 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).
  15236. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15237. */
  15238. get rotationQuaternion(): Nullable<Quaternion>;
  15239. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15240. /**
  15241. * The forward direction of that transform in world space.
  15242. */
  15243. get forward(): Vector3;
  15244. /**
  15245. * The up direction of that transform in world space.
  15246. */
  15247. get up(): Vector3;
  15248. /**
  15249. * The right direction of that transform in world space.
  15250. */
  15251. get right(): Vector3;
  15252. /**
  15253. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15254. * @param matrix the matrix to copy the pose from
  15255. * @returns this TransformNode.
  15256. */
  15257. updatePoseMatrix(matrix: Matrix): TransformNode;
  15258. /**
  15259. * Returns the mesh Pose matrix.
  15260. * @returns the pose matrix
  15261. */
  15262. getPoseMatrix(): Matrix;
  15263. /** @hidden */
  15264. _isSynchronized(): boolean;
  15265. /** @hidden */
  15266. _initCache(): void;
  15267. /**
  15268. * Flag the transform node as dirty (Forcing it to update everything)
  15269. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15270. * @returns this transform node
  15271. */
  15272. markAsDirty(property: string): TransformNode;
  15273. /**
  15274. * Returns the current mesh absolute position.
  15275. * Returns a Vector3.
  15276. */
  15277. get absolutePosition(): Vector3;
  15278. /**
  15279. * Returns the current mesh absolute scaling.
  15280. * Returns a Vector3.
  15281. */
  15282. get absoluteScaling(): Vector3;
  15283. /**
  15284. * Returns the current mesh absolute rotation.
  15285. * Returns a Quaternion.
  15286. */
  15287. get absoluteRotationQuaternion(): Quaternion;
  15288. /**
  15289. * Sets a new matrix to apply before all other transformation
  15290. * @param matrix defines the transform matrix
  15291. * @returns the current TransformNode
  15292. */
  15293. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15294. /**
  15295. * Sets a new pivot matrix to the current node
  15296. * @param matrix defines the new pivot matrix to use
  15297. * @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
  15298. * @returns the current TransformNode
  15299. */
  15300. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15301. /**
  15302. * Returns the mesh pivot matrix.
  15303. * Default : Identity.
  15304. * @returns the matrix
  15305. */
  15306. getPivotMatrix(): Matrix;
  15307. /**
  15308. * Instantiate (when possible) or clone that node with its hierarchy
  15309. * @param newParent defines the new parent to use for the instance (or clone)
  15310. * @param options defines options to configure how copy is done
  15311. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15312. * @returns an instance (or a clone) of the current node with its hiearchy
  15313. */
  15314. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15315. doNotInstantiate: boolean;
  15316. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15317. /**
  15318. * Prevents the World matrix to be computed any longer
  15319. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15320. * @returns the TransformNode.
  15321. */
  15322. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15323. /**
  15324. * Allows back the World matrix computation.
  15325. * @returns the TransformNode.
  15326. */
  15327. unfreezeWorldMatrix(): this;
  15328. /**
  15329. * True if the World matrix has been frozen.
  15330. */
  15331. get isWorldMatrixFrozen(): boolean;
  15332. /**
  15333. * Retuns the mesh absolute position in the World.
  15334. * @returns a Vector3.
  15335. */
  15336. getAbsolutePosition(): Vector3;
  15337. /**
  15338. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15339. * @param absolutePosition the absolute position to set
  15340. * @returns the TransformNode.
  15341. */
  15342. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15343. /**
  15344. * Sets the mesh position in its local space.
  15345. * @param vector3 the position to set in localspace
  15346. * @returns the TransformNode.
  15347. */
  15348. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15349. /**
  15350. * Returns the mesh position in the local space from the current World matrix values.
  15351. * @returns a new Vector3.
  15352. */
  15353. getPositionExpressedInLocalSpace(): Vector3;
  15354. /**
  15355. * Translates the mesh along the passed Vector3 in its local space.
  15356. * @param vector3 the distance to translate in localspace
  15357. * @returns the TransformNode.
  15358. */
  15359. locallyTranslate(vector3: Vector3): TransformNode;
  15360. private static _lookAtVectorCache;
  15361. /**
  15362. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15363. * @param targetPoint the position (must be in same space as current mesh) to look at
  15364. * @param yawCor optional yaw (y-axis) correction in radians
  15365. * @param pitchCor optional pitch (x-axis) correction in radians
  15366. * @param rollCor optional roll (z-axis) correction in radians
  15367. * @param space the choosen space of the target
  15368. * @returns the TransformNode.
  15369. */
  15370. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15371. /**
  15372. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15373. * This Vector3 is expressed in the World space.
  15374. * @param localAxis axis to rotate
  15375. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15376. */
  15377. getDirection(localAxis: Vector3): Vector3;
  15378. /**
  15379. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15380. * localAxis is expressed in the mesh local space.
  15381. * result is computed in the Wordl space from the mesh World matrix.
  15382. * @param localAxis axis to rotate
  15383. * @param result the resulting transformnode
  15384. * @returns this TransformNode.
  15385. */
  15386. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15387. /**
  15388. * Sets this transform node rotation to the given local axis.
  15389. * @param localAxis the axis in local space
  15390. * @param yawCor optional yaw (y-axis) correction in radians
  15391. * @param pitchCor optional pitch (x-axis) correction in radians
  15392. * @param rollCor optional roll (z-axis) correction in radians
  15393. * @returns this TransformNode
  15394. */
  15395. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15396. /**
  15397. * Sets a new pivot point to the current node
  15398. * @param point defines the new pivot point to use
  15399. * @param space defines if the point is in world or local space (local by default)
  15400. * @returns the current TransformNode
  15401. */
  15402. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15403. /**
  15404. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15405. * @returns the pivot point
  15406. */
  15407. getPivotPoint(): Vector3;
  15408. /**
  15409. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15410. * @param result the vector3 to store the result
  15411. * @returns this TransformNode.
  15412. */
  15413. getPivotPointToRef(result: Vector3): TransformNode;
  15414. /**
  15415. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15416. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15417. */
  15418. getAbsolutePivotPoint(): Vector3;
  15419. /**
  15420. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15421. * @param result vector3 to store the result
  15422. * @returns this TransformNode.
  15423. */
  15424. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15425. /**
  15426. * Defines the passed node as the parent of the current node.
  15427. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15428. * @see https://doc.babylonjs.com/how_to/parenting
  15429. * @param node the node ot set as the parent
  15430. * @returns this TransformNode.
  15431. */
  15432. setParent(node: Nullable<Node>): TransformNode;
  15433. private _nonUniformScaling;
  15434. /**
  15435. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15436. */
  15437. get nonUniformScaling(): boolean;
  15438. /** @hidden */
  15439. _updateNonUniformScalingState(value: boolean): boolean;
  15440. /**
  15441. * Attach the current TransformNode to another TransformNode associated with a bone
  15442. * @param bone Bone affecting the TransformNode
  15443. * @param affectedTransformNode TransformNode associated with the bone
  15444. * @returns this object
  15445. */
  15446. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15447. /**
  15448. * Detach the transform node if its associated with a bone
  15449. * @returns this object
  15450. */
  15451. detachFromBone(): TransformNode;
  15452. private static _rotationAxisCache;
  15453. /**
  15454. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15455. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15456. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15457. * The passed axis is also normalized.
  15458. * @param axis the axis to rotate around
  15459. * @param amount the amount to rotate in radians
  15460. * @param space Space to rotate in (Default: local)
  15461. * @returns the TransformNode.
  15462. */
  15463. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15464. /**
  15465. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15466. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15467. * The passed axis is also normalized. .
  15468. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15469. * @param point the point to rotate around
  15470. * @param axis the axis to rotate around
  15471. * @param amount the amount to rotate in radians
  15472. * @returns the TransformNode
  15473. */
  15474. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15475. /**
  15476. * Translates the mesh along the axis vector for the passed distance in the given space.
  15477. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15478. * @param axis the axis to translate in
  15479. * @param distance the distance to translate
  15480. * @param space Space to rotate in (Default: local)
  15481. * @returns the TransformNode.
  15482. */
  15483. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15484. /**
  15485. * Adds a rotation step to the mesh current rotation.
  15486. * x, y, z are Euler angles expressed in radians.
  15487. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15488. * This means this rotation is made in the mesh local space only.
  15489. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15490. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15491. * ```javascript
  15492. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15493. * ```
  15494. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15495. * 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.
  15496. * @param x Rotation to add
  15497. * @param y Rotation to add
  15498. * @param z Rotation to add
  15499. * @returns the TransformNode.
  15500. */
  15501. addRotation(x: number, y: number, z: number): TransformNode;
  15502. /**
  15503. * @hidden
  15504. */
  15505. protected _getEffectiveParent(): Nullable<Node>;
  15506. /**
  15507. * Computes the world matrix of the node
  15508. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15509. * @returns the world matrix
  15510. */
  15511. computeWorldMatrix(force?: boolean): Matrix;
  15512. /**
  15513. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15514. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15515. */
  15516. resetLocalMatrix(independentOfChildren?: boolean): void;
  15517. protected _afterComputeWorldMatrix(): void;
  15518. /**
  15519. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15520. * @param func callback function to add
  15521. *
  15522. * @returns the TransformNode.
  15523. */
  15524. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15525. /**
  15526. * Removes a registered callback function.
  15527. * @param func callback function to remove
  15528. * @returns the TransformNode.
  15529. */
  15530. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15531. /**
  15532. * Gets the position of the current mesh in camera space
  15533. * @param camera defines the camera to use
  15534. * @returns a position
  15535. */
  15536. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15537. /**
  15538. * Returns the distance from the mesh to the active camera
  15539. * @param camera defines the camera to use
  15540. * @returns the distance
  15541. */
  15542. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15543. /**
  15544. * Clone the current transform node
  15545. * @param name Name of the new clone
  15546. * @param newParent New parent for the clone
  15547. * @param doNotCloneChildren Do not clone children hierarchy
  15548. * @returns the new transform node
  15549. */
  15550. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15551. /**
  15552. * Serializes the objects information.
  15553. * @param currentSerializationObject defines the object to serialize in
  15554. * @returns the serialized object
  15555. */
  15556. serialize(currentSerializationObject?: any): any;
  15557. /**
  15558. * Returns a new TransformNode object parsed from the source provided.
  15559. * @param parsedTransformNode is the source.
  15560. * @param scene the scne the object belongs to
  15561. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15562. * @returns a new TransformNode object parsed from the source provided.
  15563. */
  15564. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15565. /**
  15566. * Get all child-transformNodes of this node
  15567. * @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
  15568. * @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
  15569. * @returns an array of TransformNode
  15570. */
  15571. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15572. /**
  15573. * Releases resources associated with this transform node.
  15574. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15575. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15576. */
  15577. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15578. /**
  15579. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15580. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15581. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15582. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15583. * @returns the current mesh
  15584. */
  15585. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15586. private _syncAbsoluteScalingAndRotation;
  15587. }
  15588. }
  15589. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15590. /**
  15591. * Class used to override all child animations of a given target
  15592. */
  15593. export class AnimationPropertiesOverride {
  15594. /**
  15595. * Gets or sets a value indicating if animation blending must be used
  15596. */
  15597. enableBlending: boolean;
  15598. /**
  15599. * Gets or sets the blending speed to use when enableBlending is true
  15600. */
  15601. blendingSpeed: number;
  15602. /**
  15603. * Gets or sets the default loop mode to use
  15604. */
  15605. loopMode: number;
  15606. }
  15607. }
  15608. declare module "babylonjs/Bones/bone" {
  15609. import { Skeleton } from "babylonjs/Bones/skeleton";
  15610. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15611. import { Nullable } from "babylonjs/types";
  15612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15613. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15614. import { Node } from "babylonjs/node";
  15615. import { Space } from "babylonjs/Maths/math.axis";
  15616. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15617. /**
  15618. * Class used to store bone information
  15619. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15620. */
  15621. export class Bone extends Node {
  15622. /**
  15623. * defines the bone name
  15624. */
  15625. name: string;
  15626. private static _tmpVecs;
  15627. private static _tmpQuat;
  15628. private static _tmpMats;
  15629. /**
  15630. * Gets the list of child bones
  15631. */
  15632. children: Bone[];
  15633. /** Gets the animations associated with this bone */
  15634. animations: import("babylonjs/Animations/animation").Animation[];
  15635. /**
  15636. * Gets or sets bone length
  15637. */
  15638. length: number;
  15639. /**
  15640. * @hidden Internal only
  15641. * Set this value to map this bone to a different index in the transform matrices
  15642. * Set this value to -1 to exclude the bone from the transform matrices
  15643. */
  15644. _index: Nullable<number>;
  15645. private _skeleton;
  15646. private _localMatrix;
  15647. private _restPose;
  15648. private _bindPose;
  15649. private _baseMatrix;
  15650. private _absoluteTransform;
  15651. private _invertedAbsoluteTransform;
  15652. private _parent;
  15653. private _scalingDeterminant;
  15654. private _worldTransform;
  15655. private _localScaling;
  15656. private _localRotation;
  15657. private _localPosition;
  15658. private _needToDecompose;
  15659. private _needToCompose;
  15660. /** @hidden */
  15661. _linkedTransformNode: Nullable<TransformNode>;
  15662. /** @hidden */
  15663. _waitingTransformNodeId: Nullable<string>;
  15664. /** @hidden */
  15665. get _matrix(): Matrix;
  15666. /** @hidden */
  15667. set _matrix(value: Matrix);
  15668. /**
  15669. * Create a new bone
  15670. * @param name defines the bone name
  15671. * @param skeleton defines the parent skeleton
  15672. * @param parentBone defines the parent (can be null if the bone is the root)
  15673. * @param localMatrix defines the local matrix
  15674. * @param restPose defines the rest pose matrix
  15675. * @param baseMatrix defines the base matrix
  15676. * @param index defines index of the bone in the hiearchy
  15677. */
  15678. constructor(
  15679. /**
  15680. * defines the bone name
  15681. */
  15682. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15683. /**
  15684. * Gets the current object class name.
  15685. * @return the class name
  15686. */
  15687. getClassName(): string;
  15688. /**
  15689. * Gets the parent skeleton
  15690. * @returns a skeleton
  15691. */
  15692. getSkeleton(): Skeleton;
  15693. /**
  15694. * Gets parent bone
  15695. * @returns a bone or null if the bone is the root of the bone hierarchy
  15696. */
  15697. getParent(): Nullable<Bone>;
  15698. /**
  15699. * Returns an array containing the root bones
  15700. * @returns an array containing the root bones
  15701. */
  15702. getChildren(): Array<Bone>;
  15703. /**
  15704. * Gets the node index in matrix array generated for rendering
  15705. * @returns the node index
  15706. */
  15707. getIndex(): number;
  15708. /**
  15709. * Sets the parent bone
  15710. * @param parent defines the parent (can be null if the bone is the root)
  15711. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15712. */
  15713. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15714. /**
  15715. * Gets the local matrix
  15716. * @returns a matrix
  15717. */
  15718. getLocalMatrix(): Matrix;
  15719. /**
  15720. * Gets the base matrix (initial matrix which remains unchanged)
  15721. * @returns a matrix
  15722. */
  15723. getBaseMatrix(): Matrix;
  15724. /**
  15725. * Gets the rest pose matrix
  15726. * @returns a matrix
  15727. */
  15728. getRestPose(): Matrix;
  15729. /**
  15730. * Sets the rest pose matrix
  15731. * @param matrix the local-space rest pose to set for this bone
  15732. */
  15733. setRestPose(matrix: Matrix): void;
  15734. /**
  15735. * Gets the bind pose matrix
  15736. * @returns the bind pose matrix
  15737. */
  15738. getBindPose(): Matrix;
  15739. /**
  15740. * Sets the bind pose matrix
  15741. * @param matrix the local-space bind pose to set for this bone
  15742. */
  15743. setBindPose(matrix: Matrix): void;
  15744. /**
  15745. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15746. */
  15747. getWorldMatrix(): Matrix;
  15748. /**
  15749. * Sets the local matrix to rest pose matrix
  15750. */
  15751. returnToRest(): void;
  15752. /**
  15753. * Gets the inverse of the absolute transform matrix.
  15754. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15755. * @returns a matrix
  15756. */
  15757. getInvertedAbsoluteTransform(): Matrix;
  15758. /**
  15759. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15760. * @returns a matrix
  15761. */
  15762. getAbsoluteTransform(): Matrix;
  15763. /**
  15764. * Links with the given transform node.
  15765. * The local matrix of this bone is copied from the transform node every frame.
  15766. * @param transformNode defines the transform node to link to
  15767. */
  15768. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15769. /**
  15770. * Gets the node used to drive the bone's transformation
  15771. * @returns a transform node or null
  15772. */
  15773. getTransformNode(): Nullable<TransformNode>;
  15774. /** Gets or sets current position (in local space) */
  15775. get position(): Vector3;
  15776. set position(newPosition: Vector3);
  15777. /** Gets or sets current rotation (in local space) */
  15778. get rotation(): Vector3;
  15779. set rotation(newRotation: Vector3);
  15780. /** Gets or sets current rotation quaternion (in local space) */
  15781. get rotationQuaternion(): Quaternion;
  15782. set rotationQuaternion(newRotation: Quaternion);
  15783. /** Gets or sets current scaling (in local space) */
  15784. get scaling(): Vector3;
  15785. set scaling(newScaling: Vector3);
  15786. /**
  15787. * Gets the animation properties override
  15788. */
  15789. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15790. private _decompose;
  15791. private _compose;
  15792. /**
  15793. * Update the base and local matrices
  15794. * @param matrix defines the new base or local matrix
  15795. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15796. * @param updateLocalMatrix defines if the local matrix should be updated
  15797. */
  15798. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15799. /** @hidden */
  15800. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15801. /**
  15802. * Flag the bone as dirty (Forcing it to update everything)
  15803. */
  15804. markAsDirty(): void;
  15805. /** @hidden */
  15806. _markAsDirtyAndCompose(): void;
  15807. private _markAsDirtyAndDecompose;
  15808. /**
  15809. * Translate the bone in local or world space
  15810. * @param vec The amount to translate the bone
  15811. * @param space The space that the translation is in
  15812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15813. */
  15814. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15815. /**
  15816. * Set the postion of the bone in local or world space
  15817. * @param position The position to set the bone
  15818. * @param space The space that the position is in
  15819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15820. */
  15821. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15822. /**
  15823. * Set the absolute position of the bone (world space)
  15824. * @param position The position to set the bone
  15825. * @param mesh The mesh that this bone is attached to
  15826. */
  15827. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15828. /**
  15829. * Scale the bone on the x, y and z axes (in local space)
  15830. * @param x The amount to scale the bone on the x axis
  15831. * @param y The amount to scale the bone on the y axis
  15832. * @param z The amount to scale the bone on the z axis
  15833. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15834. */
  15835. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15836. /**
  15837. * Set the bone scaling in local space
  15838. * @param scale defines the scaling vector
  15839. */
  15840. setScale(scale: Vector3): void;
  15841. /**
  15842. * Gets the current scaling in local space
  15843. * @returns the current scaling vector
  15844. */
  15845. getScale(): Vector3;
  15846. /**
  15847. * Gets the current scaling in local space and stores it in a target vector
  15848. * @param result defines the target vector
  15849. */
  15850. getScaleToRef(result: Vector3): void;
  15851. /**
  15852. * Set the yaw, pitch, and roll of the bone in local or world space
  15853. * @param yaw The rotation of the bone on the y axis
  15854. * @param pitch The rotation of the bone on the x axis
  15855. * @param roll The rotation of the bone on the z axis
  15856. * @param space The space that the axes of rotation are in
  15857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15858. */
  15859. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15860. /**
  15861. * Add a rotation to the bone on an axis in local or world space
  15862. * @param axis The axis to rotate the bone on
  15863. * @param amount The amount to rotate the bone
  15864. * @param space The space that the axis is in
  15865. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15866. */
  15867. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15868. /**
  15869. * Set the rotation of the bone to a particular axis angle in local or world space
  15870. * @param axis The axis to rotate the bone on
  15871. * @param angle The angle that the bone should be rotated to
  15872. * @param space The space that the axis is in
  15873. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15874. */
  15875. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15876. /**
  15877. * Set the euler rotation of the bone in local or world space
  15878. * @param rotation The euler rotation that the bone should be set to
  15879. * @param space The space that the rotation is in
  15880. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15881. */
  15882. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15883. /**
  15884. * Set the quaternion rotation of the bone in local or world space
  15885. * @param quat The quaternion rotation that the bone should be set to
  15886. * @param space The space that the rotation is in
  15887. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15888. */
  15889. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15890. /**
  15891. * Set the rotation matrix of the bone in local or world space
  15892. * @param rotMat The rotation matrix that the bone should be set to
  15893. * @param space The space that the rotation is in
  15894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15895. */
  15896. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15897. private _rotateWithMatrix;
  15898. private _getNegativeRotationToRef;
  15899. /**
  15900. * Get the position of the bone in local or world space
  15901. * @param space The space that the returned position is in
  15902. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15903. * @returns The position of the bone
  15904. */
  15905. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15906. /**
  15907. * Copy the position of the bone to a vector3 in local or world space
  15908. * @param space The space that the returned position is in
  15909. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15910. * @param result The vector3 to copy the position to
  15911. */
  15912. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15913. /**
  15914. * Get the absolute position of the bone (world space)
  15915. * @param mesh The mesh that this bone is attached to
  15916. * @returns The absolute position of the bone
  15917. */
  15918. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15919. /**
  15920. * Copy the absolute position of the bone (world space) to the result param
  15921. * @param mesh The mesh that this bone is attached to
  15922. * @param result The vector3 to copy the absolute position to
  15923. */
  15924. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15925. /**
  15926. * Compute the absolute transforms of this bone and its children
  15927. */
  15928. computeAbsoluteTransforms(): void;
  15929. /**
  15930. * Get the world direction from an axis that is in the local space of the bone
  15931. * @param localAxis The local direction that is used to compute the world direction
  15932. * @param mesh The mesh that this bone is attached to
  15933. * @returns The world direction
  15934. */
  15935. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15936. /**
  15937. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15938. * @param localAxis The local direction that is used to compute the world direction
  15939. * @param mesh The mesh that this bone is attached to
  15940. * @param result The vector3 that the world direction will be copied to
  15941. */
  15942. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15943. /**
  15944. * Get the euler rotation of the bone in local or world space
  15945. * @param space The space that the rotation should be in
  15946. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15947. * @returns The euler rotation
  15948. */
  15949. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15950. /**
  15951. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15952. * @param space The space that the rotation should be in
  15953. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15954. * @param result The vector3 that the rotation should be copied to
  15955. */
  15956. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15957. /**
  15958. * Get the quaternion rotation of the bone in either local or world space
  15959. * @param space The space that the rotation should be in
  15960. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15961. * @returns The quaternion rotation
  15962. */
  15963. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15964. /**
  15965. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15966. * @param space The space that the rotation should be in
  15967. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15968. * @param result The quaternion that the rotation should be copied to
  15969. */
  15970. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15971. /**
  15972. * Get the rotation matrix of the bone in local or world space
  15973. * @param space The space that the rotation should be in
  15974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15975. * @returns The rotation matrix
  15976. */
  15977. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15978. /**
  15979. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15980. * @param space The space that the rotation should be in
  15981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15982. * @param result The quaternion that the rotation should be copied to
  15983. */
  15984. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15985. /**
  15986. * Get the world position of a point that is in the local space of the bone
  15987. * @param position The local position
  15988. * @param mesh The mesh that this bone is attached to
  15989. * @returns The world position
  15990. */
  15991. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15992. /**
  15993. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15994. * @param position The local position
  15995. * @param mesh The mesh that this bone is attached to
  15996. * @param result The vector3 that the world position should be copied to
  15997. */
  15998. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15999. /**
  16000. * Get the local position of a point that is in world space
  16001. * @param position The world position
  16002. * @param mesh The mesh that this bone is attached to
  16003. * @returns The local position
  16004. */
  16005. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  16006. /**
  16007. * Get the local position of a point that is in world space and copy it to the result param
  16008. * @param position The world position
  16009. * @param mesh The mesh that this bone is attached to
  16010. * @param result The vector3 that the local position should be copied to
  16011. */
  16012. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16013. /**
  16014. * Set the current local matrix as the restPose for this bone.
  16015. */
  16016. setCurrentPoseAsRest(): void;
  16017. }
  16018. }
  16019. declare module "babylonjs/Animations/runtimeAnimation" {
  16020. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  16021. import { Animatable } from "babylonjs/Animations/animatable";
  16022. import { Scene } from "babylonjs/scene";
  16023. /**
  16024. * Defines a runtime animation
  16025. */
  16026. export class RuntimeAnimation {
  16027. private _events;
  16028. /**
  16029. * The current frame of the runtime animation
  16030. */
  16031. private _currentFrame;
  16032. /**
  16033. * The animation used by the runtime animation
  16034. */
  16035. private _animation;
  16036. /**
  16037. * The target of the runtime animation
  16038. */
  16039. private _target;
  16040. /**
  16041. * The initiating animatable
  16042. */
  16043. private _host;
  16044. /**
  16045. * The original value of the runtime animation
  16046. */
  16047. private _originalValue;
  16048. /**
  16049. * The original blend value of the runtime animation
  16050. */
  16051. private _originalBlendValue;
  16052. /**
  16053. * The offsets cache of the runtime animation
  16054. */
  16055. private _offsetsCache;
  16056. /**
  16057. * The high limits cache of the runtime animation
  16058. */
  16059. private _highLimitsCache;
  16060. /**
  16061. * Specifies if the runtime animation has been stopped
  16062. */
  16063. private _stopped;
  16064. /**
  16065. * The blending factor of the runtime animation
  16066. */
  16067. private _blendingFactor;
  16068. /**
  16069. * The BabylonJS scene
  16070. */
  16071. private _scene;
  16072. /**
  16073. * The current value of the runtime animation
  16074. */
  16075. private _currentValue;
  16076. /** @hidden */
  16077. _animationState: _IAnimationState;
  16078. /**
  16079. * The active target of the runtime animation
  16080. */
  16081. private _activeTargets;
  16082. private _currentActiveTarget;
  16083. private _directTarget;
  16084. /**
  16085. * The target path of the runtime animation
  16086. */
  16087. private _targetPath;
  16088. /**
  16089. * The weight of the runtime animation
  16090. */
  16091. private _weight;
  16092. /**
  16093. * The ratio offset of the runtime animation
  16094. */
  16095. private _ratioOffset;
  16096. /**
  16097. * The previous delay of the runtime animation
  16098. */
  16099. private _previousDelay;
  16100. /**
  16101. * The previous ratio of the runtime animation
  16102. */
  16103. private _previousRatio;
  16104. private _enableBlending;
  16105. private _keys;
  16106. private _minFrame;
  16107. private _maxFrame;
  16108. private _minValue;
  16109. private _maxValue;
  16110. private _targetIsArray;
  16111. /**
  16112. * Gets the current frame of the runtime animation
  16113. */
  16114. get currentFrame(): number;
  16115. /**
  16116. * Gets the weight of the runtime animation
  16117. */
  16118. get weight(): number;
  16119. /**
  16120. * Gets the current value of the runtime animation
  16121. */
  16122. get currentValue(): any;
  16123. /**
  16124. * Gets the target path of the runtime animation
  16125. */
  16126. get targetPath(): string;
  16127. /**
  16128. * Gets the actual target of the runtime animation
  16129. */
  16130. get target(): any;
  16131. /**
  16132. * Gets the additive state of the runtime animation
  16133. */
  16134. get isAdditive(): boolean;
  16135. /** @hidden */
  16136. _onLoop: () => void;
  16137. /**
  16138. * Create a new RuntimeAnimation object
  16139. * @param target defines the target of the animation
  16140. * @param animation defines the source animation object
  16141. * @param scene defines the hosting scene
  16142. * @param host defines the initiating Animatable
  16143. */
  16144. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16145. private _preparePath;
  16146. /**
  16147. * Gets the animation from the runtime animation
  16148. */
  16149. get animation(): Animation;
  16150. /**
  16151. * Resets the runtime animation to the beginning
  16152. * @param restoreOriginal defines whether to restore the target property to the original value
  16153. */
  16154. reset(restoreOriginal?: boolean): void;
  16155. /**
  16156. * Specifies if the runtime animation is stopped
  16157. * @returns Boolean specifying if the runtime animation is stopped
  16158. */
  16159. isStopped(): boolean;
  16160. /**
  16161. * Disposes of the runtime animation
  16162. */
  16163. dispose(): void;
  16164. /**
  16165. * Apply the interpolated value to the target
  16166. * @param currentValue defines the value computed by the animation
  16167. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16168. */
  16169. setValue(currentValue: any, weight: number): void;
  16170. private _getOriginalValues;
  16171. private _setValue;
  16172. /**
  16173. * Gets the loop pmode of the runtime animation
  16174. * @returns Loop Mode
  16175. */
  16176. private _getCorrectLoopMode;
  16177. /**
  16178. * Move the current animation to a given frame
  16179. * @param frame defines the frame to move to
  16180. */
  16181. goToFrame(frame: number): void;
  16182. /**
  16183. * @hidden Internal use only
  16184. */
  16185. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16186. /**
  16187. * Execute the current animation
  16188. * @param delay defines the delay to add to the current frame
  16189. * @param from defines the lower bound of the animation range
  16190. * @param to defines the upper bound of the animation range
  16191. * @param loop defines if the current animation must loop
  16192. * @param speedRatio defines the current speed ratio
  16193. * @param weight defines the weight of the animation (default is -1 so no weight)
  16194. * @param onLoop optional callback called when animation loops
  16195. * @returns a boolean indicating if the animation is running
  16196. */
  16197. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16198. }
  16199. }
  16200. declare module "babylonjs/Animations/animatable" {
  16201. import { Animation } from "babylonjs/Animations/animation";
  16202. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16203. import { Nullable } from "babylonjs/types";
  16204. import { Observable } from "babylonjs/Misc/observable";
  16205. import { Scene } from "babylonjs/scene";
  16206. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16207. import { Node } from "babylonjs/node";
  16208. /**
  16209. * Class used to store an actual running animation
  16210. */
  16211. export class Animatable {
  16212. /** defines the target object */
  16213. target: any;
  16214. /** defines the starting frame number (default is 0) */
  16215. fromFrame: number;
  16216. /** defines the ending frame number (default is 100) */
  16217. toFrame: number;
  16218. /** defines if the animation must loop (default is false) */
  16219. loopAnimation: boolean;
  16220. /** defines a callback to call when animation ends if it is not looping */
  16221. onAnimationEnd?: (() => void) | null | undefined;
  16222. /** defines a callback to call when animation loops */
  16223. onAnimationLoop?: (() => void) | null | undefined;
  16224. /** defines whether the animation should be evaluated additively */
  16225. isAdditive: boolean;
  16226. private _localDelayOffset;
  16227. private _pausedDelay;
  16228. private _runtimeAnimations;
  16229. private _paused;
  16230. private _scene;
  16231. private _speedRatio;
  16232. private _weight;
  16233. private _syncRoot;
  16234. /**
  16235. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16236. * This will only apply for non looping animation (default is true)
  16237. */
  16238. disposeOnEnd: boolean;
  16239. /**
  16240. * Gets a boolean indicating if the animation has started
  16241. */
  16242. animationStarted: boolean;
  16243. /**
  16244. * Observer raised when the animation ends
  16245. */
  16246. onAnimationEndObservable: Observable<Animatable>;
  16247. /**
  16248. * Observer raised when the animation loops
  16249. */
  16250. onAnimationLoopObservable: Observable<Animatable>;
  16251. /**
  16252. * Gets the root Animatable used to synchronize and normalize animations
  16253. */
  16254. get syncRoot(): Nullable<Animatable>;
  16255. /**
  16256. * Gets the current frame of the first RuntimeAnimation
  16257. * Used to synchronize Animatables
  16258. */
  16259. get masterFrame(): number;
  16260. /**
  16261. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16262. */
  16263. get weight(): number;
  16264. set weight(value: number);
  16265. /**
  16266. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16267. */
  16268. get speedRatio(): number;
  16269. set speedRatio(value: number);
  16270. /**
  16271. * Creates a new Animatable
  16272. * @param scene defines the hosting scene
  16273. * @param target defines the target object
  16274. * @param fromFrame defines the starting frame number (default is 0)
  16275. * @param toFrame defines the ending frame number (default is 100)
  16276. * @param loopAnimation defines if the animation must loop (default is false)
  16277. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16278. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16279. * @param animations defines a group of animation to add to the new Animatable
  16280. * @param onAnimationLoop defines a callback to call when animation loops
  16281. * @param isAdditive defines whether the animation should be evaluated additively
  16282. */
  16283. constructor(scene: Scene,
  16284. /** defines the target object */
  16285. target: any,
  16286. /** defines the starting frame number (default is 0) */
  16287. fromFrame?: number,
  16288. /** defines the ending frame number (default is 100) */
  16289. toFrame?: number,
  16290. /** defines if the animation must loop (default is false) */
  16291. loopAnimation?: boolean, speedRatio?: number,
  16292. /** defines a callback to call when animation ends if it is not looping */
  16293. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16294. /** defines a callback to call when animation loops */
  16295. onAnimationLoop?: (() => void) | null | undefined,
  16296. /** defines whether the animation should be evaluated additively */
  16297. isAdditive?: boolean);
  16298. /**
  16299. * Synchronize and normalize current Animatable with a source Animatable
  16300. * This is useful when using animation weights and when animations are not of the same length
  16301. * @param root defines the root Animatable to synchronize with
  16302. * @returns the current Animatable
  16303. */
  16304. syncWith(root: Animatable): Animatable;
  16305. /**
  16306. * Gets the list of runtime animations
  16307. * @returns an array of RuntimeAnimation
  16308. */
  16309. getAnimations(): RuntimeAnimation[];
  16310. /**
  16311. * Adds more animations to the current animatable
  16312. * @param target defines the target of the animations
  16313. * @param animations defines the new animations to add
  16314. */
  16315. appendAnimations(target: any, animations: Animation[]): void;
  16316. /**
  16317. * Gets the source animation for a specific property
  16318. * @param property defines the propertyu to look for
  16319. * @returns null or the source animation for the given property
  16320. */
  16321. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16322. /**
  16323. * Gets the runtime animation for a specific property
  16324. * @param property defines the propertyu to look for
  16325. * @returns null or the runtime animation for the given property
  16326. */
  16327. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16328. /**
  16329. * Resets the animatable to its original state
  16330. */
  16331. reset(): void;
  16332. /**
  16333. * Allows the animatable to blend with current running animations
  16334. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16335. * @param blendingSpeed defines the blending speed to use
  16336. */
  16337. enableBlending(blendingSpeed: number): void;
  16338. /**
  16339. * Disable animation blending
  16340. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16341. */
  16342. disableBlending(): void;
  16343. /**
  16344. * Jump directly to a given frame
  16345. * @param frame defines the frame to jump to
  16346. */
  16347. goToFrame(frame: number): void;
  16348. /**
  16349. * Pause the animation
  16350. */
  16351. pause(): void;
  16352. /**
  16353. * Restart the animation
  16354. */
  16355. restart(): void;
  16356. private _raiseOnAnimationEnd;
  16357. /**
  16358. * Stop and delete the current animation
  16359. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16360. * @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)
  16361. */
  16362. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16363. /**
  16364. * Wait asynchronously for the animation to end
  16365. * @returns a promise which will be fullfilled when the animation ends
  16366. */
  16367. waitAsync(): Promise<Animatable>;
  16368. /** @hidden */
  16369. _animate(delay: number): boolean;
  16370. }
  16371. module "babylonjs/scene" {
  16372. interface Scene {
  16373. /** @hidden */
  16374. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16375. /** @hidden */
  16376. _processLateAnimationBindingsForMatrices(holder: {
  16377. totalWeight: number;
  16378. totalAdditiveWeight: number;
  16379. animations: RuntimeAnimation[];
  16380. additiveAnimations: RuntimeAnimation[];
  16381. originalValue: Matrix;
  16382. }): any;
  16383. /** @hidden */
  16384. _processLateAnimationBindingsForQuaternions(holder: {
  16385. totalWeight: number;
  16386. totalAdditiveWeight: number;
  16387. animations: RuntimeAnimation[];
  16388. additiveAnimations: RuntimeAnimation[];
  16389. originalValue: Quaternion;
  16390. }, refQuaternion: Quaternion): Quaternion;
  16391. /** @hidden */
  16392. _processLateAnimationBindings(): void;
  16393. /**
  16394. * Will start the animation sequence of a given target
  16395. * @param target defines the target
  16396. * @param from defines from which frame should animation start
  16397. * @param to defines until which frame should animation run.
  16398. * @param weight defines the weight to apply to the animation (1.0 by default)
  16399. * @param loop defines if the animation loops
  16400. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16401. * @param onAnimationEnd defines the function to be executed when the animation ends
  16402. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16403. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16404. * @param onAnimationLoop defines the callback to call when an animation loops
  16405. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16406. * @returns the animatable object created for this animation
  16407. */
  16408. 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;
  16409. /**
  16410. * Will start the animation sequence of a given target
  16411. * @param target defines the target
  16412. * @param from defines from which frame should animation start
  16413. * @param to defines until which frame should animation run.
  16414. * @param loop defines if the animation loops
  16415. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16416. * @param onAnimationEnd defines the function to be executed when the animation ends
  16417. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16418. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16419. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16420. * @param onAnimationLoop defines the callback to call when an animation loops
  16421. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16422. * @returns the animatable object created for this animation
  16423. */
  16424. 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;
  16425. /**
  16426. * Will start the animation sequence of a given target and its hierarchy
  16427. * @param target defines the target
  16428. * @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.
  16429. * @param from defines from which frame should animation start
  16430. * @param to defines until which frame should animation run.
  16431. * @param loop defines if the animation loops
  16432. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16433. * @param onAnimationEnd defines the function to be executed when the animation ends
  16434. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16435. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16436. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16437. * @param onAnimationLoop defines the callback to call when an animation loops
  16438. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16439. * @returns the list of created animatables
  16440. */
  16441. 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[];
  16442. /**
  16443. * Begin a new animation on a given node
  16444. * @param target defines the target where the animation will take place
  16445. * @param animations defines the list of animations to start
  16446. * @param from defines the initial value
  16447. * @param to defines the final value
  16448. * @param loop defines if you want animation to loop (off by default)
  16449. * @param speedRatio defines the speed ratio to apply to all animations
  16450. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16451. * @param onAnimationLoop defines the callback to call when an animation loops
  16452. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16453. * @returns the list of created animatables
  16454. */
  16455. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16456. /**
  16457. * Begin a new animation on a given node and its hierarchy
  16458. * @param target defines the root node where the animation will take place
  16459. * @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.
  16460. * @param animations defines the list of animations to start
  16461. * @param from defines the initial value
  16462. * @param to defines the final value
  16463. * @param loop defines if you want animation to loop (off by default)
  16464. * @param speedRatio defines the speed ratio to apply to all animations
  16465. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16466. * @param onAnimationLoop defines the callback to call when an animation loops
  16467. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16468. * @returns the list of animatables created for all nodes
  16469. */
  16470. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16471. /**
  16472. * Gets the animatable associated with a specific target
  16473. * @param target defines the target of the animatable
  16474. * @returns the required animatable if found
  16475. */
  16476. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16477. /**
  16478. * Gets all animatables associated with a given target
  16479. * @param target defines the target to look animatables for
  16480. * @returns an array of Animatables
  16481. */
  16482. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16483. /**
  16484. * Stops and removes all animations that have been applied to the scene
  16485. */
  16486. stopAllAnimations(): void;
  16487. /**
  16488. * Gets the current delta time used by animation engine
  16489. */
  16490. deltaTime: number;
  16491. }
  16492. }
  16493. module "babylonjs/Bones/bone" {
  16494. interface Bone {
  16495. /**
  16496. * Copy an animation range from another bone
  16497. * @param source defines the source bone
  16498. * @param rangeName defines the range name to copy
  16499. * @param frameOffset defines the frame offset
  16500. * @param rescaleAsRequired defines if rescaling must be applied if required
  16501. * @param skelDimensionsRatio defines the scaling ratio
  16502. * @returns true if operation was successful
  16503. */
  16504. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16505. }
  16506. }
  16507. }
  16508. declare module "babylonjs/Bones/skeleton" {
  16509. import { Bone } from "babylonjs/Bones/bone";
  16510. import { Observable } from "babylonjs/Misc/observable";
  16511. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16512. import { Scene } from "babylonjs/scene";
  16513. import { Nullable } from "babylonjs/types";
  16514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16515. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16516. import { Animatable } from "babylonjs/Animations/animatable";
  16517. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16518. import { Animation } from "babylonjs/Animations/animation";
  16519. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16520. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16521. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16522. /**
  16523. * Class used to handle skinning animations
  16524. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16525. */
  16526. export class Skeleton implements IAnimatable {
  16527. /** defines the skeleton name */
  16528. name: string;
  16529. /** defines the skeleton Id */
  16530. id: string;
  16531. /**
  16532. * Defines the list of child bones
  16533. */
  16534. bones: Bone[];
  16535. /**
  16536. * Defines an estimate of the dimension of the skeleton at rest
  16537. */
  16538. dimensionsAtRest: Vector3;
  16539. /**
  16540. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16541. */
  16542. needInitialSkinMatrix: boolean;
  16543. /**
  16544. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16545. */
  16546. overrideMesh: Nullable<AbstractMesh>;
  16547. /**
  16548. * Gets the list of animations attached to this skeleton
  16549. */
  16550. animations: Array<Animation>;
  16551. private _scene;
  16552. private _isDirty;
  16553. private _transformMatrices;
  16554. private _transformMatrixTexture;
  16555. private _meshesWithPoseMatrix;
  16556. private _animatables;
  16557. private _identity;
  16558. private _synchronizedWithMesh;
  16559. private _ranges;
  16560. private _lastAbsoluteTransformsUpdateId;
  16561. private _canUseTextureForBones;
  16562. private _uniqueId;
  16563. /** @hidden */
  16564. _numBonesWithLinkedTransformNode: number;
  16565. /** @hidden */
  16566. _hasWaitingData: Nullable<boolean>;
  16567. /** @hidden */
  16568. _waitingOverrideMeshId: Nullable<string>;
  16569. /**
  16570. * Specifies if the skeleton should be serialized
  16571. */
  16572. doNotSerialize: boolean;
  16573. private _useTextureToStoreBoneMatrices;
  16574. /**
  16575. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16576. * Please note that this option is not available if the hardware does not support it
  16577. */
  16578. get useTextureToStoreBoneMatrices(): boolean;
  16579. set useTextureToStoreBoneMatrices(value: boolean);
  16580. private _animationPropertiesOverride;
  16581. /**
  16582. * Gets or sets the animation properties override
  16583. */
  16584. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16585. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16586. /**
  16587. * List of inspectable custom properties (used by the Inspector)
  16588. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16589. */
  16590. inspectableCustomProperties: IInspectable[];
  16591. /**
  16592. * An observable triggered before computing the skeleton's matrices
  16593. */
  16594. onBeforeComputeObservable: Observable<Skeleton>;
  16595. /**
  16596. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16597. */
  16598. get isUsingTextureForMatrices(): boolean;
  16599. /**
  16600. * Gets the unique ID of this skeleton
  16601. */
  16602. get uniqueId(): number;
  16603. /**
  16604. * Creates a new skeleton
  16605. * @param name defines the skeleton name
  16606. * @param id defines the skeleton Id
  16607. * @param scene defines the hosting scene
  16608. */
  16609. constructor(
  16610. /** defines the skeleton name */
  16611. name: string,
  16612. /** defines the skeleton Id */
  16613. id: string, scene: Scene);
  16614. /**
  16615. * Gets the current object class name.
  16616. * @return the class name
  16617. */
  16618. getClassName(): string;
  16619. /**
  16620. * Returns an array containing the root bones
  16621. * @returns an array containing the root bones
  16622. */
  16623. getChildren(): Array<Bone>;
  16624. /**
  16625. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16626. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16627. * @returns a Float32Array containing matrices data
  16628. */
  16629. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16630. /**
  16631. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16632. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16633. * @returns a raw texture containing the data
  16634. */
  16635. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16636. /**
  16637. * Gets the current hosting scene
  16638. * @returns a scene object
  16639. */
  16640. getScene(): Scene;
  16641. /**
  16642. * Gets a string representing the current skeleton data
  16643. * @param fullDetails defines a boolean indicating if we want a verbose version
  16644. * @returns a string representing the current skeleton data
  16645. */
  16646. toString(fullDetails?: boolean): string;
  16647. /**
  16648. * Get bone's index searching by name
  16649. * @param name defines bone's name to search for
  16650. * @return the indice of the bone. Returns -1 if not found
  16651. */
  16652. getBoneIndexByName(name: string): number;
  16653. /**
  16654. * Creater a new animation range
  16655. * @param name defines the name of the range
  16656. * @param from defines the start key
  16657. * @param to defines the end key
  16658. */
  16659. createAnimationRange(name: string, from: number, to: number): void;
  16660. /**
  16661. * Delete a specific animation range
  16662. * @param name defines the name of the range
  16663. * @param deleteFrames defines if frames must be removed as well
  16664. */
  16665. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16666. /**
  16667. * Gets a specific animation range
  16668. * @param name defines the name of the range to look for
  16669. * @returns the requested animation range or null if not found
  16670. */
  16671. getAnimationRange(name: string): Nullable<AnimationRange>;
  16672. /**
  16673. * Gets the list of all animation ranges defined on this skeleton
  16674. * @returns an array
  16675. */
  16676. getAnimationRanges(): Nullable<AnimationRange>[];
  16677. /**
  16678. * Copy animation range from a source skeleton.
  16679. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16680. * @param source defines the source skeleton
  16681. * @param name defines the name of the range to copy
  16682. * @param rescaleAsRequired defines if rescaling must be applied if required
  16683. * @returns true if operation was successful
  16684. */
  16685. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16686. /**
  16687. * Forces the skeleton to go to rest pose
  16688. */
  16689. returnToRest(): void;
  16690. private _getHighestAnimationFrame;
  16691. /**
  16692. * Begin a specific animation range
  16693. * @param name defines the name of the range to start
  16694. * @param loop defines if looping must be turned on (false by default)
  16695. * @param speedRatio defines the speed ratio to apply (1 by default)
  16696. * @param onAnimationEnd defines a callback which will be called when animation will end
  16697. * @returns a new animatable
  16698. */
  16699. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16700. /**
  16701. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16702. * @param skeleton defines the Skeleton containing the animation range to convert
  16703. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16704. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16705. * @returns the original skeleton
  16706. */
  16707. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16708. /** @hidden */
  16709. _markAsDirty(): void;
  16710. /** @hidden */
  16711. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16712. /** @hidden */
  16713. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16714. private _computeTransformMatrices;
  16715. /**
  16716. * Build all resources required to render a skeleton
  16717. */
  16718. prepare(): void;
  16719. /**
  16720. * Gets the list of animatables currently running for this skeleton
  16721. * @returns an array of animatables
  16722. */
  16723. getAnimatables(): IAnimatable[];
  16724. /**
  16725. * Clone the current skeleton
  16726. * @param name defines the name of the new skeleton
  16727. * @param id defines the id of the new skeleton
  16728. * @returns the new skeleton
  16729. */
  16730. clone(name: string, id?: string): Skeleton;
  16731. /**
  16732. * Enable animation blending for this skeleton
  16733. * @param blendingSpeed defines the blending speed to apply
  16734. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16735. */
  16736. enableBlending(blendingSpeed?: number): void;
  16737. /**
  16738. * Releases all resources associated with the current skeleton
  16739. */
  16740. dispose(): void;
  16741. /**
  16742. * Serialize the skeleton in a JSON object
  16743. * @returns a JSON object
  16744. */
  16745. serialize(): any;
  16746. /**
  16747. * Creates a new skeleton from serialized data
  16748. * @param parsedSkeleton defines the serialized data
  16749. * @param scene defines the hosting scene
  16750. * @returns a new skeleton
  16751. */
  16752. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16753. /**
  16754. * Compute all node absolute transforms
  16755. * @param forceUpdate defines if computation must be done even if cache is up to date
  16756. */
  16757. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16758. /**
  16759. * Gets the root pose matrix
  16760. * @returns a matrix
  16761. */
  16762. getPoseMatrix(): Nullable<Matrix>;
  16763. /**
  16764. * Sorts bones per internal index
  16765. */
  16766. sortBones(): void;
  16767. private _sortBones;
  16768. /**
  16769. * Set the current local matrix as the restPose for all bones in the skeleton.
  16770. */
  16771. setCurrentPoseAsRest(): void;
  16772. }
  16773. }
  16774. declare module "babylonjs/Meshes/instancedMesh" {
  16775. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16776. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16777. import { Camera } from "babylonjs/Cameras/camera";
  16778. import { Node } from "babylonjs/node";
  16779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16780. import { Mesh } from "babylonjs/Meshes/mesh";
  16781. import { Material } from "babylonjs/Materials/material";
  16782. import { Skeleton } from "babylonjs/Bones/skeleton";
  16783. import { Light } from "babylonjs/Lights/light";
  16784. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16785. /**
  16786. * Creates an instance based on a source mesh.
  16787. */
  16788. export class InstancedMesh extends AbstractMesh {
  16789. private _sourceMesh;
  16790. private _currentLOD;
  16791. /** @hidden */
  16792. _indexInSourceMeshInstanceArray: number;
  16793. constructor(name: string, source: Mesh);
  16794. /**
  16795. * Returns the string "InstancedMesh".
  16796. */
  16797. getClassName(): string;
  16798. /** Gets the list of lights affecting that mesh */
  16799. get lightSources(): Light[];
  16800. _resyncLightSources(): void;
  16801. _resyncLightSource(light: Light): void;
  16802. _removeLightSource(light: Light, dispose: boolean): void;
  16803. /**
  16804. * If the source mesh receives shadows
  16805. */
  16806. get receiveShadows(): boolean;
  16807. /**
  16808. * The material of the source mesh
  16809. */
  16810. get material(): Nullable<Material>;
  16811. /**
  16812. * Visibility of the source mesh
  16813. */
  16814. get visibility(): number;
  16815. /**
  16816. * Skeleton of the source mesh
  16817. */
  16818. get skeleton(): Nullable<Skeleton>;
  16819. /**
  16820. * Rendering ground id of the source mesh
  16821. */
  16822. get renderingGroupId(): number;
  16823. set renderingGroupId(value: number);
  16824. /**
  16825. * Returns the total number of vertices (integer).
  16826. */
  16827. getTotalVertices(): number;
  16828. /**
  16829. * Returns a positive integer : the total number of indices in this mesh geometry.
  16830. * @returns the numner of indices or zero if the mesh has no geometry.
  16831. */
  16832. getTotalIndices(): number;
  16833. /**
  16834. * The source mesh of the instance
  16835. */
  16836. get sourceMesh(): Mesh;
  16837. /**
  16838. * Creates a new InstancedMesh object from the mesh model.
  16839. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16840. * @param name defines the name of the new instance
  16841. * @returns a new InstancedMesh
  16842. */
  16843. createInstance(name: string): InstancedMesh;
  16844. /**
  16845. * Is this node ready to be used/rendered
  16846. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16847. * @return {boolean} is it ready
  16848. */
  16849. isReady(completeCheck?: boolean): boolean;
  16850. /**
  16851. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16852. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16853. * @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.
  16854. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16855. */
  16856. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16857. /**
  16858. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16859. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16860. * The `data` are either a numeric array either a Float32Array.
  16861. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16862. * 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).
  16863. * Note that a new underlying VertexBuffer object is created each call.
  16864. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16865. *
  16866. * Possible `kind` values :
  16867. * - VertexBuffer.PositionKind
  16868. * - VertexBuffer.UVKind
  16869. * - VertexBuffer.UV2Kind
  16870. * - VertexBuffer.UV3Kind
  16871. * - VertexBuffer.UV4Kind
  16872. * - VertexBuffer.UV5Kind
  16873. * - VertexBuffer.UV6Kind
  16874. * - VertexBuffer.ColorKind
  16875. * - VertexBuffer.MatricesIndicesKind
  16876. * - VertexBuffer.MatricesIndicesExtraKind
  16877. * - VertexBuffer.MatricesWeightsKind
  16878. * - VertexBuffer.MatricesWeightsExtraKind
  16879. *
  16880. * Returns the Mesh.
  16881. */
  16882. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16883. /**
  16884. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16885. * If the mesh has no geometry, it is simply returned as it is.
  16886. * The `data` are either a numeric array either a Float32Array.
  16887. * No new underlying VertexBuffer object is created.
  16888. * 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.
  16889. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16890. *
  16891. * Possible `kind` values :
  16892. * - VertexBuffer.PositionKind
  16893. * - VertexBuffer.UVKind
  16894. * - VertexBuffer.UV2Kind
  16895. * - VertexBuffer.UV3Kind
  16896. * - VertexBuffer.UV4Kind
  16897. * - VertexBuffer.UV5Kind
  16898. * - VertexBuffer.UV6Kind
  16899. * - VertexBuffer.ColorKind
  16900. * - VertexBuffer.MatricesIndicesKind
  16901. * - VertexBuffer.MatricesIndicesExtraKind
  16902. * - VertexBuffer.MatricesWeightsKind
  16903. * - VertexBuffer.MatricesWeightsExtraKind
  16904. *
  16905. * Returns the Mesh.
  16906. */
  16907. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16908. /**
  16909. * Sets the mesh indices.
  16910. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16911. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16912. * This method creates a new index buffer each call.
  16913. * Returns the Mesh.
  16914. */
  16915. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16916. /**
  16917. * Boolean : True if the mesh owns the requested kind of data.
  16918. */
  16919. isVerticesDataPresent(kind: string): boolean;
  16920. /**
  16921. * Returns an array of indices (IndicesArray).
  16922. */
  16923. getIndices(): Nullable<IndicesArray>;
  16924. get _positions(): Nullable<Vector3[]>;
  16925. /**
  16926. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16927. * This means the mesh underlying bounding box and sphere are recomputed.
  16928. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16929. * @returns the current mesh
  16930. */
  16931. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16932. /** @hidden */
  16933. _preActivate(): InstancedMesh;
  16934. /** @hidden */
  16935. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16936. /** @hidden */
  16937. _postActivate(): void;
  16938. getWorldMatrix(): Matrix;
  16939. get isAnInstance(): boolean;
  16940. /**
  16941. * Returns the current associated LOD AbstractMesh.
  16942. */
  16943. getLOD(camera: Camera): AbstractMesh;
  16944. /** @hidden */
  16945. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16946. /** @hidden */
  16947. _syncSubMeshes(): InstancedMesh;
  16948. /** @hidden */
  16949. _generatePointsArray(): boolean;
  16950. /** @hidden */
  16951. _updateBoundingInfo(): AbstractMesh;
  16952. /**
  16953. * Creates a new InstancedMesh from the current mesh.
  16954. * - name (string) : the cloned mesh name
  16955. * - newParent (optional Node) : the optional Node to parent the clone to.
  16956. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16957. *
  16958. * Returns the clone.
  16959. */
  16960. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16961. /**
  16962. * Disposes the InstancedMesh.
  16963. * Returns nothing.
  16964. */
  16965. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16966. }
  16967. module "babylonjs/Meshes/mesh" {
  16968. interface Mesh {
  16969. /**
  16970. * Register a custom buffer that will be instanced
  16971. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16972. * @param kind defines the buffer kind
  16973. * @param stride defines the stride in floats
  16974. */
  16975. registerInstancedBuffer(kind: string, stride: number): void;
  16976. /**
  16977. * true to use the edge renderer for all instances of this mesh
  16978. */
  16979. edgesShareWithInstances: boolean;
  16980. /** @hidden */
  16981. _userInstancedBuffersStorage: {
  16982. data: {
  16983. [key: string]: Float32Array;
  16984. };
  16985. sizes: {
  16986. [key: string]: number;
  16987. };
  16988. vertexBuffers: {
  16989. [key: string]: Nullable<VertexBuffer>;
  16990. };
  16991. strides: {
  16992. [key: string]: number;
  16993. };
  16994. };
  16995. }
  16996. }
  16997. module "babylonjs/Meshes/abstractMesh" {
  16998. interface AbstractMesh {
  16999. /**
  17000. * Object used to store instanced buffers defined by user
  17001. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  17002. */
  17003. instancedBuffers: {
  17004. [key: string]: any;
  17005. };
  17006. }
  17007. }
  17008. }
  17009. declare module "babylonjs/Materials/shaderMaterial" {
  17010. import { Nullable } from "babylonjs/types";
  17011. import { Scene } from "babylonjs/scene";
  17012. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  17013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17014. import { Mesh } from "babylonjs/Meshes/mesh";
  17015. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17016. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17017. import { Effect } from "babylonjs/Materials/effect";
  17018. import { Material } from "babylonjs/Materials/material";
  17019. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17020. /**
  17021. * Defines the options associated with the creation of a shader material.
  17022. */
  17023. export interface IShaderMaterialOptions {
  17024. /**
  17025. * Does the material work in alpha blend mode
  17026. */
  17027. needAlphaBlending: boolean;
  17028. /**
  17029. * Does the material work in alpha test mode
  17030. */
  17031. needAlphaTesting: boolean;
  17032. /**
  17033. * The list of attribute names used in the shader
  17034. */
  17035. attributes: string[];
  17036. /**
  17037. * The list of unifrom names used in the shader
  17038. */
  17039. uniforms: string[];
  17040. /**
  17041. * The list of UBO names used in the shader
  17042. */
  17043. uniformBuffers: string[];
  17044. /**
  17045. * The list of sampler names used in the shader
  17046. */
  17047. samplers: string[];
  17048. /**
  17049. * The list of defines used in the shader
  17050. */
  17051. defines: string[];
  17052. }
  17053. /**
  17054. * 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.
  17055. *
  17056. * This returned material effects how the mesh will look based on the code in the shaders.
  17057. *
  17058. * @see https://doc.babylonjs.com/how_to/shader_material
  17059. */
  17060. export class ShaderMaterial extends Material {
  17061. private _shaderPath;
  17062. private _options;
  17063. private _textures;
  17064. private _textureArrays;
  17065. private _floats;
  17066. private _ints;
  17067. private _floatsArrays;
  17068. private _colors3;
  17069. private _colors3Arrays;
  17070. private _colors4;
  17071. private _colors4Arrays;
  17072. private _vectors2;
  17073. private _vectors3;
  17074. private _vectors4;
  17075. private _matrices;
  17076. private _matrixArrays;
  17077. private _matrices3x3;
  17078. private _matrices2x2;
  17079. private _vectors2Arrays;
  17080. private _vectors3Arrays;
  17081. private _vectors4Arrays;
  17082. private _cachedWorldViewMatrix;
  17083. private _cachedWorldViewProjectionMatrix;
  17084. private _renderId;
  17085. private _multiview;
  17086. private _cachedDefines;
  17087. /** Define the Url to load snippets */
  17088. static SnippetUrl: string;
  17089. /** Snippet ID if the material was created from the snippet server */
  17090. snippetId: string;
  17091. /**
  17092. * Instantiate a new shader material.
  17093. * 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.
  17094. * This returned material effects how the mesh will look based on the code in the shaders.
  17095. * @see https://doc.babylonjs.com/how_to/shader_material
  17096. * @param name Define the name of the material in the scene
  17097. * @param scene Define the scene the material belongs to
  17098. * @param shaderPath Defines the route to the shader code in one of three ways:
  17099. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17100. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17101. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17102. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17103. * @param options Define the options used to create the shader
  17104. */
  17105. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17106. /**
  17107. * Gets the shader path used to define the shader code
  17108. * It can be modified to trigger a new compilation
  17109. */
  17110. get shaderPath(): any;
  17111. /**
  17112. * Sets the shader path used to define the shader code
  17113. * It can be modified to trigger a new compilation
  17114. */
  17115. set shaderPath(shaderPath: any);
  17116. /**
  17117. * Gets the options used to compile the shader.
  17118. * They can be modified to trigger a new compilation
  17119. */
  17120. get options(): IShaderMaterialOptions;
  17121. /**
  17122. * Gets the current class name of the material e.g. "ShaderMaterial"
  17123. * Mainly use in serialization.
  17124. * @returns the class name
  17125. */
  17126. getClassName(): string;
  17127. /**
  17128. * Specifies if the material will require alpha blending
  17129. * @returns a boolean specifying if alpha blending is needed
  17130. */
  17131. needAlphaBlending(): boolean;
  17132. /**
  17133. * Specifies if this material should be rendered in alpha test mode
  17134. * @returns a boolean specifying if an alpha test is needed.
  17135. */
  17136. needAlphaTesting(): boolean;
  17137. private _checkUniform;
  17138. /**
  17139. * Set a texture in the shader.
  17140. * @param name Define the name of the uniform samplers as defined in the shader
  17141. * @param texture Define the texture to bind to this sampler
  17142. * @return the material itself allowing "fluent" like uniform updates
  17143. */
  17144. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17145. /**
  17146. * Set a texture array in the shader.
  17147. * @param name Define the name of the uniform sampler array as defined in the shader
  17148. * @param textures Define the list of textures to bind to this sampler
  17149. * @return the material itself allowing "fluent" like uniform updates
  17150. */
  17151. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17152. /**
  17153. * Set a float in the shader.
  17154. * @param name Define the name of the uniform as defined in the shader
  17155. * @param value Define the value to give to the uniform
  17156. * @return the material itself allowing "fluent" like uniform updates
  17157. */
  17158. setFloat(name: string, value: number): ShaderMaterial;
  17159. /**
  17160. * Set a int in the shader.
  17161. * @param name Define the name of the uniform as defined in the shader
  17162. * @param value Define the value to give to the uniform
  17163. * @return the material itself allowing "fluent" like uniform updates
  17164. */
  17165. setInt(name: string, value: number): ShaderMaterial;
  17166. /**
  17167. * Set an array of floats in the shader.
  17168. * @param name Define the name of the uniform as defined in the shader
  17169. * @param value Define the value to give to the uniform
  17170. * @return the material itself allowing "fluent" like uniform updates
  17171. */
  17172. setFloats(name: string, value: number[]): ShaderMaterial;
  17173. /**
  17174. * Set a vec3 in the shader from a Color3.
  17175. * @param name Define the name of the uniform as defined in the shader
  17176. * @param value Define the value to give to the uniform
  17177. * @return the material itself allowing "fluent" like uniform updates
  17178. */
  17179. setColor3(name: string, value: Color3): ShaderMaterial;
  17180. /**
  17181. * Set a vec3 array in the shader from a Color3 array.
  17182. * @param name Define the name of the uniform as defined in the shader
  17183. * @param value Define the value to give to the uniform
  17184. * @return the material itself allowing "fluent" like uniform updates
  17185. */
  17186. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17187. /**
  17188. * Set a vec4 in the shader from a Color4.
  17189. * @param name Define the name of the uniform as defined in the shader
  17190. * @param value Define the value to give to the uniform
  17191. * @return the material itself allowing "fluent" like uniform updates
  17192. */
  17193. setColor4(name: string, value: Color4): ShaderMaterial;
  17194. /**
  17195. * Set a vec4 array in the shader from a Color4 array.
  17196. * @param name Define the name of the uniform as defined in the shader
  17197. * @param value Define the value to give to the uniform
  17198. * @return the material itself allowing "fluent" like uniform updates
  17199. */
  17200. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17201. /**
  17202. * Set a vec2 in the shader from a Vector2.
  17203. * @param name Define the name of the uniform as defined in the shader
  17204. * @param value Define the value to give to the uniform
  17205. * @return the material itself allowing "fluent" like uniform updates
  17206. */
  17207. setVector2(name: string, value: Vector2): ShaderMaterial;
  17208. /**
  17209. * Set a vec3 in the shader from a Vector3.
  17210. * @param name Define the name of the uniform as defined in the shader
  17211. * @param value Define the value to give to the uniform
  17212. * @return the material itself allowing "fluent" like uniform updates
  17213. */
  17214. setVector3(name: string, value: Vector3): ShaderMaterial;
  17215. /**
  17216. * Set a vec4 in the shader from a Vector4.
  17217. * @param name Define the name of the uniform as defined in the shader
  17218. * @param value Define the value to give to the uniform
  17219. * @return the material itself allowing "fluent" like uniform updates
  17220. */
  17221. setVector4(name: string, value: Vector4): ShaderMaterial;
  17222. /**
  17223. * Set a mat4 in the shader from a Matrix.
  17224. * @param name Define the name of the uniform as defined in the shader
  17225. * @param value Define the value to give to the uniform
  17226. * @return the material itself allowing "fluent" like uniform updates
  17227. */
  17228. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17229. /**
  17230. * Set a float32Array in the shader from a matrix array.
  17231. * @param name Define the name of the uniform as defined in the shader
  17232. * @param value Define the value to give to the uniform
  17233. * @return the material itself allowing "fluent" like uniform updates
  17234. */
  17235. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17236. /**
  17237. * Set a mat3 in the shader from a Float32Array.
  17238. * @param name Define the name of the uniform as defined in the shader
  17239. * @param value Define the value to give to the uniform
  17240. * @return the material itself allowing "fluent" like uniform updates
  17241. */
  17242. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17243. /**
  17244. * Set a mat2 in the shader from a Float32Array.
  17245. * @param name Define the name of the uniform as defined in the shader
  17246. * @param value Define the value to give to the uniform
  17247. * @return the material itself allowing "fluent" like uniform updates
  17248. */
  17249. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17250. /**
  17251. * Set a vec2 array in the shader from a number array.
  17252. * @param name Define the name of the uniform as defined in the shader
  17253. * @param value Define the value to give to the uniform
  17254. * @return the material itself allowing "fluent" like uniform updates
  17255. */
  17256. setArray2(name: string, value: number[]): ShaderMaterial;
  17257. /**
  17258. * Set a vec3 array in the shader from a number array.
  17259. * @param name Define the name of the uniform as defined in the shader
  17260. * @param value Define the value to give to the uniform
  17261. * @return the material itself allowing "fluent" like uniform updates
  17262. */
  17263. setArray3(name: string, value: number[]): ShaderMaterial;
  17264. /**
  17265. * Set a vec4 array in the shader from a number array.
  17266. * @param name Define the name of the uniform as defined in the shader
  17267. * @param value Define the value to give to the uniform
  17268. * @return the material itself allowing "fluent" like uniform updates
  17269. */
  17270. setArray4(name: string, value: number[]): ShaderMaterial;
  17271. private _checkCache;
  17272. /**
  17273. * Specifies that the submesh is ready to be used
  17274. * @param mesh defines the mesh to check
  17275. * @param subMesh defines which submesh to check
  17276. * @param useInstances specifies that instances should be used
  17277. * @returns a boolean indicating that the submesh is ready or not
  17278. */
  17279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17280. /**
  17281. * Checks if the material is ready to render the requested mesh
  17282. * @param mesh Define the mesh to render
  17283. * @param useInstances Define whether or not the material is used with instances
  17284. * @returns true if ready, otherwise false
  17285. */
  17286. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17287. /**
  17288. * Binds the world matrix to the material
  17289. * @param world defines the world transformation matrix
  17290. * @param effectOverride - If provided, use this effect instead of internal effect
  17291. */
  17292. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17293. /**
  17294. * Binds the submesh to this material by preparing the effect and shader to draw
  17295. * @param world defines the world transformation matrix
  17296. * @param mesh defines the mesh containing the submesh
  17297. * @param subMesh defines the submesh to bind the material to
  17298. */
  17299. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17300. /**
  17301. * Binds the material to the mesh
  17302. * @param world defines the world transformation matrix
  17303. * @param mesh defines the mesh to bind the material to
  17304. * @param effectOverride - If provided, use this effect instead of internal effect
  17305. */
  17306. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17307. protected _afterBind(mesh?: Mesh): void;
  17308. /**
  17309. * Gets the active textures from the material
  17310. * @returns an array of textures
  17311. */
  17312. getActiveTextures(): BaseTexture[];
  17313. /**
  17314. * Specifies if the material uses a texture
  17315. * @param texture defines the texture to check against the material
  17316. * @returns a boolean specifying if the material uses the texture
  17317. */
  17318. hasTexture(texture: BaseTexture): boolean;
  17319. /**
  17320. * Makes a duplicate of the material, and gives it a new name
  17321. * @param name defines the new name for the duplicated material
  17322. * @returns the cloned material
  17323. */
  17324. clone(name: string): ShaderMaterial;
  17325. /**
  17326. * Disposes the material
  17327. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17328. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17329. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17330. */
  17331. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17332. /**
  17333. * Serializes this material in a JSON representation
  17334. * @returns the serialized material object
  17335. */
  17336. serialize(): any;
  17337. /**
  17338. * Creates a shader material from parsed shader material data
  17339. * @param source defines the JSON represnetation of the material
  17340. * @param scene defines the hosting scene
  17341. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17342. * @returns a new material
  17343. */
  17344. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17345. /**
  17346. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17347. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17348. * @param url defines the url to load from
  17349. * @param scene defines the hosting scene
  17350. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17351. * @returns a promise that will resolve to the new ShaderMaterial
  17352. */
  17353. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17354. /**
  17355. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17356. * @param snippetId defines the snippet to load
  17357. * @param scene defines the hosting scene
  17358. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17359. * @returns a promise that will resolve to the new ShaderMaterial
  17360. */
  17361. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17362. }
  17363. }
  17364. declare module "babylonjs/Shaders/color.fragment" {
  17365. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17366. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17367. /** @hidden */
  17368. export var colorPixelShader: {
  17369. name: string;
  17370. shader: string;
  17371. };
  17372. }
  17373. declare module "babylonjs/Shaders/color.vertex" {
  17374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17375. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17376. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17377. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17378. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17379. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17380. /** @hidden */
  17381. export var colorVertexShader: {
  17382. name: string;
  17383. shader: string;
  17384. };
  17385. }
  17386. declare module "babylonjs/Meshes/linesMesh" {
  17387. import { Nullable } from "babylonjs/types";
  17388. import { Scene } from "babylonjs/scene";
  17389. import { Color3 } from "babylonjs/Maths/math.color";
  17390. import { Node } from "babylonjs/node";
  17391. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17392. import { Mesh } from "babylonjs/Meshes/mesh";
  17393. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17394. import { Effect } from "babylonjs/Materials/effect";
  17395. import { Material } from "babylonjs/Materials/material";
  17396. import "babylonjs/Shaders/color.fragment";
  17397. import "babylonjs/Shaders/color.vertex";
  17398. /**
  17399. * Line mesh
  17400. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17401. */
  17402. export class LinesMesh extends Mesh {
  17403. /**
  17404. * If vertex color should be applied to the mesh
  17405. */
  17406. readonly useVertexColor?: boolean | undefined;
  17407. /**
  17408. * If vertex alpha should be applied to the mesh
  17409. */
  17410. readonly useVertexAlpha?: boolean | undefined;
  17411. /**
  17412. * Color of the line (Default: White)
  17413. */
  17414. color: Color3;
  17415. /**
  17416. * Alpha of the line (Default: 1)
  17417. */
  17418. alpha: number;
  17419. /**
  17420. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17421. * This margin is expressed in world space coordinates, so its value may vary.
  17422. * Default value is 0.1
  17423. */
  17424. intersectionThreshold: number;
  17425. private _colorShader;
  17426. private color4;
  17427. /**
  17428. * Creates a new LinesMesh
  17429. * @param name defines the name
  17430. * @param scene defines the hosting scene
  17431. * @param parent defines the parent mesh if any
  17432. * @param source defines the optional source LinesMesh used to clone data from
  17433. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17434. * When false, achieved by calling a clone(), also passing False.
  17435. * This will make creation of children, recursive.
  17436. * @param useVertexColor defines if this LinesMesh supports vertex color
  17437. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17438. */
  17439. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17440. /**
  17441. * If vertex color should be applied to the mesh
  17442. */
  17443. useVertexColor?: boolean | undefined,
  17444. /**
  17445. * If vertex alpha should be applied to the mesh
  17446. */
  17447. useVertexAlpha?: boolean | undefined);
  17448. private _addClipPlaneDefine;
  17449. private _removeClipPlaneDefine;
  17450. isReady(): boolean;
  17451. /**
  17452. * Returns the string "LineMesh"
  17453. */
  17454. getClassName(): string;
  17455. /**
  17456. * @hidden
  17457. */
  17458. get material(): Material;
  17459. /**
  17460. * @hidden
  17461. */
  17462. set material(value: Material);
  17463. /**
  17464. * @hidden
  17465. */
  17466. get checkCollisions(): boolean;
  17467. /** @hidden */
  17468. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17469. /** @hidden */
  17470. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17471. /**
  17472. * Disposes of the line mesh
  17473. * @param doNotRecurse If children should be disposed
  17474. */
  17475. dispose(doNotRecurse?: boolean): void;
  17476. /**
  17477. * Returns a new LineMesh object cloned from the current one.
  17478. */
  17479. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17480. /**
  17481. * Creates a new InstancedLinesMesh object from the mesh model.
  17482. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17483. * @param name defines the name of the new instance
  17484. * @returns a new InstancedLinesMesh
  17485. */
  17486. createInstance(name: string): InstancedLinesMesh;
  17487. }
  17488. /**
  17489. * Creates an instance based on a source LinesMesh
  17490. */
  17491. export class InstancedLinesMesh extends InstancedMesh {
  17492. /**
  17493. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17494. * This margin is expressed in world space coordinates, so its value may vary.
  17495. * Initilized with the intersectionThreshold value of the source LinesMesh
  17496. */
  17497. intersectionThreshold: number;
  17498. constructor(name: string, source: LinesMesh);
  17499. /**
  17500. * Returns the string "InstancedLinesMesh".
  17501. */
  17502. getClassName(): string;
  17503. }
  17504. }
  17505. declare module "babylonjs/Shaders/line.fragment" {
  17506. /** @hidden */
  17507. export var linePixelShader: {
  17508. name: string;
  17509. shader: string;
  17510. };
  17511. }
  17512. declare module "babylonjs/Shaders/line.vertex" {
  17513. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17514. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17515. /** @hidden */
  17516. export var lineVertexShader: {
  17517. name: string;
  17518. shader: string;
  17519. };
  17520. }
  17521. declare module "babylonjs/Rendering/edgesRenderer" {
  17522. import { Nullable } from "babylonjs/types";
  17523. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17525. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17526. import { IDisposable } from "babylonjs/scene";
  17527. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17528. import "babylonjs/Shaders/line.fragment";
  17529. import "babylonjs/Shaders/line.vertex";
  17530. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17531. import { SmartArray } from "babylonjs/Misc/smartArray";
  17532. module "babylonjs/scene" {
  17533. interface Scene {
  17534. /** @hidden */
  17535. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17536. }
  17537. }
  17538. module "babylonjs/Meshes/abstractMesh" {
  17539. interface AbstractMesh {
  17540. /**
  17541. * Gets the edgesRenderer associated with the mesh
  17542. */
  17543. edgesRenderer: Nullable<EdgesRenderer>;
  17544. }
  17545. }
  17546. module "babylonjs/Meshes/linesMesh" {
  17547. interface LinesMesh {
  17548. /**
  17549. * Enables the edge rendering mode on the mesh.
  17550. * This mode makes the mesh edges visible
  17551. * @param epsilon defines the maximal distance between two angles to detect a face
  17552. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17553. * @returns the currentAbstractMesh
  17554. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17555. */
  17556. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17557. }
  17558. }
  17559. module "babylonjs/Meshes/linesMesh" {
  17560. interface InstancedLinesMesh {
  17561. /**
  17562. * Enables the edge rendering mode on the mesh.
  17563. * This mode makes the mesh edges visible
  17564. * @param epsilon defines the maximal distance between two angles to detect a face
  17565. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17566. * @returns the current InstancedLinesMesh
  17567. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17568. */
  17569. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17570. }
  17571. }
  17572. /**
  17573. * Defines the minimum contract an Edges renderer should follow.
  17574. */
  17575. export interface IEdgesRenderer extends IDisposable {
  17576. /**
  17577. * Gets or sets a boolean indicating if the edgesRenderer is active
  17578. */
  17579. isEnabled: boolean;
  17580. /**
  17581. * Renders the edges of the attached mesh,
  17582. */
  17583. render(): void;
  17584. /**
  17585. * Checks wether or not the edges renderer is ready to render.
  17586. * @return true if ready, otherwise false.
  17587. */
  17588. isReady(): boolean;
  17589. /**
  17590. * List of instances to render in case the source mesh has instances
  17591. */
  17592. customInstances: SmartArray<Matrix>;
  17593. }
  17594. /**
  17595. * Defines the additional options of the edges renderer
  17596. */
  17597. export interface IEdgesRendererOptions {
  17598. /**
  17599. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17600. * If not defined, the default value is true
  17601. */
  17602. useAlternateEdgeFinder?: boolean;
  17603. /**
  17604. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17605. * If not defined, the default value is true.
  17606. * 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)
  17607. * This option is used only if useAlternateEdgeFinder = true
  17608. */
  17609. useFastVertexMerger?: boolean;
  17610. /**
  17611. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17612. * The default value is 1e-6
  17613. * This option is used only if useAlternateEdgeFinder = true
  17614. */
  17615. epsilonVertexMerge?: number;
  17616. /**
  17617. * 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
  17618. * 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.
  17619. * This option is used only if useAlternateEdgeFinder = true
  17620. */
  17621. applyTessellation?: boolean;
  17622. /**
  17623. * 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
  17624. * The default value is 1e-6
  17625. * This option is used only if useAlternateEdgeFinder = true
  17626. */
  17627. epsilonVertexAligned?: number;
  17628. }
  17629. /**
  17630. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17631. */
  17632. export class EdgesRenderer implements IEdgesRenderer {
  17633. /**
  17634. * Define the size of the edges with an orthographic camera
  17635. */
  17636. edgesWidthScalerForOrthographic: number;
  17637. /**
  17638. * Define the size of the edges with a perspective camera
  17639. */
  17640. edgesWidthScalerForPerspective: number;
  17641. protected _source: AbstractMesh;
  17642. protected _linesPositions: number[];
  17643. protected _linesNormals: number[];
  17644. protected _linesIndices: number[];
  17645. protected _epsilon: number;
  17646. protected _indicesCount: number;
  17647. protected _lineShader: ShaderMaterial;
  17648. protected _ib: DataBuffer;
  17649. protected _buffers: {
  17650. [key: string]: Nullable<VertexBuffer>;
  17651. };
  17652. protected _buffersForInstances: {
  17653. [key: string]: Nullable<VertexBuffer>;
  17654. };
  17655. protected _checkVerticesInsteadOfIndices: boolean;
  17656. protected _options: Nullable<IEdgesRendererOptions>;
  17657. private _meshRebuildObserver;
  17658. private _meshDisposeObserver;
  17659. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17660. isEnabled: boolean;
  17661. /**
  17662. * List of instances to render in case the source mesh has instances
  17663. */
  17664. customInstances: SmartArray<Matrix>;
  17665. private static GetShader;
  17666. /**
  17667. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17668. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17669. * @param source Mesh used to create edges
  17670. * @param epsilon sum of angles in adjacency to check for edge
  17671. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17672. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17673. * @param options The options to apply when generating the edges
  17674. */
  17675. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17676. protected _prepareRessources(): void;
  17677. /** @hidden */
  17678. _rebuild(): void;
  17679. /**
  17680. * Releases the required resources for the edges renderer
  17681. */
  17682. dispose(): void;
  17683. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17684. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17685. /**
  17686. * Checks if the pair of p0 and p1 is en edge
  17687. * @param faceIndex
  17688. * @param edge
  17689. * @param faceNormals
  17690. * @param p0
  17691. * @param p1
  17692. * @private
  17693. */
  17694. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17695. /**
  17696. * push line into the position, normal and index buffer
  17697. * @protected
  17698. */
  17699. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17700. /**
  17701. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17702. */
  17703. private _tessellateTriangle;
  17704. private _generateEdgesLinesAlternate;
  17705. /**
  17706. * Generates lines edges from adjacencjes
  17707. * @private
  17708. */
  17709. _generateEdgesLines(): void;
  17710. /**
  17711. * Checks wether or not the edges renderer is ready to render.
  17712. * @return true if ready, otherwise false.
  17713. */
  17714. isReady(): boolean;
  17715. /**
  17716. * Renders the edges of the attached mesh,
  17717. */
  17718. render(): void;
  17719. }
  17720. /**
  17721. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17722. */
  17723. export class LineEdgesRenderer extends EdgesRenderer {
  17724. /**
  17725. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17726. * @param source LineMesh used to generate edges
  17727. * @param epsilon not important (specified angle for edge detection)
  17728. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17729. */
  17730. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17731. /**
  17732. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17733. */
  17734. _generateEdgesLines(): void;
  17735. }
  17736. }
  17737. declare module "babylonjs/Rendering/renderingGroup" {
  17738. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17739. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17741. import { Nullable } from "babylonjs/types";
  17742. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17743. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17744. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17745. import { Material } from "babylonjs/Materials/material";
  17746. import { Scene } from "babylonjs/scene";
  17747. /**
  17748. * This represents the object necessary to create a rendering group.
  17749. * This is exclusively used and created by the rendering manager.
  17750. * To modify the behavior, you use the available helpers in your scene or meshes.
  17751. * @hidden
  17752. */
  17753. export class RenderingGroup {
  17754. index: number;
  17755. private static _zeroVector;
  17756. private _scene;
  17757. private _opaqueSubMeshes;
  17758. private _transparentSubMeshes;
  17759. private _alphaTestSubMeshes;
  17760. private _depthOnlySubMeshes;
  17761. private _particleSystems;
  17762. private _spriteManagers;
  17763. private _opaqueSortCompareFn;
  17764. private _alphaTestSortCompareFn;
  17765. private _transparentSortCompareFn;
  17766. private _renderOpaque;
  17767. private _renderAlphaTest;
  17768. private _renderTransparent;
  17769. /** @hidden */
  17770. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17771. onBeforeTransparentRendering: () => void;
  17772. /**
  17773. * Set the opaque sort comparison function.
  17774. * If null the sub meshes will be render in the order they were created
  17775. */
  17776. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17777. /**
  17778. * Set the alpha test sort comparison function.
  17779. * If null the sub meshes will be render in the order they were created
  17780. */
  17781. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17782. /**
  17783. * Set the transparent sort comparison function.
  17784. * If null the sub meshes will be render in the order they were created
  17785. */
  17786. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17787. /**
  17788. * Creates a new rendering group.
  17789. * @param index The rendering group index
  17790. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17791. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17792. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17793. */
  17794. 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>);
  17795. /**
  17796. * Render all the sub meshes contained in the group.
  17797. * @param customRenderFunction Used to override the default render behaviour of the group.
  17798. * @returns true if rendered some submeshes.
  17799. */
  17800. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17801. /**
  17802. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17803. * @param subMeshes The submeshes to render
  17804. */
  17805. private renderOpaqueSorted;
  17806. /**
  17807. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17808. * @param subMeshes The submeshes to render
  17809. */
  17810. private renderAlphaTestSorted;
  17811. /**
  17812. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17813. * @param subMeshes The submeshes to render
  17814. */
  17815. private renderTransparentSorted;
  17816. /**
  17817. * Renders the submeshes in a specified order.
  17818. * @param subMeshes The submeshes to sort before render
  17819. * @param sortCompareFn The comparison function use to sort
  17820. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17821. * @param transparent Specifies to activate blending if true
  17822. */
  17823. private static renderSorted;
  17824. /**
  17825. * Renders the submeshes in the order they were dispatched (no sort applied).
  17826. * @param subMeshes The submeshes to render
  17827. */
  17828. private static renderUnsorted;
  17829. /**
  17830. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17831. * are rendered back to front if in the same alpha index.
  17832. *
  17833. * @param a The first submesh
  17834. * @param b The second submesh
  17835. * @returns The result of the comparison
  17836. */
  17837. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17838. /**
  17839. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17840. * are rendered back to front.
  17841. *
  17842. * @param a The first submesh
  17843. * @param b The second submesh
  17844. * @returns The result of the comparison
  17845. */
  17846. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17847. /**
  17848. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17849. * are rendered front to back (prevent overdraw).
  17850. *
  17851. * @param a The first submesh
  17852. * @param b The second submesh
  17853. * @returns The result of the comparison
  17854. */
  17855. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17856. /**
  17857. * Resets the different lists of submeshes to prepare a new frame.
  17858. */
  17859. prepare(): void;
  17860. dispose(): void;
  17861. /**
  17862. * Inserts the submesh in its correct queue depending on its material.
  17863. * @param subMesh The submesh to dispatch
  17864. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17865. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17866. */
  17867. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17868. dispatchSprites(spriteManager: ISpriteManager): void;
  17869. dispatchParticles(particleSystem: IParticleSystem): void;
  17870. private _renderParticles;
  17871. private _renderSprites;
  17872. }
  17873. }
  17874. declare module "babylonjs/Rendering/renderingManager" {
  17875. import { Nullable } from "babylonjs/types";
  17876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17877. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17878. import { SmartArray } from "babylonjs/Misc/smartArray";
  17879. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17880. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17881. import { Material } from "babylonjs/Materials/material";
  17882. import { Scene } from "babylonjs/scene";
  17883. import { Camera } from "babylonjs/Cameras/camera";
  17884. /**
  17885. * Interface describing the different options available in the rendering manager
  17886. * regarding Auto Clear between groups.
  17887. */
  17888. export interface IRenderingManagerAutoClearSetup {
  17889. /**
  17890. * Defines whether or not autoclear is enable.
  17891. */
  17892. autoClear: boolean;
  17893. /**
  17894. * Defines whether or not to autoclear the depth buffer.
  17895. */
  17896. depth: boolean;
  17897. /**
  17898. * Defines whether or not to autoclear the stencil buffer.
  17899. */
  17900. stencil: boolean;
  17901. }
  17902. /**
  17903. * This class is used by the onRenderingGroupObservable
  17904. */
  17905. export class RenderingGroupInfo {
  17906. /**
  17907. * The Scene that being rendered
  17908. */
  17909. scene: Scene;
  17910. /**
  17911. * The camera currently used for the rendering pass
  17912. */
  17913. camera: Nullable<Camera>;
  17914. /**
  17915. * The ID of the renderingGroup being processed
  17916. */
  17917. renderingGroupId: number;
  17918. }
  17919. /**
  17920. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17921. * It is enable to manage the different groups as well as the different necessary sort functions.
  17922. * This should not be used directly aside of the few static configurations
  17923. */
  17924. export class RenderingManager {
  17925. /**
  17926. * The max id used for rendering groups (not included)
  17927. */
  17928. static MAX_RENDERINGGROUPS: number;
  17929. /**
  17930. * The min id used for rendering groups (included)
  17931. */
  17932. static MIN_RENDERINGGROUPS: number;
  17933. /**
  17934. * Used to globally prevent autoclearing scenes.
  17935. */
  17936. static AUTOCLEAR: boolean;
  17937. /**
  17938. * @hidden
  17939. */
  17940. _useSceneAutoClearSetup: boolean;
  17941. private _scene;
  17942. private _renderingGroups;
  17943. private _depthStencilBufferAlreadyCleaned;
  17944. private _autoClearDepthStencil;
  17945. private _customOpaqueSortCompareFn;
  17946. private _customAlphaTestSortCompareFn;
  17947. private _customTransparentSortCompareFn;
  17948. private _renderingGroupInfo;
  17949. /**
  17950. * Instantiates a new rendering group for a particular scene
  17951. * @param scene Defines the scene the groups belongs to
  17952. */
  17953. constructor(scene: Scene);
  17954. private _clearDepthStencilBuffer;
  17955. /**
  17956. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17957. * @hidden
  17958. */
  17959. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17960. /**
  17961. * Resets the different information of the group to prepare a new frame
  17962. * @hidden
  17963. */
  17964. reset(): void;
  17965. /**
  17966. * Dispose and release the group and its associated resources.
  17967. * @hidden
  17968. */
  17969. dispose(): void;
  17970. /**
  17971. * Clear the info related to rendering groups preventing retention points during dispose.
  17972. */
  17973. freeRenderingGroups(): void;
  17974. private _prepareRenderingGroup;
  17975. /**
  17976. * Add a sprite manager to the rendering manager in order to render it this frame.
  17977. * @param spriteManager Define the sprite manager to render
  17978. */
  17979. dispatchSprites(spriteManager: ISpriteManager): void;
  17980. /**
  17981. * Add a particle system to the rendering manager in order to render it this frame.
  17982. * @param particleSystem Define the particle system to render
  17983. */
  17984. dispatchParticles(particleSystem: IParticleSystem): void;
  17985. /**
  17986. * Add a submesh to the manager in order to render it this frame
  17987. * @param subMesh The submesh to dispatch
  17988. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17989. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17990. */
  17991. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17992. /**
  17993. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17994. * This allowed control for front to back rendering or reversly depending of the special needs.
  17995. *
  17996. * @param renderingGroupId The rendering group id corresponding to its index
  17997. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17998. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17999. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18000. */
  18001. 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;
  18002. /**
  18003. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18004. *
  18005. * @param renderingGroupId The rendering group id corresponding to its index
  18006. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18007. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18008. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18009. */
  18010. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18011. /**
  18012. * Gets the current auto clear configuration for one rendering group of the rendering
  18013. * manager.
  18014. * @param index the rendering group index to get the information for
  18015. * @returns The auto clear setup for the requested rendering group
  18016. */
  18017. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18018. }
  18019. }
  18020. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  18021. import { SmartArray } from "babylonjs/Misc/smartArray";
  18022. import { Nullable } from "babylonjs/types";
  18023. import { Scene } from "babylonjs/scene";
  18024. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  18025. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18027. import { Mesh } from "babylonjs/Meshes/mesh";
  18028. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  18029. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18030. import { Effect } from "babylonjs/Materials/effect";
  18031. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18032. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18033. import "babylonjs/Shaders/shadowMap.fragment";
  18034. import "babylonjs/Shaders/shadowMap.vertex";
  18035. import "babylonjs/Shaders/depthBoxBlur.fragment";
  18036. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  18037. import { Observable } from "babylonjs/Misc/observable";
  18038. /**
  18039. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18040. */
  18041. export interface ICustomShaderOptions {
  18042. /**
  18043. * Gets or sets the custom shader name to use
  18044. */
  18045. shaderName: string;
  18046. /**
  18047. * The list of attribute names used in the shader
  18048. */
  18049. attributes?: string[];
  18050. /**
  18051. * The list of unifrom names used in the shader
  18052. */
  18053. uniforms?: string[];
  18054. /**
  18055. * The list of sampler names used in the shader
  18056. */
  18057. samplers?: string[];
  18058. /**
  18059. * The list of defines used in the shader
  18060. */
  18061. defines?: string[];
  18062. }
  18063. /**
  18064. * Interface to implement to create a shadow generator compatible with BJS.
  18065. */
  18066. export interface IShadowGenerator {
  18067. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18068. id: string;
  18069. /**
  18070. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18071. * @returns The render target texture if present otherwise, null
  18072. */
  18073. getShadowMap(): Nullable<RenderTargetTexture>;
  18074. /**
  18075. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18076. * @param subMesh The submesh we want to render in the shadow map
  18077. * @param useInstances Defines wether will draw in the map using instances
  18078. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18079. * @returns true if ready otherwise, false
  18080. */
  18081. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18082. /**
  18083. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18084. * @param defines Defines of the material we want to update
  18085. * @param lightIndex Index of the light in the enabled light list of the material
  18086. */
  18087. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18088. /**
  18089. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18090. * defined in the generator but impacting the effect).
  18091. * It implies the unifroms available on the materials are the standard BJS ones.
  18092. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18093. * @param effect The effect we are binfing the information for
  18094. */
  18095. bindShadowLight(lightIndex: string, effect: Effect): void;
  18096. /**
  18097. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18098. * (eq to shadow prjection matrix * light transform matrix)
  18099. * @returns The transform matrix used to create the shadow map
  18100. */
  18101. getTransformMatrix(): Matrix;
  18102. /**
  18103. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18104. * Cube and 2D textures for instance.
  18105. */
  18106. recreateShadowMap(): void;
  18107. /**
  18108. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18109. * @param onCompiled Callback triggered at the and of the effects compilation
  18110. * @param options Sets of optional options forcing the compilation with different modes
  18111. */
  18112. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18113. useInstances: boolean;
  18114. }>): void;
  18115. /**
  18116. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18117. * @param options Sets of optional options forcing the compilation with different modes
  18118. * @returns A promise that resolves when the compilation completes
  18119. */
  18120. forceCompilationAsync(options?: Partial<{
  18121. useInstances: boolean;
  18122. }>): Promise<void>;
  18123. /**
  18124. * Serializes the shadow generator setup to a json object.
  18125. * @returns The serialized JSON object
  18126. */
  18127. serialize(): any;
  18128. /**
  18129. * Disposes the Shadow map and related Textures and effects.
  18130. */
  18131. dispose(): void;
  18132. }
  18133. /**
  18134. * Default implementation IShadowGenerator.
  18135. * This is the main object responsible of generating shadows in the framework.
  18136. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18137. */
  18138. export class ShadowGenerator implements IShadowGenerator {
  18139. /**
  18140. * Name of the shadow generator class
  18141. */
  18142. static CLASSNAME: string;
  18143. /**
  18144. * Shadow generator mode None: no filtering applied.
  18145. */
  18146. static readonly FILTER_NONE: number;
  18147. /**
  18148. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18149. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18150. */
  18151. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18152. /**
  18153. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18154. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18155. */
  18156. static readonly FILTER_POISSONSAMPLING: number;
  18157. /**
  18158. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18159. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18160. */
  18161. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18162. /**
  18163. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18164. * edge artifacts on steep falloff.
  18165. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18166. */
  18167. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18168. /**
  18169. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18170. * edge artifacts on steep falloff.
  18171. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18172. */
  18173. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18174. /**
  18175. * Shadow generator mode PCF: Percentage Closer Filtering
  18176. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18177. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18178. */
  18179. static readonly FILTER_PCF: number;
  18180. /**
  18181. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18182. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18183. * Contact Hardening
  18184. */
  18185. static readonly FILTER_PCSS: number;
  18186. /**
  18187. * Reserved for PCF and PCSS
  18188. * Highest Quality.
  18189. *
  18190. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18191. *
  18192. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18193. */
  18194. static readonly QUALITY_HIGH: number;
  18195. /**
  18196. * Reserved for PCF and PCSS
  18197. * Good tradeoff for quality/perf cross devices
  18198. *
  18199. * Execute PCF on a 3*3 kernel.
  18200. *
  18201. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18202. */
  18203. static readonly QUALITY_MEDIUM: number;
  18204. /**
  18205. * Reserved for PCF and PCSS
  18206. * The lowest quality but the fastest.
  18207. *
  18208. * Execute PCF on a 1*1 kernel.
  18209. *
  18210. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18211. */
  18212. static readonly QUALITY_LOW: number;
  18213. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18214. id: string;
  18215. /** Gets or sets the custom shader name to use */
  18216. customShaderOptions: ICustomShaderOptions;
  18217. /**
  18218. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18219. */
  18220. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18221. /**
  18222. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18223. */
  18224. onAfterShadowMapRenderObservable: Observable<Effect>;
  18225. /**
  18226. * Observable triggered before a mesh is rendered in the shadow map.
  18227. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18228. */
  18229. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18230. /**
  18231. * Observable triggered after a mesh is rendered in the shadow map.
  18232. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18233. */
  18234. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18235. protected _bias: number;
  18236. /**
  18237. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18238. */
  18239. get bias(): number;
  18240. /**
  18241. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18242. */
  18243. set bias(bias: number);
  18244. protected _normalBias: number;
  18245. /**
  18246. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18247. */
  18248. get normalBias(): number;
  18249. /**
  18250. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18251. */
  18252. set normalBias(normalBias: number);
  18253. protected _blurBoxOffset: number;
  18254. /**
  18255. * Gets the blur box offset: offset applied during the blur pass.
  18256. * Only useful if useKernelBlur = false
  18257. */
  18258. get blurBoxOffset(): number;
  18259. /**
  18260. * Sets the blur box offset: offset applied during the blur pass.
  18261. * Only useful if useKernelBlur = false
  18262. */
  18263. set blurBoxOffset(value: number);
  18264. protected _blurScale: number;
  18265. /**
  18266. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18267. * 2 means half of the size.
  18268. */
  18269. get blurScale(): number;
  18270. /**
  18271. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18272. * 2 means half of the size.
  18273. */
  18274. set blurScale(value: number);
  18275. protected _blurKernel: number;
  18276. /**
  18277. * Gets the blur kernel: kernel size of the blur pass.
  18278. * Only useful if useKernelBlur = true
  18279. */
  18280. get blurKernel(): number;
  18281. /**
  18282. * Sets the blur kernel: kernel size of the blur pass.
  18283. * Only useful if useKernelBlur = true
  18284. */
  18285. set blurKernel(value: number);
  18286. protected _useKernelBlur: boolean;
  18287. /**
  18288. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18289. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18290. */
  18291. get useKernelBlur(): boolean;
  18292. /**
  18293. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18294. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18295. */
  18296. set useKernelBlur(value: boolean);
  18297. protected _depthScale: number;
  18298. /**
  18299. * Gets the depth scale used in ESM mode.
  18300. */
  18301. get depthScale(): number;
  18302. /**
  18303. * Sets the depth scale used in ESM mode.
  18304. * This can override the scale stored on the light.
  18305. */
  18306. set depthScale(value: number);
  18307. protected _validateFilter(filter: number): number;
  18308. protected _filter: number;
  18309. /**
  18310. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18311. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18312. */
  18313. get filter(): number;
  18314. /**
  18315. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18316. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18317. */
  18318. set filter(value: number);
  18319. /**
  18320. * Gets if the current filter is set to Poisson Sampling.
  18321. */
  18322. get usePoissonSampling(): boolean;
  18323. /**
  18324. * Sets the current filter to Poisson Sampling.
  18325. */
  18326. set usePoissonSampling(value: boolean);
  18327. /**
  18328. * Gets if the current filter is set to ESM.
  18329. */
  18330. get useExponentialShadowMap(): boolean;
  18331. /**
  18332. * Sets the current filter is to ESM.
  18333. */
  18334. set useExponentialShadowMap(value: boolean);
  18335. /**
  18336. * Gets if the current filter is set to filtered ESM.
  18337. */
  18338. get useBlurExponentialShadowMap(): boolean;
  18339. /**
  18340. * Gets if the current filter is set to filtered ESM.
  18341. */
  18342. set useBlurExponentialShadowMap(value: boolean);
  18343. /**
  18344. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18345. * exponential to prevent steep falloff artifacts).
  18346. */
  18347. get useCloseExponentialShadowMap(): boolean;
  18348. /**
  18349. * Sets the current filter to "close ESM" (using the inverse of the
  18350. * exponential to prevent steep falloff artifacts).
  18351. */
  18352. set useCloseExponentialShadowMap(value: boolean);
  18353. /**
  18354. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18355. * exponential to prevent steep falloff artifacts).
  18356. */
  18357. get useBlurCloseExponentialShadowMap(): boolean;
  18358. /**
  18359. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18360. * exponential to prevent steep falloff artifacts).
  18361. */
  18362. set useBlurCloseExponentialShadowMap(value: boolean);
  18363. /**
  18364. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18365. */
  18366. get usePercentageCloserFiltering(): boolean;
  18367. /**
  18368. * Sets the current filter to "PCF" (percentage closer filtering).
  18369. */
  18370. set usePercentageCloserFiltering(value: boolean);
  18371. protected _filteringQuality: number;
  18372. /**
  18373. * Gets the PCF or PCSS Quality.
  18374. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18375. */
  18376. get filteringQuality(): number;
  18377. /**
  18378. * Sets the PCF or PCSS Quality.
  18379. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18380. */
  18381. set filteringQuality(filteringQuality: number);
  18382. /**
  18383. * Gets if the current filter is set to "PCSS" (contact hardening).
  18384. */
  18385. get useContactHardeningShadow(): boolean;
  18386. /**
  18387. * Sets the current filter to "PCSS" (contact hardening).
  18388. */
  18389. set useContactHardeningShadow(value: boolean);
  18390. protected _contactHardeningLightSizeUVRatio: number;
  18391. /**
  18392. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18393. * Using a ratio helps keeping shape stability independently of the map size.
  18394. *
  18395. * It does not account for the light projection as it was having too much
  18396. * instability during the light setup or during light position changes.
  18397. *
  18398. * Only valid if useContactHardeningShadow is true.
  18399. */
  18400. get contactHardeningLightSizeUVRatio(): number;
  18401. /**
  18402. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18403. * Using a ratio helps keeping shape stability independently of the map size.
  18404. *
  18405. * It does not account for the light projection as it was having too much
  18406. * instability during the light setup or during light position changes.
  18407. *
  18408. * Only valid if useContactHardeningShadow is true.
  18409. */
  18410. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18411. protected _darkness: number;
  18412. /** Gets or sets the actual darkness of a shadow */
  18413. get darkness(): number;
  18414. set darkness(value: number);
  18415. /**
  18416. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18417. * 0 means strongest and 1 would means no shadow.
  18418. * @returns the darkness.
  18419. */
  18420. getDarkness(): number;
  18421. /**
  18422. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18423. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18424. * @returns the shadow generator allowing fluent coding.
  18425. */
  18426. setDarkness(darkness: number): ShadowGenerator;
  18427. protected _transparencyShadow: boolean;
  18428. /** Gets or sets the ability to have transparent shadow */
  18429. get transparencyShadow(): boolean;
  18430. set transparencyShadow(value: boolean);
  18431. /**
  18432. * Sets the ability to have transparent shadow (boolean).
  18433. * @param transparent True if transparent else False
  18434. * @returns the shadow generator allowing fluent coding
  18435. */
  18436. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18437. /**
  18438. * Enables or disables shadows with varying strength based on the transparency
  18439. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18440. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18441. * mesh.visibility * alphaTexture.a
  18442. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18443. */
  18444. enableSoftTransparentShadow: boolean;
  18445. protected _shadowMap: Nullable<RenderTargetTexture>;
  18446. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18447. /**
  18448. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18449. * @returns The render target texture if present otherwise, null
  18450. */
  18451. getShadowMap(): Nullable<RenderTargetTexture>;
  18452. /**
  18453. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18454. * @returns The render target texture if the shadow map is present otherwise, null
  18455. */
  18456. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18457. /**
  18458. * Gets the class name of that object
  18459. * @returns "ShadowGenerator"
  18460. */
  18461. getClassName(): string;
  18462. /**
  18463. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18464. * @param mesh Mesh to add
  18465. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18466. * @returns the Shadow Generator itself
  18467. */
  18468. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18469. /**
  18470. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18471. * @param mesh Mesh to remove
  18472. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18473. * @returns the Shadow Generator itself
  18474. */
  18475. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18476. /**
  18477. * Controls the extent to which the shadows fade out at the edge of the frustum
  18478. */
  18479. frustumEdgeFalloff: number;
  18480. protected _light: IShadowLight;
  18481. /**
  18482. * Returns the associated light object.
  18483. * @returns the light generating the shadow
  18484. */
  18485. getLight(): IShadowLight;
  18486. /**
  18487. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18488. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18489. * It might on the other hand introduce peter panning.
  18490. */
  18491. forceBackFacesOnly: boolean;
  18492. protected _scene: Scene;
  18493. protected _lightDirection: Vector3;
  18494. protected _effect: Effect;
  18495. protected _viewMatrix: Matrix;
  18496. protected _projectionMatrix: Matrix;
  18497. protected _transformMatrix: Matrix;
  18498. protected _cachedPosition: Vector3;
  18499. protected _cachedDirection: Vector3;
  18500. protected _cachedDefines: string;
  18501. protected _currentRenderID: number;
  18502. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18503. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18504. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18505. protected _blurPostProcesses: PostProcess[];
  18506. protected _mapSize: number;
  18507. protected _currentFaceIndex: number;
  18508. protected _currentFaceIndexCache: number;
  18509. protected _textureType: number;
  18510. protected _defaultTextureMatrix: Matrix;
  18511. protected _storedUniqueId: Nullable<number>;
  18512. /** @hidden */
  18513. static _SceneComponentInitialization: (scene: Scene) => void;
  18514. /**
  18515. * Gets or sets the size of the texture what stores the shadows
  18516. */
  18517. get mapSize(): number;
  18518. set mapSize(size: number);
  18519. /**
  18520. * Creates a ShadowGenerator object.
  18521. * A ShadowGenerator is the required tool to use the shadows.
  18522. * Each light casting shadows needs to use its own ShadowGenerator.
  18523. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18524. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18525. * @param light The light object generating the shadows.
  18526. * @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.
  18527. */
  18528. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18529. protected _initializeGenerator(): void;
  18530. protected _createTargetRenderTexture(): void;
  18531. protected _initializeShadowMap(): void;
  18532. protected _initializeBlurRTTAndPostProcesses(): void;
  18533. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18534. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18535. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18536. protected _applyFilterValues(): void;
  18537. /**
  18538. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18539. * @param onCompiled Callback triggered at the and of the effects compilation
  18540. * @param options Sets of optional options forcing the compilation with different modes
  18541. */
  18542. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18543. useInstances: boolean;
  18544. }>): void;
  18545. /**
  18546. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18547. * @param options Sets of optional options forcing the compilation with different modes
  18548. * @returns A promise that resolves when the compilation completes
  18549. */
  18550. forceCompilationAsync(options?: Partial<{
  18551. useInstances: boolean;
  18552. }>): Promise<void>;
  18553. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18554. private _prepareShadowDefines;
  18555. /**
  18556. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18557. * @param subMesh The submesh we want to render in the shadow map
  18558. * @param useInstances Defines wether will draw in the map using instances
  18559. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18560. * @returns true if ready otherwise, false
  18561. */
  18562. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18563. /**
  18564. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18565. * @param defines Defines of the material we want to update
  18566. * @param lightIndex Index of the light in the enabled light list of the material
  18567. */
  18568. prepareDefines(defines: any, lightIndex: number): void;
  18569. /**
  18570. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18571. * defined in the generator but impacting the effect).
  18572. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18573. * @param effect The effect we are binfing the information for
  18574. */
  18575. bindShadowLight(lightIndex: string, effect: Effect): void;
  18576. /**
  18577. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18578. * (eq to shadow prjection matrix * light transform matrix)
  18579. * @returns The transform matrix used to create the shadow map
  18580. */
  18581. getTransformMatrix(): Matrix;
  18582. /**
  18583. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18584. * Cube and 2D textures for instance.
  18585. */
  18586. recreateShadowMap(): void;
  18587. protected _disposeBlurPostProcesses(): void;
  18588. protected _disposeRTTandPostProcesses(): void;
  18589. /**
  18590. * Disposes the ShadowGenerator.
  18591. * Returns nothing.
  18592. */
  18593. dispose(): void;
  18594. /**
  18595. * Serializes the shadow generator setup to a json object.
  18596. * @returns The serialized JSON object
  18597. */
  18598. serialize(): any;
  18599. /**
  18600. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18601. * @param parsedShadowGenerator The JSON object to parse
  18602. * @param scene The scene to create the shadow map for
  18603. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18604. * @returns The parsed shadow generator
  18605. */
  18606. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18607. }
  18608. }
  18609. declare module "babylonjs/Lights/light" {
  18610. import { Nullable } from "babylonjs/types";
  18611. import { Scene } from "babylonjs/scene";
  18612. import { Vector3 } from "babylonjs/Maths/math.vector";
  18613. import { Color3 } from "babylonjs/Maths/math.color";
  18614. import { Node } from "babylonjs/node";
  18615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18616. import { Effect } from "babylonjs/Materials/effect";
  18617. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18618. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18619. /**
  18620. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18621. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18622. * 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.
  18623. */
  18624. export abstract class Light extends Node {
  18625. /**
  18626. * Falloff Default: light is falling off following the material specification:
  18627. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18628. */
  18629. static readonly FALLOFF_DEFAULT: number;
  18630. /**
  18631. * Falloff Physical: light is falling off following the inverse squared distance law.
  18632. */
  18633. static readonly FALLOFF_PHYSICAL: number;
  18634. /**
  18635. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18636. * to enhance interoperability with other engines.
  18637. */
  18638. static readonly FALLOFF_GLTF: number;
  18639. /**
  18640. * Falloff Standard: light is falling off like in the standard material
  18641. * to enhance interoperability with other materials.
  18642. */
  18643. static readonly FALLOFF_STANDARD: number;
  18644. /**
  18645. * If every light affecting the material is in this lightmapMode,
  18646. * material.lightmapTexture adds or multiplies
  18647. * (depends on material.useLightmapAsShadowmap)
  18648. * after every other light calculations.
  18649. */
  18650. static readonly LIGHTMAP_DEFAULT: number;
  18651. /**
  18652. * material.lightmapTexture as only diffuse lighting from this light
  18653. * adds only specular lighting from this light
  18654. * adds dynamic shadows
  18655. */
  18656. static readonly LIGHTMAP_SPECULAR: number;
  18657. /**
  18658. * material.lightmapTexture as only lighting
  18659. * no light calculation from this light
  18660. * only adds dynamic shadows from this light
  18661. */
  18662. static readonly LIGHTMAP_SHADOWSONLY: number;
  18663. /**
  18664. * Each light type uses the default quantity according to its type:
  18665. * point/spot lights use luminous intensity
  18666. * directional lights use illuminance
  18667. */
  18668. static readonly INTENSITYMODE_AUTOMATIC: number;
  18669. /**
  18670. * lumen (lm)
  18671. */
  18672. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18673. /**
  18674. * candela (lm/sr)
  18675. */
  18676. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18677. /**
  18678. * lux (lm/m^2)
  18679. */
  18680. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18681. /**
  18682. * nit (cd/m^2)
  18683. */
  18684. static readonly INTENSITYMODE_LUMINANCE: number;
  18685. /**
  18686. * Light type const id of the point light.
  18687. */
  18688. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18689. /**
  18690. * Light type const id of the directional light.
  18691. */
  18692. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18693. /**
  18694. * Light type const id of the spot light.
  18695. */
  18696. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18697. /**
  18698. * Light type const id of the hemispheric light.
  18699. */
  18700. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18701. /**
  18702. * Diffuse gives the basic color to an object.
  18703. */
  18704. diffuse: Color3;
  18705. /**
  18706. * Specular produces a highlight color on an object.
  18707. * Note: This is note affecting PBR materials.
  18708. */
  18709. specular: Color3;
  18710. /**
  18711. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18712. * falling off base on range or angle.
  18713. * This can be set to any values in Light.FALLOFF_x.
  18714. *
  18715. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18716. * other types of materials.
  18717. */
  18718. falloffType: number;
  18719. /**
  18720. * Strength of the light.
  18721. * Note: By default it is define in the framework own unit.
  18722. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18723. */
  18724. intensity: number;
  18725. private _range;
  18726. protected _inverseSquaredRange: number;
  18727. /**
  18728. * Defines how far from the source the light is impacting in scene units.
  18729. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18730. */
  18731. get range(): number;
  18732. /**
  18733. * Defines how far from the source the light is impacting in scene units.
  18734. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18735. */
  18736. set range(value: number);
  18737. /**
  18738. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18739. * of light.
  18740. */
  18741. private _photometricScale;
  18742. private _intensityMode;
  18743. /**
  18744. * Gets the photometric scale used to interpret the intensity.
  18745. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18746. */
  18747. get intensityMode(): number;
  18748. /**
  18749. * Sets the photometric scale used to interpret the intensity.
  18750. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18751. */
  18752. set intensityMode(value: number);
  18753. private _radius;
  18754. /**
  18755. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18756. */
  18757. get radius(): number;
  18758. /**
  18759. * sets the light radius used by PBR Materials to simulate soft area lights.
  18760. */
  18761. set radius(value: number);
  18762. private _renderPriority;
  18763. /**
  18764. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18765. * exceeding the number allowed of the materials.
  18766. */
  18767. renderPriority: number;
  18768. private _shadowEnabled;
  18769. /**
  18770. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18771. * the current shadow generator.
  18772. */
  18773. get shadowEnabled(): boolean;
  18774. /**
  18775. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18776. * the current shadow generator.
  18777. */
  18778. set shadowEnabled(value: boolean);
  18779. private _includedOnlyMeshes;
  18780. /**
  18781. * Gets the only meshes impacted by this light.
  18782. */
  18783. get includedOnlyMeshes(): AbstractMesh[];
  18784. /**
  18785. * Sets the only meshes impacted by this light.
  18786. */
  18787. set includedOnlyMeshes(value: AbstractMesh[]);
  18788. private _excludedMeshes;
  18789. /**
  18790. * Gets the meshes not impacted by this light.
  18791. */
  18792. get excludedMeshes(): AbstractMesh[];
  18793. /**
  18794. * Sets the meshes not impacted by this light.
  18795. */
  18796. set excludedMeshes(value: AbstractMesh[]);
  18797. private _excludeWithLayerMask;
  18798. /**
  18799. * Gets the layer id use to find what meshes are not impacted by the light.
  18800. * Inactive if 0
  18801. */
  18802. get excludeWithLayerMask(): number;
  18803. /**
  18804. * Sets the layer id use to find what meshes are not impacted by the light.
  18805. * Inactive if 0
  18806. */
  18807. set excludeWithLayerMask(value: number);
  18808. private _includeOnlyWithLayerMask;
  18809. /**
  18810. * Gets the layer id use to find what meshes are impacted by the light.
  18811. * Inactive if 0
  18812. */
  18813. get includeOnlyWithLayerMask(): number;
  18814. /**
  18815. * Sets the layer id use to find what meshes are impacted by the light.
  18816. * Inactive if 0
  18817. */
  18818. set includeOnlyWithLayerMask(value: number);
  18819. private _lightmapMode;
  18820. /**
  18821. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18822. */
  18823. get lightmapMode(): number;
  18824. /**
  18825. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18826. */
  18827. set lightmapMode(value: number);
  18828. /**
  18829. * Shadow generator associted to the light.
  18830. * @hidden Internal use only.
  18831. */
  18832. _shadowGenerator: Nullable<IShadowGenerator>;
  18833. /**
  18834. * @hidden Internal use only.
  18835. */
  18836. _excludedMeshesIds: string[];
  18837. /**
  18838. * @hidden Internal use only.
  18839. */
  18840. _includedOnlyMeshesIds: string[];
  18841. /**
  18842. * The current light unifom buffer.
  18843. * @hidden Internal use only.
  18844. */
  18845. _uniformBuffer: UniformBuffer;
  18846. /** @hidden */
  18847. _renderId: number;
  18848. /**
  18849. * Creates a Light object in the scene.
  18850. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18851. * @param name The firendly name of the light
  18852. * @param scene The scene the light belongs too
  18853. */
  18854. constructor(name: string, scene: Scene);
  18855. protected abstract _buildUniformLayout(): void;
  18856. /**
  18857. * Sets the passed Effect "effect" with the Light information.
  18858. * @param effect The effect to update
  18859. * @param lightIndex The index of the light in the effect to update
  18860. * @returns The light
  18861. */
  18862. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18863. /**
  18864. * Sets the passed Effect "effect" with the Light textures.
  18865. * @param effect The effect to update
  18866. * @param lightIndex The index of the light in the effect to update
  18867. * @returns The light
  18868. */
  18869. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18870. /**
  18871. * Binds the lights information from the scene to the effect for the given mesh.
  18872. * @param lightIndex Light index
  18873. * @param scene The scene where the light belongs to
  18874. * @param effect The effect we are binding the data to
  18875. * @param useSpecular Defines if specular is supported
  18876. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18877. */
  18878. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18879. /**
  18880. * Sets the passed Effect "effect" with the Light information.
  18881. * @param effect The effect to update
  18882. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18883. * @returns The light
  18884. */
  18885. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18886. /**
  18887. * Returns the string "Light".
  18888. * @returns the class name
  18889. */
  18890. getClassName(): string;
  18891. /** @hidden */
  18892. readonly _isLight: boolean;
  18893. /**
  18894. * Converts the light information to a readable string for debug purpose.
  18895. * @param fullDetails Supports for multiple levels of logging within scene loading
  18896. * @returns the human readable light info
  18897. */
  18898. toString(fullDetails?: boolean): string;
  18899. /** @hidden */
  18900. protected _syncParentEnabledState(): void;
  18901. /**
  18902. * Set the enabled state of this node.
  18903. * @param value - the new enabled state
  18904. */
  18905. setEnabled(value: boolean): void;
  18906. /**
  18907. * Returns the Light associated shadow generator if any.
  18908. * @return the associated shadow generator.
  18909. */
  18910. getShadowGenerator(): Nullable<IShadowGenerator>;
  18911. /**
  18912. * Returns a Vector3, the absolute light position in the World.
  18913. * @returns the world space position of the light
  18914. */
  18915. getAbsolutePosition(): Vector3;
  18916. /**
  18917. * Specifies if the light will affect the passed mesh.
  18918. * @param mesh The mesh to test against the light
  18919. * @return true the mesh is affected otherwise, false.
  18920. */
  18921. canAffectMesh(mesh: AbstractMesh): boolean;
  18922. /**
  18923. * Sort function to order lights for rendering.
  18924. * @param a First Light object to compare to second.
  18925. * @param b Second Light object to compare first.
  18926. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18927. */
  18928. static CompareLightsPriority(a: Light, b: Light): number;
  18929. /**
  18930. * Releases resources associated with this node.
  18931. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18932. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18933. */
  18934. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18935. /**
  18936. * Returns the light type ID (integer).
  18937. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18938. */
  18939. getTypeID(): number;
  18940. /**
  18941. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18942. * @returns the scaled intensity in intensity mode unit
  18943. */
  18944. getScaledIntensity(): number;
  18945. /**
  18946. * Returns a new Light object, named "name", from the current one.
  18947. * @param name The name of the cloned light
  18948. * @param newParent The parent of this light, if it has one
  18949. * @returns the new created light
  18950. */
  18951. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18952. /**
  18953. * Serializes the current light into a Serialization object.
  18954. * @returns the serialized object.
  18955. */
  18956. serialize(): any;
  18957. /**
  18958. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18959. * This new light is named "name" and added to the passed scene.
  18960. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18961. * @param name The friendly name of the light
  18962. * @param scene The scene the new light will belong to
  18963. * @returns the constructor function
  18964. */
  18965. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18966. /**
  18967. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18968. * @param parsedLight The JSON representation of the light
  18969. * @param scene The scene to create the parsed light in
  18970. * @returns the created light after parsing
  18971. */
  18972. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18973. private _hookArrayForExcluded;
  18974. private _hookArrayForIncludedOnly;
  18975. private _resyncMeshes;
  18976. /**
  18977. * Forces the meshes to update their light related information in their rendering used effects
  18978. * @hidden Internal Use Only
  18979. */
  18980. _markMeshesAsLightDirty(): void;
  18981. /**
  18982. * Recomputes the cached photometric scale if needed.
  18983. */
  18984. private _computePhotometricScale;
  18985. /**
  18986. * Returns the Photometric Scale according to the light type and intensity mode.
  18987. */
  18988. private _getPhotometricScale;
  18989. /**
  18990. * Reorder the light in the scene according to their defined priority.
  18991. * @hidden Internal Use Only
  18992. */
  18993. _reorderLightsInScene(): void;
  18994. /**
  18995. * Prepares the list of defines specific to the light type.
  18996. * @param defines the list of defines
  18997. * @param lightIndex defines the index of the light for the effect
  18998. */
  18999. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19000. }
  19001. }
  19002. declare module "babylonjs/Materials/prePassConfiguration" {
  19003. import { Matrix } from "babylonjs/Maths/math.vector";
  19004. import { Mesh } from "babylonjs/Meshes/mesh";
  19005. import { Scene } from "babylonjs/scene";
  19006. import { Effect } from "babylonjs/Materials/effect";
  19007. /**
  19008. * Configuration needed for prepass-capable materials
  19009. */
  19010. export class PrePassConfiguration {
  19011. /**
  19012. * Previous world matrices of meshes carrying this material
  19013. * Used for computing velocity
  19014. */
  19015. previousWorldMatrices: {
  19016. [index: number]: Matrix;
  19017. };
  19018. /**
  19019. * Previous view project matrix
  19020. * Used for computing velocity
  19021. */
  19022. previousViewProjection: Matrix;
  19023. /**
  19024. * Previous bones of meshes carrying this material
  19025. * Used for computing velocity
  19026. */
  19027. previousBones: {
  19028. [index: number]: Float32Array;
  19029. };
  19030. /**
  19031. * Add the required uniforms to the current list.
  19032. * @param uniforms defines the current uniform list.
  19033. */
  19034. static AddUniforms(uniforms: string[]): void;
  19035. /**
  19036. * Add the required samplers to the current list.
  19037. * @param samplers defines the current sampler list.
  19038. */
  19039. static AddSamplers(samplers: string[]): void;
  19040. /**
  19041. * Binds the material data.
  19042. * @param effect defines the effect to update
  19043. * @param scene defines the scene the material belongs to.
  19044. * @param mesh The mesh
  19045. * @param world World matrix of this mesh
  19046. * @param isFrozen Is the material frozen
  19047. */
  19048. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19049. }
  19050. }
  19051. declare module "babylonjs/Cameras/targetCamera" {
  19052. import { Nullable } from "babylonjs/types";
  19053. import { Camera } from "babylonjs/Cameras/camera";
  19054. import { Scene } from "babylonjs/scene";
  19055. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19056. /**
  19057. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19058. * This is the base of the follow, arc rotate cameras and Free camera
  19059. * @see https://doc.babylonjs.com/features/cameras
  19060. */
  19061. export class TargetCamera extends Camera {
  19062. private static _RigCamTransformMatrix;
  19063. private static _TargetTransformMatrix;
  19064. private static _TargetFocalPoint;
  19065. private _tmpUpVector;
  19066. private _tmpTargetVector;
  19067. /**
  19068. * Define the current direction the camera is moving to
  19069. */
  19070. cameraDirection: Vector3;
  19071. /**
  19072. * Define the current rotation the camera is rotating to
  19073. */
  19074. cameraRotation: Vector2;
  19075. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19076. ignoreParentScaling: boolean;
  19077. /**
  19078. * When set, the up vector of the camera will be updated by the rotation of the camera
  19079. */
  19080. updateUpVectorFromRotation: boolean;
  19081. private _tmpQuaternion;
  19082. /**
  19083. * Define the current rotation of the camera
  19084. */
  19085. rotation: Vector3;
  19086. /**
  19087. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19088. */
  19089. rotationQuaternion: Quaternion;
  19090. /**
  19091. * Define the current speed of the camera
  19092. */
  19093. speed: number;
  19094. /**
  19095. * Add constraint to the camera to prevent it to move freely in all directions and
  19096. * around all axis.
  19097. */
  19098. noRotationConstraint: boolean;
  19099. /**
  19100. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19101. * panning
  19102. */
  19103. invertRotation: boolean;
  19104. /**
  19105. * Speed multiplier for inverse camera panning
  19106. */
  19107. inverseRotationSpeed: number;
  19108. /**
  19109. * Define the current target of the camera as an object or a position.
  19110. */
  19111. lockedTarget: any;
  19112. /** @hidden */
  19113. _currentTarget: Vector3;
  19114. /** @hidden */
  19115. _initialFocalDistance: number;
  19116. /** @hidden */
  19117. _viewMatrix: Matrix;
  19118. /** @hidden */
  19119. _camMatrix: Matrix;
  19120. /** @hidden */
  19121. _cameraTransformMatrix: Matrix;
  19122. /** @hidden */
  19123. _cameraRotationMatrix: Matrix;
  19124. /** @hidden */
  19125. _referencePoint: Vector3;
  19126. /** @hidden */
  19127. _transformedReferencePoint: Vector3;
  19128. /** @hidden */
  19129. _reset: () => void;
  19130. private _defaultUp;
  19131. /**
  19132. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19133. * This is the base of the follow, arc rotate cameras and Free camera
  19134. * @see https://doc.babylonjs.com/features/cameras
  19135. * @param name Defines the name of the camera in the scene
  19136. * @param position Defines the start position of the camera in the scene
  19137. * @param scene Defines the scene the camera belongs to
  19138. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19139. */
  19140. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19141. /**
  19142. * Gets the position in front of the camera at a given distance.
  19143. * @param distance The distance from the camera we want the position to be
  19144. * @returns the position
  19145. */
  19146. getFrontPosition(distance: number): Vector3;
  19147. /** @hidden */
  19148. _getLockedTargetPosition(): Nullable<Vector3>;
  19149. private _storedPosition;
  19150. private _storedRotation;
  19151. private _storedRotationQuaternion;
  19152. /**
  19153. * Store current camera state of the camera (fov, position, rotation, etc..)
  19154. * @returns the camera
  19155. */
  19156. storeState(): Camera;
  19157. /**
  19158. * Restored camera state. You must call storeState() first
  19159. * @returns whether it was successful or not
  19160. * @hidden
  19161. */
  19162. _restoreStateValues(): boolean;
  19163. /** @hidden */
  19164. _initCache(): void;
  19165. /** @hidden */
  19166. _updateCache(ignoreParentClass?: boolean): void;
  19167. /** @hidden */
  19168. _isSynchronizedViewMatrix(): boolean;
  19169. /** @hidden */
  19170. _computeLocalCameraSpeed(): number;
  19171. /**
  19172. * Defines the target the camera should look at.
  19173. * @param target Defines the new target as a Vector or a mesh
  19174. */
  19175. setTarget(target: Vector3): void;
  19176. /**
  19177. * Defines the target point of the camera.
  19178. * The camera looks towards it form the radius distance.
  19179. */
  19180. get target(): Vector3;
  19181. set target(value: Vector3);
  19182. /**
  19183. * Return the current target position of the camera. This value is expressed in local space.
  19184. * @returns the target position
  19185. */
  19186. getTarget(): Vector3;
  19187. /** @hidden */
  19188. _decideIfNeedsToMove(): boolean;
  19189. /** @hidden */
  19190. _updatePosition(): void;
  19191. /** @hidden */
  19192. _checkInputs(): void;
  19193. protected _updateCameraRotationMatrix(): void;
  19194. /**
  19195. * 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)
  19196. * @returns the current camera
  19197. */
  19198. private _rotateUpVectorWithCameraRotationMatrix;
  19199. private _cachedRotationZ;
  19200. private _cachedQuaternionRotationZ;
  19201. /** @hidden */
  19202. _getViewMatrix(): Matrix;
  19203. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19204. /**
  19205. * @hidden
  19206. */
  19207. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19208. /**
  19209. * @hidden
  19210. */
  19211. _updateRigCameras(): void;
  19212. private _getRigCamPositionAndTarget;
  19213. /**
  19214. * Gets the current object class name.
  19215. * @return the class name
  19216. */
  19217. getClassName(): string;
  19218. }
  19219. }
  19220. declare module "babylonjs/Events/keyboardEvents" {
  19221. /**
  19222. * Gather the list of keyboard event types as constants.
  19223. */
  19224. export class KeyboardEventTypes {
  19225. /**
  19226. * The keydown event is fired when a key becomes active (pressed).
  19227. */
  19228. static readonly KEYDOWN: number;
  19229. /**
  19230. * The keyup event is fired when a key has been released.
  19231. */
  19232. static readonly KEYUP: number;
  19233. }
  19234. /**
  19235. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19236. */
  19237. export class KeyboardInfo {
  19238. /**
  19239. * Defines the type of event (KeyboardEventTypes)
  19240. */
  19241. type: number;
  19242. /**
  19243. * Defines the related dom event
  19244. */
  19245. event: KeyboardEvent;
  19246. /**
  19247. * Instantiates a new keyboard info.
  19248. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19249. * @param type Defines the type of event (KeyboardEventTypes)
  19250. * @param event Defines the related dom event
  19251. */
  19252. constructor(
  19253. /**
  19254. * Defines the type of event (KeyboardEventTypes)
  19255. */
  19256. type: number,
  19257. /**
  19258. * Defines the related dom event
  19259. */
  19260. event: KeyboardEvent);
  19261. }
  19262. /**
  19263. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19264. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19265. */
  19266. export class KeyboardInfoPre extends KeyboardInfo {
  19267. /**
  19268. * Defines the type of event (KeyboardEventTypes)
  19269. */
  19270. type: number;
  19271. /**
  19272. * Defines the related dom event
  19273. */
  19274. event: KeyboardEvent;
  19275. /**
  19276. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19277. */
  19278. skipOnPointerObservable: boolean;
  19279. /**
  19280. * Instantiates a new keyboard pre info.
  19281. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19282. * @param type Defines the type of event (KeyboardEventTypes)
  19283. * @param event Defines the related dom event
  19284. */
  19285. constructor(
  19286. /**
  19287. * Defines the type of event (KeyboardEventTypes)
  19288. */
  19289. type: number,
  19290. /**
  19291. * Defines the related dom event
  19292. */
  19293. event: KeyboardEvent);
  19294. }
  19295. }
  19296. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19297. import { Nullable } from "babylonjs/types";
  19298. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19299. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19300. /**
  19301. * Manage the keyboard inputs to control the movement of a free camera.
  19302. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19303. */
  19304. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19305. /**
  19306. * Defines the camera the input is attached to.
  19307. */
  19308. camera: FreeCamera;
  19309. /**
  19310. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19311. */
  19312. keysUp: number[];
  19313. /**
  19314. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19315. */
  19316. keysUpward: number[];
  19317. /**
  19318. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19319. */
  19320. keysDown: number[];
  19321. /**
  19322. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19323. */
  19324. keysDownward: number[];
  19325. /**
  19326. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19327. */
  19328. keysLeft: number[];
  19329. /**
  19330. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19331. */
  19332. keysRight: number[];
  19333. private _keys;
  19334. private _onCanvasBlurObserver;
  19335. private _onKeyboardObserver;
  19336. private _engine;
  19337. private _scene;
  19338. /**
  19339. * Attach the input controls to a specific dom element to get the input from.
  19340. * @param element Defines the element the controls should be listened from
  19341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19342. */
  19343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19344. /**
  19345. * Detach the current controls from the specified dom element.
  19346. * @param element Defines the element to stop listening the inputs from
  19347. */
  19348. detachControl(element: Nullable<HTMLElement>): void;
  19349. /**
  19350. * Update the current camera state depending on the inputs that have been used this frame.
  19351. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19352. */
  19353. checkInputs(): void;
  19354. /**
  19355. * Gets the class name of the current intput.
  19356. * @returns the class name
  19357. */
  19358. getClassName(): string;
  19359. /** @hidden */
  19360. _onLostFocus(): void;
  19361. /**
  19362. * Get the friendly name associated with the input class.
  19363. * @returns the input friendly name
  19364. */
  19365. getSimpleName(): string;
  19366. }
  19367. }
  19368. declare module "babylonjs/Events/pointerEvents" {
  19369. import { Nullable } from "babylonjs/types";
  19370. import { Vector2 } from "babylonjs/Maths/math.vector";
  19371. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19372. import { Ray } from "babylonjs/Culling/ray";
  19373. /**
  19374. * Gather the list of pointer event types as constants.
  19375. */
  19376. export class PointerEventTypes {
  19377. /**
  19378. * 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.
  19379. */
  19380. static readonly POINTERDOWN: number;
  19381. /**
  19382. * The pointerup event is fired when a pointer is no longer active.
  19383. */
  19384. static readonly POINTERUP: number;
  19385. /**
  19386. * The pointermove event is fired when a pointer changes coordinates.
  19387. */
  19388. static readonly POINTERMOVE: number;
  19389. /**
  19390. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19391. */
  19392. static readonly POINTERWHEEL: number;
  19393. /**
  19394. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19395. */
  19396. static readonly POINTERPICK: number;
  19397. /**
  19398. * The pointertap event is fired when a the object has been touched and released without drag.
  19399. */
  19400. static readonly POINTERTAP: number;
  19401. /**
  19402. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19403. */
  19404. static readonly POINTERDOUBLETAP: number;
  19405. }
  19406. /**
  19407. * Base class of pointer info types.
  19408. */
  19409. export class PointerInfoBase {
  19410. /**
  19411. * Defines the type of event (PointerEventTypes)
  19412. */
  19413. type: number;
  19414. /**
  19415. * Defines the related dom event
  19416. */
  19417. event: PointerEvent | MouseWheelEvent;
  19418. /**
  19419. * Instantiates the base class of pointers info.
  19420. * @param type Defines the type of event (PointerEventTypes)
  19421. * @param event Defines the related dom event
  19422. */
  19423. constructor(
  19424. /**
  19425. * Defines the type of event (PointerEventTypes)
  19426. */
  19427. type: number,
  19428. /**
  19429. * Defines the related dom event
  19430. */
  19431. event: PointerEvent | MouseWheelEvent);
  19432. }
  19433. /**
  19434. * This class is used to store pointer related info for the onPrePointerObservable event.
  19435. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19436. */
  19437. export class PointerInfoPre extends PointerInfoBase {
  19438. /**
  19439. * Ray from a pointer if availible (eg. 6dof controller)
  19440. */
  19441. ray: Nullable<Ray>;
  19442. /**
  19443. * Defines the local position of the pointer on the canvas.
  19444. */
  19445. localPosition: Vector2;
  19446. /**
  19447. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19448. */
  19449. skipOnPointerObservable: boolean;
  19450. /**
  19451. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19452. * @param type Defines the type of event (PointerEventTypes)
  19453. * @param event Defines the related dom event
  19454. * @param localX Defines the local x coordinates of the pointer when the event occured
  19455. * @param localY Defines the local y coordinates of the pointer when the event occured
  19456. */
  19457. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19458. }
  19459. /**
  19460. * This type contains all the data related to a pointer event in Babylon.js.
  19461. * 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.
  19462. */
  19463. export class PointerInfo extends PointerInfoBase {
  19464. /**
  19465. * Defines the picking info associated to the info (if any)\
  19466. */
  19467. pickInfo: Nullable<PickingInfo>;
  19468. /**
  19469. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19470. * @param type Defines the type of event (PointerEventTypes)
  19471. * @param event Defines the related dom event
  19472. * @param pickInfo Defines the picking info associated to the info (if any)\
  19473. */
  19474. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19475. /**
  19476. * Defines the picking info associated to the info (if any)\
  19477. */
  19478. pickInfo: Nullable<PickingInfo>);
  19479. }
  19480. /**
  19481. * Data relating to a touch event on the screen.
  19482. */
  19483. export interface PointerTouch {
  19484. /**
  19485. * X coordinate of touch.
  19486. */
  19487. x: number;
  19488. /**
  19489. * Y coordinate of touch.
  19490. */
  19491. y: number;
  19492. /**
  19493. * Id of touch. Unique for each finger.
  19494. */
  19495. pointerId: number;
  19496. /**
  19497. * Event type passed from DOM.
  19498. */
  19499. type: any;
  19500. }
  19501. }
  19502. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19503. import { Observable } from "babylonjs/Misc/observable";
  19504. import { Nullable } from "babylonjs/types";
  19505. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19506. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19507. /**
  19508. * Manage the mouse inputs to control the movement of a free camera.
  19509. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19510. */
  19511. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19512. /**
  19513. * Define if touch is enabled in the mouse input
  19514. */
  19515. touchEnabled: boolean;
  19516. /**
  19517. * Defines the camera the input is attached to.
  19518. */
  19519. camera: FreeCamera;
  19520. /**
  19521. * Defines the buttons associated with the input to handle camera move.
  19522. */
  19523. buttons: number[];
  19524. /**
  19525. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19526. */
  19527. angularSensibility: number;
  19528. private _pointerInput;
  19529. private _onMouseMove;
  19530. private _observer;
  19531. private previousPosition;
  19532. /**
  19533. * Observable for when a pointer move event occurs containing the move offset
  19534. */
  19535. onPointerMovedObservable: Observable<{
  19536. offsetX: number;
  19537. offsetY: number;
  19538. }>;
  19539. /**
  19540. * @hidden
  19541. * If the camera should be rotated automatically based on pointer movement
  19542. */
  19543. _allowCameraRotation: boolean;
  19544. /**
  19545. * Manage the mouse inputs to control the movement of a free camera.
  19546. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19547. * @param touchEnabled Defines if touch is enabled or not
  19548. */
  19549. constructor(
  19550. /**
  19551. * Define if touch is enabled in the mouse input
  19552. */
  19553. touchEnabled?: boolean);
  19554. /**
  19555. * Attach the input controls to a specific dom element to get the input from.
  19556. * @param element Defines the element the controls should be listened from
  19557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19558. */
  19559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19560. /**
  19561. * Called on JS contextmenu event.
  19562. * Override this method to provide functionality.
  19563. */
  19564. protected onContextMenu(evt: PointerEvent): void;
  19565. /**
  19566. * Detach the current controls from the specified dom element.
  19567. * @param element Defines the element to stop listening the inputs from
  19568. */
  19569. detachControl(element: Nullable<HTMLElement>): void;
  19570. /**
  19571. * Gets the class name of the current intput.
  19572. * @returns the class name
  19573. */
  19574. getClassName(): string;
  19575. /**
  19576. * Get the friendly name associated with the input class.
  19577. * @returns the input friendly name
  19578. */
  19579. getSimpleName(): string;
  19580. }
  19581. }
  19582. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19583. import { Nullable } from "babylonjs/types";
  19584. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19585. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19586. /**
  19587. * Manage the touch inputs to control the movement of a free camera.
  19588. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19589. */
  19590. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19591. /**
  19592. * Define if mouse events can be treated as touch events
  19593. */
  19594. allowMouse: boolean;
  19595. /**
  19596. * Defines the camera the input is attached to.
  19597. */
  19598. camera: FreeCamera;
  19599. /**
  19600. * Defines the touch sensibility for rotation.
  19601. * The higher the faster.
  19602. */
  19603. touchAngularSensibility: number;
  19604. /**
  19605. * Defines the touch sensibility for move.
  19606. * The higher the faster.
  19607. */
  19608. touchMoveSensibility: number;
  19609. private _offsetX;
  19610. private _offsetY;
  19611. private _pointerPressed;
  19612. private _pointerInput;
  19613. private _observer;
  19614. private _onLostFocus;
  19615. /**
  19616. * Manage the touch inputs to control the movement of a free camera.
  19617. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19618. * @param allowMouse Defines if mouse events can be treated as touch events
  19619. */
  19620. constructor(
  19621. /**
  19622. * Define if mouse events can be treated as touch events
  19623. */
  19624. allowMouse?: boolean);
  19625. /**
  19626. * Attach the input controls to a specific dom element to get the input from.
  19627. * @param element Defines the element the controls should be listened from
  19628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19629. */
  19630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19631. /**
  19632. * Detach the current controls from the specified dom element.
  19633. * @param element Defines the element to stop listening the inputs from
  19634. */
  19635. detachControl(element: Nullable<HTMLElement>): void;
  19636. /**
  19637. * Update the current camera state depending on the inputs that have been used this frame.
  19638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19639. */
  19640. checkInputs(): void;
  19641. /**
  19642. * Gets the class name of the current intput.
  19643. * @returns the class name
  19644. */
  19645. getClassName(): string;
  19646. /**
  19647. * Get the friendly name associated with the input class.
  19648. * @returns the input friendly name
  19649. */
  19650. getSimpleName(): string;
  19651. }
  19652. }
  19653. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19654. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19655. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19656. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19657. import { Nullable } from "babylonjs/types";
  19658. /**
  19659. * Default Inputs manager for the FreeCamera.
  19660. * It groups all the default supported inputs for ease of use.
  19661. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19662. */
  19663. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19664. /**
  19665. * @hidden
  19666. */
  19667. _mouseInput: Nullable<FreeCameraMouseInput>;
  19668. /**
  19669. * Instantiates a new FreeCameraInputsManager.
  19670. * @param camera Defines the camera the inputs belong to
  19671. */
  19672. constructor(camera: FreeCamera);
  19673. /**
  19674. * Add keyboard input support to the input manager.
  19675. * @returns the current input manager
  19676. */
  19677. addKeyboard(): FreeCameraInputsManager;
  19678. /**
  19679. * Add mouse input support to the input manager.
  19680. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19681. * @returns the current input manager
  19682. */
  19683. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19684. /**
  19685. * Removes the mouse input support from the manager
  19686. * @returns the current input manager
  19687. */
  19688. removeMouse(): FreeCameraInputsManager;
  19689. /**
  19690. * Add touch input support to the input manager.
  19691. * @returns the current input manager
  19692. */
  19693. addTouch(): FreeCameraInputsManager;
  19694. /**
  19695. * Remove all attached input methods from a camera
  19696. */
  19697. clear(): void;
  19698. }
  19699. }
  19700. declare module "babylonjs/Cameras/freeCamera" {
  19701. import { Vector3 } from "babylonjs/Maths/math.vector";
  19702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19703. import { Scene } from "babylonjs/scene";
  19704. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19705. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19706. /**
  19707. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19708. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19709. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19710. */
  19711. export class FreeCamera extends TargetCamera {
  19712. /**
  19713. * Define the collision ellipsoid of the camera.
  19714. * This is helpful to simulate a camera body like the player body around the camera
  19715. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19716. */
  19717. ellipsoid: Vector3;
  19718. /**
  19719. * Define an offset for the position of the ellipsoid around the camera.
  19720. * This can be helpful to determine the center of the body near the gravity center of the body
  19721. * instead of its head.
  19722. */
  19723. ellipsoidOffset: Vector3;
  19724. /**
  19725. * Enable or disable collisions of the camera with the rest of the scene objects.
  19726. */
  19727. checkCollisions: boolean;
  19728. /**
  19729. * Enable or disable gravity on the camera.
  19730. */
  19731. applyGravity: boolean;
  19732. /**
  19733. * Define the input manager associated to the camera.
  19734. */
  19735. inputs: FreeCameraInputsManager;
  19736. /**
  19737. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19738. * Higher values reduce sensitivity.
  19739. */
  19740. get angularSensibility(): number;
  19741. /**
  19742. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19743. * Higher values reduce sensitivity.
  19744. */
  19745. set angularSensibility(value: number);
  19746. /**
  19747. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19748. */
  19749. get keysUp(): number[];
  19750. set keysUp(value: number[]);
  19751. /**
  19752. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19753. */
  19754. get keysUpward(): number[];
  19755. set keysUpward(value: number[]);
  19756. /**
  19757. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19758. */
  19759. get keysDown(): number[];
  19760. set keysDown(value: number[]);
  19761. /**
  19762. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19763. */
  19764. get keysDownward(): number[];
  19765. set keysDownward(value: number[]);
  19766. /**
  19767. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19768. */
  19769. get keysLeft(): number[];
  19770. set keysLeft(value: number[]);
  19771. /**
  19772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19773. */
  19774. get keysRight(): number[];
  19775. set keysRight(value: number[]);
  19776. /**
  19777. * Event raised when the camera collide with a mesh in the scene.
  19778. */
  19779. onCollide: (collidedMesh: AbstractMesh) => void;
  19780. private _collider;
  19781. private _needMoveForGravity;
  19782. private _oldPosition;
  19783. private _diffPosition;
  19784. private _newPosition;
  19785. /** @hidden */
  19786. _localDirection: Vector3;
  19787. /** @hidden */
  19788. _transformedDirection: Vector3;
  19789. /**
  19790. * Instantiates a Free Camera.
  19791. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19792. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19793. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19794. * @param name Define the name of the camera in the scene
  19795. * @param position Define the start position of the camera in the scene
  19796. * @param scene Define the scene the camera belongs to
  19797. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19798. */
  19799. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19800. /**
  19801. * Attached controls to the current camera.
  19802. * @param element Defines the element the controls should be listened from
  19803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19804. */
  19805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19806. /**
  19807. * Detach the current controls from the camera.
  19808. * The camera will stop reacting to inputs.
  19809. * @param element Defines the element to stop listening the inputs from
  19810. */
  19811. detachControl(element: HTMLElement): void;
  19812. private _collisionMask;
  19813. /**
  19814. * Define a collision mask to limit the list of object the camera can collide with
  19815. */
  19816. get collisionMask(): number;
  19817. set collisionMask(mask: number);
  19818. /** @hidden */
  19819. _collideWithWorld(displacement: Vector3): void;
  19820. private _onCollisionPositionChange;
  19821. /** @hidden */
  19822. _checkInputs(): void;
  19823. /** @hidden */
  19824. _decideIfNeedsToMove(): boolean;
  19825. /** @hidden */
  19826. _updatePosition(): void;
  19827. /**
  19828. * Destroy the camera and release the current resources hold by it.
  19829. */
  19830. dispose(): void;
  19831. /**
  19832. * Gets the current object class name.
  19833. * @return the class name
  19834. */
  19835. getClassName(): string;
  19836. }
  19837. }
  19838. declare module "babylonjs/Gamepads/gamepad" {
  19839. import { Observable } from "babylonjs/Misc/observable";
  19840. /**
  19841. * Represents a gamepad control stick position
  19842. */
  19843. export class StickValues {
  19844. /**
  19845. * The x component of the control stick
  19846. */
  19847. x: number;
  19848. /**
  19849. * The y component of the control stick
  19850. */
  19851. y: number;
  19852. /**
  19853. * Initializes the gamepad x and y control stick values
  19854. * @param x The x component of the gamepad control stick value
  19855. * @param y The y component of the gamepad control stick value
  19856. */
  19857. constructor(
  19858. /**
  19859. * The x component of the control stick
  19860. */
  19861. x: number,
  19862. /**
  19863. * The y component of the control stick
  19864. */
  19865. y: number);
  19866. }
  19867. /**
  19868. * An interface which manages callbacks for gamepad button changes
  19869. */
  19870. export interface GamepadButtonChanges {
  19871. /**
  19872. * Called when a gamepad has been changed
  19873. */
  19874. changed: boolean;
  19875. /**
  19876. * Called when a gamepad press event has been triggered
  19877. */
  19878. pressChanged: boolean;
  19879. /**
  19880. * Called when a touch event has been triggered
  19881. */
  19882. touchChanged: boolean;
  19883. /**
  19884. * Called when a value has changed
  19885. */
  19886. valueChanged: boolean;
  19887. }
  19888. /**
  19889. * Represents a gamepad
  19890. */
  19891. export class Gamepad {
  19892. /**
  19893. * The id of the gamepad
  19894. */
  19895. id: string;
  19896. /**
  19897. * The index of the gamepad
  19898. */
  19899. index: number;
  19900. /**
  19901. * The browser gamepad
  19902. */
  19903. browserGamepad: any;
  19904. /**
  19905. * Specifies what type of gamepad this represents
  19906. */
  19907. type: number;
  19908. private _leftStick;
  19909. private _rightStick;
  19910. /** @hidden */
  19911. _isConnected: boolean;
  19912. private _leftStickAxisX;
  19913. private _leftStickAxisY;
  19914. private _rightStickAxisX;
  19915. private _rightStickAxisY;
  19916. /**
  19917. * Triggered when the left control stick has been changed
  19918. */
  19919. private _onleftstickchanged;
  19920. /**
  19921. * Triggered when the right control stick has been changed
  19922. */
  19923. private _onrightstickchanged;
  19924. /**
  19925. * Represents a gamepad controller
  19926. */
  19927. static GAMEPAD: number;
  19928. /**
  19929. * Represents a generic controller
  19930. */
  19931. static GENERIC: number;
  19932. /**
  19933. * Represents an XBox controller
  19934. */
  19935. static XBOX: number;
  19936. /**
  19937. * Represents a pose-enabled controller
  19938. */
  19939. static POSE_ENABLED: number;
  19940. /**
  19941. * Represents an Dual Shock controller
  19942. */
  19943. static DUALSHOCK: number;
  19944. /**
  19945. * Specifies whether the left control stick should be Y-inverted
  19946. */
  19947. protected _invertLeftStickY: boolean;
  19948. /**
  19949. * Specifies if the gamepad has been connected
  19950. */
  19951. get isConnected(): boolean;
  19952. /**
  19953. * Initializes the gamepad
  19954. * @param id The id of the gamepad
  19955. * @param index The index of the gamepad
  19956. * @param browserGamepad The browser gamepad
  19957. * @param leftStickX The x component of the left joystick
  19958. * @param leftStickY The y component of the left joystick
  19959. * @param rightStickX The x component of the right joystick
  19960. * @param rightStickY The y component of the right joystick
  19961. */
  19962. constructor(
  19963. /**
  19964. * The id of the gamepad
  19965. */
  19966. id: string,
  19967. /**
  19968. * The index of the gamepad
  19969. */
  19970. index: number,
  19971. /**
  19972. * The browser gamepad
  19973. */
  19974. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19975. /**
  19976. * Callback triggered when the left joystick has changed
  19977. * @param callback
  19978. */
  19979. onleftstickchanged(callback: (values: StickValues) => void): void;
  19980. /**
  19981. * Callback triggered when the right joystick has changed
  19982. * @param callback
  19983. */
  19984. onrightstickchanged(callback: (values: StickValues) => void): void;
  19985. /**
  19986. * Gets the left joystick
  19987. */
  19988. get leftStick(): StickValues;
  19989. /**
  19990. * Sets the left joystick values
  19991. */
  19992. set leftStick(newValues: StickValues);
  19993. /**
  19994. * Gets the right joystick
  19995. */
  19996. get rightStick(): StickValues;
  19997. /**
  19998. * Sets the right joystick value
  19999. */
  20000. set rightStick(newValues: StickValues);
  20001. /**
  20002. * Updates the gamepad joystick positions
  20003. */
  20004. update(): void;
  20005. /**
  20006. * Disposes the gamepad
  20007. */
  20008. dispose(): void;
  20009. }
  20010. /**
  20011. * Represents a generic gamepad
  20012. */
  20013. export class GenericPad extends Gamepad {
  20014. private _buttons;
  20015. private _onbuttondown;
  20016. private _onbuttonup;
  20017. /**
  20018. * Observable triggered when a button has been pressed
  20019. */
  20020. onButtonDownObservable: Observable<number>;
  20021. /**
  20022. * Observable triggered when a button has been released
  20023. */
  20024. onButtonUpObservable: Observable<number>;
  20025. /**
  20026. * Callback triggered when a button has been pressed
  20027. * @param callback Called when a button has been pressed
  20028. */
  20029. onbuttondown(callback: (buttonPressed: number) => void): void;
  20030. /**
  20031. * Callback triggered when a button has been released
  20032. * @param callback Called when a button has been released
  20033. */
  20034. onbuttonup(callback: (buttonReleased: number) => void): void;
  20035. /**
  20036. * Initializes the generic gamepad
  20037. * @param id The id of the generic gamepad
  20038. * @param index The index of the generic gamepad
  20039. * @param browserGamepad The browser gamepad
  20040. */
  20041. constructor(id: string, index: number, browserGamepad: any);
  20042. private _setButtonValue;
  20043. /**
  20044. * Updates the generic gamepad
  20045. */
  20046. update(): void;
  20047. /**
  20048. * Disposes the generic gamepad
  20049. */
  20050. dispose(): void;
  20051. }
  20052. }
  20053. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20054. import { Observable } from "babylonjs/Misc/observable";
  20055. import { Nullable } from "babylonjs/types";
  20056. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20057. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20059. import { Ray } from "babylonjs/Culling/ray";
  20060. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20061. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20062. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20063. /**
  20064. * Defines the types of pose enabled controllers that are supported
  20065. */
  20066. export enum PoseEnabledControllerType {
  20067. /**
  20068. * HTC Vive
  20069. */
  20070. VIVE = 0,
  20071. /**
  20072. * Oculus Rift
  20073. */
  20074. OCULUS = 1,
  20075. /**
  20076. * Windows mixed reality
  20077. */
  20078. WINDOWS = 2,
  20079. /**
  20080. * Samsung gear VR
  20081. */
  20082. GEAR_VR = 3,
  20083. /**
  20084. * Google Daydream
  20085. */
  20086. DAYDREAM = 4,
  20087. /**
  20088. * Generic
  20089. */
  20090. GENERIC = 5
  20091. }
  20092. /**
  20093. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20094. */
  20095. export interface MutableGamepadButton {
  20096. /**
  20097. * Value of the button/trigger
  20098. */
  20099. value: number;
  20100. /**
  20101. * If the button/trigger is currently touched
  20102. */
  20103. touched: boolean;
  20104. /**
  20105. * If the button/trigger is currently pressed
  20106. */
  20107. pressed: boolean;
  20108. }
  20109. /**
  20110. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20111. * @hidden
  20112. */
  20113. export interface ExtendedGamepadButton extends GamepadButton {
  20114. /**
  20115. * If the button/trigger is currently pressed
  20116. */
  20117. readonly pressed: boolean;
  20118. /**
  20119. * If the button/trigger is currently touched
  20120. */
  20121. readonly touched: boolean;
  20122. /**
  20123. * Value of the button/trigger
  20124. */
  20125. readonly value: number;
  20126. }
  20127. /** @hidden */
  20128. export interface _GamePadFactory {
  20129. /**
  20130. * Returns whether or not the current gamepad can be created for this type of controller.
  20131. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20132. * @returns true if it can be created, otherwise false
  20133. */
  20134. canCreate(gamepadInfo: any): boolean;
  20135. /**
  20136. * Creates a new instance of the Gamepad.
  20137. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20138. * @returns the new gamepad instance
  20139. */
  20140. create(gamepadInfo: any): Gamepad;
  20141. }
  20142. /**
  20143. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20144. */
  20145. export class PoseEnabledControllerHelper {
  20146. /** @hidden */
  20147. static _ControllerFactories: _GamePadFactory[];
  20148. /** @hidden */
  20149. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20150. /**
  20151. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20152. * @param vrGamepad the gamepad to initialized
  20153. * @returns a vr controller of the type the gamepad identified as
  20154. */
  20155. static InitiateController(vrGamepad: any): Gamepad;
  20156. }
  20157. /**
  20158. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20159. */
  20160. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20161. /**
  20162. * If the controller is used in a webXR session
  20163. */
  20164. isXR: boolean;
  20165. private _deviceRoomPosition;
  20166. private _deviceRoomRotationQuaternion;
  20167. /**
  20168. * The device position in babylon space
  20169. */
  20170. devicePosition: Vector3;
  20171. /**
  20172. * The device rotation in babylon space
  20173. */
  20174. deviceRotationQuaternion: Quaternion;
  20175. /**
  20176. * The scale factor of the device in babylon space
  20177. */
  20178. deviceScaleFactor: number;
  20179. /**
  20180. * (Likely devicePosition should be used instead) The device position in its room space
  20181. */
  20182. position: Vector3;
  20183. /**
  20184. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20185. */
  20186. rotationQuaternion: Quaternion;
  20187. /**
  20188. * The type of controller (Eg. Windows mixed reality)
  20189. */
  20190. controllerType: PoseEnabledControllerType;
  20191. protected _calculatedPosition: Vector3;
  20192. private _calculatedRotation;
  20193. /**
  20194. * The raw pose from the device
  20195. */
  20196. rawPose: DevicePose;
  20197. private _trackPosition;
  20198. private _maxRotationDistFromHeadset;
  20199. private _draggedRoomRotation;
  20200. /**
  20201. * @hidden
  20202. */
  20203. _disableTrackPosition(fixedPosition: Vector3): void;
  20204. /**
  20205. * Internal, the mesh attached to the controller
  20206. * @hidden
  20207. */
  20208. _mesh: Nullable<AbstractMesh>;
  20209. private _poseControlledCamera;
  20210. private _leftHandSystemQuaternion;
  20211. /**
  20212. * Internal, matrix used to convert room space to babylon space
  20213. * @hidden
  20214. */
  20215. _deviceToWorld: Matrix;
  20216. /**
  20217. * Node to be used when casting a ray from the controller
  20218. * @hidden
  20219. */
  20220. _pointingPoseNode: Nullable<TransformNode>;
  20221. /**
  20222. * Name of the child mesh that can be used to cast a ray from the controller
  20223. */
  20224. static readonly POINTING_POSE: string;
  20225. /**
  20226. * Creates a new PoseEnabledController from a gamepad
  20227. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20228. */
  20229. constructor(browserGamepad: any);
  20230. private _workingMatrix;
  20231. /**
  20232. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20233. */
  20234. update(): void;
  20235. /**
  20236. * Updates only the pose device and mesh without doing any button event checking
  20237. */
  20238. protected _updatePoseAndMesh(): void;
  20239. /**
  20240. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20241. * @param poseData raw pose fromthe device
  20242. */
  20243. updateFromDevice(poseData: DevicePose): void;
  20244. /**
  20245. * @hidden
  20246. */
  20247. _meshAttachedObservable: Observable<AbstractMesh>;
  20248. /**
  20249. * Attaches a mesh to the controller
  20250. * @param mesh the mesh to be attached
  20251. */
  20252. attachToMesh(mesh: AbstractMesh): void;
  20253. /**
  20254. * Attaches the controllers mesh to a camera
  20255. * @param camera the camera the mesh should be attached to
  20256. */
  20257. attachToPoseControlledCamera(camera: TargetCamera): void;
  20258. /**
  20259. * Disposes of the controller
  20260. */
  20261. dispose(): void;
  20262. /**
  20263. * The mesh that is attached to the controller
  20264. */
  20265. get mesh(): Nullable<AbstractMesh>;
  20266. /**
  20267. * Gets the ray of the controller in the direction the controller is pointing
  20268. * @param length the length the resulting ray should be
  20269. * @returns a ray in the direction the controller is pointing
  20270. */
  20271. getForwardRay(length?: number): Ray;
  20272. }
  20273. }
  20274. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20275. import { Observable } from "babylonjs/Misc/observable";
  20276. import { Scene } from "babylonjs/scene";
  20277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20278. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20279. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20280. import { Nullable } from "babylonjs/types";
  20281. /**
  20282. * Defines the WebVRController object that represents controllers tracked in 3D space
  20283. */
  20284. export abstract class WebVRController extends PoseEnabledController {
  20285. /**
  20286. * Internal, the default controller model for the controller
  20287. */
  20288. protected _defaultModel: Nullable<AbstractMesh>;
  20289. /**
  20290. * Fired when the trigger state has changed
  20291. */
  20292. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20293. /**
  20294. * Fired when the main button state has changed
  20295. */
  20296. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20297. /**
  20298. * Fired when the secondary button state has changed
  20299. */
  20300. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20301. /**
  20302. * Fired when the pad state has changed
  20303. */
  20304. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20305. /**
  20306. * Fired when controllers stick values have changed
  20307. */
  20308. onPadValuesChangedObservable: Observable<StickValues>;
  20309. /**
  20310. * Array of button availible on the controller
  20311. */
  20312. protected _buttons: Array<MutableGamepadButton>;
  20313. private _onButtonStateChange;
  20314. /**
  20315. * Fired when a controller button's state has changed
  20316. * @param callback the callback containing the button that was modified
  20317. */
  20318. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20319. /**
  20320. * X and Y axis corresponding to the controllers joystick
  20321. */
  20322. pad: StickValues;
  20323. /**
  20324. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20325. */
  20326. hand: string;
  20327. /**
  20328. * The default controller model for the controller
  20329. */
  20330. get defaultModel(): Nullable<AbstractMesh>;
  20331. /**
  20332. * Creates a new WebVRController from a gamepad
  20333. * @param vrGamepad the gamepad that the WebVRController should be created from
  20334. */
  20335. constructor(vrGamepad: any);
  20336. /**
  20337. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20338. */
  20339. update(): void;
  20340. /**
  20341. * Function to be called when a button is modified
  20342. */
  20343. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20344. /**
  20345. * Loads a mesh and attaches it to the controller
  20346. * @param scene the scene the mesh should be added to
  20347. * @param meshLoaded callback for when the mesh has been loaded
  20348. */
  20349. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20350. private _setButtonValue;
  20351. private _changes;
  20352. private _checkChanges;
  20353. /**
  20354. * Disposes of th webVRCOntroller
  20355. */
  20356. dispose(): void;
  20357. }
  20358. }
  20359. declare module "babylonjs/Lights/hemisphericLight" {
  20360. import { Nullable } from "babylonjs/types";
  20361. import { Scene } from "babylonjs/scene";
  20362. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20363. import { Color3 } from "babylonjs/Maths/math.color";
  20364. import { Effect } from "babylonjs/Materials/effect";
  20365. import { Light } from "babylonjs/Lights/light";
  20366. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20367. /**
  20368. * The HemisphericLight simulates the ambient environment light,
  20369. * so the passed direction is the light reflection direction, not the incoming direction.
  20370. */
  20371. export class HemisphericLight extends Light {
  20372. /**
  20373. * The groundColor is the light in the opposite direction to the one specified during creation.
  20374. * 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.
  20375. */
  20376. groundColor: Color3;
  20377. /**
  20378. * The light reflection direction, not the incoming direction.
  20379. */
  20380. direction: Vector3;
  20381. /**
  20382. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20383. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20384. * The HemisphericLight can't cast shadows.
  20385. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20386. * @param name The friendly name of the light
  20387. * @param direction The direction of the light reflection
  20388. * @param scene The scene the light belongs to
  20389. */
  20390. constructor(name: string, direction: Vector3, scene: Scene);
  20391. protected _buildUniformLayout(): void;
  20392. /**
  20393. * Returns the string "HemisphericLight".
  20394. * @return The class name
  20395. */
  20396. getClassName(): string;
  20397. /**
  20398. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20399. * Returns the updated direction.
  20400. * @param target The target the direction should point to
  20401. * @return The computed direction
  20402. */
  20403. setDirectionToTarget(target: Vector3): Vector3;
  20404. /**
  20405. * Returns the shadow generator associated to the light.
  20406. * @returns Always null for hemispheric lights because it does not support shadows.
  20407. */
  20408. getShadowGenerator(): Nullable<IShadowGenerator>;
  20409. /**
  20410. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20411. * @param effect The effect to update
  20412. * @param lightIndex The index of the light in the effect to update
  20413. * @returns The hemispheric light
  20414. */
  20415. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20416. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20417. /**
  20418. * Computes the world matrix of the node
  20419. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20420. * @param useWasUpdatedFlag defines a reserved property
  20421. * @returns the world matrix
  20422. */
  20423. computeWorldMatrix(): Matrix;
  20424. /**
  20425. * Returns the integer 3.
  20426. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20427. */
  20428. getTypeID(): number;
  20429. /**
  20430. * Prepares the list of defines specific to the light type.
  20431. * @param defines the list of defines
  20432. * @param lightIndex defines the index of the light for the effect
  20433. */
  20434. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20435. }
  20436. }
  20437. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20438. /** @hidden */
  20439. export var vrMultiviewToSingleviewPixelShader: {
  20440. name: string;
  20441. shader: string;
  20442. };
  20443. }
  20444. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20445. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20446. import { Scene } from "babylonjs/scene";
  20447. /**
  20448. * Renders to multiple views with a single draw call
  20449. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20450. */
  20451. export class MultiviewRenderTarget extends RenderTargetTexture {
  20452. /**
  20453. * Creates a multiview render target
  20454. * @param scene scene used with the render target
  20455. * @param size the size of the render target (used for each view)
  20456. */
  20457. constructor(scene: Scene, size?: number | {
  20458. width: number;
  20459. height: number;
  20460. } | {
  20461. ratio: number;
  20462. });
  20463. /**
  20464. * @hidden
  20465. * @param faceIndex the face index, if its a cube texture
  20466. */
  20467. _bindFrameBuffer(faceIndex?: number): void;
  20468. /**
  20469. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20470. * @returns the view count
  20471. */
  20472. getViewCount(): number;
  20473. }
  20474. }
  20475. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20476. import { Camera } from "babylonjs/Cameras/camera";
  20477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20478. import { Nullable } from "babylonjs/types";
  20479. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20480. import { Matrix } from "babylonjs/Maths/math.vector";
  20481. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20482. module "babylonjs/Engines/engine" {
  20483. interface Engine {
  20484. /**
  20485. * Creates a new multiview render target
  20486. * @param width defines the width of the texture
  20487. * @param height defines the height of the texture
  20488. * @returns the created multiview texture
  20489. */
  20490. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20491. /**
  20492. * Binds a multiview framebuffer to be drawn to
  20493. * @param multiviewTexture texture to bind
  20494. */
  20495. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20496. }
  20497. }
  20498. module "babylonjs/Cameras/camera" {
  20499. interface Camera {
  20500. /**
  20501. * @hidden
  20502. * 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)
  20503. */
  20504. _useMultiviewToSingleView: boolean;
  20505. /**
  20506. * @hidden
  20507. * 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)
  20508. */
  20509. _multiviewTexture: Nullable<RenderTargetTexture>;
  20510. /**
  20511. * @hidden
  20512. * ensures the multiview texture of the camera exists and has the specified width/height
  20513. * @param width height to set on the multiview texture
  20514. * @param height width to set on the multiview texture
  20515. */
  20516. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20517. }
  20518. }
  20519. module "babylonjs/scene" {
  20520. interface Scene {
  20521. /** @hidden */
  20522. _transformMatrixR: Matrix;
  20523. /** @hidden */
  20524. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20525. /** @hidden */
  20526. _createMultiviewUbo(): void;
  20527. /** @hidden */
  20528. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20529. /** @hidden */
  20530. _renderMultiviewToSingleView(camera: Camera): void;
  20531. }
  20532. }
  20533. }
  20534. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20535. import { Camera } from "babylonjs/Cameras/camera";
  20536. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20537. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20538. import "babylonjs/Engines/Extensions/engine.multiview";
  20539. /**
  20540. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20541. * This will not be used for webXR as it supports displaying texture arrays directly
  20542. */
  20543. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20544. /**
  20545. * Gets a string identifying the name of the class
  20546. * @returns "VRMultiviewToSingleviewPostProcess" string
  20547. */
  20548. getClassName(): string;
  20549. /**
  20550. * Initializes a VRMultiviewToSingleview
  20551. * @param name name of the post process
  20552. * @param camera camera to be applied to
  20553. * @param scaleFactor scaling factor to the size of the output texture
  20554. */
  20555. constructor(name: string, camera: Camera, scaleFactor: number);
  20556. }
  20557. }
  20558. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20559. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20560. import { Nullable } from "babylonjs/types";
  20561. import { Size } from "babylonjs/Maths/math.size";
  20562. import { Observable } from "babylonjs/Misc/observable";
  20563. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20564. /**
  20565. * Interface used to define additional presentation attributes
  20566. */
  20567. export interface IVRPresentationAttributes {
  20568. /**
  20569. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20570. */
  20571. highRefreshRate: boolean;
  20572. /**
  20573. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20574. */
  20575. foveationLevel: number;
  20576. }
  20577. module "babylonjs/Engines/engine" {
  20578. interface Engine {
  20579. /** @hidden */
  20580. _vrDisplay: any;
  20581. /** @hidden */
  20582. _vrSupported: boolean;
  20583. /** @hidden */
  20584. _oldSize: Size;
  20585. /** @hidden */
  20586. _oldHardwareScaleFactor: number;
  20587. /** @hidden */
  20588. _vrExclusivePointerMode: boolean;
  20589. /** @hidden */
  20590. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20591. /** @hidden */
  20592. _onVRDisplayPointerRestricted: () => void;
  20593. /** @hidden */
  20594. _onVRDisplayPointerUnrestricted: () => void;
  20595. /** @hidden */
  20596. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20597. /** @hidden */
  20598. _onVrDisplayDisconnect: Nullable<() => void>;
  20599. /** @hidden */
  20600. _onVrDisplayPresentChange: Nullable<() => void>;
  20601. /**
  20602. * Observable signaled when VR display mode changes
  20603. */
  20604. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20605. /**
  20606. * Observable signaled when VR request present is complete
  20607. */
  20608. onVRRequestPresentComplete: Observable<boolean>;
  20609. /**
  20610. * Observable signaled when VR request present starts
  20611. */
  20612. onVRRequestPresentStart: Observable<Engine>;
  20613. /**
  20614. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20615. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20616. */
  20617. isInVRExclusivePointerMode: boolean;
  20618. /**
  20619. * Gets a boolean indicating if a webVR device was detected
  20620. * @returns true if a webVR device was detected
  20621. */
  20622. isVRDevicePresent(): boolean;
  20623. /**
  20624. * Gets the current webVR device
  20625. * @returns the current webVR device (or null)
  20626. */
  20627. getVRDevice(): any;
  20628. /**
  20629. * Initializes a webVR display and starts listening to display change events
  20630. * The onVRDisplayChangedObservable will be notified upon these changes
  20631. * @returns A promise containing a VRDisplay and if vr is supported
  20632. */
  20633. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20634. /** @hidden */
  20635. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20636. /**
  20637. * Gets or sets the presentation attributes used to configure VR rendering
  20638. */
  20639. vrPresentationAttributes?: IVRPresentationAttributes;
  20640. /**
  20641. * Call this function to switch to webVR mode
  20642. * Will do nothing if webVR is not supported or if there is no webVR device
  20643. * @param options the webvr options provided to the camera. mainly used for multiview
  20644. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20645. */
  20646. enableVR(options: WebVROptions): void;
  20647. /** @hidden */
  20648. _onVRFullScreenTriggered(): void;
  20649. }
  20650. }
  20651. }
  20652. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20653. import { Nullable } from "babylonjs/types";
  20654. import { Observable } from "babylonjs/Misc/observable";
  20655. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20656. import { Scene } from "babylonjs/scene";
  20657. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20658. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20659. import { Node } from "babylonjs/node";
  20660. import { Ray } from "babylonjs/Culling/ray";
  20661. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20662. import "babylonjs/Engines/Extensions/engine.webVR";
  20663. /**
  20664. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20665. * IMPORTANT!! The data is right-hand data.
  20666. * @export
  20667. * @interface DevicePose
  20668. */
  20669. export interface DevicePose {
  20670. /**
  20671. * The position of the device, values in array are [x,y,z].
  20672. */
  20673. readonly position: Nullable<Float32Array>;
  20674. /**
  20675. * The linearVelocity of the device, values in array are [x,y,z].
  20676. */
  20677. readonly linearVelocity: Nullable<Float32Array>;
  20678. /**
  20679. * The linearAcceleration of the device, values in array are [x,y,z].
  20680. */
  20681. readonly linearAcceleration: Nullable<Float32Array>;
  20682. /**
  20683. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20684. */
  20685. readonly orientation: Nullable<Float32Array>;
  20686. /**
  20687. * The angularVelocity of the device, values in array are [x,y,z].
  20688. */
  20689. readonly angularVelocity: Nullable<Float32Array>;
  20690. /**
  20691. * The angularAcceleration of the device, values in array are [x,y,z].
  20692. */
  20693. readonly angularAcceleration: Nullable<Float32Array>;
  20694. }
  20695. /**
  20696. * Interface representing a pose controlled object in Babylon.
  20697. * A pose controlled object has both regular pose values as well as pose values
  20698. * from an external device such as a VR head mounted display
  20699. */
  20700. export interface PoseControlled {
  20701. /**
  20702. * The position of the object in babylon space.
  20703. */
  20704. position: Vector3;
  20705. /**
  20706. * The rotation quaternion of the object in babylon space.
  20707. */
  20708. rotationQuaternion: Quaternion;
  20709. /**
  20710. * The position of the device in babylon space.
  20711. */
  20712. devicePosition?: Vector3;
  20713. /**
  20714. * The rotation quaternion of the device in babylon space.
  20715. */
  20716. deviceRotationQuaternion: Quaternion;
  20717. /**
  20718. * The raw pose coming from the device.
  20719. */
  20720. rawPose: Nullable<DevicePose>;
  20721. /**
  20722. * The scale of the device to be used when translating from device space to babylon space.
  20723. */
  20724. deviceScaleFactor: number;
  20725. /**
  20726. * Updates the poseControlled values based on the input device pose.
  20727. * @param poseData the pose data to update the object with
  20728. */
  20729. updateFromDevice(poseData: DevicePose): void;
  20730. }
  20731. /**
  20732. * Set of options to customize the webVRCamera
  20733. */
  20734. export interface WebVROptions {
  20735. /**
  20736. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20737. */
  20738. trackPosition?: boolean;
  20739. /**
  20740. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20741. */
  20742. positionScale?: number;
  20743. /**
  20744. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20745. */
  20746. displayName?: string;
  20747. /**
  20748. * Should the native controller meshes be initialized. (default: true)
  20749. */
  20750. controllerMeshes?: boolean;
  20751. /**
  20752. * Creating a default HemiLight only on controllers. (default: true)
  20753. */
  20754. defaultLightingOnControllers?: boolean;
  20755. /**
  20756. * If you don't want to use the default VR button of the helper. (default: false)
  20757. */
  20758. useCustomVRButton?: boolean;
  20759. /**
  20760. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20761. */
  20762. customVRButton?: HTMLButtonElement;
  20763. /**
  20764. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20765. */
  20766. rayLength?: number;
  20767. /**
  20768. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20769. */
  20770. defaultHeight?: number;
  20771. /**
  20772. * If multiview should be used if availible (default: false)
  20773. */
  20774. useMultiview?: boolean;
  20775. }
  20776. /**
  20777. * This represents a WebVR camera.
  20778. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20779. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20780. */
  20781. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20782. private webVROptions;
  20783. /**
  20784. * @hidden
  20785. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20786. */
  20787. _vrDevice: any;
  20788. /**
  20789. * The rawPose of the vrDevice.
  20790. */
  20791. rawPose: Nullable<DevicePose>;
  20792. private _onVREnabled;
  20793. private _specsVersion;
  20794. private _attached;
  20795. private _frameData;
  20796. protected _descendants: Array<Node>;
  20797. private _deviceRoomPosition;
  20798. /** @hidden */
  20799. _deviceRoomRotationQuaternion: Quaternion;
  20800. private _standingMatrix;
  20801. /**
  20802. * Represents device position in babylon space.
  20803. */
  20804. devicePosition: Vector3;
  20805. /**
  20806. * Represents device rotation in babylon space.
  20807. */
  20808. deviceRotationQuaternion: Quaternion;
  20809. /**
  20810. * The scale of the device to be used when translating from device space to babylon space.
  20811. */
  20812. deviceScaleFactor: number;
  20813. private _deviceToWorld;
  20814. private _worldToDevice;
  20815. /**
  20816. * References to the webVR controllers for the vrDevice.
  20817. */
  20818. controllers: Array<WebVRController>;
  20819. /**
  20820. * Emits an event when a controller is attached.
  20821. */
  20822. onControllersAttachedObservable: Observable<WebVRController[]>;
  20823. /**
  20824. * Emits an event when a controller's mesh has been loaded;
  20825. */
  20826. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20827. /**
  20828. * Emits an event when the HMD's pose has been updated.
  20829. */
  20830. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20831. private _poseSet;
  20832. /**
  20833. * If the rig cameras be used as parent instead of this camera.
  20834. */
  20835. rigParenting: boolean;
  20836. private _lightOnControllers;
  20837. private _defaultHeight?;
  20838. /**
  20839. * Instantiates a WebVRFreeCamera.
  20840. * @param name The name of the WebVRFreeCamera
  20841. * @param position The starting anchor position for the camera
  20842. * @param scene The scene the camera belongs to
  20843. * @param webVROptions a set of customizable options for the webVRCamera
  20844. */
  20845. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20846. /**
  20847. * Gets the device distance from the ground in meters.
  20848. * @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.
  20849. */
  20850. deviceDistanceToRoomGround(): number;
  20851. /**
  20852. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20853. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20854. */
  20855. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20856. /**
  20857. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20858. * @returns A promise with a boolean set to if the standing matrix is supported.
  20859. */
  20860. useStandingMatrixAsync(): Promise<boolean>;
  20861. /**
  20862. * Disposes the camera
  20863. */
  20864. dispose(): void;
  20865. /**
  20866. * Gets a vrController by name.
  20867. * @param name The name of the controller to retreive
  20868. * @returns the controller matching the name specified or null if not found
  20869. */
  20870. getControllerByName(name: string): Nullable<WebVRController>;
  20871. private _leftController;
  20872. /**
  20873. * The controller corresponding to the users left hand.
  20874. */
  20875. get leftController(): Nullable<WebVRController>;
  20876. private _rightController;
  20877. /**
  20878. * The controller corresponding to the users right hand.
  20879. */
  20880. get rightController(): Nullable<WebVRController>;
  20881. /**
  20882. * Casts a ray forward from the vrCamera's gaze.
  20883. * @param length Length of the ray (default: 100)
  20884. * @returns the ray corresponding to the gaze
  20885. */
  20886. getForwardRay(length?: number): Ray;
  20887. /**
  20888. * @hidden
  20889. * Updates the camera based on device's frame data
  20890. */
  20891. _checkInputs(): void;
  20892. /**
  20893. * Updates the poseControlled values based on the input device pose.
  20894. * @param poseData Pose coming from the device
  20895. */
  20896. updateFromDevice(poseData: DevicePose): void;
  20897. private _htmlElementAttached;
  20898. private _detachIfAttached;
  20899. /**
  20900. * WebVR's attach control will start broadcasting frames to the device.
  20901. * Note that in certain browsers (chrome for example) this function must be called
  20902. * within a user-interaction callback. Example:
  20903. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20904. *
  20905. * @param element html element to attach the vrDevice to
  20906. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20907. */
  20908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20909. /**
  20910. * Detaches the camera from the html element and disables VR
  20911. *
  20912. * @param element html element to detach from
  20913. */
  20914. detachControl(element: HTMLElement): void;
  20915. /**
  20916. * @returns the name of this class
  20917. */
  20918. getClassName(): string;
  20919. /**
  20920. * Calls resetPose on the vrDisplay
  20921. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20922. */
  20923. resetToCurrentRotation(): void;
  20924. /**
  20925. * @hidden
  20926. * Updates the rig cameras (left and right eye)
  20927. */
  20928. _updateRigCameras(): void;
  20929. private _workingVector;
  20930. private _oneVector;
  20931. private _workingMatrix;
  20932. private updateCacheCalled;
  20933. private _correctPositionIfNotTrackPosition;
  20934. /**
  20935. * @hidden
  20936. * Updates the cached values of the camera
  20937. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20938. */
  20939. _updateCache(ignoreParentClass?: boolean): void;
  20940. /**
  20941. * @hidden
  20942. * Get current device position in babylon world
  20943. */
  20944. _computeDevicePosition(): void;
  20945. /**
  20946. * Updates the current device position and rotation in the babylon world
  20947. */
  20948. update(): void;
  20949. /**
  20950. * @hidden
  20951. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20952. * @returns an identity matrix
  20953. */
  20954. _getViewMatrix(): Matrix;
  20955. private _tmpMatrix;
  20956. /**
  20957. * This function is called by the two RIG cameras.
  20958. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20959. * @hidden
  20960. */
  20961. _getWebVRViewMatrix(): Matrix;
  20962. /** @hidden */
  20963. _getWebVRProjectionMatrix(): Matrix;
  20964. private _onGamepadConnectedObserver;
  20965. private _onGamepadDisconnectedObserver;
  20966. private _updateCacheWhenTrackingDisabledObserver;
  20967. /**
  20968. * Initializes the controllers and their meshes
  20969. */
  20970. initControllers(): void;
  20971. }
  20972. }
  20973. declare module "babylonjs/Materials/materialHelper" {
  20974. import { Nullable } from "babylonjs/types";
  20975. import { Scene } from "babylonjs/scene";
  20976. import { Engine } from "babylonjs/Engines/engine";
  20977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20978. import { Light } from "babylonjs/Lights/light";
  20979. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20980. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20981. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20983. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20984. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20985. /**
  20986. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20987. *
  20988. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20989. *
  20990. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20991. */
  20992. export class MaterialHelper {
  20993. /**
  20994. * Bind the current view position to an effect.
  20995. * @param effect The effect to be bound
  20996. * @param scene The scene the eyes position is used from
  20997. * @param variableName name of the shader variable that will hold the eye position
  20998. */
  20999. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  21000. /**
  21001. * Helps preparing the defines values about the UVs in used in the effect.
  21002. * UVs are shared as much as we can accross channels in the shaders.
  21003. * @param texture The texture we are preparing the UVs for
  21004. * @param defines The defines to update
  21005. * @param key The channel key "diffuse", "specular"... used in the shader
  21006. */
  21007. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  21008. /**
  21009. * Binds a texture matrix value to its corrsponding uniform
  21010. * @param texture The texture to bind the matrix for
  21011. * @param uniformBuffer The uniform buffer receivin the data
  21012. * @param key The channel key "diffuse", "specular"... used in the shader
  21013. */
  21014. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  21015. /**
  21016. * Gets the current status of the fog (should it be enabled?)
  21017. * @param mesh defines the mesh to evaluate for fog support
  21018. * @param scene defines the hosting scene
  21019. * @returns true if fog must be enabled
  21020. */
  21021. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  21022. /**
  21023. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  21024. * @param mesh defines the current mesh
  21025. * @param scene defines the current scene
  21026. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21027. * @param pointsCloud defines if point cloud rendering has to be turned on
  21028. * @param fogEnabled defines if fog has to be turned on
  21029. * @param alphaTest defines if alpha testing has to be turned on
  21030. * @param defines defines the current list of defines
  21031. */
  21032. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21033. /**
  21034. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21035. * @param scene defines the current scene
  21036. * @param engine defines the current engine
  21037. * @param defines specifies the list of active defines
  21038. * @param useInstances defines if instances have to be turned on
  21039. * @param useClipPlane defines if clip plane have to be turned on
  21040. * @param useInstances defines if instances have to be turned on
  21041. * @param useThinInstances defines if thin instances have to be turned on
  21042. */
  21043. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21044. /**
  21045. * Prepares the defines for bones
  21046. * @param mesh The mesh containing the geometry data we will draw
  21047. * @param defines The defines to update
  21048. */
  21049. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21050. /**
  21051. * Prepares the defines for morph targets
  21052. * @param mesh The mesh containing the geometry data we will draw
  21053. * @param defines The defines to update
  21054. */
  21055. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21056. /**
  21057. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21058. * @param mesh The mesh containing the geometry data we will draw
  21059. * @param defines The defines to update
  21060. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21061. * @param useBones Precise whether bones should be used or not (override mesh info)
  21062. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21063. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21064. * @returns false if defines are considered not dirty and have not been checked
  21065. */
  21066. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21067. /**
  21068. * Prepares the defines related to multiview
  21069. * @param scene The scene we are intending to draw
  21070. * @param defines The defines to update
  21071. */
  21072. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21073. /**
  21074. * Prepares the defines related to the prepass
  21075. * @param scene The scene we are intending to draw
  21076. * @param defines The defines to update
  21077. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21078. */
  21079. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21080. /**
  21081. * Prepares the defines related to the light information passed in parameter
  21082. * @param scene The scene we are intending to draw
  21083. * @param mesh The mesh the effect is compiling for
  21084. * @param light The light the effect is compiling for
  21085. * @param lightIndex The index of the light
  21086. * @param defines The defines to update
  21087. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21088. * @param state Defines the current state regarding what is needed (normals, etc...)
  21089. */
  21090. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21091. needNormals: boolean;
  21092. needRebuild: boolean;
  21093. shadowEnabled: boolean;
  21094. specularEnabled: boolean;
  21095. lightmapMode: boolean;
  21096. }): void;
  21097. /**
  21098. * Prepares the defines related to the light information passed in parameter
  21099. * @param scene The scene we are intending to draw
  21100. * @param mesh The mesh the effect is compiling for
  21101. * @param defines The defines to update
  21102. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21103. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21104. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21105. * @returns true if normals will be required for the rest of the effect
  21106. */
  21107. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21108. /**
  21109. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21110. * @param lightIndex defines the light index
  21111. * @param uniformsList The uniform list
  21112. * @param samplersList The sampler list
  21113. * @param projectedLightTexture defines if projected texture must be used
  21114. * @param uniformBuffersList defines an optional list of uniform buffers
  21115. */
  21116. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21117. /**
  21118. * Prepares the uniforms and samplers list to be used in the effect
  21119. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21120. * @param samplersList The sampler list
  21121. * @param defines The defines helping in the list generation
  21122. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21123. */
  21124. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21125. /**
  21126. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21127. * @param defines The defines to update while falling back
  21128. * @param fallbacks The authorized effect fallbacks
  21129. * @param maxSimultaneousLights The maximum number of lights allowed
  21130. * @param rank the current rank of the Effect
  21131. * @returns The newly affected rank
  21132. */
  21133. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21134. private static _TmpMorphInfluencers;
  21135. /**
  21136. * Prepares the list of attributes required for morph targets according to the effect defines.
  21137. * @param attribs The current list of supported attribs
  21138. * @param mesh The mesh to prepare the morph targets attributes for
  21139. * @param influencers The number of influencers
  21140. */
  21141. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21142. /**
  21143. * Prepares the list of attributes required for morph targets according to the effect defines.
  21144. * @param attribs The current list of supported attribs
  21145. * @param mesh The mesh to prepare the morph targets attributes for
  21146. * @param defines The current Defines of the effect
  21147. */
  21148. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21149. /**
  21150. * Prepares the list of attributes required for bones according to the effect defines.
  21151. * @param attribs The current list of supported attribs
  21152. * @param mesh The mesh to prepare the bones attributes for
  21153. * @param defines The current Defines of the effect
  21154. * @param fallbacks The current efffect fallback strategy
  21155. */
  21156. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21157. /**
  21158. * Check and prepare the list of attributes required for instances according to the effect defines.
  21159. * @param attribs The current list of supported attribs
  21160. * @param defines The current MaterialDefines of the effect
  21161. */
  21162. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21163. /**
  21164. * Add the list of attributes required for instances to the attribs array.
  21165. * @param attribs The current list of supported attribs
  21166. */
  21167. static PushAttributesForInstances(attribs: string[]): void;
  21168. /**
  21169. * Binds the light information to the effect.
  21170. * @param light The light containing the generator
  21171. * @param effect The effect we are binding the data to
  21172. * @param lightIndex The light index in the effect used to render
  21173. */
  21174. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21175. /**
  21176. * Binds the lights information from the scene to the effect for the given mesh.
  21177. * @param light Light to bind
  21178. * @param lightIndex Light index
  21179. * @param scene The scene where the light belongs to
  21180. * @param effect The effect we are binding the data to
  21181. * @param useSpecular Defines if specular is supported
  21182. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21183. */
  21184. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21185. /**
  21186. * Binds the lights information from the scene to the effect for the given mesh.
  21187. * @param scene The scene the lights belongs to
  21188. * @param mesh The mesh we are binding the information to render
  21189. * @param effect The effect we are binding the data to
  21190. * @param defines The generated defines for the effect
  21191. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21192. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21193. */
  21194. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21195. private static _tempFogColor;
  21196. /**
  21197. * Binds the fog information from the scene to the effect for the given mesh.
  21198. * @param scene The scene the lights belongs to
  21199. * @param mesh The mesh we are binding the information to render
  21200. * @param effect The effect we are binding the data to
  21201. * @param linearSpace Defines if the fog effect is applied in linear space
  21202. */
  21203. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21204. /**
  21205. * Binds the bones information from the mesh to the effect.
  21206. * @param mesh The mesh we are binding the information to render
  21207. * @param effect The effect we are binding the data to
  21208. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21209. */
  21210. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21211. private static _CopyBonesTransformationMatrices;
  21212. /**
  21213. * Binds the morph targets information from the mesh to the effect.
  21214. * @param abstractMesh The mesh we are binding the information to render
  21215. * @param effect The effect we are binding the data to
  21216. */
  21217. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21218. /**
  21219. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21220. * @param defines The generated defines used in the effect
  21221. * @param effect The effect we are binding the data to
  21222. * @param scene The scene we are willing to render with logarithmic scale for
  21223. */
  21224. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21225. /**
  21226. * Binds the clip plane information from the scene to the effect.
  21227. * @param scene The scene the clip plane information are extracted from
  21228. * @param effect The effect we are binding the data to
  21229. */
  21230. static BindClipPlane(effect: Effect, scene: Scene): void;
  21231. }
  21232. }
  21233. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21235. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21236. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21237. import { Nullable } from "babylonjs/types";
  21238. import { Effect } from "babylonjs/Materials/effect";
  21239. import { Matrix } from "babylonjs/Maths/math.vector";
  21240. import { Scene } from "babylonjs/scene";
  21241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21243. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21244. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21245. import { Observable } from "babylonjs/Misc/observable";
  21246. /**
  21247. * Block used to expose an input value
  21248. */
  21249. export class InputBlock extends NodeMaterialBlock {
  21250. private _mode;
  21251. private _associatedVariableName;
  21252. private _storedValue;
  21253. private _valueCallback;
  21254. private _type;
  21255. private _animationType;
  21256. /** Gets or set a value used to limit the range of float values */
  21257. min: number;
  21258. /** Gets or set a value used to limit the range of float values */
  21259. max: number;
  21260. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21261. isBoolean: boolean;
  21262. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21263. matrixMode: number;
  21264. /** @hidden */
  21265. _systemValue: Nullable<NodeMaterialSystemValues>;
  21266. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21267. isConstant: boolean;
  21268. /** Gets or sets the group to use to display this block in the Inspector */
  21269. groupInInspector: string;
  21270. /** Gets an observable raised when the value is changed */
  21271. onValueChangedObservable: Observable<InputBlock>;
  21272. /**
  21273. * Gets or sets the connection point type (default is float)
  21274. */
  21275. get type(): NodeMaterialBlockConnectionPointTypes;
  21276. /**
  21277. * Creates a new InputBlock
  21278. * @param name defines the block name
  21279. * @param target defines the target of that block (Vertex by default)
  21280. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21281. */
  21282. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21283. /**
  21284. * Validates if a name is a reserve word.
  21285. * @param newName the new name to be given to the node.
  21286. * @returns false if the name is a reserve word, else true.
  21287. */
  21288. validateBlockName(newName: string): boolean;
  21289. /**
  21290. * Gets the output component
  21291. */
  21292. get output(): NodeMaterialConnectionPoint;
  21293. /**
  21294. * Set the source of this connection point to a vertex attribute
  21295. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21296. * @returns the current connection point
  21297. */
  21298. setAsAttribute(attributeName?: string): InputBlock;
  21299. /**
  21300. * Set the source of this connection point to a system value
  21301. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21302. * @returns the current connection point
  21303. */
  21304. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21305. /**
  21306. * Gets or sets the value of that point.
  21307. * Please note that this value will be ignored if valueCallback is defined
  21308. */
  21309. get value(): any;
  21310. set value(value: any);
  21311. /**
  21312. * Gets or sets a callback used to get the value of that point.
  21313. * Please note that setting this value will force the connection point to ignore the value property
  21314. */
  21315. get valueCallback(): () => any;
  21316. set valueCallback(value: () => any);
  21317. /**
  21318. * Gets or sets the associated variable name in the shader
  21319. */
  21320. get associatedVariableName(): string;
  21321. set associatedVariableName(value: string);
  21322. /** Gets or sets the type of animation applied to the input */
  21323. get animationType(): AnimatedInputBlockTypes;
  21324. set animationType(value: AnimatedInputBlockTypes);
  21325. /**
  21326. * Gets a boolean indicating that this connection point not defined yet
  21327. */
  21328. get isUndefined(): boolean;
  21329. /**
  21330. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21331. * In this case the connection point name must be the name of the uniform to use.
  21332. * Can only be set on inputs
  21333. */
  21334. get isUniform(): boolean;
  21335. set isUniform(value: boolean);
  21336. /**
  21337. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21338. * In this case the connection point name must be the name of the attribute to use
  21339. * Can only be set on inputs
  21340. */
  21341. get isAttribute(): boolean;
  21342. set isAttribute(value: boolean);
  21343. /**
  21344. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21345. * Can only be set on exit points
  21346. */
  21347. get isVarying(): boolean;
  21348. set isVarying(value: boolean);
  21349. /**
  21350. * Gets a boolean indicating that the current connection point is a system value
  21351. */
  21352. get isSystemValue(): boolean;
  21353. /**
  21354. * Gets or sets the current well known value or null if not defined as a system value
  21355. */
  21356. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21357. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21358. /**
  21359. * Gets the current class name
  21360. * @returns the class name
  21361. */
  21362. getClassName(): string;
  21363. /**
  21364. * Animate the input if animationType !== None
  21365. * @param scene defines the rendering scene
  21366. */
  21367. animate(scene: Scene): void;
  21368. private _emitDefine;
  21369. initialize(state: NodeMaterialBuildState): void;
  21370. /**
  21371. * Set the input block to its default value (based on its type)
  21372. */
  21373. setDefaultValue(): void;
  21374. private _emitConstant;
  21375. /** @hidden */
  21376. get _noContextSwitch(): boolean;
  21377. private _emit;
  21378. /** @hidden */
  21379. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21380. /** @hidden */
  21381. _transmit(effect: Effect, scene: Scene): void;
  21382. protected _buildBlock(state: NodeMaterialBuildState): void;
  21383. protected _dumpPropertiesCode(): string;
  21384. dispose(): void;
  21385. serialize(): any;
  21386. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21387. }
  21388. }
  21389. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21390. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21391. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21392. import { Nullable } from "babylonjs/types";
  21393. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21394. import { Observable } from "babylonjs/Misc/observable";
  21395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21396. /**
  21397. * Enum used to define the compatibility state between two connection points
  21398. */
  21399. export enum NodeMaterialConnectionPointCompatibilityStates {
  21400. /** Points are compatibles */
  21401. Compatible = 0,
  21402. /** Points are incompatible because of their types */
  21403. TypeIncompatible = 1,
  21404. /** Points are incompatible because of their targets (vertex vs fragment) */
  21405. TargetIncompatible = 2
  21406. }
  21407. /**
  21408. * Defines the direction of a connection point
  21409. */
  21410. export enum NodeMaterialConnectionPointDirection {
  21411. /** Input */
  21412. Input = 0,
  21413. /** Output */
  21414. Output = 1
  21415. }
  21416. /**
  21417. * Defines a connection point for a block
  21418. */
  21419. export class NodeMaterialConnectionPoint {
  21420. /** @hidden */
  21421. _ownerBlock: NodeMaterialBlock;
  21422. /** @hidden */
  21423. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21424. private _endpoints;
  21425. private _associatedVariableName;
  21426. private _direction;
  21427. /** @hidden */
  21428. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21429. /** @hidden */
  21430. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21431. private _type;
  21432. /** @hidden */
  21433. _enforceAssociatedVariableName: boolean;
  21434. /** Gets the direction of the point */
  21435. get direction(): NodeMaterialConnectionPointDirection;
  21436. /** Indicates that this connection point needs dual validation before being connected to another point */
  21437. needDualDirectionValidation: boolean;
  21438. /**
  21439. * Gets or sets the additional types supported by this connection point
  21440. */
  21441. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21442. /**
  21443. * Gets or sets the additional types excluded by this connection point
  21444. */
  21445. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21446. /**
  21447. * Observable triggered when this point is connected
  21448. */
  21449. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21450. /**
  21451. * Gets or sets the associated variable name in the shader
  21452. */
  21453. get associatedVariableName(): string;
  21454. set associatedVariableName(value: string);
  21455. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21456. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21457. /**
  21458. * Gets or sets the connection point type (default is float)
  21459. */
  21460. get type(): NodeMaterialBlockConnectionPointTypes;
  21461. set type(value: NodeMaterialBlockConnectionPointTypes);
  21462. /**
  21463. * Gets or sets the connection point name
  21464. */
  21465. name: string;
  21466. /**
  21467. * Gets or sets the connection point name
  21468. */
  21469. displayName: string;
  21470. /**
  21471. * Gets or sets a boolean indicating that this connection point can be omitted
  21472. */
  21473. isOptional: boolean;
  21474. /**
  21475. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21476. */
  21477. isExposedOnFrame: boolean;
  21478. /**
  21479. * Gets or sets number indicating the position that the port is exposed to on a frame
  21480. */
  21481. exposedPortPosition: number;
  21482. /**
  21483. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21484. */
  21485. define: string;
  21486. /** @hidden */
  21487. _prioritizeVertex: boolean;
  21488. private _target;
  21489. /** Gets or sets the target of that connection point */
  21490. get target(): NodeMaterialBlockTargets;
  21491. set target(value: NodeMaterialBlockTargets);
  21492. /**
  21493. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21494. */
  21495. get isConnected(): boolean;
  21496. /**
  21497. * Gets a boolean indicating that the current point is connected to an input block
  21498. */
  21499. get isConnectedToInputBlock(): boolean;
  21500. /**
  21501. * Gets a the connected input block (if any)
  21502. */
  21503. get connectInputBlock(): Nullable<InputBlock>;
  21504. /** Get the other side of the connection (if any) */
  21505. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21506. /** Get the block that owns this connection point */
  21507. get ownerBlock(): NodeMaterialBlock;
  21508. /** Get the block connected on the other side of this connection (if any) */
  21509. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21510. /** Get the block connected on the endpoints of this connection (if any) */
  21511. get connectedBlocks(): Array<NodeMaterialBlock>;
  21512. /** Gets the list of connected endpoints */
  21513. get endpoints(): NodeMaterialConnectionPoint[];
  21514. /** Gets a boolean indicating if that output point is connected to at least one input */
  21515. get hasEndpoints(): boolean;
  21516. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21517. get isConnectedInVertexShader(): boolean;
  21518. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21519. get isConnectedInFragmentShader(): boolean;
  21520. /**
  21521. * Creates a block suitable to be used as an input for this input point.
  21522. * If null is returned, a block based on the point type will be created.
  21523. * @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
  21524. */
  21525. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21526. /**
  21527. * Creates a new connection point
  21528. * @param name defines the connection point name
  21529. * @param ownerBlock defines the block hosting this connection point
  21530. * @param direction defines the direction of the connection point
  21531. */
  21532. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21533. /**
  21534. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21535. * @returns the class name
  21536. */
  21537. getClassName(): string;
  21538. /**
  21539. * Gets a boolean indicating if the current point can be connected to another point
  21540. * @param connectionPoint defines the other connection point
  21541. * @returns a boolean
  21542. */
  21543. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21544. /**
  21545. * Gets a number indicating if the current point can be connected to another point
  21546. * @param connectionPoint defines the other connection point
  21547. * @returns a number defining the compatibility state
  21548. */
  21549. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21550. /**
  21551. * Connect this point to another connection point
  21552. * @param connectionPoint defines the other connection point
  21553. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21554. * @returns the current connection point
  21555. */
  21556. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21557. /**
  21558. * Disconnect this point from one of his endpoint
  21559. * @param endpoint defines the other connection point
  21560. * @returns the current connection point
  21561. */
  21562. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21563. /**
  21564. * Serializes this point in a JSON representation
  21565. * @param isInput defines if the connection point is an input (default is true)
  21566. * @returns the serialized point object
  21567. */
  21568. serialize(isInput?: boolean): any;
  21569. /**
  21570. * Release resources
  21571. */
  21572. dispose(): void;
  21573. }
  21574. }
  21575. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21576. /**
  21577. * Enum used to define the material modes
  21578. */
  21579. export enum NodeMaterialModes {
  21580. /** Regular material */
  21581. Material = 0,
  21582. /** For post process */
  21583. PostProcess = 1,
  21584. /** For particle system */
  21585. Particle = 2,
  21586. /** For procedural texture */
  21587. ProceduralTexture = 3
  21588. }
  21589. }
  21590. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21593. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21594. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21596. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21597. import { Effect } from "babylonjs/Materials/effect";
  21598. import { Mesh } from "babylonjs/Meshes/mesh";
  21599. import { Nullable } from "babylonjs/types";
  21600. import { Texture } from "babylonjs/Materials/Textures/texture";
  21601. import { Scene } from "babylonjs/scene";
  21602. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21603. /**
  21604. * Block used to read a texture from a sampler
  21605. */
  21606. export class TextureBlock extends NodeMaterialBlock {
  21607. private _defineName;
  21608. private _linearDefineName;
  21609. private _gammaDefineName;
  21610. private _tempTextureRead;
  21611. private _samplerName;
  21612. private _transformedUVName;
  21613. private _textureTransformName;
  21614. private _textureInfoName;
  21615. private _mainUVName;
  21616. private _mainUVDefineName;
  21617. private _fragmentOnly;
  21618. /**
  21619. * Gets or sets the texture associated with the node
  21620. */
  21621. texture: Nullable<Texture>;
  21622. /**
  21623. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21624. */
  21625. convertToGammaSpace: boolean;
  21626. /**
  21627. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21628. */
  21629. convertToLinearSpace: boolean;
  21630. /**
  21631. * Create a new TextureBlock
  21632. * @param name defines the block name
  21633. */
  21634. constructor(name: string, fragmentOnly?: boolean);
  21635. /**
  21636. * Gets the current class name
  21637. * @returns the class name
  21638. */
  21639. getClassName(): string;
  21640. /**
  21641. * Gets the uv input component
  21642. */
  21643. get uv(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the rgba output component
  21646. */
  21647. get rgba(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the rgb output component
  21650. */
  21651. get rgb(): NodeMaterialConnectionPoint;
  21652. /**
  21653. * Gets the r output component
  21654. */
  21655. get r(): NodeMaterialConnectionPoint;
  21656. /**
  21657. * Gets the g output component
  21658. */
  21659. get g(): NodeMaterialConnectionPoint;
  21660. /**
  21661. * Gets the b output component
  21662. */
  21663. get b(): NodeMaterialConnectionPoint;
  21664. /**
  21665. * Gets the a output component
  21666. */
  21667. get a(): NodeMaterialConnectionPoint;
  21668. get target(): NodeMaterialBlockTargets;
  21669. autoConfigure(material: NodeMaterial): void;
  21670. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21671. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21672. isReady(): boolean;
  21673. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21674. private get _isMixed();
  21675. private _injectVertexCode;
  21676. private _writeTextureRead;
  21677. private _writeOutput;
  21678. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21679. protected _dumpPropertiesCode(): string;
  21680. serialize(): any;
  21681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21682. }
  21683. }
  21684. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21685. /** @hidden */
  21686. export var reflectionFunction: {
  21687. name: string;
  21688. shader: string;
  21689. };
  21690. }
  21691. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21692. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21693. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21694. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21695. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21697. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21698. import { Effect } from "babylonjs/Materials/effect";
  21699. import { Mesh } from "babylonjs/Meshes/mesh";
  21700. import { Nullable } from "babylonjs/types";
  21701. import { Scene } from "babylonjs/scene";
  21702. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21703. /**
  21704. * Base block used to read a reflection texture from a sampler
  21705. */
  21706. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21707. /** @hidden */
  21708. _define3DName: string;
  21709. /** @hidden */
  21710. _defineCubicName: string;
  21711. /** @hidden */
  21712. _defineExplicitName: string;
  21713. /** @hidden */
  21714. _defineProjectionName: string;
  21715. /** @hidden */
  21716. _defineLocalCubicName: string;
  21717. /** @hidden */
  21718. _defineSphericalName: string;
  21719. /** @hidden */
  21720. _definePlanarName: string;
  21721. /** @hidden */
  21722. _defineEquirectangularName: string;
  21723. /** @hidden */
  21724. _defineMirroredEquirectangularFixedName: string;
  21725. /** @hidden */
  21726. _defineEquirectangularFixedName: string;
  21727. /** @hidden */
  21728. _defineSkyboxName: string;
  21729. /** @hidden */
  21730. _defineOppositeZ: string;
  21731. /** @hidden */
  21732. _cubeSamplerName: string;
  21733. /** @hidden */
  21734. _2DSamplerName: string;
  21735. protected _positionUVWName: string;
  21736. protected _directionWName: string;
  21737. protected _reflectionVectorName: string;
  21738. /** @hidden */
  21739. _reflectionCoordsName: string;
  21740. /** @hidden */
  21741. _reflectionMatrixName: string;
  21742. protected _reflectionColorName: string;
  21743. /**
  21744. * Gets or sets the texture associated with the node
  21745. */
  21746. texture: Nullable<BaseTexture>;
  21747. /**
  21748. * Create a new ReflectionTextureBaseBlock
  21749. * @param name defines the block name
  21750. */
  21751. constructor(name: string);
  21752. /**
  21753. * Gets the current class name
  21754. * @returns the class name
  21755. */
  21756. getClassName(): string;
  21757. /**
  21758. * Gets the world position input component
  21759. */
  21760. abstract get position(): NodeMaterialConnectionPoint;
  21761. /**
  21762. * Gets the world position input component
  21763. */
  21764. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21765. /**
  21766. * Gets the world normal input component
  21767. */
  21768. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21769. /**
  21770. * Gets the world input component
  21771. */
  21772. abstract get world(): NodeMaterialConnectionPoint;
  21773. /**
  21774. * Gets the camera (or eye) position component
  21775. */
  21776. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21777. /**
  21778. * Gets the view input component
  21779. */
  21780. abstract get view(): NodeMaterialConnectionPoint;
  21781. protected _getTexture(): Nullable<BaseTexture>;
  21782. autoConfigure(material: NodeMaterial): void;
  21783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21784. isReady(): boolean;
  21785. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21786. /**
  21787. * Gets the code to inject in the vertex shader
  21788. * @param state current state of the node material building
  21789. * @returns the shader code
  21790. */
  21791. handleVertexSide(state: NodeMaterialBuildState): string;
  21792. /**
  21793. * Handles the inits for the fragment code path
  21794. * @param state node material build state
  21795. */
  21796. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21797. /**
  21798. * Generates the reflection coords code for the fragment code path
  21799. * @param worldNormalVarName name of the world normal variable
  21800. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21801. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21802. * @returns the shader code
  21803. */
  21804. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21805. /**
  21806. * Generates the reflection color code for the fragment code path
  21807. * @param lodVarName name of the lod variable
  21808. * @param swizzleLookupTexture swizzle to use for the final color variable
  21809. * @returns the shader code
  21810. */
  21811. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21812. /**
  21813. * Generates the code corresponding to the connected output points
  21814. * @param state node material build state
  21815. * @param varName name of the variable to output
  21816. * @returns the shader code
  21817. */
  21818. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21819. protected _buildBlock(state: NodeMaterialBuildState): this;
  21820. protected _dumpPropertiesCode(): string;
  21821. serialize(): any;
  21822. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21823. }
  21824. }
  21825. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21827. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21828. import { Nullable } from "babylonjs/types";
  21829. /**
  21830. * Defines a connection point to be used for points with a custom object type
  21831. */
  21832. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21833. private _blockType;
  21834. private _blockName;
  21835. private _nameForCheking?;
  21836. /**
  21837. * Creates a new connection point
  21838. * @param name defines the connection point name
  21839. * @param ownerBlock defines the block hosting this connection point
  21840. * @param direction defines the direction of the connection point
  21841. */
  21842. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21843. /**
  21844. * Gets a number indicating if the current point can be connected to another point
  21845. * @param connectionPoint defines the other connection point
  21846. * @returns a number defining the compatibility state
  21847. */
  21848. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21849. /**
  21850. * Creates a block suitable to be used as an input for this input point.
  21851. * If null is returned, a block based on the point type will be created.
  21852. * @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
  21853. */
  21854. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21855. }
  21856. }
  21857. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21858. /**
  21859. * Enum defining the type of properties that can be edited in the property pages in the NME
  21860. */
  21861. export enum PropertyTypeForEdition {
  21862. /** property is a boolean */
  21863. Boolean = 0,
  21864. /** property is a float */
  21865. Float = 1,
  21866. /** property is a Vector2 */
  21867. Vector2 = 2,
  21868. /** property is a list of values */
  21869. List = 3
  21870. }
  21871. /**
  21872. * Interface that defines an option in a variable of type list
  21873. */
  21874. export interface IEditablePropertyListOption {
  21875. /** label of the option */
  21876. "label": string;
  21877. /** value of the option */
  21878. "value": number;
  21879. }
  21880. /**
  21881. * Interface that defines the options available for an editable property
  21882. */
  21883. export interface IEditablePropertyOption {
  21884. /** min value */
  21885. "min"?: number;
  21886. /** max value */
  21887. "max"?: number;
  21888. /** notifiers: indicates which actions to take when the property is changed */
  21889. "notifiers"?: {
  21890. /** the material should be rebuilt */
  21891. "rebuild"?: boolean;
  21892. /** the preview should be updated */
  21893. "update"?: boolean;
  21894. };
  21895. /** list of the options for a variable of type list */
  21896. "options"?: IEditablePropertyListOption[];
  21897. }
  21898. /**
  21899. * Interface that describes an editable property
  21900. */
  21901. export interface IPropertyDescriptionForEdition {
  21902. /** name of the property */
  21903. "propertyName": string;
  21904. /** display name of the property */
  21905. "displayName": string;
  21906. /** type of the property */
  21907. "type": PropertyTypeForEdition;
  21908. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21909. "groupName": string;
  21910. /** options for the property */
  21911. "options": IEditablePropertyOption;
  21912. }
  21913. /**
  21914. * Decorator that flags a property in a node material block as being editable
  21915. */
  21916. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21917. }
  21918. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21921. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21923. import { Nullable } from "babylonjs/types";
  21924. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21925. import { Mesh } from "babylonjs/Meshes/mesh";
  21926. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21927. import { Effect } from "babylonjs/Materials/effect";
  21928. import { Scene } from "babylonjs/scene";
  21929. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21930. /**
  21931. * Block used to implement the refraction part of the sub surface module of the PBR material
  21932. */
  21933. export class RefractionBlock extends NodeMaterialBlock {
  21934. /** @hidden */
  21935. _define3DName: string;
  21936. /** @hidden */
  21937. _refractionMatrixName: string;
  21938. /** @hidden */
  21939. _defineLODRefractionAlpha: string;
  21940. /** @hidden */
  21941. _defineLinearSpecularRefraction: string;
  21942. /** @hidden */
  21943. _defineOppositeZ: string;
  21944. /** @hidden */
  21945. _cubeSamplerName: string;
  21946. /** @hidden */
  21947. _2DSamplerName: string;
  21948. /** @hidden */
  21949. _vRefractionMicrosurfaceInfosName: string;
  21950. /** @hidden */
  21951. _vRefractionInfosName: string;
  21952. private _scene;
  21953. /**
  21954. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21955. * Materials half opaque for instance using refraction could benefit from this control.
  21956. */
  21957. linkRefractionWithTransparency: boolean;
  21958. /**
  21959. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21960. */
  21961. invertRefractionY: boolean;
  21962. /**
  21963. * Gets or sets the texture associated with the node
  21964. */
  21965. texture: Nullable<BaseTexture>;
  21966. /**
  21967. * Create a new RefractionBlock
  21968. * @param name defines the block name
  21969. */
  21970. constructor(name: string);
  21971. /**
  21972. * Gets the current class name
  21973. * @returns the class name
  21974. */
  21975. getClassName(): string;
  21976. /**
  21977. * Gets the intensity input component
  21978. */
  21979. get intensity(): NodeMaterialConnectionPoint;
  21980. /**
  21981. * Gets the index of refraction input component
  21982. */
  21983. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21984. /**
  21985. * Gets the tint at distance input component
  21986. */
  21987. get tintAtDistance(): NodeMaterialConnectionPoint;
  21988. /**
  21989. * Gets the view input component
  21990. */
  21991. get view(): NodeMaterialConnectionPoint;
  21992. /**
  21993. * Gets the refraction object output component
  21994. */
  21995. get refraction(): NodeMaterialConnectionPoint;
  21996. /**
  21997. * Returns true if the block has a texture
  21998. */
  21999. get hasTexture(): boolean;
  22000. protected _getTexture(): Nullable<BaseTexture>;
  22001. autoConfigure(material: NodeMaterial): void;
  22002. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22003. isReady(): boolean;
  22004. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22005. /**
  22006. * Gets the main code of the block (fragment side)
  22007. * @param state current state of the node material building
  22008. * @returns the shader code
  22009. */
  22010. getCode(state: NodeMaterialBuildState): string;
  22011. protected _buildBlock(state: NodeMaterialBuildState): this;
  22012. protected _dumpPropertiesCode(): string;
  22013. serialize(): any;
  22014. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22015. }
  22016. }
  22017. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  22018. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22019. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22020. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22023. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22025. import { Nullable } from "babylonjs/types";
  22026. import { Scene } from "babylonjs/scene";
  22027. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22028. /**
  22029. * Base block used as input for post process
  22030. */
  22031. export class CurrentScreenBlock extends NodeMaterialBlock {
  22032. private _samplerName;
  22033. private _linearDefineName;
  22034. private _gammaDefineName;
  22035. private _mainUVName;
  22036. private _tempTextureRead;
  22037. /**
  22038. * Gets or sets the texture associated with the node
  22039. */
  22040. texture: Nullable<BaseTexture>;
  22041. /**
  22042. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22043. */
  22044. convertToGammaSpace: boolean;
  22045. /**
  22046. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22047. */
  22048. convertToLinearSpace: boolean;
  22049. /**
  22050. * Create a new CurrentScreenBlock
  22051. * @param name defines the block name
  22052. */
  22053. constructor(name: string);
  22054. /**
  22055. * Gets the current class name
  22056. * @returns the class name
  22057. */
  22058. getClassName(): string;
  22059. /**
  22060. * Gets the uv input component
  22061. */
  22062. get uv(): NodeMaterialConnectionPoint;
  22063. /**
  22064. * Gets the rgba output component
  22065. */
  22066. get rgba(): NodeMaterialConnectionPoint;
  22067. /**
  22068. * Gets the rgb output component
  22069. */
  22070. get rgb(): NodeMaterialConnectionPoint;
  22071. /**
  22072. * Gets the r output component
  22073. */
  22074. get r(): NodeMaterialConnectionPoint;
  22075. /**
  22076. * Gets the g output component
  22077. */
  22078. get g(): NodeMaterialConnectionPoint;
  22079. /**
  22080. * Gets the b output component
  22081. */
  22082. get b(): NodeMaterialConnectionPoint;
  22083. /**
  22084. * Gets the a output component
  22085. */
  22086. get a(): NodeMaterialConnectionPoint;
  22087. /**
  22088. * Initialize the block and prepare the context for build
  22089. * @param state defines the state that will be used for the build
  22090. */
  22091. initialize(state: NodeMaterialBuildState): void;
  22092. get target(): NodeMaterialBlockTargets;
  22093. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22094. isReady(): boolean;
  22095. private _injectVertexCode;
  22096. private _writeTextureRead;
  22097. private _writeOutput;
  22098. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22099. serialize(): any;
  22100. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22101. }
  22102. }
  22103. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22104. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22105. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22106. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22108. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22109. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22110. import { Nullable } from "babylonjs/types";
  22111. import { Scene } from "babylonjs/scene";
  22112. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22113. /**
  22114. * Base block used for the particle texture
  22115. */
  22116. export class ParticleTextureBlock extends NodeMaterialBlock {
  22117. private _samplerName;
  22118. private _linearDefineName;
  22119. private _gammaDefineName;
  22120. private _tempTextureRead;
  22121. /**
  22122. * Gets or sets the texture associated with the node
  22123. */
  22124. texture: Nullable<BaseTexture>;
  22125. /**
  22126. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22127. */
  22128. convertToGammaSpace: boolean;
  22129. /**
  22130. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22131. */
  22132. convertToLinearSpace: boolean;
  22133. /**
  22134. * Create a new ParticleTextureBlock
  22135. * @param name defines the block name
  22136. */
  22137. constructor(name: string);
  22138. /**
  22139. * Gets the current class name
  22140. * @returns the class name
  22141. */
  22142. getClassName(): string;
  22143. /**
  22144. * Gets the uv input component
  22145. */
  22146. get uv(): NodeMaterialConnectionPoint;
  22147. /**
  22148. * Gets the rgba output component
  22149. */
  22150. get rgba(): NodeMaterialConnectionPoint;
  22151. /**
  22152. * Gets the rgb output component
  22153. */
  22154. get rgb(): NodeMaterialConnectionPoint;
  22155. /**
  22156. * Gets the r output component
  22157. */
  22158. get r(): NodeMaterialConnectionPoint;
  22159. /**
  22160. * Gets the g output component
  22161. */
  22162. get g(): NodeMaterialConnectionPoint;
  22163. /**
  22164. * Gets the b output component
  22165. */
  22166. get b(): NodeMaterialConnectionPoint;
  22167. /**
  22168. * Gets the a output component
  22169. */
  22170. get a(): NodeMaterialConnectionPoint;
  22171. /**
  22172. * Initialize the block and prepare the context for build
  22173. * @param state defines the state that will be used for the build
  22174. */
  22175. initialize(state: NodeMaterialBuildState): void;
  22176. autoConfigure(material: NodeMaterial): void;
  22177. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22178. isReady(): boolean;
  22179. private _writeOutput;
  22180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22181. serialize(): any;
  22182. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22183. }
  22184. }
  22185. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22187. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22188. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22189. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22190. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22191. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22192. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22193. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22194. import { Scene } from "babylonjs/scene";
  22195. /**
  22196. * Class used to store shared data between 2 NodeMaterialBuildState
  22197. */
  22198. export class NodeMaterialBuildStateSharedData {
  22199. /**
  22200. * Gets the list of emitted varyings
  22201. */
  22202. temps: string[];
  22203. /**
  22204. * Gets the list of emitted varyings
  22205. */
  22206. varyings: string[];
  22207. /**
  22208. * Gets the varying declaration string
  22209. */
  22210. varyingDeclaration: string;
  22211. /**
  22212. * Input blocks
  22213. */
  22214. inputBlocks: InputBlock[];
  22215. /**
  22216. * Input blocks
  22217. */
  22218. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22219. /**
  22220. * Bindable blocks (Blocks that need to set data to the effect)
  22221. */
  22222. bindableBlocks: NodeMaterialBlock[];
  22223. /**
  22224. * List of blocks that can provide a compilation fallback
  22225. */
  22226. blocksWithFallbacks: NodeMaterialBlock[];
  22227. /**
  22228. * List of blocks that can provide a define update
  22229. */
  22230. blocksWithDefines: NodeMaterialBlock[];
  22231. /**
  22232. * List of blocks that can provide a repeatable content
  22233. */
  22234. repeatableContentBlocks: NodeMaterialBlock[];
  22235. /**
  22236. * List of blocks that can provide a dynamic list of uniforms
  22237. */
  22238. dynamicUniformBlocks: NodeMaterialBlock[];
  22239. /**
  22240. * List of blocks that can block the isReady function for the material
  22241. */
  22242. blockingBlocks: NodeMaterialBlock[];
  22243. /**
  22244. * Gets the list of animated inputs
  22245. */
  22246. animatedInputs: InputBlock[];
  22247. /**
  22248. * Build Id used to avoid multiple recompilations
  22249. */
  22250. buildId: number;
  22251. /** List of emitted variables */
  22252. variableNames: {
  22253. [key: string]: number;
  22254. };
  22255. /** List of emitted defines */
  22256. defineNames: {
  22257. [key: string]: number;
  22258. };
  22259. /** Should emit comments? */
  22260. emitComments: boolean;
  22261. /** Emit build activity */
  22262. verbose: boolean;
  22263. /** Gets or sets the hosting scene */
  22264. scene: Scene;
  22265. /**
  22266. * Gets the compilation hints emitted at compilation time
  22267. */
  22268. hints: {
  22269. needWorldViewMatrix: boolean;
  22270. needWorldViewProjectionMatrix: boolean;
  22271. needAlphaBlending: boolean;
  22272. needAlphaTesting: boolean;
  22273. };
  22274. /**
  22275. * List of compilation checks
  22276. */
  22277. checks: {
  22278. emitVertex: boolean;
  22279. emitFragment: boolean;
  22280. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22281. };
  22282. /**
  22283. * Is vertex program allowed to be empty?
  22284. */
  22285. allowEmptyVertexProgram: boolean;
  22286. /** Creates a new shared data */
  22287. constructor();
  22288. /**
  22289. * Emits console errors and exceptions if there is a failing check
  22290. */
  22291. emitErrors(): void;
  22292. }
  22293. }
  22294. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22295. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22296. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22297. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22298. /**
  22299. * Class used to store node based material build state
  22300. */
  22301. export class NodeMaterialBuildState {
  22302. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22303. supportUniformBuffers: boolean;
  22304. /**
  22305. * Gets the list of emitted attributes
  22306. */
  22307. attributes: string[];
  22308. /**
  22309. * Gets the list of emitted uniforms
  22310. */
  22311. uniforms: string[];
  22312. /**
  22313. * Gets the list of emitted constants
  22314. */
  22315. constants: string[];
  22316. /**
  22317. * Gets the list of emitted samplers
  22318. */
  22319. samplers: string[];
  22320. /**
  22321. * Gets the list of emitted functions
  22322. */
  22323. functions: {
  22324. [key: string]: string;
  22325. };
  22326. /**
  22327. * Gets the list of emitted extensions
  22328. */
  22329. extensions: {
  22330. [key: string]: string;
  22331. };
  22332. /**
  22333. * Gets the target of the compilation state
  22334. */
  22335. target: NodeMaterialBlockTargets;
  22336. /**
  22337. * Gets the list of emitted counters
  22338. */
  22339. counters: {
  22340. [key: string]: number;
  22341. };
  22342. /**
  22343. * Shared data between multiple NodeMaterialBuildState instances
  22344. */
  22345. sharedData: NodeMaterialBuildStateSharedData;
  22346. /** @hidden */
  22347. _vertexState: NodeMaterialBuildState;
  22348. /** @hidden */
  22349. _attributeDeclaration: string;
  22350. /** @hidden */
  22351. _uniformDeclaration: string;
  22352. /** @hidden */
  22353. _constantDeclaration: string;
  22354. /** @hidden */
  22355. _samplerDeclaration: string;
  22356. /** @hidden */
  22357. _varyingTransfer: string;
  22358. /** @hidden */
  22359. _injectAtEnd: string;
  22360. private _repeatableContentAnchorIndex;
  22361. /** @hidden */
  22362. _builtCompilationString: string;
  22363. /**
  22364. * Gets the emitted compilation strings
  22365. */
  22366. compilationString: string;
  22367. /**
  22368. * Finalize the compilation strings
  22369. * @param state defines the current compilation state
  22370. */
  22371. finalize(state: NodeMaterialBuildState): void;
  22372. /** @hidden */
  22373. get _repeatableContentAnchor(): string;
  22374. /** @hidden */
  22375. _getFreeVariableName(prefix: string): string;
  22376. /** @hidden */
  22377. _getFreeDefineName(prefix: string): string;
  22378. /** @hidden */
  22379. _excludeVariableName(name: string): void;
  22380. /** @hidden */
  22381. _emit2DSampler(name: string): void;
  22382. /** @hidden */
  22383. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22384. /** @hidden */
  22385. _emitExtension(name: string, extension: string, define?: string): void;
  22386. /** @hidden */
  22387. _emitFunction(name: string, code: string, comments: string): void;
  22388. /** @hidden */
  22389. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22390. replaceStrings?: {
  22391. search: RegExp;
  22392. replace: string;
  22393. }[];
  22394. repeatKey?: string;
  22395. }): string;
  22396. /** @hidden */
  22397. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22398. repeatKey?: string;
  22399. removeAttributes?: boolean;
  22400. removeUniforms?: boolean;
  22401. removeVaryings?: boolean;
  22402. removeIfDef?: boolean;
  22403. replaceStrings?: {
  22404. search: RegExp;
  22405. replace: string;
  22406. }[];
  22407. }, storeKey?: string): void;
  22408. /** @hidden */
  22409. _registerTempVariable(name: string): boolean;
  22410. /** @hidden */
  22411. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22412. /** @hidden */
  22413. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22414. /** @hidden */
  22415. _emitFloat(value: number): string;
  22416. }
  22417. }
  22418. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22419. /**
  22420. * Helper class used to generate session unique ID
  22421. */
  22422. export class UniqueIdGenerator {
  22423. private static _UniqueIdCounter;
  22424. /**
  22425. * Gets an unique (relatively to the current scene) Id
  22426. */
  22427. static get UniqueId(): number;
  22428. }
  22429. }
  22430. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22431. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22432. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22433. import { Nullable } from "babylonjs/types";
  22434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22435. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22436. import { Effect } from "babylonjs/Materials/effect";
  22437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22438. import { Mesh } from "babylonjs/Meshes/mesh";
  22439. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22440. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22441. import { Scene } from "babylonjs/scene";
  22442. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22443. /**
  22444. * Defines a block that can be used inside a node based material
  22445. */
  22446. export class NodeMaterialBlock {
  22447. private _buildId;
  22448. private _buildTarget;
  22449. private _target;
  22450. private _isFinalMerger;
  22451. private _isInput;
  22452. private _name;
  22453. protected _isUnique: boolean;
  22454. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22455. inputsAreExclusive: boolean;
  22456. /** @hidden */
  22457. _codeVariableName: string;
  22458. /** @hidden */
  22459. _inputs: NodeMaterialConnectionPoint[];
  22460. /** @hidden */
  22461. _outputs: NodeMaterialConnectionPoint[];
  22462. /** @hidden */
  22463. _preparationId: number;
  22464. /**
  22465. * Gets the name of the block
  22466. */
  22467. get name(): string;
  22468. /**
  22469. * Sets the name of the block. Will check if the name is valid.
  22470. */
  22471. set name(newName: string);
  22472. /**
  22473. * Gets or sets the unique id of the node
  22474. */
  22475. uniqueId: number;
  22476. /**
  22477. * Gets or sets the comments associated with this block
  22478. */
  22479. comments: string;
  22480. /**
  22481. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22482. */
  22483. get isUnique(): boolean;
  22484. /**
  22485. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22486. */
  22487. get isFinalMerger(): boolean;
  22488. /**
  22489. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22490. */
  22491. get isInput(): boolean;
  22492. /**
  22493. * Gets or sets the build Id
  22494. */
  22495. get buildId(): number;
  22496. set buildId(value: number);
  22497. /**
  22498. * Gets or sets the target of the block
  22499. */
  22500. get target(): NodeMaterialBlockTargets;
  22501. set target(value: NodeMaterialBlockTargets);
  22502. /**
  22503. * Gets the list of input points
  22504. */
  22505. get inputs(): NodeMaterialConnectionPoint[];
  22506. /** Gets the list of output points */
  22507. get outputs(): NodeMaterialConnectionPoint[];
  22508. /**
  22509. * Find an input by its name
  22510. * @param name defines the name of the input to look for
  22511. * @returns the input or null if not found
  22512. */
  22513. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22514. /**
  22515. * Find an output by its name
  22516. * @param name defines the name of the outputto look for
  22517. * @returns the output or null if not found
  22518. */
  22519. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22520. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22521. visibleInInspector: boolean;
  22522. /**
  22523. * Creates a new NodeMaterialBlock
  22524. * @param name defines the block name
  22525. * @param target defines the target of that block (Vertex by default)
  22526. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22527. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22528. */
  22529. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22530. /**
  22531. * Initialize the block and prepare the context for build
  22532. * @param state defines the state that will be used for the build
  22533. */
  22534. initialize(state: NodeMaterialBuildState): void;
  22535. /**
  22536. * Bind data to effect. Will only be called for blocks with isBindable === true
  22537. * @param effect defines the effect to bind data to
  22538. * @param nodeMaterial defines the hosting NodeMaterial
  22539. * @param mesh defines the mesh that will be rendered
  22540. * @param subMesh defines the submesh that will be rendered
  22541. */
  22542. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22543. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22544. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22545. protected _writeFloat(value: number): string;
  22546. /**
  22547. * Gets the current class name e.g. "NodeMaterialBlock"
  22548. * @returns the class name
  22549. */
  22550. getClassName(): string;
  22551. /**
  22552. * Register a new input. Must be called inside a block constructor
  22553. * @param name defines the connection point name
  22554. * @param type defines the connection point type
  22555. * @param isOptional defines a boolean indicating that this input can be omitted
  22556. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22557. * @param point an already created connection point. If not provided, create a new one
  22558. * @returns the current block
  22559. */
  22560. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22561. /**
  22562. * Register a new output. Must be called inside a block constructor
  22563. * @param name defines the connection point name
  22564. * @param type defines the connection point type
  22565. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22566. * @param point an already created connection point. If not provided, create a new one
  22567. * @returns the current block
  22568. */
  22569. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22570. /**
  22571. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22572. * @param forOutput defines an optional connection point to check compatibility with
  22573. * @returns the first available input or null
  22574. */
  22575. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22576. /**
  22577. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22578. * @param forBlock defines an optional block to check compatibility with
  22579. * @returns the first available input or null
  22580. */
  22581. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22582. /**
  22583. * Gets the sibling of the given output
  22584. * @param current defines the current output
  22585. * @returns the next output in the list or null
  22586. */
  22587. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22588. /**
  22589. * Connect current block with another block
  22590. * @param other defines the block to connect with
  22591. * @param options define the various options to help pick the right connections
  22592. * @returns the current block
  22593. */
  22594. connectTo(other: NodeMaterialBlock, options?: {
  22595. input?: string;
  22596. output?: string;
  22597. outputSwizzle?: string;
  22598. }): this | undefined;
  22599. protected _buildBlock(state: NodeMaterialBuildState): void;
  22600. /**
  22601. * Add uniforms, samplers and uniform buffers at compilation time
  22602. * @param state defines the state to update
  22603. * @param nodeMaterial defines the node material requesting the update
  22604. * @param defines defines the material defines to update
  22605. * @param uniformBuffers defines the list of uniform buffer names
  22606. */
  22607. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22608. /**
  22609. * Add potential fallbacks if shader compilation fails
  22610. * @param mesh defines the mesh to be rendered
  22611. * @param fallbacks defines the current prioritized list of fallbacks
  22612. */
  22613. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22614. /**
  22615. * Initialize defines for shader compilation
  22616. * @param mesh defines the mesh to be rendered
  22617. * @param nodeMaterial defines the node material requesting the update
  22618. * @param defines defines the material defines to update
  22619. * @param useInstances specifies that instances should be used
  22620. */
  22621. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22622. /**
  22623. * Update defines for shader compilation
  22624. * @param mesh defines the mesh to be rendered
  22625. * @param nodeMaterial defines the node material requesting the update
  22626. * @param defines defines the material defines to update
  22627. * @param useInstances specifies that instances should be used
  22628. * @param subMesh defines which submesh to render
  22629. */
  22630. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22631. /**
  22632. * Lets the block try to connect some inputs automatically
  22633. * @param material defines the hosting NodeMaterial
  22634. */
  22635. autoConfigure(material: NodeMaterial): void;
  22636. /**
  22637. * Function called when a block is declared as repeatable content generator
  22638. * @param vertexShaderState defines the current compilation state for the vertex shader
  22639. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22640. * @param mesh defines the mesh to be rendered
  22641. * @param defines defines the material defines to update
  22642. */
  22643. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22644. /**
  22645. * Checks if the block is ready
  22646. * @param mesh defines the mesh to be rendered
  22647. * @param nodeMaterial defines the node material requesting the update
  22648. * @param defines defines the material defines to update
  22649. * @param useInstances specifies that instances should be used
  22650. * @returns true if the block is ready
  22651. */
  22652. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22653. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22654. private _processBuild;
  22655. /**
  22656. * Validates the new name for the block node.
  22657. * @param newName the new name to be given to the node.
  22658. * @returns false if the name is a reserve word, else true.
  22659. */
  22660. validateBlockName(newName: string): boolean;
  22661. /**
  22662. * Compile the current node and generate the shader code
  22663. * @param state defines the current compilation state (uniforms, samplers, current string)
  22664. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22665. * @returns true if already built
  22666. */
  22667. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22668. protected _inputRename(name: string): string;
  22669. protected _outputRename(name: string): string;
  22670. protected _dumpPropertiesCode(): string;
  22671. /** @hidden */
  22672. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22673. /** @hidden */
  22674. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22675. /**
  22676. * Clone the current block to a new identical block
  22677. * @param scene defines the hosting scene
  22678. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22679. * @returns a copy of the current block
  22680. */
  22681. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22682. /**
  22683. * Serializes this block in a JSON representation
  22684. * @returns the serialized block object
  22685. */
  22686. serialize(): any;
  22687. /** @hidden */
  22688. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22689. private _deserializePortDisplayNamesAndExposedOnFrame;
  22690. /**
  22691. * Release resources
  22692. */
  22693. dispose(): void;
  22694. }
  22695. }
  22696. declare module "babylonjs/Materials/pushMaterial" {
  22697. import { Nullable } from "babylonjs/types";
  22698. import { Scene } from "babylonjs/scene";
  22699. import { Matrix } from "babylonjs/Maths/math.vector";
  22700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22701. import { Mesh } from "babylonjs/Meshes/mesh";
  22702. import { Material } from "babylonjs/Materials/material";
  22703. import { Effect } from "babylonjs/Materials/effect";
  22704. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22705. /**
  22706. * Base class of materials working in push mode in babylon JS
  22707. * @hidden
  22708. */
  22709. export class PushMaterial extends Material {
  22710. protected _activeEffect: Effect;
  22711. protected _normalMatrix: Matrix;
  22712. constructor(name: string, scene: Scene);
  22713. getEffect(): Effect;
  22714. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22715. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22716. /**
  22717. * Binds the given world matrix to the active effect
  22718. *
  22719. * @param world the matrix to bind
  22720. */
  22721. bindOnlyWorldMatrix(world: Matrix): void;
  22722. /**
  22723. * Binds the given normal matrix to the active effect
  22724. *
  22725. * @param normalMatrix the matrix to bind
  22726. */
  22727. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22728. bind(world: Matrix, mesh?: Mesh): void;
  22729. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22730. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22731. }
  22732. }
  22733. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22735. /**
  22736. * Root class for all node material optimizers
  22737. */
  22738. export class NodeMaterialOptimizer {
  22739. /**
  22740. * Function used to optimize a NodeMaterial graph
  22741. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22742. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22743. */
  22744. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22745. }
  22746. }
  22747. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22751. import { Scene } from "babylonjs/scene";
  22752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22753. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22754. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22755. /**
  22756. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22757. */
  22758. export class TransformBlock extends NodeMaterialBlock {
  22759. /**
  22760. * Defines the value to use to complement W value to transform it to a Vector4
  22761. */
  22762. complementW: number;
  22763. /**
  22764. * Defines the value to use to complement z value to transform it to a Vector4
  22765. */
  22766. complementZ: number;
  22767. /**
  22768. * Creates a new TransformBlock
  22769. * @param name defines the block name
  22770. */
  22771. constructor(name: string);
  22772. /**
  22773. * Gets the current class name
  22774. * @returns the class name
  22775. */
  22776. getClassName(): string;
  22777. /**
  22778. * Gets the vector input
  22779. */
  22780. get vector(): NodeMaterialConnectionPoint;
  22781. /**
  22782. * Gets the output component
  22783. */
  22784. get output(): NodeMaterialConnectionPoint;
  22785. /**
  22786. * Gets the xyz output component
  22787. */
  22788. get xyz(): NodeMaterialConnectionPoint;
  22789. /**
  22790. * Gets the matrix transform input
  22791. */
  22792. get transform(): NodeMaterialConnectionPoint;
  22793. protected _buildBlock(state: NodeMaterialBuildState): this;
  22794. /**
  22795. * Update defines for shader compilation
  22796. * @param mesh defines the mesh to be rendered
  22797. * @param nodeMaterial defines the node material requesting the update
  22798. * @param defines defines the material defines to update
  22799. * @param useInstances specifies that instances should be used
  22800. * @param subMesh defines which submesh to render
  22801. */
  22802. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22803. serialize(): any;
  22804. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22805. protected _dumpPropertiesCode(): string;
  22806. }
  22807. }
  22808. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22812. /**
  22813. * Block used to output the vertex position
  22814. */
  22815. export class VertexOutputBlock extends NodeMaterialBlock {
  22816. /**
  22817. * Creates a new VertexOutputBlock
  22818. * @param name defines the block name
  22819. */
  22820. constructor(name: string);
  22821. /**
  22822. * Gets the current class name
  22823. * @returns the class name
  22824. */
  22825. getClassName(): string;
  22826. /**
  22827. * Gets the vector input component
  22828. */
  22829. get vector(): NodeMaterialConnectionPoint;
  22830. protected _buildBlock(state: NodeMaterialBuildState): this;
  22831. }
  22832. }
  22833. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22837. /**
  22838. * Block used to output the final color
  22839. */
  22840. export class FragmentOutputBlock extends NodeMaterialBlock {
  22841. /**
  22842. * Create a new FragmentOutputBlock
  22843. * @param name defines the block name
  22844. */
  22845. constructor(name: string);
  22846. /**
  22847. * Gets the current class name
  22848. * @returns the class name
  22849. */
  22850. getClassName(): string;
  22851. /**
  22852. * Gets the rgba input component
  22853. */
  22854. get rgba(): NodeMaterialConnectionPoint;
  22855. /**
  22856. * Gets the rgb input component
  22857. */
  22858. get rgb(): NodeMaterialConnectionPoint;
  22859. /**
  22860. * Gets the a input component
  22861. */
  22862. get a(): NodeMaterialConnectionPoint;
  22863. protected _buildBlock(state: NodeMaterialBuildState): this;
  22864. }
  22865. }
  22866. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22870. /**
  22871. * Block used for the particle ramp gradient section
  22872. */
  22873. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22874. /**
  22875. * Create a new ParticleRampGradientBlock
  22876. * @param name defines the block name
  22877. */
  22878. constructor(name: string);
  22879. /**
  22880. * Gets the current class name
  22881. * @returns the class name
  22882. */
  22883. getClassName(): string;
  22884. /**
  22885. * Gets the color input component
  22886. */
  22887. get color(): NodeMaterialConnectionPoint;
  22888. /**
  22889. * Gets the rampColor output component
  22890. */
  22891. get rampColor(): NodeMaterialConnectionPoint;
  22892. /**
  22893. * Initialize the block and prepare the context for build
  22894. * @param state defines the state that will be used for the build
  22895. */
  22896. initialize(state: NodeMaterialBuildState): void;
  22897. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22898. }
  22899. }
  22900. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22904. /**
  22905. * Block used for the particle blend multiply section
  22906. */
  22907. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22908. /**
  22909. * Create a new ParticleBlendMultiplyBlock
  22910. * @param name defines the block name
  22911. */
  22912. constructor(name: string);
  22913. /**
  22914. * Gets the current class name
  22915. * @returns the class name
  22916. */
  22917. getClassName(): string;
  22918. /**
  22919. * Gets the color input component
  22920. */
  22921. get color(): NodeMaterialConnectionPoint;
  22922. /**
  22923. * Gets the alphaTexture input component
  22924. */
  22925. get alphaTexture(): NodeMaterialConnectionPoint;
  22926. /**
  22927. * Gets the alphaColor input component
  22928. */
  22929. get alphaColor(): NodeMaterialConnectionPoint;
  22930. /**
  22931. * Gets the blendColor output component
  22932. */
  22933. get blendColor(): NodeMaterialConnectionPoint;
  22934. /**
  22935. * Initialize the block and prepare the context for build
  22936. * @param state defines the state that will be used for the build
  22937. */
  22938. initialize(state: NodeMaterialBuildState): void;
  22939. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22940. }
  22941. }
  22942. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22946. /**
  22947. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22948. */
  22949. export class VectorMergerBlock extends NodeMaterialBlock {
  22950. /**
  22951. * Create a new VectorMergerBlock
  22952. * @param name defines the block name
  22953. */
  22954. constructor(name: string);
  22955. /**
  22956. * Gets the current class name
  22957. * @returns the class name
  22958. */
  22959. getClassName(): string;
  22960. /**
  22961. * Gets the xyz component (input)
  22962. */
  22963. get xyzIn(): NodeMaterialConnectionPoint;
  22964. /**
  22965. * Gets the xy component (input)
  22966. */
  22967. get xyIn(): NodeMaterialConnectionPoint;
  22968. /**
  22969. * Gets the x component (input)
  22970. */
  22971. get x(): NodeMaterialConnectionPoint;
  22972. /**
  22973. * Gets the y component (input)
  22974. */
  22975. get y(): NodeMaterialConnectionPoint;
  22976. /**
  22977. * Gets the z component (input)
  22978. */
  22979. get z(): NodeMaterialConnectionPoint;
  22980. /**
  22981. * Gets the w component (input)
  22982. */
  22983. get w(): NodeMaterialConnectionPoint;
  22984. /**
  22985. * Gets the xyzw component (output)
  22986. */
  22987. get xyzw(): NodeMaterialConnectionPoint;
  22988. /**
  22989. * Gets the xyz component (output)
  22990. */
  22991. get xyzOut(): NodeMaterialConnectionPoint;
  22992. /**
  22993. * Gets the xy component (output)
  22994. */
  22995. get xyOut(): NodeMaterialConnectionPoint;
  22996. /**
  22997. * Gets the xy component (output)
  22998. * @deprecated Please use xyOut instead.
  22999. */
  23000. get xy(): NodeMaterialConnectionPoint;
  23001. /**
  23002. * Gets the xyz component (output)
  23003. * @deprecated Please use xyzOut instead.
  23004. */
  23005. get xyz(): NodeMaterialConnectionPoint;
  23006. protected _buildBlock(state: NodeMaterialBuildState): this;
  23007. }
  23008. }
  23009. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  23010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23011. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23013. import { Vector2 } from "babylonjs/Maths/math.vector";
  23014. import { Scene } from "babylonjs/scene";
  23015. /**
  23016. * Block used to remap a float from a range to a new one
  23017. */
  23018. export class RemapBlock extends NodeMaterialBlock {
  23019. /**
  23020. * Gets or sets the source range
  23021. */
  23022. sourceRange: Vector2;
  23023. /**
  23024. * Gets or sets the target range
  23025. */
  23026. targetRange: Vector2;
  23027. /**
  23028. * Creates a new RemapBlock
  23029. * @param name defines the block name
  23030. */
  23031. constructor(name: string);
  23032. /**
  23033. * Gets the current class name
  23034. * @returns the class name
  23035. */
  23036. getClassName(): string;
  23037. /**
  23038. * Gets the input component
  23039. */
  23040. get input(): NodeMaterialConnectionPoint;
  23041. /**
  23042. * Gets the source min input component
  23043. */
  23044. get sourceMin(): NodeMaterialConnectionPoint;
  23045. /**
  23046. * Gets the source max input component
  23047. */
  23048. get sourceMax(): NodeMaterialConnectionPoint;
  23049. /**
  23050. * Gets the target min input component
  23051. */
  23052. get targetMin(): NodeMaterialConnectionPoint;
  23053. /**
  23054. * Gets the target max input component
  23055. */
  23056. get targetMax(): NodeMaterialConnectionPoint;
  23057. /**
  23058. * Gets the output component
  23059. */
  23060. get output(): NodeMaterialConnectionPoint;
  23061. protected _buildBlock(state: NodeMaterialBuildState): this;
  23062. protected _dumpPropertiesCode(): string;
  23063. serialize(): any;
  23064. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23065. }
  23066. }
  23067. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23071. /**
  23072. * Block used to multiply 2 values
  23073. */
  23074. export class MultiplyBlock extends NodeMaterialBlock {
  23075. /**
  23076. * Creates a new MultiplyBlock
  23077. * @param name defines the block name
  23078. */
  23079. constructor(name: string);
  23080. /**
  23081. * Gets the current class name
  23082. * @returns the class name
  23083. */
  23084. getClassName(): string;
  23085. /**
  23086. * Gets the left operand input component
  23087. */
  23088. get left(): NodeMaterialConnectionPoint;
  23089. /**
  23090. * Gets the right operand input component
  23091. */
  23092. get right(): NodeMaterialConnectionPoint;
  23093. /**
  23094. * Gets the output component
  23095. */
  23096. get output(): NodeMaterialConnectionPoint;
  23097. protected _buildBlock(state: NodeMaterialBuildState): this;
  23098. }
  23099. }
  23100. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23104. /**
  23105. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23106. */
  23107. export class ColorSplitterBlock extends NodeMaterialBlock {
  23108. /**
  23109. * Create a new ColorSplitterBlock
  23110. * @param name defines the block name
  23111. */
  23112. constructor(name: string);
  23113. /**
  23114. * Gets the current class name
  23115. * @returns the class name
  23116. */
  23117. getClassName(): string;
  23118. /**
  23119. * Gets the rgba component (input)
  23120. */
  23121. get rgba(): NodeMaterialConnectionPoint;
  23122. /**
  23123. * Gets the rgb component (input)
  23124. */
  23125. get rgbIn(): NodeMaterialConnectionPoint;
  23126. /**
  23127. * Gets the rgb component (output)
  23128. */
  23129. get rgbOut(): NodeMaterialConnectionPoint;
  23130. /**
  23131. * Gets the r component (output)
  23132. */
  23133. get r(): NodeMaterialConnectionPoint;
  23134. /**
  23135. * Gets the g component (output)
  23136. */
  23137. get g(): NodeMaterialConnectionPoint;
  23138. /**
  23139. * Gets the b component (output)
  23140. */
  23141. get b(): NodeMaterialConnectionPoint;
  23142. /**
  23143. * Gets the a component (output)
  23144. */
  23145. get a(): NodeMaterialConnectionPoint;
  23146. protected _inputRename(name: string): string;
  23147. protected _outputRename(name: string): string;
  23148. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23149. }
  23150. }
  23151. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23155. import { Scene } from "babylonjs/scene";
  23156. /**
  23157. * Operations supported by the Trigonometry block
  23158. */
  23159. export enum TrigonometryBlockOperations {
  23160. /** Cos */
  23161. Cos = 0,
  23162. /** Sin */
  23163. Sin = 1,
  23164. /** Abs */
  23165. Abs = 2,
  23166. /** Exp */
  23167. Exp = 3,
  23168. /** Exp2 */
  23169. Exp2 = 4,
  23170. /** Round */
  23171. Round = 5,
  23172. /** Floor */
  23173. Floor = 6,
  23174. /** Ceiling */
  23175. Ceiling = 7,
  23176. /** Square root */
  23177. Sqrt = 8,
  23178. /** Log */
  23179. Log = 9,
  23180. /** Tangent */
  23181. Tan = 10,
  23182. /** Arc tangent */
  23183. ArcTan = 11,
  23184. /** Arc cosinus */
  23185. ArcCos = 12,
  23186. /** Arc sinus */
  23187. ArcSin = 13,
  23188. /** Fraction */
  23189. Fract = 14,
  23190. /** Sign */
  23191. Sign = 15,
  23192. /** To radians (from degrees) */
  23193. Radians = 16,
  23194. /** To degrees (from radians) */
  23195. Degrees = 17
  23196. }
  23197. /**
  23198. * Block used to apply trigonometry operation to floats
  23199. */
  23200. export class TrigonometryBlock extends NodeMaterialBlock {
  23201. /**
  23202. * Gets or sets the operation applied by the block
  23203. */
  23204. operation: TrigonometryBlockOperations;
  23205. /**
  23206. * Creates a new TrigonometryBlock
  23207. * @param name defines the block name
  23208. */
  23209. constructor(name: string);
  23210. /**
  23211. * Gets the current class name
  23212. * @returns the class name
  23213. */
  23214. getClassName(): string;
  23215. /**
  23216. * Gets the input component
  23217. */
  23218. get input(): NodeMaterialConnectionPoint;
  23219. /**
  23220. * Gets the output component
  23221. */
  23222. get output(): NodeMaterialConnectionPoint;
  23223. protected _buildBlock(state: NodeMaterialBuildState): this;
  23224. serialize(): any;
  23225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23226. protected _dumpPropertiesCode(): string;
  23227. }
  23228. }
  23229. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23231. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23232. import { Scene } from "babylonjs/scene";
  23233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23234. import { Matrix } from "babylonjs/Maths/math.vector";
  23235. import { Mesh } from "babylonjs/Meshes/mesh";
  23236. import { Engine } from "babylonjs/Engines/engine";
  23237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23238. import { Observable } from "babylonjs/Misc/observable";
  23239. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23240. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23241. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23242. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23243. import { Nullable } from "babylonjs/types";
  23244. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23245. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23246. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23247. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23248. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23249. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23250. import { Effect } from "babylonjs/Materials/effect";
  23251. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23252. import { Camera } from "babylonjs/Cameras/camera";
  23253. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23254. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23255. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23256. /**
  23257. * Interface used to configure the node material editor
  23258. */
  23259. export interface INodeMaterialEditorOptions {
  23260. /** Define the URl to load node editor script */
  23261. editorURL?: string;
  23262. }
  23263. /** @hidden */
  23264. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23265. NORMAL: boolean;
  23266. TANGENT: boolean;
  23267. UV1: boolean;
  23268. /** BONES */
  23269. NUM_BONE_INFLUENCERS: number;
  23270. BonesPerMesh: number;
  23271. BONETEXTURE: boolean;
  23272. /** MORPH TARGETS */
  23273. MORPHTARGETS: boolean;
  23274. MORPHTARGETS_NORMAL: boolean;
  23275. MORPHTARGETS_TANGENT: boolean;
  23276. MORPHTARGETS_UV: boolean;
  23277. NUM_MORPH_INFLUENCERS: number;
  23278. /** IMAGE PROCESSING */
  23279. IMAGEPROCESSING: boolean;
  23280. VIGNETTE: boolean;
  23281. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23282. VIGNETTEBLENDMODEOPAQUE: boolean;
  23283. TONEMAPPING: boolean;
  23284. TONEMAPPING_ACES: boolean;
  23285. CONTRAST: boolean;
  23286. EXPOSURE: boolean;
  23287. COLORCURVES: boolean;
  23288. COLORGRADING: boolean;
  23289. COLORGRADING3D: boolean;
  23290. SAMPLER3DGREENDEPTH: boolean;
  23291. SAMPLER3DBGRMAP: boolean;
  23292. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23293. /** MISC. */
  23294. BUMPDIRECTUV: number;
  23295. constructor();
  23296. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23297. }
  23298. /**
  23299. * Class used to configure NodeMaterial
  23300. */
  23301. export interface INodeMaterialOptions {
  23302. /**
  23303. * Defines if blocks should emit comments
  23304. */
  23305. emitComments: boolean;
  23306. }
  23307. /**
  23308. * Class used to create a node based material built by assembling shader blocks
  23309. */
  23310. export class NodeMaterial extends PushMaterial {
  23311. private static _BuildIdGenerator;
  23312. private _options;
  23313. private _vertexCompilationState;
  23314. private _fragmentCompilationState;
  23315. private _sharedData;
  23316. private _buildId;
  23317. private _buildWasSuccessful;
  23318. private _cachedWorldViewMatrix;
  23319. private _cachedWorldViewProjectionMatrix;
  23320. private _optimizers;
  23321. private _animationFrame;
  23322. /** Define the Url to load node editor script */
  23323. static EditorURL: string;
  23324. /** Define the Url to load snippets */
  23325. static SnippetUrl: string;
  23326. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23327. static IgnoreTexturesAtLoadTime: boolean;
  23328. private BJSNODEMATERIALEDITOR;
  23329. /** Get the inspector from bundle or global */
  23330. private _getGlobalNodeMaterialEditor;
  23331. /**
  23332. * Snippet ID if the material was created from the snippet server
  23333. */
  23334. snippetId: string;
  23335. /**
  23336. * Gets or sets data used by visual editor
  23337. * @see https://nme.babylonjs.com
  23338. */
  23339. editorData: any;
  23340. /**
  23341. * 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)
  23342. */
  23343. ignoreAlpha: boolean;
  23344. /**
  23345. * Defines the maximum number of lights that can be used in the material
  23346. */
  23347. maxSimultaneousLights: number;
  23348. /**
  23349. * Observable raised when the material is built
  23350. */
  23351. onBuildObservable: Observable<NodeMaterial>;
  23352. /**
  23353. * Gets or sets the root nodes of the material vertex shader
  23354. */
  23355. _vertexOutputNodes: NodeMaterialBlock[];
  23356. /**
  23357. * Gets or sets the root nodes of the material fragment (pixel) shader
  23358. */
  23359. _fragmentOutputNodes: NodeMaterialBlock[];
  23360. /** Gets or sets options to control the node material overall behavior */
  23361. get options(): INodeMaterialOptions;
  23362. set options(options: INodeMaterialOptions);
  23363. /**
  23364. * Default configuration related to image processing available in the standard Material.
  23365. */
  23366. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23367. /**
  23368. * Gets the image processing configuration used either in this material.
  23369. */
  23370. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23371. /**
  23372. * Sets the Default image processing configuration used either in the this material.
  23373. *
  23374. * If sets to null, the scene one is in use.
  23375. */
  23376. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23377. /**
  23378. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23379. */
  23380. attachedBlocks: NodeMaterialBlock[];
  23381. /**
  23382. * Specifies the mode of the node material
  23383. * @hidden
  23384. */
  23385. _mode: NodeMaterialModes;
  23386. /**
  23387. * Gets the mode property
  23388. */
  23389. get mode(): NodeMaterialModes;
  23390. /**
  23391. * Create a new node based material
  23392. * @param name defines the material name
  23393. * @param scene defines the hosting scene
  23394. * @param options defines creation option
  23395. */
  23396. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23397. /**
  23398. * Gets the current class name of the material e.g. "NodeMaterial"
  23399. * @returns the class name
  23400. */
  23401. getClassName(): string;
  23402. /**
  23403. * Keep track of the image processing observer to allow dispose and replace.
  23404. */
  23405. private _imageProcessingObserver;
  23406. /**
  23407. * Attaches a new image processing configuration to the Standard Material.
  23408. * @param configuration
  23409. */
  23410. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23411. /**
  23412. * Get a block by its name
  23413. * @param name defines the name of the block to retrieve
  23414. * @returns the required block or null if not found
  23415. */
  23416. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23417. /**
  23418. * Get a block by its name
  23419. * @param predicate defines the predicate used to find the good candidate
  23420. * @returns the required block or null if not found
  23421. */
  23422. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23423. /**
  23424. * Get an input block by its name
  23425. * @param predicate defines the predicate used to find the good candidate
  23426. * @returns the required input block or null if not found
  23427. */
  23428. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23429. /**
  23430. * Gets the list of input blocks attached to this material
  23431. * @returns an array of InputBlocks
  23432. */
  23433. getInputBlocks(): InputBlock[];
  23434. /**
  23435. * Adds a new optimizer to the list of optimizers
  23436. * @param optimizer defines the optimizers to add
  23437. * @returns the current material
  23438. */
  23439. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23440. /**
  23441. * Remove an optimizer from the list of optimizers
  23442. * @param optimizer defines the optimizers to remove
  23443. * @returns the current material
  23444. */
  23445. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23446. /**
  23447. * Add a new block to the list of output nodes
  23448. * @param node defines the node to add
  23449. * @returns the current material
  23450. */
  23451. addOutputNode(node: NodeMaterialBlock): this;
  23452. /**
  23453. * Remove a block from the list of root nodes
  23454. * @param node defines the node to remove
  23455. * @returns the current material
  23456. */
  23457. removeOutputNode(node: NodeMaterialBlock): this;
  23458. private _addVertexOutputNode;
  23459. private _removeVertexOutputNode;
  23460. private _addFragmentOutputNode;
  23461. private _removeFragmentOutputNode;
  23462. /**
  23463. * Specifies if the material will require alpha blending
  23464. * @returns a boolean specifying if alpha blending is needed
  23465. */
  23466. needAlphaBlending(): boolean;
  23467. /**
  23468. * Specifies if this material should be rendered in alpha test mode
  23469. * @returns a boolean specifying if an alpha test is needed.
  23470. */
  23471. needAlphaTesting(): boolean;
  23472. private _initializeBlock;
  23473. private _resetDualBlocks;
  23474. /**
  23475. * Remove a block from the current node material
  23476. * @param block defines the block to remove
  23477. */
  23478. removeBlock(block: NodeMaterialBlock): void;
  23479. /**
  23480. * Build the material and generates the inner effect
  23481. * @param verbose defines if the build should log activity
  23482. */
  23483. build(verbose?: boolean): void;
  23484. /**
  23485. * Runs an otpimization phase to try to improve the shader code
  23486. */
  23487. optimize(): void;
  23488. private _prepareDefinesForAttributes;
  23489. /**
  23490. * Create a post process from the material
  23491. * @param camera The camera to apply the render pass to.
  23492. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23494. * @param engine The engine which the post process will be applied. (default: current engine)
  23495. * @param reusable If the post process can be reused on the same frame. (default: false)
  23496. * @param textureType Type of textures used when performing the post process. (default: 0)
  23497. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23498. * @returns the post process created
  23499. */
  23500. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23501. /**
  23502. * Create the post process effect from the material
  23503. * @param postProcess The post process to create the effect for
  23504. */
  23505. createEffectForPostProcess(postProcess: PostProcess): void;
  23506. private _createEffectForPostProcess;
  23507. /**
  23508. * Create a new procedural texture based on this node material
  23509. * @param size defines the size of the texture
  23510. * @param scene defines the hosting scene
  23511. * @returns the new procedural texture attached to this node material
  23512. */
  23513. createProceduralTexture(size: number | {
  23514. width: number;
  23515. height: number;
  23516. layers?: number;
  23517. }, scene: Scene): Nullable<ProceduralTexture>;
  23518. private _createEffectForParticles;
  23519. private _checkInternals;
  23520. /**
  23521. * Create the effect to be used as the custom effect for a particle system
  23522. * @param particleSystem Particle system to create the effect for
  23523. * @param onCompiled defines a function to call when the effect creation is successful
  23524. * @param onError defines a function to call when the effect creation has failed
  23525. */
  23526. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23527. private _processDefines;
  23528. /**
  23529. * Get if the submesh is ready to be used and all its information available.
  23530. * Child classes can use it to update shaders
  23531. * @param mesh defines the mesh to check
  23532. * @param subMesh defines which submesh to check
  23533. * @param useInstances specifies that instances should be used
  23534. * @returns a boolean indicating that the submesh is ready or not
  23535. */
  23536. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23537. /**
  23538. * Get a string representing the shaders built by the current node graph
  23539. */
  23540. get compiledShaders(): string;
  23541. /**
  23542. * Binds the world matrix to the material
  23543. * @param world defines the world transformation matrix
  23544. */
  23545. bindOnlyWorldMatrix(world: Matrix): void;
  23546. /**
  23547. * Binds the submesh to this material by preparing the effect and shader to draw
  23548. * @param world defines the world transformation matrix
  23549. * @param mesh defines the mesh containing the submesh
  23550. * @param subMesh defines the submesh to bind the material to
  23551. */
  23552. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23553. /**
  23554. * Gets the active textures from the material
  23555. * @returns an array of textures
  23556. */
  23557. getActiveTextures(): BaseTexture[];
  23558. /**
  23559. * Gets the list of texture blocks
  23560. * @returns an array of texture blocks
  23561. */
  23562. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23563. /**
  23564. * Specifies if the material uses a texture
  23565. * @param texture defines the texture to check against the material
  23566. * @returns a boolean specifying if the material uses the texture
  23567. */
  23568. hasTexture(texture: BaseTexture): boolean;
  23569. /**
  23570. * Disposes the material
  23571. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23572. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23573. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23574. */
  23575. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23576. /** Creates the node editor window. */
  23577. private _createNodeEditor;
  23578. /**
  23579. * Launch the node material editor
  23580. * @param config Define the configuration of the editor
  23581. * @return a promise fulfilled when the node editor is visible
  23582. */
  23583. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23584. /**
  23585. * Clear the current material
  23586. */
  23587. clear(): void;
  23588. /**
  23589. * Clear the current material and set it to a default state
  23590. */
  23591. setToDefault(): void;
  23592. /**
  23593. * Clear the current material and set it to a default state for post process
  23594. */
  23595. setToDefaultPostProcess(): void;
  23596. /**
  23597. * Clear the current material and set it to a default state for procedural texture
  23598. */
  23599. setToDefaultProceduralTexture(): void;
  23600. /**
  23601. * Clear the current material and set it to a default state for particle
  23602. */
  23603. setToDefaultParticle(): void;
  23604. /**
  23605. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23606. * @param url defines the url to load from
  23607. * @returns a promise that will fullfil when the material is fully loaded
  23608. */
  23609. loadAsync(url: string): Promise<void>;
  23610. private _gatherBlocks;
  23611. /**
  23612. * Generate a string containing the code declaration required to create an equivalent of this material
  23613. * @returns a string
  23614. */
  23615. generateCode(): string;
  23616. /**
  23617. * Serializes this material in a JSON representation
  23618. * @returns the serialized material object
  23619. */
  23620. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23621. private _restoreConnections;
  23622. /**
  23623. * Clear the current graph and load a new one from a serialization object
  23624. * @param source defines the JSON representation of the material
  23625. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23626. * @param merge defines whether or not the source must be merged or replace the current content
  23627. */
  23628. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23629. /**
  23630. * Makes a duplicate of the current material.
  23631. * @param name - name to use for the new material.
  23632. */
  23633. clone(name: string): NodeMaterial;
  23634. /**
  23635. * Creates a node material from parsed material data
  23636. * @param source defines the JSON representation of the material
  23637. * @param scene defines the hosting scene
  23638. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23639. * @returns a new node material
  23640. */
  23641. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23642. /**
  23643. * Creates a node material from a snippet saved in a remote file
  23644. * @param name defines the name of the material to create
  23645. * @param url defines the url to load from
  23646. * @param scene defines the hosting scene
  23647. * @returns a promise that will resolve to the new node material
  23648. */
  23649. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23650. /**
  23651. * Creates a node material from a snippet saved by the node material editor
  23652. * @param snippetId defines the snippet to load
  23653. * @param scene defines the hosting scene
  23654. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23655. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23656. * @returns a promise that will resolve to the new node material
  23657. */
  23658. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23659. /**
  23660. * Creates a new node material set to default basic configuration
  23661. * @param name defines the name of the material
  23662. * @param scene defines the hosting scene
  23663. * @returns a new NodeMaterial
  23664. */
  23665. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23666. }
  23667. }
  23668. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23669. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23670. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23671. import { Nullable } from "babylonjs/types";
  23672. module "babylonjs/Engines/thinEngine" {
  23673. interface ThinEngine {
  23674. /**
  23675. * Unbind a list of render target textures from the webGL context
  23676. * This is used only when drawBuffer extension or webGL2 are active
  23677. * @param textures defines the render target textures to unbind
  23678. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23679. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23680. */
  23681. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23682. /**
  23683. * Create a multi render target texture
  23684. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23685. * @param size defines the size of the texture
  23686. * @param options defines the creation options
  23687. * @returns the cube texture as an InternalTexture
  23688. */
  23689. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23690. /**
  23691. * Update the sample count for a given multiple render target texture
  23692. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23693. * @param textures defines the textures to update
  23694. * @param samples defines the sample count to set
  23695. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23696. */
  23697. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23698. /**
  23699. * Select a subsets of attachments to draw to.
  23700. * @param attachments gl attachments
  23701. */
  23702. bindAttachments(attachments: number[]): void;
  23703. /**
  23704. * Creates a layout object to draw/clear on specific textures in a MRT
  23705. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23706. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23707. */
  23708. buildTextureLayout(textureStatus: boolean[]): number[];
  23709. /**
  23710. * Restores the webgl state to only draw on the main color attachment
  23711. */
  23712. restoreSingleAttachment(): void;
  23713. }
  23714. }
  23715. }
  23716. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23717. import { Scene } from "babylonjs/scene";
  23718. import { Engine } from "babylonjs/Engines/engine";
  23719. import { Texture } from "babylonjs/Materials/Textures/texture";
  23720. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23721. import "babylonjs/Engines/Extensions/engine.multiRender";
  23722. /**
  23723. * Creation options of the multi render target texture.
  23724. */
  23725. export interface IMultiRenderTargetOptions {
  23726. /**
  23727. * Define if the texture needs to create mip maps after render.
  23728. */
  23729. generateMipMaps?: boolean;
  23730. /**
  23731. * Define the types of all the draw buffers we want to create
  23732. */
  23733. types?: number[];
  23734. /**
  23735. * Define the sampling modes of all the draw buffers we want to create
  23736. */
  23737. samplingModes?: number[];
  23738. /**
  23739. * Define if a depth buffer is required
  23740. */
  23741. generateDepthBuffer?: boolean;
  23742. /**
  23743. * Define if a stencil buffer is required
  23744. */
  23745. generateStencilBuffer?: boolean;
  23746. /**
  23747. * Define if a depth texture is required instead of a depth buffer
  23748. */
  23749. generateDepthTexture?: boolean;
  23750. /**
  23751. * Define the number of desired draw buffers
  23752. */
  23753. textureCount?: number;
  23754. /**
  23755. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23756. */
  23757. doNotChangeAspectRatio?: boolean;
  23758. /**
  23759. * Define the default type of the buffers we are creating
  23760. */
  23761. defaultType?: number;
  23762. }
  23763. /**
  23764. * A multi render target, like a render target provides the ability to render to a texture.
  23765. * Unlike the render target, it can render to several draw buffers in one draw.
  23766. * This is specially interesting in deferred rendering or for any effects requiring more than
  23767. * just one color from a single pass.
  23768. */
  23769. export class MultiRenderTarget extends RenderTargetTexture {
  23770. private _internalTextures;
  23771. private _textures;
  23772. private _multiRenderTargetOptions;
  23773. private _count;
  23774. /**
  23775. * Get if draw buffers are currently supported by the used hardware and browser.
  23776. */
  23777. get isSupported(): boolean;
  23778. /**
  23779. * Get the list of textures generated by the multi render target.
  23780. */
  23781. get textures(): Texture[];
  23782. /**
  23783. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23784. */
  23785. get count(): number;
  23786. /**
  23787. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23788. */
  23789. get depthTexture(): Texture;
  23790. /**
  23791. * Set the wrapping mode on U of all the textures we are rendering to.
  23792. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23793. */
  23794. set wrapU(wrap: number);
  23795. /**
  23796. * Set the wrapping mode on V of all the textures we are rendering to.
  23797. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23798. */
  23799. set wrapV(wrap: number);
  23800. /**
  23801. * Instantiate a new multi render target texture.
  23802. * A multi render target, like a render target provides the ability to render to a texture.
  23803. * Unlike the render target, it can render to several draw buffers in one draw.
  23804. * This is specially interesting in deferred rendering or for any effects requiring more than
  23805. * just one color from a single pass.
  23806. * @param name Define the name of the texture
  23807. * @param size Define the size of the buffers to render to
  23808. * @param count Define the number of target we are rendering into
  23809. * @param scene Define the scene the texture belongs to
  23810. * @param options Define the options used to create the multi render target
  23811. */
  23812. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23813. private _initTypes;
  23814. /** @hidden */
  23815. _rebuild(forceFullRebuild?: boolean): void;
  23816. private _createInternalTextures;
  23817. private _createTextures;
  23818. /**
  23819. * Replaces a texture within the MRT.
  23820. * @param texture The new texture to insert in the MRT
  23821. * @param index The index of the texture to replace
  23822. */
  23823. replaceTexture(texture: Texture, index: number): void;
  23824. /**
  23825. * Define the number of samples used if MSAA is enabled.
  23826. */
  23827. get samples(): number;
  23828. set samples(value: number);
  23829. /**
  23830. * Resize all the textures in the multi render target.
  23831. * Be careful as it will recreate all the data in the new texture.
  23832. * @param size Define the new size
  23833. */
  23834. resize(size: any): void;
  23835. /**
  23836. * Changes the number of render targets in this MRT
  23837. * Be careful as it will recreate all the data in the new texture.
  23838. * @param count new texture count
  23839. * @param options Specifies texture types and sampling modes for new textures
  23840. */
  23841. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23842. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23843. /**
  23844. * Dispose the render targets and their associated resources
  23845. */
  23846. dispose(): void;
  23847. /**
  23848. * Release all the underlying texture used as draw buffers.
  23849. */
  23850. releaseInternalTextures(): void;
  23851. }
  23852. }
  23853. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  23854. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  23855. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  23856. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  23857. /** @hidden */
  23858. export var imageProcessingPixelShader: {
  23859. name: string;
  23860. shader: string;
  23861. };
  23862. }
  23863. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  23864. import { Nullable } from "babylonjs/types";
  23865. import { Color4 } from "babylonjs/Maths/math.color";
  23866. import { Camera } from "babylonjs/Cameras/camera";
  23867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23868. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23869. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23870. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23871. import { Engine } from "babylonjs/Engines/engine";
  23872. import "babylonjs/Shaders/imageProcessing.fragment";
  23873. import "babylonjs/Shaders/postprocess.vertex";
  23874. /**
  23875. * ImageProcessingPostProcess
  23876. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23877. */
  23878. export class ImageProcessingPostProcess extends PostProcess {
  23879. /**
  23880. * Default configuration related to image processing available in the PBR Material.
  23881. */
  23882. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23883. /**
  23884. * Gets the image processing configuration used either in this material.
  23885. */
  23886. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23887. /**
  23888. * Sets the Default image processing configuration used either in the this material.
  23889. *
  23890. * If sets to null, the scene one is in use.
  23891. */
  23892. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23893. /**
  23894. * Keep track of the image processing observer to allow dispose and replace.
  23895. */
  23896. private _imageProcessingObserver;
  23897. /**
  23898. * Attaches a new image processing configuration to the PBR Material.
  23899. * @param configuration
  23900. */
  23901. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23902. /**
  23903. * If the post process is supported.
  23904. */
  23905. get isSupported(): boolean;
  23906. /**
  23907. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23908. */
  23909. get colorCurves(): Nullable<ColorCurves>;
  23910. /**
  23911. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23912. */
  23913. set colorCurves(value: Nullable<ColorCurves>);
  23914. /**
  23915. * Gets wether the color curves effect is enabled.
  23916. */
  23917. get colorCurvesEnabled(): boolean;
  23918. /**
  23919. * Sets wether the color curves effect is enabled.
  23920. */
  23921. set colorCurvesEnabled(value: boolean);
  23922. /**
  23923. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23924. */
  23925. get colorGradingTexture(): Nullable<BaseTexture>;
  23926. /**
  23927. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23928. */
  23929. set colorGradingTexture(value: Nullable<BaseTexture>);
  23930. /**
  23931. * Gets wether the color grading effect is enabled.
  23932. */
  23933. get colorGradingEnabled(): boolean;
  23934. /**
  23935. * Gets wether the color grading effect is enabled.
  23936. */
  23937. set colorGradingEnabled(value: boolean);
  23938. /**
  23939. * Gets exposure used in the effect.
  23940. */
  23941. get exposure(): number;
  23942. /**
  23943. * Sets exposure used in the effect.
  23944. */
  23945. set exposure(value: number);
  23946. /**
  23947. * Gets wether tonemapping is enabled or not.
  23948. */
  23949. get toneMappingEnabled(): boolean;
  23950. /**
  23951. * Sets wether tonemapping is enabled or not
  23952. */
  23953. set toneMappingEnabled(value: boolean);
  23954. /**
  23955. * Gets the type of tone mapping effect.
  23956. */
  23957. get toneMappingType(): number;
  23958. /**
  23959. * Sets the type of tone mapping effect.
  23960. */
  23961. set toneMappingType(value: number);
  23962. /**
  23963. * Gets contrast used in the effect.
  23964. */
  23965. get contrast(): number;
  23966. /**
  23967. * Sets contrast used in the effect.
  23968. */
  23969. set contrast(value: number);
  23970. /**
  23971. * Gets Vignette stretch size.
  23972. */
  23973. get vignetteStretch(): number;
  23974. /**
  23975. * Sets Vignette stretch size.
  23976. */
  23977. set vignetteStretch(value: number);
  23978. /**
  23979. * Gets Vignette centre X Offset.
  23980. */
  23981. get vignetteCentreX(): number;
  23982. /**
  23983. * Sets Vignette centre X Offset.
  23984. */
  23985. set vignetteCentreX(value: number);
  23986. /**
  23987. * Gets Vignette centre Y Offset.
  23988. */
  23989. get vignetteCentreY(): number;
  23990. /**
  23991. * Sets Vignette centre Y Offset.
  23992. */
  23993. set vignetteCentreY(value: number);
  23994. /**
  23995. * Gets Vignette weight or intensity of the vignette effect.
  23996. */
  23997. get vignetteWeight(): number;
  23998. /**
  23999. * Sets Vignette weight or intensity of the vignette effect.
  24000. */
  24001. set vignetteWeight(value: number);
  24002. /**
  24003. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24004. * if vignetteEnabled is set to true.
  24005. */
  24006. get vignetteColor(): Color4;
  24007. /**
  24008. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24009. * if vignetteEnabled is set to true.
  24010. */
  24011. set vignetteColor(value: Color4);
  24012. /**
  24013. * Gets Camera field of view used by the Vignette effect.
  24014. */
  24015. get vignetteCameraFov(): number;
  24016. /**
  24017. * Sets Camera field of view used by the Vignette effect.
  24018. */
  24019. set vignetteCameraFov(value: number);
  24020. /**
  24021. * Gets the vignette blend mode allowing different kind of effect.
  24022. */
  24023. get vignetteBlendMode(): number;
  24024. /**
  24025. * Sets the vignette blend mode allowing different kind of effect.
  24026. */
  24027. set vignetteBlendMode(value: number);
  24028. /**
  24029. * Gets wether the vignette effect is enabled.
  24030. */
  24031. get vignetteEnabled(): boolean;
  24032. /**
  24033. * Sets wether the vignette effect is enabled.
  24034. */
  24035. set vignetteEnabled(value: boolean);
  24036. private _fromLinearSpace;
  24037. /**
  24038. * Gets wether the input of the processing is in Gamma or Linear Space.
  24039. */
  24040. get fromLinearSpace(): boolean;
  24041. /**
  24042. * Sets wether the input of the processing is in Gamma or Linear Space.
  24043. */
  24044. set fromLinearSpace(value: boolean);
  24045. /**
  24046. * Defines cache preventing GC.
  24047. */
  24048. private _defines;
  24049. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24050. /**
  24051. * "ImageProcessingPostProcess"
  24052. * @returns "ImageProcessingPostProcess"
  24053. */
  24054. getClassName(): string;
  24055. /**
  24056. * @hidden
  24057. */
  24058. _updateParameters(): void;
  24059. dispose(camera?: Camera): void;
  24060. }
  24061. }
  24062. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24063. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24064. /**
  24065. * Interface for defining prepass effects in the prepass post-process pipeline
  24066. */
  24067. export interface PrePassEffectConfiguration {
  24068. /**
  24069. * Name of the effect
  24070. */
  24071. name: string;
  24072. /**
  24073. * Post process to attach for this effect
  24074. */
  24075. postProcess?: PostProcess;
  24076. /**
  24077. * Textures required in the MRT
  24078. */
  24079. texturesRequired: number[];
  24080. /**
  24081. * Is the effect enabled
  24082. */
  24083. enabled: boolean;
  24084. /**
  24085. * Disposes the effect configuration
  24086. */
  24087. dispose?: () => void;
  24088. /**
  24089. * Creates the associated post process
  24090. */
  24091. createPostProcess?: () => PostProcess;
  24092. }
  24093. }
  24094. declare module "babylonjs/Materials/fresnelParameters" {
  24095. import { DeepImmutable } from "babylonjs/types";
  24096. import { Color3 } from "babylonjs/Maths/math.color";
  24097. /**
  24098. * Options to be used when creating a FresnelParameters.
  24099. */
  24100. export type IFresnelParametersCreationOptions = {
  24101. /**
  24102. * Define the color used on edges (grazing angle)
  24103. */
  24104. leftColor?: Color3;
  24105. /**
  24106. * Define the color used on center
  24107. */
  24108. rightColor?: Color3;
  24109. /**
  24110. * Define bias applied to computed fresnel term
  24111. */
  24112. bias?: number;
  24113. /**
  24114. * Defined the power exponent applied to fresnel term
  24115. */
  24116. power?: number;
  24117. /**
  24118. * Define if the fresnel effect is enable or not.
  24119. */
  24120. isEnabled?: boolean;
  24121. };
  24122. /**
  24123. * Serialized format for FresnelParameters.
  24124. */
  24125. export type IFresnelParametersSerialized = {
  24126. /**
  24127. * Define the color used on edges (grazing angle) [as an array]
  24128. */
  24129. leftColor: number[];
  24130. /**
  24131. * Define the color used on center [as an array]
  24132. */
  24133. rightColor: number[];
  24134. /**
  24135. * Define bias applied to computed fresnel term
  24136. */
  24137. bias: number;
  24138. /**
  24139. * Defined the power exponent applied to fresnel term
  24140. */
  24141. power?: number;
  24142. /**
  24143. * Define if the fresnel effect is enable or not.
  24144. */
  24145. isEnabled: boolean;
  24146. };
  24147. /**
  24148. * This represents all the required information to add a fresnel effect on a material:
  24149. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24150. */
  24151. export class FresnelParameters {
  24152. private _isEnabled;
  24153. /**
  24154. * Define if the fresnel effect is enable or not.
  24155. */
  24156. get isEnabled(): boolean;
  24157. set isEnabled(value: boolean);
  24158. /**
  24159. * Define the color used on edges (grazing angle)
  24160. */
  24161. leftColor: Color3;
  24162. /**
  24163. * Define the color used on center
  24164. */
  24165. rightColor: Color3;
  24166. /**
  24167. * Define bias applied to computed fresnel term
  24168. */
  24169. bias: number;
  24170. /**
  24171. * Defined the power exponent applied to fresnel term
  24172. */
  24173. power: number;
  24174. /**
  24175. * Creates a new FresnelParameters object.
  24176. *
  24177. * @param options provide your own settings to optionally to override defaults
  24178. */
  24179. constructor(options?: IFresnelParametersCreationOptions);
  24180. /**
  24181. * Clones the current fresnel and its valuues
  24182. * @returns a clone fresnel configuration
  24183. */
  24184. clone(): FresnelParameters;
  24185. /**
  24186. * Determines equality between FresnelParameters objects
  24187. * @param otherFresnelParameters defines the second operand
  24188. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24189. */
  24190. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24191. /**
  24192. * Serializes the current fresnel parameters to a JSON representation.
  24193. * @return the JSON serialization
  24194. */
  24195. serialize(): IFresnelParametersSerialized;
  24196. /**
  24197. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24198. * @param parsedFresnelParameters Define the JSON representation
  24199. * @returns the parsed parameters
  24200. */
  24201. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24202. }
  24203. }
  24204. declare module "babylonjs/Materials/materialFlags" {
  24205. /**
  24206. * This groups all the flags used to control the materials channel.
  24207. */
  24208. export class MaterialFlags {
  24209. private static _DiffuseTextureEnabled;
  24210. /**
  24211. * Are diffuse textures enabled in the application.
  24212. */
  24213. static get DiffuseTextureEnabled(): boolean;
  24214. static set DiffuseTextureEnabled(value: boolean);
  24215. private static _DetailTextureEnabled;
  24216. /**
  24217. * Are detail textures enabled in the application.
  24218. */
  24219. static get DetailTextureEnabled(): boolean;
  24220. static set DetailTextureEnabled(value: boolean);
  24221. private static _AmbientTextureEnabled;
  24222. /**
  24223. * Are ambient textures enabled in the application.
  24224. */
  24225. static get AmbientTextureEnabled(): boolean;
  24226. static set AmbientTextureEnabled(value: boolean);
  24227. private static _OpacityTextureEnabled;
  24228. /**
  24229. * Are opacity textures enabled in the application.
  24230. */
  24231. static get OpacityTextureEnabled(): boolean;
  24232. static set OpacityTextureEnabled(value: boolean);
  24233. private static _ReflectionTextureEnabled;
  24234. /**
  24235. * Are reflection textures enabled in the application.
  24236. */
  24237. static get ReflectionTextureEnabled(): boolean;
  24238. static set ReflectionTextureEnabled(value: boolean);
  24239. private static _EmissiveTextureEnabled;
  24240. /**
  24241. * Are emissive textures enabled in the application.
  24242. */
  24243. static get EmissiveTextureEnabled(): boolean;
  24244. static set EmissiveTextureEnabled(value: boolean);
  24245. private static _SpecularTextureEnabled;
  24246. /**
  24247. * Are specular textures enabled in the application.
  24248. */
  24249. static get SpecularTextureEnabled(): boolean;
  24250. static set SpecularTextureEnabled(value: boolean);
  24251. private static _BumpTextureEnabled;
  24252. /**
  24253. * Are bump textures enabled in the application.
  24254. */
  24255. static get BumpTextureEnabled(): boolean;
  24256. static set BumpTextureEnabled(value: boolean);
  24257. private static _LightmapTextureEnabled;
  24258. /**
  24259. * Are lightmap textures enabled in the application.
  24260. */
  24261. static get LightmapTextureEnabled(): boolean;
  24262. static set LightmapTextureEnabled(value: boolean);
  24263. private static _RefractionTextureEnabled;
  24264. /**
  24265. * Are refraction textures enabled in the application.
  24266. */
  24267. static get RefractionTextureEnabled(): boolean;
  24268. static set RefractionTextureEnabled(value: boolean);
  24269. private static _ColorGradingTextureEnabled;
  24270. /**
  24271. * Are color grading textures enabled in the application.
  24272. */
  24273. static get ColorGradingTextureEnabled(): boolean;
  24274. static set ColorGradingTextureEnabled(value: boolean);
  24275. private static _FresnelEnabled;
  24276. /**
  24277. * Are fresnels enabled in the application.
  24278. */
  24279. static get FresnelEnabled(): boolean;
  24280. static set FresnelEnabled(value: boolean);
  24281. private static _ClearCoatTextureEnabled;
  24282. /**
  24283. * Are clear coat textures enabled in the application.
  24284. */
  24285. static get ClearCoatTextureEnabled(): boolean;
  24286. static set ClearCoatTextureEnabled(value: boolean);
  24287. private static _ClearCoatBumpTextureEnabled;
  24288. /**
  24289. * Are clear coat bump textures enabled in the application.
  24290. */
  24291. static get ClearCoatBumpTextureEnabled(): boolean;
  24292. static set ClearCoatBumpTextureEnabled(value: boolean);
  24293. private static _ClearCoatTintTextureEnabled;
  24294. /**
  24295. * Are clear coat tint textures enabled in the application.
  24296. */
  24297. static get ClearCoatTintTextureEnabled(): boolean;
  24298. static set ClearCoatTintTextureEnabled(value: boolean);
  24299. private static _SheenTextureEnabled;
  24300. /**
  24301. * Are sheen textures enabled in the application.
  24302. */
  24303. static get SheenTextureEnabled(): boolean;
  24304. static set SheenTextureEnabled(value: boolean);
  24305. private static _AnisotropicTextureEnabled;
  24306. /**
  24307. * Are anisotropic textures enabled in the application.
  24308. */
  24309. static get AnisotropicTextureEnabled(): boolean;
  24310. static set AnisotropicTextureEnabled(value: boolean);
  24311. private static _ThicknessTextureEnabled;
  24312. /**
  24313. * Are thickness textures enabled in the application.
  24314. */
  24315. static get ThicknessTextureEnabled(): boolean;
  24316. static set ThicknessTextureEnabled(value: boolean);
  24317. }
  24318. }
  24319. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24320. /** @hidden */
  24321. export var defaultFragmentDeclaration: {
  24322. name: string;
  24323. shader: string;
  24324. };
  24325. }
  24326. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24327. /** @hidden */
  24328. export var defaultUboDeclaration: {
  24329. name: string;
  24330. shader: string;
  24331. };
  24332. }
  24333. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24334. /** @hidden */
  24335. export var prePassDeclaration: {
  24336. name: string;
  24337. shader: string;
  24338. };
  24339. }
  24340. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24341. /** @hidden */
  24342. export var lightFragmentDeclaration: {
  24343. name: string;
  24344. shader: string;
  24345. };
  24346. }
  24347. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24348. /** @hidden */
  24349. export var lightUboDeclaration: {
  24350. name: string;
  24351. shader: string;
  24352. };
  24353. }
  24354. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24355. /** @hidden */
  24356. export var lightsFragmentFunctions: {
  24357. name: string;
  24358. shader: string;
  24359. };
  24360. }
  24361. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24362. /** @hidden */
  24363. export var shadowsFragmentFunctions: {
  24364. name: string;
  24365. shader: string;
  24366. };
  24367. }
  24368. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24369. /** @hidden */
  24370. export var fresnelFunction: {
  24371. name: string;
  24372. shader: string;
  24373. };
  24374. }
  24375. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24376. /** @hidden */
  24377. export var bumpFragmentMainFunctions: {
  24378. name: string;
  24379. shader: string;
  24380. };
  24381. }
  24382. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24383. /** @hidden */
  24384. export var bumpFragmentFunctions: {
  24385. name: string;
  24386. shader: string;
  24387. };
  24388. }
  24389. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24390. /** @hidden */
  24391. export var logDepthDeclaration: {
  24392. name: string;
  24393. shader: string;
  24394. };
  24395. }
  24396. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24397. /** @hidden */
  24398. export var bumpFragment: {
  24399. name: string;
  24400. shader: string;
  24401. };
  24402. }
  24403. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24404. /** @hidden */
  24405. export var depthPrePass: {
  24406. name: string;
  24407. shader: string;
  24408. };
  24409. }
  24410. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24411. /** @hidden */
  24412. export var lightFragment: {
  24413. name: string;
  24414. shader: string;
  24415. };
  24416. }
  24417. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24418. /** @hidden */
  24419. export var logDepthFragment: {
  24420. name: string;
  24421. shader: string;
  24422. };
  24423. }
  24424. declare module "babylonjs/Shaders/default.fragment" {
  24425. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24426. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24427. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24428. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24429. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24430. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24431. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24432. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24433. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24434. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24435. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24436. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24437. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24438. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24439. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24440. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24441. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24442. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24443. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24444. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24445. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24446. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24447. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24448. /** @hidden */
  24449. export var defaultPixelShader: {
  24450. name: string;
  24451. shader: string;
  24452. };
  24453. }
  24454. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24455. /** @hidden */
  24456. export var defaultVertexDeclaration: {
  24457. name: string;
  24458. shader: string;
  24459. };
  24460. }
  24461. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24462. /** @hidden */
  24463. export var prePassVertexDeclaration: {
  24464. name: string;
  24465. shader: string;
  24466. };
  24467. }
  24468. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24469. /** @hidden */
  24470. export var bumpVertexDeclaration: {
  24471. name: string;
  24472. shader: string;
  24473. };
  24474. }
  24475. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24476. /** @hidden */
  24477. export var prePassVertex: {
  24478. name: string;
  24479. shader: string;
  24480. };
  24481. }
  24482. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24483. /** @hidden */
  24484. export var bumpVertex: {
  24485. name: string;
  24486. shader: string;
  24487. };
  24488. }
  24489. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24490. /** @hidden */
  24491. export var fogVertex: {
  24492. name: string;
  24493. shader: string;
  24494. };
  24495. }
  24496. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24497. /** @hidden */
  24498. export var shadowsVertex: {
  24499. name: string;
  24500. shader: string;
  24501. };
  24502. }
  24503. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24504. /** @hidden */
  24505. export var pointCloudVertex: {
  24506. name: string;
  24507. shader: string;
  24508. };
  24509. }
  24510. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24511. /** @hidden */
  24512. export var logDepthVertex: {
  24513. name: string;
  24514. shader: string;
  24515. };
  24516. }
  24517. declare module "babylonjs/Shaders/default.vertex" {
  24518. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24519. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24520. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24521. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24522. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24523. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24524. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24525. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24526. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24527. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24528. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24529. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24530. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24531. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24533. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24534. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24535. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24536. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24537. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24538. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24539. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24540. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24541. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24542. /** @hidden */
  24543. export var defaultVertexShader: {
  24544. name: string;
  24545. shader: string;
  24546. };
  24547. }
  24548. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24549. import { Nullable } from "babylonjs/types";
  24550. import { Scene } from "babylonjs/scene";
  24551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24552. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24553. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24554. /**
  24555. * @hidden
  24556. */
  24557. export interface IMaterialDetailMapDefines {
  24558. DETAIL: boolean;
  24559. DETAILDIRECTUV: number;
  24560. DETAIL_NORMALBLENDMETHOD: number;
  24561. /** @hidden */
  24562. _areTexturesDirty: boolean;
  24563. }
  24564. /**
  24565. * Define the code related to the detail map parameters of a material
  24566. *
  24567. * Inspired from:
  24568. * 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
  24569. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24570. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24571. */
  24572. export class DetailMapConfiguration {
  24573. private _texture;
  24574. /**
  24575. * The detail texture of the material.
  24576. */
  24577. texture: Nullable<BaseTexture>;
  24578. /**
  24579. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24580. * Bigger values mean stronger blending
  24581. */
  24582. diffuseBlendLevel: number;
  24583. /**
  24584. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24585. * Bigger values mean stronger blending. Only used with PBR materials
  24586. */
  24587. roughnessBlendLevel: number;
  24588. /**
  24589. * Defines how strong the bump effect from the detail map is
  24590. * Bigger values mean stronger effect
  24591. */
  24592. bumpLevel: number;
  24593. private _normalBlendMethod;
  24594. /**
  24595. * The method used to blend the bump and detail normals together
  24596. */
  24597. normalBlendMethod: number;
  24598. private _isEnabled;
  24599. /**
  24600. * Enable or disable the detail map on this material
  24601. */
  24602. isEnabled: boolean;
  24603. /** @hidden */
  24604. private _internalMarkAllSubMeshesAsTexturesDirty;
  24605. /** @hidden */
  24606. _markAllSubMeshesAsTexturesDirty(): void;
  24607. /**
  24608. * Instantiate a new detail map
  24609. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24610. */
  24611. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24612. /**
  24613. * Gets whether the submesh is ready to be used or not.
  24614. * @param defines the list of "defines" to update.
  24615. * @param scene defines the scene the material belongs to.
  24616. * @returns - boolean indicating that the submesh is ready or not.
  24617. */
  24618. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24619. /**
  24620. * Update the defines for detail map usage
  24621. * @param defines the list of "defines" to update.
  24622. * @param scene defines the scene the material belongs to.
  24623. */
  24624. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24625. /**
  24626. * Binds the material data.
  24627. * @param uniformBuffer defines the Uniform buffer to fill in.
  24628. * @param scene defines the scene the material belongs to.
  24629. * @param isFrozen defines whether the material is frozen or not.
  24630. */
  24631. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24632. /**
  24633. * Checks to see if a texture is used in the material.
  24634. * @param texture - Base texture to use.
  24635. * @returns - Boolean specifying if a texture is used in the material.
  24636. */
  24637. hasTexture(texture: BaseTexture): boolean;
  24638. /**
  24639. * Returns an array of the actively used textures.
  24640. * @param activeTextures Array of BaseTextures
  24641. */
  24642. getActiveTextures(activeTextures: BaseTexture[]): void;
  24643. /**
  24644. * Returns the animatable textures.
  24645. * @param animatables Array of animatable textures.
  24646. */
  24647. getAnimatables(animatables: IAnimatable[]): void;
  24648. /**
  24649. * Disposes the resources of the material.
  24650. * @param forceDisposeTextures - Forces the disposal of all textures.
  24651. */
  24652. dispose(forceDisposeTextures?: boolean): void;
  24653. /**
  24654. * Get the current class name useful for serialization or dynamic coding.
  24655. * @returns "DetailMap"
  24656. */
  24657. getClassName(): string;
  24658. /**
  24659. * Add the required uniforms to the current list.
  24660. * @param uniforms defines the current uniform list.
  24661. */
  24662. static AddUniforms(uniforms: string[]): void;
  24663. /**
  24664. * Add the required samplers to the current list.
  24665. * @param samplers defines the current sampler list.
  24666. */
  24667. static AddSamplers(samplers: string[]): void;
  24668. /**
  24669. * Add the required uniforms to the current buffer.
  24670. * @param uniformBuffer defines the current uniform buffer.
  24671. */
  24672. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24673. /**
  24674. * Makes a duplicate of the current instance into another one.
  24675. * @param detailMap define the instance where to copy the info
  24676. */
  24677. copyTo(detailMap: DetailMapConfiguration): void;
  24678. /**
  24679. * Serializes this detail map instance
  24680. * @returns - An object with the serialized instance.
  24681. */
  24682. serialize(): any;
  24683. /**
  24684. * Parses a detail map setting from a serialized object.
  24685. * @param source - Serialized object.
  24686. * @param scene Defines the scene we are parsing for
  24687. * @param rootUrl Defines the rootUrl to load from
  24688. */
  24689. parse(source: any, scene: Scene, rootUrl: string): void;
  24690. }
  24691. }
  24692. declare module "babylonjs/Materials/standardMaterial" {
  24693. import { SmartArray } from "babylonjs/Misc/smartArray";
  24694. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24695. import { Nullable } from "babylonjs/types";
  24696. import { Scene } from "babylonjs/scene";
  24697. import { Matrix } from "babylonjs/Maths/math.vector";
  24698. import { Color3 } from "babylonjs/Maths/math.color";
  24699. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24701. import { Mesh } from "babylonjs/Meshes/mesh";
  24702. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24703. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24704. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24705. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24706. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24707. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24708. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24710. import "babylonjs/Shaders/default.fragment";
  24711. import "babylonjs/Shaders/default.vertex";
  24712. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24713. /** @hidden */
  24714. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24715. MAINUV1: boolean;
  24716. MAINUV2: boolean;
  24717. DIFFUSE: boolean;
  24718. DIFFUSEDIRECTUV: number;
  24719. DETAIL: boolean;
  24720. DETAILDIRECTUV: number;
  24721. DETAIL_NORMALBLENDMETHOD: number;
  24722. AMBIENT: boolean;
  24723. AMBIENTDIRECTUV: number;
  24724. OPACITY: boolean;
  24725. OPACITYDIRECTUV: number;
  24726. OPACITYRGB: boolean;
  24727. REFLECTION: boolean;
  24728. EMISSIVE: boolean;
  24729. EMISSIVEDIRECTUV: number;
  24730. SPECULAR: boolean;
  24731. SPECULARDIRECTUV: number;
  24732. BUMP: boolean;
  24733. BUMPDIRECTUV: number;
  24734. PARALLAX: boolean;
  24735. PARALLAXOCCLUSION: boolean;
  24736. SPECULAROVERALPHA: boolean;
  24737. CLIPPLANE: boolean;
  24738. CLIPPLANE2: boolean;
  24739. CLIPPLANE3: boolean;
  24740. CLIPPLANE4: boolean;
  24741. CLIPPLANE5: boolean;
  24742. CLIPPLANE6: boolean;
  24743. ALPHATEST: boolean;
  24744. DEPTHPREPASS: boolean;
  24745. ALPHAFROMDIFFUSE: boolean;
  24746. POINTSIZE: boolean;
  24747. FOG: boolean;
  24748. SPECULARTERM: boolean;
  24749. DIFFUSEFRESNEL: boolean;
  24750. OPACITYFRESNEL: boolean;
  24751. REFLECTIONFRESNEL: boolean;
  24752. REFRACTIONFRESNEL: boolean;
  24753. EMISSIVEFRESNEL: boolean;
  24754. FRESNEL: boolean;
  24755. NORMAL: boolean;
  24756. UV1: boolean;
  24757. UV2: boolean;
  24758. VERTEXCOLOR: boolean;
  24759. VERTEXALPHA: boolean;
  24760. NUM_BONE_INFLUENCERS: number;
  24761. BonesPerMesh: number;
  24762. BONETEXTURE: boolean;
  24763. BONES_VELOCITY_ENABLED: boolean;
  24764. INSTANCES: boolean;
  24765. THIN_INSTANCES: boolean;
  24766. GLOSSINESS: boolean;
  24767. ROUGHNESS: boolean;
  24768. EMISSIVEASILLUMINATION: boolean;
  24769. LINKEMISSIVEWITHDIFFUSE: boolean;
  24770. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24771. LIGHTMAP: boolean;
  24772. LIGHTMAPDIRECTUV: number;
  24773. OBJECTSPACE_NORMALMAP: boolean;
  24774. USELIGHTMAPASSHADOWMAP: boolean;
  24775. REFLECTIONMAP_3D: boolean;
  24776. REFLECTIONMAP_SPHERICAL: boolean;
  24777. REFLECTIONMAP_PLANAR: boolean;
  24778. REFLECTIONMAP_CUBIC: boolean;
  24779. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24780. REFLECTIONMAP_PROJECTION: boolean;
  24781. REFLECTIONMAP_SKYBOX: boolean;
  24782. REFLECTIONMAP_EXPLICIT: boolean;
  24783. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24784. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24785. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24786. INVERTCUBICMAP: boolean;
  24787. LOGARITHMICDEPTH: boolean;
  24788. REFRACTION: boolean;
  24789. REFRACTIONMAP_3D: boolean;
  24790. REFLECTIONOVERALPHA: boolean;
  24791. TWOSIDEDLIGHTING: boolean;
  24792. SHADOWFLOAT: boolean;
  24793. MORPHTARGETS: boolean;
  24794. MORPHTARGETS_NORMAL: boolean;
  24795. MORPHTARGETS_TANGENT: boolean;
  24796. MORPHTARGETS_UV: boolean;
  24797. NUM_MORPH_INFLUENCERS: number;
  24798. NONUNIFORMSCALING: boolean;
  24799. PREMULTIPLYALPHA: boolean;
  24800. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24801. ALPHABLEND: boolean;
  24802. PREPASS: boolean;
  24803. PREPASS_IRRADIANCE: boolean;
  24804. PREPASS_IRRADIANCE_INDEX: number;
  24805. PREPASS_ALBEDO: boolean;
  24806. PREPASS_ALBEDO_INDEX: number;
  24807. PREPASS_DEPTHNORMAL: boolean;
  24808. PREPASS_DEPTHNORMAL_INDEX: number;
  24809. PREPASS_POSITION: boolean;
  24810. PREPASS_POSITION_INDEX: number;
  24811. PREPASS_VELOCITY: boolean;
  24812. PREPASS_VELOCITY_INDEX: number;
  24813. PREPASS_REFLECTIVITY: boolean;
  24814. PREPASS_REFLECTIVITY_INDEX: number;
  24815. SCENE_MRT_COUNT: number;
  24816. RGBDLIGHTMAP: boolean;
  24817. RGBDREFLECTION: boolean;
  24818. RGBDREFRACTION: boolean;
  24819. IMAGEPROCESSING: boolean;
  24820. VIGNETTE: boolean;
  24821. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24822. VIGNETTEBLENDMODEOPAQUE: boolean;
  24823. TONEMAPPING: boolean;
  24824. TONEMAPPING_ACES: boolean;
  24825. CONTRAST: boolean;
  24826. COLORCURVES: boolean;
  24827. COLORGRADING: boolean;
  24828. COLORGRADING3D: boolean;
  24829. SAMPLER3DGREENDEPTH: boolean;
  24830. SAMPLER3DBGRMAP: boolean;
  24831. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24832. MULTIVIEW: boolean;
  24833. /**
  24834. * If the reflection texture on this material is in linear color space
  24835. * @hidden
  24836. */
  24837. IS_REFLECTION_LINEAR: boolean;
  24838. /**
  24839. * If the refraction texture on this material is in linear color space
  24840. * @hidden
  24841. */
  24842. IS_REFRACTION_LINEAR: boolean;
  24843. EXPOSURE: boolean;
  24844. constructor();
  24845. setReflectionMode(modeToEnable: string): void;
  24846. }
  24847. /**
  24848. * This is the default material used in Babylon. It is the best trade off between quality
  24849. * and performances.
  24850. * @see https://doc.babylonjs.com/babylon101/materials
  24851. */
  24852. export class StandardMaterial extends PushMaterial {
  24853. private _diffuseTexture;
  24854. /**
  24855. * The basic texture of the material as viewed under a light.
  24856. */
  24857. diffuseTexture: Nullable<BaseTexture>;
  24858. private _ambientTexture;
  24859. /**
  24860. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24861. */
  24862. ambientTexture: Nullable<BaseTexture>;
  24863. private _opacityTexture;
  24864. /**
  24865. * Define the transparency of the material from a texture.
  24866. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24867. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24868. */
  24869. opacityTexture: Nullable<BaseTexture>;
  24870. private _reflectionTexture;
  24871. /**
  24872. * Define the texture used to display the reflection.
  24873. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24874. */
  24875. reflectionTexture: Nullable<BaseTexture>;
  24876. private _emissiveTexture;
  24877. /**
  24878. * Define texture of the material as if self lit.
  24879. * This will be mixed in the final result even in the absence of light.
  24880. */
  24881. emissiveTexture: Nullable<BaseTexture>;
  24882. private _specularTexture;
  24883. /**
  24884. * Define how the color and intensity of the highlight given by the light in the material.
  24885. */
  24886. specularTexture: Nullable<BaseTexture>;
  24887. private _bumpTexture;
  24888. /**
  24889. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24890. * 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.
  24891. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24892. */
  24893. bumpTexture: Nullable<BaseTexture>;
  24894. private _lightmapTexture;
  24895. /**
  24896. * Complex lighting can be computationally expensive to compute at runtime.
  24897. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24898. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24899. */
  24900. lightmapTexture: Nullable<BaseTexture>;
  24901. private _refractionTexture;
  24902. /**
  24903. * Define the texture used to display the refraction.
  24904. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24905. */
  24906. refractionTexture: Nullable<BaseTexture>;
  24907. /**
  24908. * The color of the material lit by the environmental background lighting.
  24909. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24910. */
  24911. ambientColor: Color3;
  24912. /**
  24913. * The basic color of the material as viewed under a light.
  24914. */
  24915. diffuseColor: Color3;
  24916. /**
  24917. * Define how the color and intensity of the highlight given by the light in the material.
  24918. */
  24919. specularColor: Color3;
  24920. /**
  24921. * Define the color of the material as if self lit.
  24922. * This will be mixed in the final result even in the absence of light.
  24923. */
  24924. emissiveColor: Color3;
  24925. /**
  24926. * Defines how sharp are the highlights in the material.
  24927. * The bigger the value the sharper giving a more glossy feeling to the result.
  24928. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24929. */
  24930. specularPower: number;
  24931. private _useAlphaFromDiffuseTexture;
  24932. /**
  24933. * Does the transparency come from the diffuse texture alpha channel.
  24934. */
  24935. useAlphaFromDiffuseTexture: boolean;
  24936. private _useEmissiveAsIllumination;
  24937. /**
  24938. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24939. */
  24940. useEmissiveAsIllumination: boolean;
  24941. private _linkEmissiveWithDiffuse;
  24942. /**
  24943. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24944. * the emissive level when the final color is close to one.
  24945. */
  24946. linkEmissiveWithDiffuse: boolean;
  24947. private _useSpecularOverAlpha;
  24948. /**
  24949. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24950. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24951. */
  24952. useSpecularOverAlpha: boolean;
  24953. private _useReflectionOverAlpha;
  24954. /**
  24955. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24956. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24957. */
  24958. useReflectionOverAlpha: boolean;
  24959. private _disableLighting;
  24960. /**
  24961. * Does lights from the scene impacts this material.
  24962. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24963. */
  24964. disableLighting: boolean;
  24965. private _useObjectSpaceNormalMap;
  24966. /**
  24967. * Allows using an object space normal map (instead of tangent space).
  24968. */
  24969. useObjectSpaceNormalMap: boolean;
  24970. private _useParallax;
  24971. /**
  24972. * Is parallax enabled or not.
  24973. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24974. */
  24975. useParallax: boolean;
  24976. private _useParallaxOcclusion;
  24977. /**
  24978. * Is parallax occlusion enabled or not.
  24979. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24980. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24981. */
  24982. useParallaxOcclusion: boolean;
  24983. /**
  24984. * 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.
  24985. */
  24986. parallaxScaleBias: number;
  24987. private _roughness;
  24988. /**
  24989. * Helps to define how blurry the reflections should appears in the material.
  24990. */
  24991. roughness: number;
  24992. /**
  24993. * In case of refraction, define the value of the index of refraction.
  24994. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24995. */
  24996. indexOfRefraction: number;
  24997. /**
  24998. * Invert the refraction texture alongside the y axis.
  24999. * It can be useful with procedural textures or probe for instance.
  25000. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25001. */
  25002. invertRefractionY: boolean;
  25003. /**
  25004. * Defines the alpha limits in alpha test mode.
  25005. */
  25006. alphaCutOff: number;
  25007. private _useLightmapAsShadowmap;
  25008. /**
  25009. * In case of light mapping, define whether the map contains light or shadow informations.
  25010. */
  25011. useLightmapAsShadowmap: boolean;
  25012. private _diffuseFresnelParameters;
  25013. /**
  25014. * Define the diffuse fresnel parameters of the material.
  25015. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25016. */
  25017. diffuseFresnelParameters: FresnelParameters;
  25018. private _opacityFresnelParameters;
  25019. /**
  25020. * Define the opacity fresnel parameters of the material.
  25021. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25022. */
  25023. opacityFresnelParameters: FresnelParameters;
  25024. private _reflectionFresnelParameters;
  25025. /**
  25026. * Define the reflection fresnel parameters of the material.
  25027. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25028. */
  25029. reflectionFresnelParameters: FresnelParameters;
  25030. private _refractionFresnelParameters;
  25031. /**
  25032. * Define the refraction fresnel parameters of the material.
  25033. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25034. */
  25035. refractionFresnelParameters: FresnelParameters;
  25036. private _emissiveFresnelParameters;
  25037. /**
  25038. * Define the emissive fresnel parameters of the material.
  25039. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25040. */
  25041. emissiveFresnelParameters: FresnelParameters;
  25042. private _useReflectionFresnelFromSpecular;
  25043. /**
  25044. * If true automatically deducts the fresnels values from the material specularity.
  25045. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25046. */
  25047. useReflectionFresnelFromSpecular: boolean;
  25048. private _useGlossinessFromSpecularMapAlpha;
  25049. /**
  25050. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25051. */
  25052. useGlossinessFromSpecularMapAlpha: boolean;
  25053. private _maxSimultaneousLights;
  25054. /**
  25055. * Defines the maximum number of lights that can be used in the material
  25056. */
  25057. maxSimultaneousLights: number;
  25058. private _invertNormalMapX;
  25059. /**
  25060. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25061. */
  25062. invertNormalMapX: boolean;
  25063. private _invertNormalMapY;
  25064. /**
  25065. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25066. */
  25067. invertNormalMapY: boolean;
  25068. private _twoSidedLighting;
  25069. /**
  25070. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25071. */
  25072. twoSidedLighting: boolean;
  25073. /**
  25074. * Default configuration related to image processing available in the standard Material.
  25075. */
  25076. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25077. /**
  25078. * Gets the image processing configuration used either in this material.
  25079. */
  25080. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25081. /**
  25082. * Sets the Default image processing configuration used either in the this material.
  25083. *
  25084. * If sets to null, the scene one is in use.
  25085. */
  25086. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25087. /**
  25088. * Keep track of the image processing observer to allow dispose and replace.
  25089. */
  25090. private _imageProcessingObserver;
  25091. /**
  25092. * Attaches a new image processing configuration to the Standard Material.
  25093. * @param configuration
  25094. */
  25095. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25096. /**
  25097. * Defines additionnal PrePass parameters for the material.
  25098. */
  25099. readonly prePassConfiguration: PrePassConfiguration;
  25100. /**
  25101. * Gets wether the color curves effect is enabled.
  25102. */
  25103. get cameraColorCurvesEnabled(): boolean;
  25104. /**
  25105. * Sets wether the color curves effect is enabled.
  25106. */
  25107. set cameraColorCurvesEnabled(value: boolean);
  25108. /**
  25109. * Gets wether the color grading effect is enabled.
  25110. */
  25111. get cameraColorGradingEnabled(): boolean;
  25112. /**
  25113. * Gets wether the color grading effect is enabled.
  25114. */
  25115. set cameraColorGradingEnabled(value: boolean);
  25116. /**
  25117. * Gets wether tonemapping is enabled or not.
  25118. */
  25119. get cameraToneMappingEnabled(): boolean;
  25120. /**
  25121. * Sets wether tonemapping is enabled or not
  25122. */
  25123. set cameraToneMappingEnabled(value: boolean);
  25124. /**
  25125. * The camera exposure used on this material.
  25126. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25127. * This corresponds to a photographic exposure.
  25128. */
  25129. get cameraExposure(): number;
  25130. /**
  25131. * The camera exposure used on this material.
  25132. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25133. * This corresponds to a photographic exposure.
  25134. */
  25135. set cameraExposure(value: number);
  25136. /**
  25137. * Gets The camera contrast used on this material.
  25138. */
  25139. get cameraContrast(): number;
  25140. /**
  25141. * Sets The camera contrast used on this material.
  25142. */
  25143. set cameraContrast(value: number);
  25144. /**
  25145. * Gets the Color Grading 2D Lookup Texture.
  25146. */
  25147. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25148. /**
  25149. * Sets the Color Grading 2D Lookup Texture.
  25150. */
  25151. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25152. /**
  25153. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25154. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25155. * 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;
  25156. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25157. */
  25158. get cameraColorCurves(): Nullable<ColorCurves>;
  25159. /**
  25160. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25161. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25162. * 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;
  25163. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25164. */
  25165. set cameraColorCurves(value: Nullable<ColorCurves>);
  25166. /**
  25167. * Can this material render to several textures at once
  25168. */
  25169. get canRenderToMRT(): boolean;
  25170. /**
  25171. * Defines the detail map parameters for the material.
  25172. */
  25173. readonly detailMap: DetailMapConfiguration;
  25174. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25175. protected _worldViewProjectionMatrix: Matrix;
  25176. protected _globalAmbientColor: Color3;
  25177. protected _useLogarithmicDepth: boolean;
  25178. protected _rebuildInParallel: boolean;
  25179. /**
  25180. * Instantiates a new standard material.
  25181. * This is the default material used in Babylon. It is the best trade off between quality
  25182. * and performances.
  25183. * @see https://doc.babylonjs.com/babylon101/materials
  25184. * @param name Define the name of the material in the scene
  25185. * @param scene Define the scene the material belong to
  25186. */
  25187. constructor(name: string, scene: Scene);
  25188. /**
  25189. * Gets a boolean indicating that current material needs to register RTT
  25190. */
  25191. get hasRenderTargetTextures(): boolean;
  25192. /**
  25193. * Gets the current class name of the material e.g. "StandardMaterial"
  25194. * Mainly use in serialization.
  25195. * @returns the class name
  25196. */
  25197. getClassName(): string;
  25198. /**
  25199. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25200. * You can try switching to logarithmic depth.
  25201. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25202. */
  25203. get useLogarithmicDepth(): boolean;
  25204. set useLogarithmicDepth(value: boolean);
  25205. /**
  25206. * Specifies if the material will require alpha blending
  25207. * @returns a boolean specifying if alpha blending is needed
  25208. */
  25209. needAlphaBlending(): boolean;
  25210. /**
  25211. * Specifies if this material should be rendered in alpha test mode
  25212. * @returns a boolean specifying if an alpha test is needed.
  25213. */
  25214. needAlphaTesting(): boolean;
  25215. /**
  25216. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  25217. */
  25218. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25219. /**
  25220. * Specifies whether or not there is a usable alpha channel for transparency.
  25221. */
  25222. protected _hasAlphaChannel(): boolean;
  25223. /**
  25224. * Get the texture used for alpha test purpose.
  25225. * @returns the diffuse texture in case of the standard material.
  25226. */
  25227. getAlphaTestTexture(): Nullable<BaseTexture>;
  25228. /**
  25229. * Get if the submesh is ready to be used and all its information available.
  25230. * Child classes can use it to update shaders
  25231. * @param mesh defines the mesh to check
  25232. * @param subMesh defines which submesh to check
  25233. * @param useInstances specifies that instances should be used
  25234. * @returns a boolean indicating that the submesh is ready or not
  25235. */
  25236. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25237. /**
  25238. * Builds the material UBO layouts.
  25239. * Used internally during the effect preparation.
  25240. */
  25241. buildUniformLayout(): void;
  25242. /**
  25243. * Unbinds the material from the mesh
  25244. */
  25245. unbind(): void;
  25246. /**
  25247. * Binds the submesh to this material by preparing the effect and shader to draw
  25248. * @param world defines the world transformation matrix
  25249. * @param mesh defines the mesh containing the submesh
  25250. * @param subMesh defines the submesh to bind the material to
  25251. */
  25252. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25253. /**
  25254. * Get the list of animatables in the material.
  25255. * @returns the list of animatables object used in the material
  25256. */
  25257. getAnimatables(): IAnimatable[];
  25258. /**
  25259. * Gets the active textures from the material
  25260. * @returns an array of textures
  25261. */
  25262. getActiveTextures(): BaseTexture[];
  25263. /**
  25264. * Specifies if the material uses a texture
  25265. * @param texture defines the texture to check against the material
  25266. * @returns a boolean specifying if the material uses the texture
  25267. */
  25268. hasTexture(texture: BaseTexture): boolean;
  25269. /**
  25270. * Disposes the material
  25271. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25272. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25273. */
  25274. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25275. /**
  25276. * Makes a duplicate of the material, and gives it a new name
  25277. * @param name defines the new name for the duplicated material
  25278. * @returns the cloned material
  25279. */
  25280. clone(name: string): StandardMaterial;
  25281. /**
  25282. * Serializes this material in a JSON representation
  25283. * @returns the serialized material object
  25284. */
  25285. serialize(): any;
  25286. /**
  25287. * Creates a standard material from parsed material data
  25288. * @param source defines the JSON representation of the material
  25289. * @param scene defines the hosting scene
  25290. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25291. * @returns a new standard material
  25292. */
  25293. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25294. /**
  25295. * Are diffuse textures enabled in the application.
  25296. */
  25297. static get DiffuseTextureEnabled(): boolean;
  25298. static set DiffuseTextureEnabled(value: boolean);
  25299. /**
  25300. * Are detail textures enabled in the application.
  25301. */
  25302. static get DetailTextureEnabled(): boolean;
  25303. static set DetailTextureEnabled(value: boolean);
  25304. /**
  25305. * Are ambient textures enabled in the application.
  25306. */
  25307. static get AmbientTextureEnabled(): boolean;
  25308. static set AmbientTextureEnabled(value: boolean);
  25309. /**
  25310. * Are opacity textures enabled in the application.
  25311. */
  25312. static get OpacityTextureEnabled(): boolean;
  25313. static set OpacityTextureEnabled(value: boolean);
  25314. /**
  25315. * Are reflection textures enabled in the application.
  25316. */
  25317. static get ReflectionTextureEnabled(): boolean;
  25318. static set ReflectionTextureEnabled(value: boolean);
  25319. /**
  25320. * Are emissive textures enabled in the application.
  25321. */
  25322. static get EmissiveTextureEnabled(): boolean;
  25323. static set EmissiveTextureEnabled(value: boolean);
  25324. /**
  25325. * Are specular textures enabled in the application.
  25326. */
  25327. static get SpecularTextureEnabled(): boolean;
  25328. static set SpecularTextureEnabled(value: boolean);
  25329. /**
  25330. * Are bump textures enabled in the application.
  25331. */
  25332. static get BumpTextureEnabled(): boolean;
  25333. static set BumpTextureEnabled(value: boolean);
  25334. /**
  25335. * Are lightmap textures enabled in the application.
  25336. */
  25337. static get LightmapTextureEnabled(): boolean;
  25338. static set LightmapTextureEnabled(value: boolean);
  25339. /**
  25340. * Are refraction textures enabled in the application.
  25341. */
  25342. static get RefractionTextureEnabled(): boolean;
  25343. static set RefractionTextureEnabled(value: boolean);
  25344. /**
  25345. * Are color grading textures enabled in the application.
  25346. */
  25347. static get ColorGradingTextureEnabled(): boolean;
  25348. static set ColorGradingTextureEnabled(value: boolean);
  25349. /**
  25350. * Are fresnels enabled in the application.
  25351. */
  25352. static get FresnelEnabled(): boolean;
  25353. static set FresnelEnabled(value: boolean);
  25354. }
  25355. }
  25356. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25357. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25358. /** @hidden */
  25359. export var rgbdDecodePixelShader: {
  25360. name: string;
  25361. shader: string;
  25362. };
  25363. }
  25364. declare module "babylonjs/Misc/rgbdTextureTools" {
  25365. import "babylonjs/Shaders/rgbdDecode.fragment";
  25366. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25367. import { Texture } from "babylonjs/Materials/Textures/texture";
  25368. /**
  25369. * Class used to host RGBD texture specific utilities
  25370. */
  25371. export class RGBDTextureTools {
  25372. /**
  25373. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25374. * @param texture the texture to expand.
  25375. */
  25376. static ExpandRGBDTexture(texture: Texture): void;
  25377. }
  25378. }
  25379. declare module "babylonjs/Misc/brdfTextureTools" {
  25380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25381. import { Scene } from "babylonjs/scene";
  25382. /**
  25383. * Class used to host texture specific utilities
  25384. */
  25385. export class BRDFTextureTools {
  25386. /**
  25387. * Prevents texture cache collision
  25388. */
  25389. private static _instanceNumber;
  25390. /**
  25391. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25392. * @param scene defines the hosting scene
  25393. * @returns the environment BRDF texture
  25394. */
  25395. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25396. private static _environmentBRDFBase64Texture;
  25397. }
  25398. }
  25399. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25400. import { Nullable } from "babylonjs/types";
  25401. import { Color3 } from "babylonjs/Maths/math.color";
  25402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25403. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25404. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25405. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25406. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25407. import { Engine } from "babylonjs/Engines/engine";
  25408. import { Scene } from "babylonjs/scene";
  25409. /**
  25410. * @hidden
  25411. */
  25412. export interface IMaterialClearCoatDefines {
  25413. CLEARCOAT: boolean;
  25414. CLEARCOAT_DEFAULTIOR: boolean;
  25415. CLEARCOAT_TEXTURE: boolean;
  25416. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  25417. CLEARCOAT_TEXTUREDIRECTUV: number;
  25418. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  25419. CLEARCOAT_BUMP: boolean;
  25420. CLEARCOAT_BUMPDIRECTUV: number;
  25421. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25422. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25423. CLEARCOAT_REMAP_F0: boolean;
  25424. CLEARCOAT_TINT: boolean;
  25425. CLEARCOAT_TINT_TEXTURE: boolean;
  25426. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25427. /** @hidden */
  25428. _areTexturesDirty: boolean;
  25429. }
  25430. /**
  25431. * Define the code related to the clear coat parameters of the pbr material.
  25432. */
  25433. export class PBRClearCoatConfiguration {
  25434. /**
  25435. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25436. * The default fits with a polyurethane material.
  25437. */
  25438. private static readonly _DefaultIndexOfRefraction;
  25439. private _isEnabled;
  25440. /**
  25441. * Defines if the clear coat is enabled in the material.
  25442. */
  25443. isEnabled: boolean;
  25444. /**
  25445. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25446. */
  25447. intensity: number;
  25448. /**
  25449. * Defines the clear coat layer roughness.
  25450. */
  25451. roughness: number;
  25452. private _indexOfRefraction;
  25453. /**
  25454. * Defines the index of refraction of the clear coat.
  25455. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25456. * The default fits with a polyurethane material.
  25457. * Changing the default value is more performance intensive.
  25458. */
  25459. indexOfRefraction: number;
  25460. private _texture;
  25461. /**
  25462. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  25463. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  25464. * if textureRoughness is not empty, else no texture roughness is used
  25465. */
  25466. texture: Nullable<BaseTexture>;
  25467. private _useRoughnessFromMainTexture;
  25468. /**
  25469. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  25470. * If false, the green channel from textureRoughness is used for roughness
  25471. */
  25472. useRoughnessFromMainTexture: boolean;
  25473. private _textureRoughness;
  25474. /**
  25475. * Stores the clear coat roughness in a texture (green channel)
  25476. * Not used if useRoughnessFromMainTexture is true
  25477. */
  25478. textureRoughness: Nullable<BaseTexture>;
  25479. private _remapF0OnInterfaceChange;
  25480. /**
  25481. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25482. */
  25483. remapF0OnInterfaceChange: boolean;
  25484. private _bumpTexture;
  25485. /**
  25486. * Define the clear coat specific bump texture.
  25487. */
  25488. bumpTexture: Nullable<BaseTexture>;
  25489. private _isTintEnabled;
  25490. /**
  25491. * Defines if the clear coat tint is enabled in the material.
  25492. */
  25493. isTintEnabled: boolean;
  25494. /**
  25495. * Defines the clear coat tint of the material.
  25496. * This is only use if tint is enabled
  25497. */
  25498. tintColor: Color3;
  25499. /**
  25500. * Defines the distance at which the tint color should be found in the
  25501. * clear coat media.
  25502. * This is only use if tint is enabled
  25503. */
  25504. tintColorAtDistance: number;
  25505. /**
  25506. * Defines the clear coat layer thickness.
  25507. * This is only use if tint is enabled
  25508. */
  25509. tintThickness: number;
  25510. private _tintTexture;
  25511. /**
  25512. * Stores the clear tint values in a texture.
  25513. * rgb is tint
  25514. * a is a thickness factor
  25515. */
  25516. tintTexture: Nullable<BaseTexture>;
  25517. /** @hidden */
  25518. private _internalMarkAllSubMeshesAsTexturesDirty;
  25519. /** @hidden */
  25520. _markAllSubMeshesAsTexturesDirty(): void;
  25521. /**
  25522. * Instantiate a new istance of clear coat configuration.
  25523. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25524. */
  25525. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25526. /**
  25527. * Gets wehter the submesh is ready to be used or not.
  25528. * @param defines the list of "defines" to update.
  25529. * @param scene defines the scene the material belongs to.
  25530. * @param engine defines the engine the material belongs to.
  25531. * @param disableBumpMap defines wether the material disables bump or not.
  25532. * @returns - boolean indicating that the submesh is ready or not.
  25533. */
  25534. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25535. /**
  25536. * Checks to see if a texture is used in the material.
  25537. * @param defines the list of "defines" to update.
  25538. * @param scene defines the scene to the material belongs to.
  25539. */
  25540. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25541. /**
  25542. * Binds the material data.
  25543. * @param uniformBuffer defines the Uniform buffer to fill in.
  25544. * @param scene defines the scene the material belongs to.
  25545. * @param engine defines the engine the material belongs to.
  25546. * @param disableBumpMap defines wether the material disables bump or not.
  25547. * @param isFrozen defines wether the material is frozen or not.
  25548. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25549. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25550. * @param subMesh the submesh to bind data for
  25551. */
  25552. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  25553. /**
  25554. * Checks to see if a texture is used in the material.
  25555. * @param texture - Base texture to use.
  25556. * @returns - Boolean specifying if a texture is used in the material.
  25557. */
  25558. hasTexture(texture: BaseTexture): boolean;
  25559. /**
  25560. * Returns an array of the actively used textures.
  25561. * @param activeTextures Array of BaseTextures
  25562. */
  25563. getActiveTextures(activeTextures: BaseTexture[]): void;
  25564. /**
  25565. * Returns the animatable textures.
  25566. * @param animatables Array of animatable textures.
  25567. */
  25568. getAnimatables(animatables: IAnimatable[]): void;
  25569. /**
  25570. * Disposes the resources of the material.
  25571. * @param forceDisposeTextures - Forces the disposal of all textures.
  25572. */
  25573. dispose(forceDisposeTextures?: boolean): void;
  25574. /**
  25575. * Get the current class name of the texture useful for serialization or dynamic coding.
  25576. * @returns "PBRClearCoatConfiguration"
  25577. */
  25578. getClassName(): string;
  25579. /**
  25580. * Add fallbacks to the effect fallbacks list.
  25581. * @param defines defines the Base texture to use.
  25582. * @param fallbacks defines the current fallback list.
  25583. * @param currentRank defines the current fallback rank.
  25584. * @returns the new fallback rank.
  25585. */
  25586. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25587. /**
  25588. * Add the required uniforms to the current list.
  25589. * @param uniforms defines the current uniform list.
  25590. */
  25591. static AddUniforms(uniforms: string[]): void;
  25592. /**
  25593. * Add the required samplers to the current list.
  25594. * @param samplers defines the current sampler list.
  25595. */
  25596. static AddSamplers(samplers: string[]): void;
  25597. /**
  25598. * Add the required uniforms to the current buffer.
  25599. * @param uniformBuffer defines the current uniform buffer.
  25600. */
  25601. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25602. /**
  25603. * Makes a duplicate of the current configuration into another one.
  25604. * @param clearCoatConfiguration define the config where to copy the info
  25605. */
  25606. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25607. /**
  25608. * Serializes this clear coat configuration.
  25609. * @returns - An object with the serialized config.
  25610. */
  25611. serialize(): any;
  25612. /**
  25613. * Parses a anisotropy Configuration from a serialized object.
  25614. * @param source - Serialized object.
  25615. * @param scene Defines the scene we are parsing for
  25616. * @param rootUrl Defines the rootUrl to load from
  25617. */
  25618. parse(source: any, scene: Scene, rootUrl: string): void;
  25619. }
  25620. }
  25621. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25622. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25624. import { Vector2 } from "babylonjs/Maths/math.vector";
  25625. import { Scene } from "babylonjs/scene";
  25626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25627. import { Nullable } from "babylonjs/types";
  25628. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25629. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25630. /**
  25631. * @hidden
  25632. */
  25633. export interface IMaterialAnisotropicDefines {
  25634. ANISOTROPIC: boolean;
  25635. ANISOTROPIC_TEXTURE: boolean;
  25636. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25637. MAINUV1: boolean;
  25638. _areTexturesDirty: boolean;
  25639. _needUVs: boolean;
  25640. }
  25641. /**
  25642. * Define the code related to the anisotropic parameters of the pbr material.
  25643. */
  25644. export class PBRAnisotropicConfiguration {
  25645. private _isEnabled;
  25646. /**
  25647. * Defines if the anisotropy is enabled in the material.
  25648. */
  25649. isEnabled: boolean;
  25650. /**
  25651. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25652. */
  25653. intensity: number;
  25654. /**
  25655. * Defines if the effect is along the tangents, bitangents or in between.
  25656. * By default, the effect is "strectching" the highlights along the tangents.
  25657. */
  25658. direction: Vector2;
  25659. private _texture;
  25660. /**
  25661. * Stores the anisotropy values in a texture.
  25662. * rg is direction (like normal from -1 to 1)
  25663. * b is a intensity
  25664. */
  25665. texture: Nullable<BaseTexture>;
  25666. /** @hidden */
  25667. private _internalMarkAllSubMeshesAsTexturesDirty;
  25668. /** @hidden */
  25669. _markAllSubMeshesAsTexturesDirty(): void;
  25670. /**
  25671. * Instantiate a new istance of anisotropy configuration.
  25672. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25673. */
  25674. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25675. /**
  25676. * Specifies that the submesh is ready to be used.
  25677. * @param defines the list of "defines" to update.
  25678. * @param scene defines the scene the material belongs to.
  25679. * @returns - boolean indicating that the submesh is ready or not.
  25680. */
  25681. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25682. /**
  25683. * Checks to see if a texture is used in the material.
  25684. * @param defines the list of "defines" to update.
  25685. * @param mesh the mesh we are preparing the defines for.
  25686. * @param scene defines the scene the material belongs to.
  25687. */
  25688. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25689. /**
  25690. * Binds the material data.
  25691. * @param uniformBuffer defines the Uniform buffer to fill in.
  25692. * @param scene defines the scene the material belongs to.
  25693. * @param isFrozen defines wether the material is frozen or not.
  25694. */
  25695. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25696. /**
  25697. * Checks to see if a texture is used in the material.
  25698. * @param texture - Base texture to use.
  25699. * @returns - Boolean specifying if a texture is used in the material.
  25700. */
  25701. hasTexture(texture: BaseTexture): boolean;
  25702. /**
  25703. * Returns an array of the actively used textures.
  25704. * @param activeTextures Array of BaseTextures
  25705. */
  25706. getActiveTextures(activeTextures: BaseTexture[]): void;
  25707. /**
  25708. * Returns the animatable textures.
  25709. * @param animatables Array of animatable textures.
  25710. */
  25711. getAnimatables(animatables: IAnimatable[]): void;
  25712. /**
  25713. * Disposes the resources of the material.
  25714. * @param forceDisposeTextures - Forces the disposal of all textures.
  25715. */
  25716. dispose(forceDisposeTextures?: boolean): void;
  25717. /**
  25718. * Get the current class name of the texture useful for serialization or dynamic coding.
  25719. * @returns "PBRAnisotropicConfiguration"
  25720. */
  25721. getClassName(): string;
  25722. /**
  25723. * Add fallbacks to the effect fallbacks list.
  25724. * @param defines defines the Base texture to use.
  25725. * @param fallbacks defines the current fallback list.
  25726. * @param currentRank defines the current fallback rank.
  25727. * @returns the new fallback rank.
  25728. */
  25729. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25730. /**
  25731. * Add the required uniforms to the current list.
  25732. * @param uniforms defines the current uniform list.
  25733. */
  25734. static AddUniforms(uniforms: string[]): void;
  25735. /**
  25736. * Add the required uniforms to the current buffer.
  25737. * @param uniformBuffer defines the current uniform buffer.
  25738. */
  25739. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25740. /**
  25741. * Add the required samplers to the current list.
  25742. * @param samplers defines the current sampler list.
  25743. */
  25744. static AddSamplers(samplers: string[]): void;
  25745. /**
  25746. * Makes a duplicate of the current configuration into another one.
  25747. * @param anisotropicConfiguration define the config where to copy the info
  25748. */
  25749. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25750. /**
  25751. * Serializes this anisotropy configuration.
  25752. * @returns - An object with the serialized config.
  25753. */
  25754. serialize(): any;
  25755. /**
  25756. * Parses a anisotropy Configuration from a serialized object.
  25757. * @param source - Serialized object.
  25758. * @param scene Defines the scene we are parsing for
  25759. * @param rootUrl Defines the rootUrl to load from
  25760. */
  25761. parse(source: any, scene: Scene, rootUrl: string): void;
  25762. }
  25763. }
  25764. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  25765. import { Scene } from "babylonjs/scene";
  25766. /**
  25767. * @hidden
  25768. */
  25769. export interface IMaterialBRDFDefines {
  25770. BRDF_V_HEIGHT_CORRELATED: boolean;
  25771. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25772. SPHERICAL_HARMONICS: boolean;
  25773. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25774. /** @hidden */
  25775. _areMiscDirty: boolean;
  25776. }
  25777. /**
  25778. * Define the code related to the BRDF parameters of the pbr material.
  25779. */
  25780. export class PBRBRDFConfiguration {
  25781. /**
  25782. * Default value used for the energy conservation.
  25783. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25784. */
  25785. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25786. /**
  25787. * Default value used for the Smith Visibility Height Correlated mode.
  25788. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25789. */
  25790. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25791. /**
  25792. * Default value used for the IBL diffuse part.
  25793. * This can help switching back to the polynomials mode globally which is a tiny bit
  25794. * less GPU intensive at the drawback of a lower quality.
  25795. */
  25796. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25797. /**
  25798. * Default value used for activating energy conservation for the specular workflow.
  25799. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25800. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25801. */
  25802. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25803. private _useEnergyConservation;
  25804. /**
  25805. * Defines if the material uses energy conservation.
  25806. */
  25807. useEnergyConservation: boolean;
  25808. private _useSmithVisibilityHeightCorrelated;
  25809. /**
  25810. * LEGACY Mode set to false
  25811. * Defines if the material uses height smith correlated visibility term.
  25812. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25813. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25814. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25815. * Not relying on height correlated will also disable energy conservation.
  25816. */
  25817. useSmithVisibilityHeightCorrelated: boolean;
  25818. private _useSphericalHarmonics;
  25819. /**
  25820. * LEGACY Mode set to false
  25821. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25822. * diffuse part of the IBL.
  25823. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25824. * to the ground truth.
  25825. */
  25826. useSphericalHarmonics: boolean;
  25827. private _useSpecularGlossinessInputEnergyConservation;
  25828. /**
  25829. * Defines if the material uses energy conservation, when the specular workflow is active.
  25830. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25831. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25832. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25833. */
  25834. useSpecularGlossinessInputEnergyConservation: boolean;
  25835. /** @hidden */
  25836. private _internalMarkAllSubMeshesAsMiscDirty;
  25837. /** @hidden */
  25838. _markAllSubMeshesAsMiscDirty(): void;
  25839. /**
  25840. * Instantiate a new istance of clear coat configuration.
  25841. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25842. */
  25843. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25844. /**
  25845. * Checks to see if a texture is used in the material.
  25846. * @param defines the list of "defines" to update.
  25847. */
  25848. prepareDefines(defines: IMaterialBRDFDefines): void;
  25849. /**
  25850. * Get the current class name of the texture useful for serialization or dynamic coding.
  25851. * @returns "PBRClearCoatConfiguration"
  25852. */
  25853. getClassName(): string;
  25854. /**
  25855. * Makes a duplicate of the current configuration into another one.
  25856. * @param brdfConfiguration define the config where to copy the info
  25857. */
  25858. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25859. /**
  25860. * Serializes this BRDF configuration.
  25861. * @returns - An object with the serialized config.
  25862. */
  25863. serialize(): any;
  25864. /**
  25865. * Parses a anisotropy Configuration from a serialized object.
  25866. * @param source - Serialized object.
  25867. * @param scene Defines the scene we are parsing for
  25868. * @param rootUrl Defines the rootUrl to load from
  25869. */
  25870. parse(source: any, scene: Scene, rootUrl: string): void;
  25871. }
  25872. }
  25873. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  25874. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25875. import { Color3 } from "babylonjs/Maths/math.color";
  25876. import { Scene } from "babylonjs/scene";
  25877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25878. import { Nullable } from "babylonjs/types";
  25879. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25880. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25881. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25882. /**
  25883. * @hidden
  25884. */
  25885. export interface IMaterialSheenDefines {
  25886. SHEEN: boolean;
  25887. SHEEN_TEXTURE: boolean;
  25888. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25889. SHEEN_TEXTUREDIRECTUV: number;
  25890. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25891. SHEEN_LINKWITHALBEDO: boolean;
  25892. SHEEN_ROUGHNESS: boolean;
  25893. SHEEN_ALBEDOSCALING: boolean;
  25894. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25895. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25896. /** @hidden */
  25897. _areTexturesDirty: boolean;
  25898. }
  25899. /**
  25900. * Define the code related to the Sheen parameters of the pbr material.
  25901. */
  25902. export class PBRSheenConfiguration {
  25903. private _isEnabled;
  25904. /**
  25905. * Defines if the material uses sheen.
  25906. */
  25907. isEnabled: boolean;
  25908. private _linkSheenWithAlbedo;
  25909. /**
  25910. * Defines if the sheen is linked to the sheen color.
  25911. */
  25912. linkSheenWithAlbedo: boolean;
  25913. /**
  25914. * Defines the sheen intensity.
  25915. */
  25916. intensity: number;
  25917. /**
  25918. * Defines the sheen color.
  25919. */
  25920. color: Color3;
  25921. private _texture;
  25922. /**
  25923. * Stores the sheen tint values in a texture.
  25924. * rgb is tint
  25925. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  25926. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25927. */
  25928. texture: Nullable<BaseTexture>;
  25929. private _useRoughnessFromMainTexture;
  25930. /**
  25931. * Indicates that the alpha channel of the texture property will be used for roughness.
  25932. * Has no effect if the roughness (and texture!) property is not defined
  25933. */
  25934. useRoughnessFromMainTexture: boolean;
  25935. private _roughness;
  25936. /**
  25937. * Defines the sheen roughness.
  25938. * It is not taken into account if linkSheenWithAlbedo is true.
  25939. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25940. */
  25941. roughness: Nullable<number>;
  25942. private _textureRoughness;
  25943. /**
  25944. * Stores the sheen roughness in a texture.
  25945. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25946. */
  25947. textureRoughness: Nullable<BaseTexture>;
  25948. private _albedoScaling;
  25949. /**
  25950. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25951. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25952. * making it easier to setup and tweak the effect
  25953. */
  25954. albedoScaling: boolean;
  25955. /** @hidden */
  25956. private _internalMarkAllSubMeshesAsTexturesDirty;
  25957. /** @hidden */
  25958. _markAllSubMeshesAsTexturesDirty(): void;
  25959. /**
  25960. * Instantiate a new istance of clear coat configuration.
  25961. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25962. */
  25963. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25964. /**
  25965. * Specifies that the submesh is ready to be used.
  25966. * @param defines the list of "defines" to update.
  25967. * @param scene defines the scene the material belongs to.
  25968. * @returns - boolean indicating that the submesh is ready or not.
  25969. */
  25970. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25971. /**
  25972. * Checks to see if a texture is used in the material.
  25973. * @param defines the list of "defines" to update.
  25974. * @param scene defines the scene the material belongs to.
  25975. */
  25976. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25977. /**
  25978. * Binds the material data.
  25979. * @param uniformBuffer defines the Uniform buffer to fill in.
  25980. * @param scene defines the scene the material belongs to.
  25981. * @param isFrozen defines wether the material is frozen or not.
  25982. * @param subMesh the submesh to bind data for
  25983. */
  25984. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25985. /**
  25986. * Checks to see if a texture is used in the material.
  25987. * @param texture - Base texture to use.
  25988. * @returns - Boolean specifying if a texture is used in the material.
  25989. */
  25990. hasTexture(texture: BaseTexture): boolean;
  25991. /**
  25992. * Returns an array of the actively used textures.
  25993. * @param activeTextures Array of BaseTextures
  25994. */
  25995. getActiveTextures(activeTextures: BaseTexture[]): void;
  25996. /**
  25997. * Returns the animatable textures.
  25998. * @param animatables Array of animatable textures.
  25999. */
  26000. getAnimatables(animatables: IAnimatable[]): void;
  26001. /**
  26002. * Disposes the resources of the material.
  26003. * @param forceDisposeTextures - Forces the disposal of all textures.
  26004. */
  26005. dispose(forceDisposeTextures?: boolean): void;
  26006. /**
  26007. * Get the current class name of the texture useful for serialization or dynamic coding.
  26008. * @returns "PBRSheenConfiguration"
  26009. */
  26010. getClassName(): string;
  26011. /**
  26012. * Add fallbacks to the effect fallbacks list.
  26013. * @param defines defines the Base texture to use.
  26014. * @param fallbacks defines the current fallback list.
  26015. * @param currentRank defines the current fallback rank.
  26016. * @returns the new fallback rank.
  26017. */
  26018. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26019. /**
  26020. * Add the required uniforms to the current list.
  26021. * @param uniforms defines the current uniform list.
  26022. */
  26023. static AddUniforms(uniforms: string[]): void;
  26024. /**
  26025. * Add the required uniforms to the current buffer.
  26026. * @param uniformBuffer defines the current uniform buffer.
  26027. */
  26028. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26029. /**
  26030. * Add the required samplers to the current list.
  26031. * @param samplers defines the current sampler list.
  26032. */
  26033. static AddSamplers(samplers: string[]): void;
  26034. /**
  26035. * Makes a duplicate of the current configuration into another one.
  26036. * @param sheenConfiguration define the config where to copy the info
  26037. */
  26038. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  26039. /**
  26040. * Serializes this BRDF configuration.
  26041. * @returns - An object with the serialized config.
  26042. */
  26043. serialize(): any;
  26044. /**
  26045. * Parses a anisotropy Configuration from a serialized object.
  26046. * @param source - Serialized object.
  26047. * @param scene Defines the scene we are parsing for
  26048. * @param rootUrl Defines the rootUrl to load from
  26049. */
  26050. parse(source: any, scene: Scene, rootUrl: string): void;
  26051. }
  26052. }
  26053. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  26054. import { Nullable } from "babylonjs/types";
  26055. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26056. import { Color3 } from "babylonjs/Maths/math.color";
  26057. import { SmartArray } from "babylonjs/Misc/smartArray";
  26058. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26060. import { Effect } from "babylonjs/Materials/effect";
  26061. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26062. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26063. import { Engine } from "babylonjs/Engines/engine";
  26064. import { Scene } from "babylonjs/scene";
  26065. /**
  26066. * @hidden
  26067. */
  26068. export interface IMaterialSubSurfaceDefines {
  26069. SUBSURFACE: boolean;
  26070. SS_REFRACTION: boolean;
  26071. SS_TRANSLUCENCY: boolean;
  26072. SS_SCATTERING: boolean;
  26073. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26074. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26075. SS_REFRACTIONMAP_3D: boolean;
  26076. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26077. SS_LODINREFRACTIONALPHA: boolean;
  26078. SS_GAMMAREFRACTION: boolean;
  26079. SS_RGBDREFRACTION: boolean;
  26080. SS_LINEARSPECULARREFRACTION: boolean;
  26081. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26082. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26083. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26084. /** @hidden */
  26085. _areTexturesDirty: boolean;
  26086. }
  26087. /**
  26088. * Define the code related to the sub surface parameters of the pbr material.
  26089. */
  26090. export class PBRSubSurfaceConfiguration {
  26091. private _isRefractionEnabled;
  26092. /**
  26093. * Defines if the refraction is enabled in the material.
  26094. */
  26095. isRefractionEnabled: boolean;
  26096. private _isTranslucencyEnabled;
  26097. /**
  26098. * Defines if the translucency is enabled in the material.
  26099. */
  26100. isTranslucencyEnabled: boolean;
  26101. private _isScatteringEnabled;
  26102. /**
  26103. * Defines if the sub surface scattering is enabled in the material.
  26104. */
  26105. isScatteringEnabled: boolean;
  26106. private _scatteringDiffusionProfileIndex;
  26107. /**
  26108. * Diffusion profile for subsurface scattering.
  26109. * Useful for better scattering in the skins or foliages.
  26110. */
  26111. get scatteringDiffusionProfile(): Nullable<Color3>;
  26112. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26113. /**
  26114. * Defines the refraction intensity of the material.
  26115. * The refraction when enabled replaces the Diffuse part of the material.
  26116. * The intensity helps transitionning between diffuse and refraction.
  26117. */
  26118. refractionIntensity: number;
  26119. /**
  26120. * Defines the translucency intensity of the material.
  26121. * When translucency has been enabled, this defines how much of the "translucency"
  26122. * is addded to the diffuse part of the material.
  26123. */
  26124. translucencyIntensity: number;
  26125. /**
  26126. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26127. */
  26128. useAlbedoToTintRefraction: boolean;
  26129. private _thicknessTexture;
  26130. /**
  26131. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26132. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26133. * 0 would mean minimumThickness
  26134. * 1 would mean maximumThickness
  26135. * The other channels might be use as a mask to vary the different effects intensity.
  26136. */
  26137. thicknessTexture: Nullable<BaseTexture>;
  26138. private _refractionTexture;
  26139. /**
  26140. * Defines the texture to use for refraction.
  26141. */
  26142. refractionTexture: Nullable<BaseTexture>;
  26143. private _indexOfRefraction;
  26144. /**
  26145. * Index of refraction of the material base layer.
  26146. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26147. *
  26148. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26149. *
  26150. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26151. */
  26152. indexOfRefraction: number;
  26153. private _volumeIndexOfRefraction;
  26154. /**
  26155. * Index of refraction of the material's volume.
  26156. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26157. *
  26158. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26159. * the volume will use the same IOR as the surface.
  26160. */
  26161. get volumeIndexOfRefraction(): number;
  26162. set volumeIndexOfRefraction(value: number);
  26163. private _invertRefractionY;
  26164. /**
  26165. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26166. */
  26167. invertRefractionY: boolean;
  26168. private _linkRefractionWithTransparency;
  26169. /**
  26170. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26171. * Materials half opaque for instance using refraction could benefit from this control.
  26172. */
  26173. linkRefractionWithTransparency: boolean;
  26174. /**
  26175. * Defines the minimum thickness stored in the thickness map.
  26176. * If no thickness map is defined, this value will be used to simulate thickness.
  26177. */
  26178. minimumThickness: number;
  26179. /**
  26180. * Defines the maximum thickness stored in the thickness map.
  26181. */
  26182. maximumThickness: number;
  26183. /**
  26184. * Defines the volume tint of the material.
  26185. * This is used for both translucency and scattering.
  26186. */
  26187. tintColor: Color3;
  26188. /**
  26189. * Defines the distance at which the tint color should be found in the media.
  26190. * This is used for refraction only.
  26191. */
  26192. tintColorAtDistance: number;
  26193. /**
  26194. * Defines how far each channel transmit through the media.
  26195. * It is defined as a color to simplify it selection.
  26196. */
  26197. diffusionDistance: Color3;
  26198. private _useMaskFromThicknessTexture;
  26199. /**
  26200. * Stores the intensity of the different subsurface effects in the thickness texture.
  26201. * * the green channel is the translucency intensity.
  26202. * * the blue channel is the scattering intensity.
  26203. * * the alpha channel is the refraction intensity.
  26204. */
  26205. useMaskFromThicknessTexture: boolean;
  26206. private _scene;
  26207. /** @hidden */
  26208. private _internalMarkAllSubMeshesAsTexturesDirty;
  26209. private _internalMarkScenePrePassDirty;
  26210. /** @hidden */
  26211. _markAllSubMeshesAsTexturesDirty(): void;
  26212. /** @hidden */
  26213. _markScenePrePassDirty(): void;
  26214. /**
  26215. * Instantiate a new istance of sub surface configuration.
  26216. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26217. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26218. * @param scene The scene
  26219. */
  26220. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26221. /**
  26222. * Gets wehter the submesh is ready to be used or not.
  26223. * @param defines the list of "defines" to update.
  26224. * @param scene defines the scene the material belongs to.
  26225. * @returns - boolean indicating that the submesh is ready or not.
  26226. */
  26227. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26228. /**
  26229. * Checks to see if a texture is used in the material.
  26230. * @param defines the list of "defines" to update.
  26231. * @param scene defines the scene to the material belongs to.
  26232. */
  26233. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26234. /**
  26235. * Binds the material data.
  26236. * @param uniformBuffer defines the Uniform buffer to fill in.
  26237. * @param scene defines the scene the material belongs to.
  26238. * @param engine defines the engine the material belongs to.
  26239. * @param isFrozen defines whether the material is frozen or not.
  26240. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26241. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26242. */
  26243. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26244. /**
  26245. * Unbinds the material from the mesh.
  26246. * @param activeEffect defines the effect that should be unbound from.
  26247. * @returns true if unbound, otherwise false
  26248. */
  26249. unbind(activeEffect: Effect): boolean;
  26250. /**
  26251. * Returns the texture used for refraction or null if none is used.
  26252. * @param scene defines the scene the material belongs to.
  26253. * @returns - Refraction texture if present. If no refraction texture and refraction
  26254. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26255. */
  26256. private _getRefractionTexture;
  26257. /**
  26258. * Returns true if alpha blending should be disabled.
  26259. */
  26260. get disableAlphaBlending(): boolean;
  26261. /**
  26262. * Fills the list of render target textures.
  26263. * @param renderTargets the list of render targets to update
  26264. */
  26265. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26266. /**
  26267. * Checks to see if a texture is used in the material.
  26268. * @param texture - Base texture to use.
  26269. * @returns - Boolean specifying if a texture is used in the material.
  26270. */
  26271. hasTexture(texture: BaseTexture): boolean;
  26272. /**
  26273. * Gets a boolean indicating that current material needs to register RTT
  26274. * @returns true if this uses a render target otherwise false.
  26275. */
  26276. hasRenderTargetTextures(): boolean;
  26277. /**
  26278. * Returns an array of the actively used textures.
  26279. * @param activeTextures Array of BaseTextures
  26280. */
  26281. getActiveTextures(activeTextures: BaseTexture[]): void;
  26282. /**
  26283. * Returns the animatable textures.
  26284. * @param animatables Array of animatable textures.
  26285. */
  26286. getAnimatables(animatables: IAnimatable[]): void;
  26287. /**
  26288. * Disposes the resources of the material.
  26289. * @param forceDisposeTextures - Forces the disposal of all textures.
  26290. */
  26291. dispose(forceDisposeTextures?: boolean): void;
  26292. /**
  26293. * Get the current class name of the texture useful for serialization or dynamic coding.
  26294. * @returns "PBRSubSurfaceConfiguration"
  26295. */
  26296. getClassName(): string;
  26297. /**
  26298. * Add fallbacks to the effect fallbacks list.
  26299. * @param defines defines the Base texture to use.
  26300. * @param fallbacks defines the current fallback list.
  26301. * @param currentRank defines the current fallback rank.
  26302. * @returns the new fallback rank.
  26303. */
  26304. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26305. /**
  26306. * Add the required uniforms to the current list.
  26307. * @param uniforms defines the current uniform list.
  26308. */
  26309. static AddUniforms(uniforms: string[]): void;
  26310. /**
  26311. * Add the required samplers to the current list.
  26312. * @param samplers defines the current sampler list.
  26313. */
  26314. static AddSamplers(samplers: string[]): void;
  26315. /**
  26316. * Add the required uniforms to the current buffer.
  26317. * @param uniformBuffer defines the current uniform buffer.
  26318. */
  26319. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26320. /**
  26321. * Makes a duplicate of the current configuration into another one.
  26322. * @param configuration define the config where to copy the info
  26323. */
  26324. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26325. /**
  26326. * Serializes this Sub Surface configuration.
  26327. * @returns - An object with the serialized config.
  26328. */
  26329. serialize(): any;
  26330. /**
  26331. * Parses a anisotropy Configuration from a serialized object.
  26332. * @param source - Serialized object.
  26333. * @param scene Defines the scene we are parsing for
  26334. * @param rootUrl Defines the rootUrl to load from
  26335. */
  26336. parse(source: any, scene: Scene, rootUrl: string): void;
  26337. }
  26338. }
  26339. declare module "babylonjs/Maths/sphericalPolynomial" {
  26340. import { Vector3 } from "babylonjs/Maths/math.vector";
  26341. import { Color3 } from "babylonjs/Maths/math.color";
  26342. /**
  26343. * Class representing spherical harmonics coefficients to the 3rd degree
  26344. */
  26345. export class SphericalHarmonics {
  26346. /**
  26347. * Defines whether or not the harmonics have been prescaled for rendering.
  26348. */
  26349. preScaled: boolean;
  26350. /**
  26351. * The l0,0 coefficients of the spherical harmonics
  26352. */
  26353. l00: Vector3;
  26354. /**
  26355. * The l1,-1 coefficients of the spherical harmonics
  26356. */
  26357. l1_1: Vector3;
  26358. /**
  26359. * The l1,0 coefficients of the spherical harmonics
  26360. */
  26361. l10: Vector3;
  26362. /**
  26363. * The l1,1 coefficients of the spherical harmonics
  26364. */
  26365. l11: Vector3;
  26366. /**
  26367. * The l2,-2 coefficients of the spherical harmonics
  26368. */
  26369. l2_2: Vector3;
  26370. /**
  26371. * The l2,-1 coefficients of the spherical harmonics
  26372. */
  26373. l2_1: Vector3;
  26374. /**
  26375. * The l2,0 coefficients of the spherical harmonics
  26376. */
  26377. l20: Vector3;
  26378. /**
  26379. * The l2,1 coefficients of the spherical harmonics
  26380. */
  26381. l21: Vector3;
  26382. /**
  26383. * The l2,2 coefficients of the spherical harmonics
  26384. */
  26385. l22: Vector3;
  26386. /**
  26387. * Adds a light to the spherical harmonics
  26388. * @param direction the direction of the light
  26389. * @param color the color of the light
  26390. * @param deltaSolidAngle the delta solid angle of the light
  26391. */
  26392. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26393. /**
  26394. * Scales the spherical harmonics by the given amount
  26395. * @param scale the amount to scale
  26396. */
  26397. scaleInPlace(scale: number): void;
  26398. /**
  26399. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26400. *
  26401. * ```
  26402. * E_lm = A_l * L_lm
  26403. * ```
  26404. *
  26405. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26406. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26407. * the scaling factors are given in equation 9.
  26408. */
  26409. convertIncidentRadianceToIrradiance(): void;
  26410. /**
  26411. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26412. *
  26413. * ```
  26414. * L = (1/pi) * E * rho
  26415. * ```
  26416. *
  26417. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26418. */
  26419. convertIrradianceToLambertianRadiance(): void;
  26420. /**
  26421. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26422. * required operations at run time.
  26423. *
  26424. * This is simply done by scaling back the SH with Ylm constants parameter.
  26425. * The trigonometric part being applied by the shader at run time.
  26426. */
  26427. preScaleForRendering(): void;
  26428. /**
  26429. * Constructs a spherical harmonics from an array.
  26430. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26431. * @returns the spherical harmonics
  26432. */
  26433. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26434. /**
  26435. * Gets the spherical harmonics from polynomial
  26436. * @param polynomial the spherical polynomial
  26437. * @returns the spherical harmonics
  26438. */
  26439. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26440. }
  26441. /**
  26442. * Class representing spherical polynomial coefficients to the 3rd degree
  26443. */
  26444. export class SphericalPolynomial {
  26445. private _harmonics;
  26446. /**
  26447. * The spherical harmonics used to create the polynomials.
  26448. */
  26449. get preScaledHarmonics(): SphericalHarmonics;
  26450. /**
  26451. * The x coefficients of the spherical polynomial
  26452. */
  26453. x: Vector3;
  26454. /**
  26455. * The y coefficients of the spherical polynomial
  26456. */
  26457. y: Vector3;
  26458. /**
  26459. * The z coefficients of the spherical polynomial
  26460. */
  26461. z: Vector3;
  26462. /**
  26463. * The xx coefficients of the spherical polynomial
  26464. */
  26465. xx: Vector3;
  26466. /**
  26467. * The yy coefficients of the spherical polynomial
  26468. */
  26469. yy: Vector3;
  26470. /**
  26471. * The zz coefficients of the spherical polynomial
  26472. */
  26473. zz: Vector3;
  26474. /**
  26475. * The xy coefficients of the spherical polynomial
  26476. */
  26477. xy: Vector3;
  26478. /**
  26479. * The yz coefficients of the spherical polynomial
  26480. */
  26481. yz: Vector3;
  26482. /**
  26483. * The zx coefficients of the spherical polynomial
  26484. */
  26485. zx: Vector3;
  26486. /**
  26487. * Adds an ambient color to the spherical polynomial
  26488. * @param color the color to add
  26489. */
  26490. addAmbient(color: Color3): void;
  26491. /**
  26492. * Scales the spherical polynomial by the given amount
  26493. * @param scale the amount to scale
  26494. */
  26495. scaleInPlace(scale: number): void;
  26496. /**
  26497. * Gets the spherical polynomial from harmonics
  26498. * @param harmonics the spherical harmonics
  26499. * @returns the spherical polynomial
  26500. */
  26501. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26502. /**
  26503. * Constructs a spherical polynomial from an array.
  26504. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26505. * @returns the spherical polynomial
  26506. */
  26507. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26508. }
  26509. }
  26510. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26511. import { Nullable } from "babylonjs/types";
  26512. /**
  26513. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26514. */
  26515. export interface CubeMapInfo {
  26516. /**
  26517. * The pixel array for the front face.
  26518. * This is stored in format, left to right, up to down format.
  26519. */
  26520. front: Nullable<ArrayBufferView>;
  26521. /**
  26522. * The pixel array for the back face.
  26523. * This is stored in format, left to right, up to down format.
  26524. */
  26525. back: Nullable<ArrayBufferView>;
  26526. /**
  26527. * The pixel array for the left face.
  26528. * This is stored in format, left to right, up to down format.
  26529. */
  26530. left: Nullable<ArrayBufferView>;
  26531. /**
  26532. * The pixel array for the right face.
  26533. * This is stored in format, left to right, up to down format.
  26534. */
  26535. right: Nullable<ArrayBufferView>;
  26536. /**
  26537. * The pixel array for the up face.
  26538. * This is stored in format, left to right, up to down format.
  26539. */
  26540. up: Nullable<ArrayBufferView>;
  26541. /**
  26542. * The pixel array for the down face.
  26543. * This is stored in format, left to right, up to down format.
  26544. */
  26545. down: Nullable<ArrayBufferView>;
  26546. /**
  26547. * The size of the cubemap stored.
  26548. *
  26549. * Each faces will be size * size pixels.
  26550. */
  26551. size: number;
  26552. /**
  26553. * The format of the texture.
  26554. *
  26555. * RGBA, RGB.
  26556. */
  26557. format: number;
  26558. /**
  26559. * The type of the texture data.
  26560. *
  26561. * UNSIGNED_INT, FLOAT.
  26562. */
  26563. type: number;
  26564. /**
  26565. * Specifies whether the texture is in gamma space.
  26566. */
  26567. gammaSpace: boolean;
  26568. }
  26569. /**
  26570. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26571. */
  26572. export class PanoramaToCubeMapTools {
  26573. private static FACE_LEFT;
  26574. private static FACE_RIGHT;
  26575. private static FACE_FRONT;
  26576. private static FACE_BACK;
  26577. private static FACE_DOWN;
  26578. private static FACE_UP;
  26579. /**
  26580. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26581. *
  26582. * @param float32Array The source data.
  26583. * @param inputWidth The width of the input panorama.
  26584. * @param inputHeight The height of the input panorama.
  26585. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26586. * @return The cubemap data
  26587. */
  26588. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26589. private static CreateCubemapTexture;
  26590. private static CalcProjectionSpherical;
  26591. }
  26592. }
  26593. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26594. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26595. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26596. import { Nullable } from "babylonjs/types";
  26597. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26598. /**
  26599. * Helper class dealing with the extraction of spherical polynomial dataArray
  26600. * from a cube map.
  26601. */
  26602. export class CubeMapToSphericalPolynomialTools {
  26603. private static FileFaces;
  26604. /**
  26605. * Converts a texture to the according Spherical Polynomial data.
  26606. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26607. *
  26608. * @param texture The texture to extract the information from.
  26609. * @return The Spherical Polynomial data.
  26610. */
  26611. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26612. /**
  26613. * Converts a cubemap to the according Spherical Polynomial data.
  26614. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26615. *
  26616. * @param cubeInfo The Cube map to extract the information from.
  26617. * @return The Spherical Polynomial data.
  26618. */
  26619. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26620. }
  26621. }
  26622. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26623. import { Nullable } from "babylonjs/types";
  26624. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26625. module "babylonjs/Materials/Textures/baseTexture" {
  26626. interface BaseTexture {
  26627. /**
  26628. * Get the polynomial representation of the texture data.
  26629. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26630. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26631. */
  26632. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26633. }
  26634. }
  26635. }
  26636. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26637. /** @hidden */
  26638. export var pbrFragmentDeclaration: {
  26639. name: string;
  26640. shader: string;
  26641. };
  26642. }
  26643. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26644. /** @hidden */
  26645. export var pbrUboDeclaration: {
  26646. name: string;
  26647. shader: string;
  26648. };
  26649. }
  26650. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26651. /** @hidden */
  26652. export var pbrFragmentExtraDeclaration: {
  26653. name: string;
  26654. shader: string;
  26655. };
  26656. }
  26657. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26658. /** @hidden */
  26659. export var pbrFragmentSamplersDeclaration: {
  26660. name: string;
  26661. shader: string;
  26662. };
  26663. }
  26664. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26665. /** @hidden */
  26666. export var subSurfaceScatteringFunctions: {
  26667. name: string;
  26668. shader: string;
  26669. };
  26670. }
  26671. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26672. /** @hidden */
  26673. export var importanceSampling: {
  26674. name: string;
  26675. shader: string;
  26676. };
  26677. }
  26678. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26679. /** @hidden */
  26680. export var pbrHelperFunctions: {
  26681. name: string;
  26682. shader: string;
  26683. };
  26684. }
  26685. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26686. /** @hidden */
  26687. export var harmonicsFunctions: {
  26688. name: string;
  26689. shader: string;
  26690. };
  26691. }
  26692. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26693. /** @hidden */
  26694. export var pbrDirectLightingSetupFunctions: {
  26695. name: string;
  26696. shader: string;
  26697. };
  26698. }
  26699. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26700. /** @hidden */
  26701. export var pbrDirectLightingFalloffFunctions: {
  26702. name: string;
  26703. shader: string;
  26704. };
  26705. }
  26706. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26707. /** @hidden */
  26708. export var pbrBRDFFunctions: {
  26709. name: string;
  26710. shader: string;
  26711. };
  26712. }
  26713. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26714. /** @hidden */
  26715. export var hdrFilteringFunctions: {
  26716. name: string;
  26717. shader: string;
  26718. };
  26719. }
  26720. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  26721. /** @hidden */
  26722. export var pbrDirectLightingFunctions: {
  26723. name: string;
  26724. shader: string;
  26725. };
  26726. }
  26727. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  26728. /** @hidden */
  26729. export var pbrIBLFunctions: {
  26730. name: string;
  26731. shader: string;
  26732. };
  26733. }
  26734. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  26735. /** @hidden */
  26736. export var pbrBlockAlbedoOpacity: {
  26737. name: string;
  26738. shader: string;
  26739. };
  26740. }
  26741. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  26742. /** @hidden */
  26743. export var pbrBlockReflectivity: {
  26744. name: string;
  26745. shader: string;
  26746. };
  26747. }
  26748. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  26749. /** @hidden */
  26750. export var pbrBlockAmbientOcclusion: {
  26751. name: string;
  26752. shader: string;
  26753. };
  26754. }
  26755. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  26756. /** @hidden */
  26757. export var pbrBlockAlphaFresnel: {
  26758. name: string;
  26759. shader: string;
  26760. };
  26761. }
  26762. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  26763. /** @hidden */
  26764. export var pbrBlockAnisotropic: {
  26765. name: string;
  26766. shader: string;
  26767. };
  26768. }
  26769. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  26770. /** @hidden */
  26771. export var pbrBlockReflection: {
  26772. name: string;
  26773. shader: string;
  26774. };
  26775. }
  26776. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  26777. /** @hidden */
  26778. export var pbrBlockSheen: {
  26779. name: string;
  26780. shader: string;
  26781. };
  26782. }
  26783. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  26784. /** @hidden */
  26785. export var pbrBlockClearcoat: {
  26786. name: string;
  26787. shader: string;
  26788. };
  26789. }
  26790. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  26791. /** @hidden */
  26792. export var pbrBlockSubSurface: {
  26793. name: string;
  26794. shader: string;
  26795. };
  26796. }
  26797. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  26798. /** @hidden */
  26799. export var pbrBlockNormalGeometric: {
  26800. name: string;
  26801. shader: string;
  26802. };
  26803. }
  26804. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  26805. /** @hidden */
  26806. export var pbrBlockNormalFinal: {
  26807. name: string;
  26808. shader: string;
  26809. };
  26810. }
  26811. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  26812. /** @hidden */
  26813. export var pbrBlockLightmapInit: {
  26814. name: string;
  26815. shader: string;
  26816. };
  26817. }
  26818. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  26819. /** @hidden */
  26820. export var pbrBlockGeometryInfo: {
  26821. name: string;
  26822. shader: string;
  26823. };
  26824. }
  26825. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  26826. /** @hidden */
  26827. export var pbrBlockReflectance0: {
  26828. name: string;
  26829. shader: string;
  26830. };
  26831. }
  26832. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  26833. /** @hidden */
  26834. export var pbrBlockReflectance: {
  26835. name: string;
  26836. shader: string;
  26837. };
  26838. }
  26839. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  26840. /** @hidden */
  26841. export var pbrBlockDirectLighting: {
  26842. name: string;
  26843. shader: string;
  26844. };
  26845. }
  26846. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  26847. /** @hidden */
  26848. export var pbrBlockFinalLitComponents: {
  26849. name: string;
  26850. shader: string;
  26851. };
  26852. }
  26853. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  26854. /** @hidden */
  26855. export var pbrBlockFinalUnlitComponents: {
  26856. name: string;
  26857. shader: string;
  26858. };
  26859. }
  26860. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  26861. /** @hidden */
  26862. export var pbrBlockFinalColorComposition: {
  26863. name: string;
  26864. shader: string;
  26865. };
  26866. }
  26867. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  26868. /** @hidden */
  26869. export var pbrBlockImageProcessing: {
  26870. name: string;
  26871. shader: string;
  26872. };
  26873. }
  26874. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  26875. /** @hidden */
  26876. export var pbrDebug: {
  26877. name: string;
  26878. shader: string;
  26879. };
  26880. }
  26881. declare module "babylonjs/Shaders/pbr.fragment" {
  26882. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  26883. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  26884. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26885. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  26886. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26887. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26888. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  26889. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26890. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26891. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26892. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26893. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26894. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  26895. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  26896. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  26897. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26898. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26899. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26900. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  26901. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  26902. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  26903. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  26904. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  26905. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  26906. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  26907. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26908. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26909. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  26910. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  26911. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  26912. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  26913. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  26914. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  26915. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  26916. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  26917. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  26918. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26919. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  26920. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26921. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  26922. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26923. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  26924. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  26925. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  26926. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  26927. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  26928. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26929. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  26930. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  26931. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  26932. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26933. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26934. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  26935. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  26936. /** @hidden */
  26937. export var pbrPixelShader: {
  26938. name: string;
  26939. shader: string;
  26940. };
  26941. }
  26942. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  26943. /** @hidden */
  26944. export var pbrVertexDeclaration: {
  26945. name: string;
  26946. shader: string;
  26947. };
  26948. }
  26949. declare module "babylonjs/Shaders/pbr.vertex" {
  26950. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  26951. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26952. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26953. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26954. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26955. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  26956. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26957. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26958. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26959. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26960. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26961. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26962. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26963. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26964. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26965. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26966. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26967. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26968. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  26969. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26970. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26971. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26972. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26973. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26974. /** @hidden */
  26975. export var pbrVertexShader: {
  26976. name: string;
  26977. shader: string;
  26978. };
  26979. }
  26980. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  26981. import { Nullable } from "babylonjs/types";
  26982. import { Scene } from "babylonjs/scene";
  26983. import { Matrix } from "babylonjs/Maths/math.vector";
  26984. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26986. import { Mesh } from "babylonjs/Meshes/mesh";
  26987. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  26988. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  26989. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  26990. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  26991. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  26992. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  26993. import { Color3 } from "babylonjs/Maths/math.color";
  26994. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26995. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  26996. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26997. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26998. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26999. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27000. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  27001. import "babylonjs/Shaders/pbr.fragment";
  27002. import "babylonjs/Shaders/pbr.vertex";
  27003. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  27004. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  27005. /**
  27006. * Manages the defines for the PBR Material.
  27007. * @hidden
  27008. */
  27009. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  27010. PBR: boolean;
  27011. NUM_SAMPLES: string;
  27012. REALTIME_FILTERING: boolean;
  27013. MAINUV1: boolean;
  27014. MAINUV2: boolean;
  27015. UV1: boolean;
  27016. UV2: boolean;
  27017. ALBEDO: boolean;
  27018. GAMMAALBEDO: boolean;
  27019. ALBEDODIRECTUV: number;
  27020. VERTEXCOLOR: boolean;
  27021. DETAIL: boolean;
  27022. DETAILDIRECTUV: number;
  27023. DETAIL_NORMALBLENDMETHOD: number;
  27024. AMBIENT: boolean;
  27025. AMBIENTDIRECTUV: number;
  27026. AMBIENTINGRAYSCALE: boolean;
  27027. OPACITY: boolean;
  27028. VERTEXALPHA: boolean;
  27029. OPACITYDIRECTUV: number;
  27030. OPACITYRGB: boolean;
  27031. ALPHATEST: boolean;
  27032. DEPTHPREPASS: boolean;
  27033. ALPHABLEND: boolean;
  27034. ALPHAFROMALBEDO: boolean;
  27035. ALPHATESTVALUE: string;
  27036. SPECULAROVERALPHA: boolean;
  27037. RADIANCEOVERALPHA: boolean;
  27038. ALPHAFRESNEL: boolean;
  27039. LINEARALPHAFRESNEL: boolean;
  27040. PREMULTIPLYALPHA: boolean;
  27041. EMISSIVE: boolean;
  27042. EMISSIVEDIRECTUV: number;
  27043. REFLECTIVITY: boolean;
  27044. REFLECTIVITYDIRECTUV: number;
  27045. SPECULARTERM: boolean;
  27046. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  27047. MICROSURFACEAUTOMATIC: boolean;
  27048. LODBASEDMICROSFURACE: boolean;
  27049. MICROSURFACEMAP: boolean;
  27050. MICROSURFACEMAPDIRECTUV: number;
  27051. METALLICWORKFLOW: boolean;
  27052. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  27053. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  27054. METALLNESSSTOREINMETALMAPBLUE: boolean;
  27055. AOSTOREINMETALMAPRED: boolean;
  27056. METALLIC_REFLECTANCE: boolean;
  27057. METALLIC_REFLECTANCEDIRECTUV: number;
  27058. ENVIRONMENTBRDF: boolean;
  27059. ENVIRONMENTBRDF_RGBD: boolean;
  27060. NORMAL: boolean;
  27061. TANGENT: boolean;
  27062. BUMP: boolean;
  27063. BUMPDIRECTUV: number;
  27064. OBJECTSPACE_NORMALMAP: boolean;
  27065. PARALLAX: boolean;
  27066. PARALLAXOCCLUSION: boolean;
  27067. NORMALXYSCALE: boolean;
  27068. LIGHTMAP: boolean;
  27069. LIGHTMAPDIRECTUV: number;
  27070. USELIGHTMAPASSHADOWMAP: boolean;
  27071. GAMMALIGHTMAP: boolean;
  27072. RGBDLIGHTMAP: boolean;
  27073. REFLECTION: boolean;
  27074. REFLECTIONMAP_3D: boolean;
  27075. REFLECTIONMAP_SPHERICAL: boolean;
  27076. REFLECTIONMAP_PLANAR: boolean;
  27077. REFLECTIONMAP_CUBIC: boolean;
  27078. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27079. REFLECTIONMAP_PROJECTION: boolean;
  27080. REFLECTIONMAP_SKYBOX: boolean;
  27081. REFLECTIONMAP_EXPLICIT: boolean;
  27082. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27083. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27084. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27085. INVERTCUBICMAP: boolean;
  27086. USESPHERICALFROMREFLECTIONMAP: boolean;
  27087. USEIRRADIANCEMAP: boolean;
  27088. SPHERICAL_HARMONICS: boolean;
  27089. USESPHERICALINVERTEX: boolean;
  27090. REFLECTIONMAP_OPPOSITEZ: boolean;
  27091. LODINREFLECTIONALPHA: boolean;
  27092. GAMMAREFLECTION: boolean;
  27093. RGBDREFLECTION: boolean;
  27094. LINEARSPECULARREFLECTION: boolean;
  27095. RADIANCEOCCLUSION: boolean;
  27096. HORIZONOCCLUSION: boolean;
  27097. INSTANCES: boolean;
  27098. THIN_INSTANCES: boolean;
  27099. PREPASS: boolean;
  27100. PREPASS_IRRADIANCE: boolean;
  27101. PREPASS_IRRADIANCE_INDEX: number;
  27102. PREPASS_ALBEDO: boolean;
  27103. PREPASS_ALBEDO_INDEX: number;
  27104. PREPASS_DEPTHNORMAL: boolean;
  27105. PREPASS_DEPTHNORMAL_INDEX: number;
  27106. PREPASS_POSITION: boolean;
  27107. PREPASS_POSITION_INDEX: number;
  27108. PREPASS_VELOCITY: boolean;
  27109. PREPASS_VELOCITY_INDEX: number;
  27110. PREPASS_REFLECTIVITY: boolean;
  27111. PREPASS_REFLECTIVITY_INDEX: number;
  27112. SCENE_MRT_COUNT: number;
  27113. NUM_BONE_INFLUENCERS: number;
  27114. BonesPerMesh: number;
  27115. BONETEXTURE: boolean;
  27116. BONES_VELOCITY_ENABLED: boolean;
  27117. NONUNIFORMSCALING: boolean;
  27118. MORPHTARGETS: boolean;
  27119. MORPHTARGETS_NORMAL: boolean;
  27120. MORPHTARGETS_TANGENT: boolean;
  27121. MORPHTARGETS_UV: boolean;
  27122. NUM_MORPH_INFLUENCERS: number;
  27123. IMAGEPROCESSING: boolean;
  27124. VIGNETTE: boolean;
  27125. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27126. VIGNETTEBLENDMODEOPAQUE: boolean;
  27127. TONEMAPPING: boolean;
  27128. TONEMAPPING_ACES: boolean;
  27129. CONTRAST: boolean;
  27130. COLORCURVES: boolean;
  27131. COLORGRADING: boolean;
  27132. COLORGRADING3D: boolean;
  27133. SAMPLER3DGREENDEPTH: boolean;
  27134. SAMPLER3DBGRMAP: boolean;
  27135. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27136. EXPOSURE: boolean;
  27137. MULTIVIEW: boolean;
  27138. USEPHYSICALLIGHTFALLOFF: boolean;
  27139. USEGLTFLIGHTFALLOFF: boolean;
  27140. TWOSIDEDLIGHTING: boolean;
  27141. SHADOWFLOAT: boolean;
  27142. CLIPPLANE: boolean;
  27143. CLIPPLANE2: boolean;
  27144. CLIPPLANE3: boolean;
  27145. CLIPPLANE4: boolean;
  27146. CLIPPLANE5: boolean;
  27147. CLIPPLANE6: boolean;
  27148. POINTSIZE: boolean;
  27149. FOG: boolean;
  27150. LOGARITHMICDEPTH: boolean;
  27151. FORCENORMALFORWARD: boolean;
  27152. SPECULARAA: boolean;
  27153. CLEARCOAT: boolean;
  27154. CLEARCOAT_DEFAULTIOR: boolean;
  27155. CLEARCOAT_TEXTURE: boolean;
  27156. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  27157. CLEARCOAT_TEXTUREDIRECTUV: number;
  27158. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  27159. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27160. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27161. CLEARCOAT_BUMP: boolean;
  27162. CLEARCOAT_BUMPDIRECTUV: number;
  27163. CLEARCOAT_REMAP_F0: boolean;
  27164. CLEARCOAT_TINT: boolean;
  27165. CLEARCOAT_TINT_TEXTURE: boolean;
  27166. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27167. ANISOTROPIC: boolean;
  27168. ANISOTROPIC_TEXTURE: boolean;
  27169. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27170. BRDF_V_HEIGHT_CORRELATED: boolean;
  27171. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27172. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27173. SHEEN: boolean;
  27174. SHEEN_TEXTURE: boolean;
  27175. SHEEN_TEXTURE_ROUGHNESS: boolean;
  27176. SHEEN_TEXTUREDIRECTUV: number;
  27177. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  27178. SHEEN_LINKWITHALBEDO: boolean;
  27179. SHEEN_ROUGHNESS: boolean;
  27180. SHEEN_ALBEDOSCALING: boolean;
  27181. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27182. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27183. SUBSURFACE: boolean;
  27184. SS_REFRACTION: boolean;
  27185. SS_TRANSLUCENCY: boolean;
  27186. SS_SCATTERING: boolean;
  27187. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27188. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27189. SS_REFRACTIONMAP_3D: boolean;
  27190. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27191. SS_LODINREFRACTIONALPHA: boolean;
  27192. SS_GAMMAREFRACTION: boolean;
  27193. SS_RGBDREFRACTION: boolean;
  27194. SS_LINEARSPECULARREFRACTION: boolean;
  27195. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27196. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27197. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27198. UNLIT: boolean;
  27199. DEBUGMODE: number;
  27200. /**
  27201. * Initializes the PBR Material defines.
  27202. */
  27203. constructor();
  27204. /**
  27205. * Resets the PBR Material defines.
  27206. */
  27207. reset(): void;
  27208. }
  27209. /**
  27210. * The Physically based material base class of BJS.
  27211. *
  27212. * This offers the main features of a standard PBR material.
  27213. * For more information, please refer to the documentation :
  27214. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27215. */
  27216. export abstract class PBRBaseMaterial extends PushMaterial {
  27217. /**
  27218. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27219. */
  27220. static readonly PBRMATERIAL_OPAQUE: number;
  27221. /**
  27222. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27223. */
  27224. static readonly PBRMATERIAL_ALPHATEST: number;
  27225. /**
  27226. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27227. */
  27228. static readonly PBRMATERIAL_ALPHABLEND: number;
  27229. /**
  27230. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27231. * They are also discarded below the alpha cutoff threshold to improve performances.
  27232. */
  27233. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27234. /**
  27235. * Defines the default value of how much AO map is occluding the analytical lights
  27236. * (point spot...).
  27237. */
  27238. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27239. /**
  27240. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27241. */
  27242. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27243. /**
  27244. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27245. * to enhance interoperability with other engines.
  27246. */
  27247. static readonly LIGHTFALLOFF_GLTF: number;
  27248. /**
  27249. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27250. * to enhance interoperability with other materials.
  27251. */
  27252. static readonly LIGHTFALLOFF_STANDARD: number;
  27253. /**
  27254. * Intensity of the direct lights e.g. the four lights available in your scene.
  27255. * This impacts both the direct diffuse and specular highlights.
  27256. */
  27257. protected _directIntensity: number;
  27258. /**
  27259. * Intensity of the emissive part of the material.
  27260. * This helps controlling the emissive effect without modifying the emissive color.
  27261. */
  27262. protected _emissiveIntensity: number;
  27263. /**
  27264. * Intensity of the environment e.g. how much the environment will light the object
  27265. * either through harmonics for rough material or through the refelction for shiny ones.
  27266. */
  27267. protected _environmentIntensity: number;
  27268. /**
  27269. * This is a special control allowing the reduction of the specular highlights coming from the
  27270. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27271. */
  27272. protected _specularIntensity: number;
  27273. /**
  27274. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27275. */
  27276. private _lightingInfos;
  27277. /**
  27278. * Debug Control allowing disabling the bump map on this material.
  27279. */
  27280. protected _disableBumpMap: boolean;
  27281. /**
  27282. * AKA Diffuse Texture in standard nomenclature.
  27283. */
  27284. protected _albedoTexture: Nullable<BaseTexture>;
  27285. /**
  27286. * AKA Occlusion Texture in other nomenclature.
  27287. */
  27288. protected _ambientTexture: Nullable<BaseTexture>;
  27289. /**
  27290. * AKA Occlusion Texture Intensity in other nomenclature.
  27291. */
  27292. protected _ambientTextureStrength: number;
  27293. /**
  27294. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27295. * 1 means it completely occludes it
  27296. * 0 mean it has no impact
  27297. */
  27298. protected _ambientTextureImpactOnAnalyticalLights: number;
  27299. /**
  27300. * Stores the alpha values in a texture.
  27301. */
  27302. protected _opacityTexture: Nullable<BaseTexture>;
  27303. /**
  27304. * Stores the reflection values in a texture.
  27305. */
  27306. protected _reflectionTexture: Nullable<BaseTexture>;
  27307. /**
  27308. * Stores the emissive values in a texture.
  27309. */
  27310. protected _emissiveTexture: Nullable<BaseTexture>;
  27311. /**
  27312. * AKA Specular texture in other nomenclature.
  27313. */
  27314. protected _reflectivityTexture: Nullable<BaseTexture>;
  27315. /**
  27316. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27317. */
  27318. protected _metallicTexture: Nullable<BaseTexture>;
  27319. /**
  27320. * Specifies the metallic scalar of the metallic/roughness workflow.
  27321. * Can also be used to scale the metalness values of the metallic texture.
  27322. */
  27323. protected _metallic: Nullable<number>;
  27324. /**
  27325. * Specifies the roughness scalar of the metallic/roughness workflow.
  27326. * Can also be used to scale the roughness values of the metallic texture.
  27327. */
  27328. protected _roughness: Nullable<number>;
  27329. /**
  27330. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27331. * By default the indexOfrefraction is used to compute F0;
  27332. *
  27333. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27334. *
  27335. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27336. * F90 = metallicReflectanceColor;
  27337. */
  27338. protected _metallicF0Factor: number;
  27339. /**
  27340. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27341. * By default the F90 is always 1;
  27342. *
  27343. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27344. *
  27345. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27346. * F90 = metallicReflectanceColor;
  27347. */
  27348. protected _metallicReflectanceColor: Color3;
  27349. /**
  27350. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27351. * This is multiply against the scalar values defined in the material.
  27352. */
  27353. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27354. /**
  27355. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27356. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27357. */
  27358. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27359. /**
  27360. * Stores surface normal data used to displace a mesh in a texture.
  27361. */
  27362. protected _bumpTexture: Nullable<BaseTexture>;
  27363. /**
  27364. * Stores the pre-calculated light information of a mesh in a texture.
  27365. */
  27366. protected _lightmapTexture: Nullable<BaseTexture>;
  27367. /**
  27368. * The color of a material in ambient lighting.
  27369. */
  27370. protected _ambientColor: Color3;
  27371. /**
  27372. * AKA Diffuse Color in other nomenclature.
  27373. */
  27374. protected _albedoColor: Color3;
  27375. /**
  27376. * AKA Specular Color in other nomenclature.
  27377. */
  27378. protected _reflectivityColor: Color3;
  27379. /**
  27380. * The color applied when light is reflected from a material.
  27381. */
  27382. protected _reflectionColor: Color3;
  27383. /**
  27384. * The color applied when light is emitted from a material.
  27385. */
  27386. protected _emissiveColor: Color3;
  27387. /**
  27388. * AKA Glossiness in other nomenclature.
  27389. */
  27390. protected _microSurface: number;
  27391. /**
  27392. * Specifies that the material will use the light map as a show map.
  27393. */
  27394. protected _useLightmapAsShadowmap: boolean;
  27395. /**
  27396. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27397. * makes the reflect vector face the model (under horizon).
  27398. */
  27399. protected _useHorizonOcclusion: boolean;
  27400. /**
  27401. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27402. * too much the area relying on ambient texture to define their ambient occlusion.
  27403. */
  27404. protected _useRadianceOcclusion: boolean;
  27405. /**
  27406. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27407. */
  27408. protected _useAlphaFromAlbedoTexture: boolean;
  27409. /**
  27410. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27411. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27412. */
  27413. protected _useSpecularOverAlpha: boolean;
  27414. /**
  27415. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27416. */
  27417. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27418. /**
  27419. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27420. */
  27421. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27422. /**
  27423. * Specifies if the metallic texture contains the roughness information in its green channel.
  27424. */
  27425. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27426. /**
  27427. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27428. */
  27429. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27430. /**
  27431. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27432. */
  27433. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27434. /**
  27435. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27436. */
  27437. protected _useAmbientInGrayScale: boolean;
  27438. /**
  27439. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27440. * The material will try to infer what glossiness each pixel should be.
  27441. */
  27442. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27443. /**
  27444. * Defines the falloff type used in this material.
  27445. * It by default is Physical.
  27446. */
  27447. protected _lightFalloff: number;
  27448. /**
  27449. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27450. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27451. */
  27452. protected _useRadianceOverAlpha: boolean;
  27453. /**
  27454. * Allows using an object space normal map (instead of tangent space).
  27455. */
  27456. protected _useObjectSpaceNormalMap: boolean;
  27457. /**
  27458. * Allows using the bump map in parallax mode.
  27459. */
  27460. protected _useParallax: boolean;
  27461. /**
  27462. * Allows using the bump map in parallax occlusion mode.
  27463. */
  27464. protected _useParallaxOcclusion: boolean;
  27465. /**
  27466. * Controls the scale bias of the parallax mode.
  27467. */
  27468. protected _parallaxScaleBias: number;
  27469. /**
  27470. * If sets to true, disables all the lights affecting the material.
  27471. */
  27472. protected _disableLighting: boolean;
  27473. /**
  27474. * Number of Simultaneous lights allowed on the material.
  27475. */
  27476. protected _maxSimultaneousLights: number;
  27477. /**
  27478. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27479. */
  27480. protected _invertNormalMapX: boolean;
  27481. /**
  27482. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27483. */
  27484. protected _invertNormalMapY: boolean;
  27485. /**
  27486. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27487. */
  27488. protected _twoSidedLighting: boolean;
  27489. /**
  27490. * Defines the alpha limits in alpha test mode.
  27491. */
  27492. protected _alphaCutOff: number;
  27493. /**
  27494. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27495. */
  27496. protected _forceAlphaTest: boolean;
  27497. /**
  27498. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27499. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27500. */
  27501. protected _useAlphaFresnel: boolean;
  27502. /**
  27503. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27504. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27505. */
  27506. protected _useLinearAlphaFresnel: boolean;
  27507. /**
  27508. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27509. * from cos thetav and roughness:
  27510. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27511. */
  27512. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27513. /**
  27514. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27515. */
  27516. protected _forceIrradianceInFragment: boolean;
  27517. private _realTimeFiltering;
  27518. /**
  27519. * Enables realtime filtering on the texture.
  27520. */
  27521. get realTimeFiltering(): boolean;
  27522. set realTimeFiltering(b: boolean);
  27523. private _realTimeFilteringQuality;
  27524. /**
  27525. * Quality switch for realtime filtering
  27526. */
  27527. get realTimeFilteringQuality(): number;
  27528. set realTimeFilteringQuality(n: number);
  27529. /**
  27530. * Can this material render to several textures at once
  27531. */
  27532. get canRenderToMRT(): boolean;
  27533. /**
  27534. * Force normal to face away from face.
  27535. */
  27536. protected _forceNormalForward: boolean;
  27537. /**
  27538. * Enables specular anti aliasing in the PBR shader.
  27539. * It will both interacts on the Geometry for analytical and IBL lighting.
  27540. * It also prefilter the roughness map based on the bump values.
  27541. */
  27542. protected _enableSpecularAntiAliasing: boolean;
  27543. /**
  27544. * Default configuration related to image processing available in the PBR Material.
  27545. */
  27546. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27547. /**
  27548. * Keep track of the image processing observer to allow dispose and replace.
  27549. */
  27550. private _imageProcessingObserver;
  27551. /**
  27552. * Attaches a new image processing configuration to the PBR Material.
  27553. * @param configuration
  27554. */
  27555. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27556. /**
  27557. * Stores the available render targets.
  27558. */
  27559. private _renderTargets;
  27560. /**
  27561. * Sets the global ambient color for the material used in lighting calculations.
  27562. */
  27563. private _globalAmbientColor;
  27564. /**
  27565. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27566. */
  27567. private _useLogarithmicDepth;
  27568. /**
  27569. * If set to true, no lighting calculations will be applied.
  27570. */
  27571. private _unlit;
  27572. private _debugMode;
  27573. /**
  27574. * @hidden
  27575. * This is reserved for the inspector.
  27576. * Defines the material debug mode.
  27577. * It helps seeing only some components of the material while troubleshooting.
  27578. */
  27579. debugMode: number;
  27580. /**
  27581. * @hidden
  27582. * This is reserved for the inspector.
  27583. * Specify from where on screen the debug mode should start.
  27584. * The value goes from -1 (full screen) to 1 (not visible)
  27585. * It helps with side by side comparison against the final render
  27586. * This defaults to -1
  27587. */
  27588. private debugLimit;
  27589. /**
  27590. * @hidden
  27591. * This is reserved for the inspector.
  27592. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27593. * You can use the factor to better multiply the final value.
  27594. */
  27595. private debugFactor;
  27596. /**
  27597. * Defines the clear coat layer parameters for the material.
  27598. */
  27599. readonly clearCoat: PBRClearCoatConfiguration;
  27600. /**
  27601. * Defines the anisotropic parameters for the material.
  27602. */
  27603. readonly anisotropy: PBRAnisotropicConfiguration;
  27604. /**
  27605. * Defines the BRDF parameters for the material.
  27606. */
  27607. readonly brdf: PBRBRDFConfiguration;
  27608. /**
  27609. * Defines the Sheen parameters for the material.
  27610. */
  27611. readonly sheen: PBRSheenConfiguration;
  27612. /**
  27613. * Defines the SubSurface parameters for the material.
  27614. */
  27615. readonly subSurface: PBRSubSurfaceConfiguration;
  27616. /**
  27617. * Defines additionnal PrePass parameters for the material.
  27618. */
  27619. readonly prePassConfiguration: PrePassConfiguration;
  27620. /**
  27621. * Defines the detail map parameters for the material.
  27622. */
  27623. readonly detailMap: DetailMapConfiguration;
  27624. protected _rebuildInParallel: boolean;
  27625. /**
  27626. * Instantiates a new PBRMaterial instance.
  27627. *
  27628. * @param name The material name
  27629. * @param scene The scene the material will be use in.
  27630. */
  27631. constructor(name: string, scene: Scene);
  27632. /**
  27633. * Gets a boolean indicating that current material needs to register RTT
  27634. */
  27635. get hasRenderTargetTextures(): boolean;
  27636. /**
  27637. * Gets the name of the material class.
  27638. */
  27639. getClassName(): string;
  27640. /**
  27641. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27642. */
  27643. get useLogarithmicDepth(): boolean;
  27644. /**
  27645. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27646. */
  27647. set useLogarithmicDepth(value: boolean);
  27648. /**
  27649. * Returns true if alpha blending should be disabled.
  27650. */
  27651. protected get _disableAlphaBlending(): boolean;
  27652. /**
  27653. * Specifies whether or not this material should be rendered in alpha blend mode.
  27654. */
  27655. needAlphaBlending(): boolean;
  27656. /**
  27657. * Specifies whether or not this material should be rendered in alpha test mode.
  27658. */
  27659. needAlphaTesting(): boolean;
  27660. /**
  27661. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27662. */
  27663. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27664. /**
  27665. * Specifies whether or not there is a usable alpha channel for transparency.
  27666. */
  27667. protected _hasAlphaChannel(): boolean;
  27668. /**
  27669. * Gets the texture used for the alpha test.
  27670. */
  27671. getAlphaTestTexture(): Nullable<BaseTexture>;
  27672. /**
  27673. * Specifies that the submesh is ready to be used.
  27674. * @param mesh - BJS mesh.
  27675. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27676. * @param useInstances - Specifies that instances should be used.
  27677. * @returns - boolean indicating that the submesh is ready or not.
  27678. */
  27679. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27680. /**
  27681. * Specifies if the material uses metallic roughness workflow.
  27682. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27683. */
  27684. isMetallicWorkflow(): boolean;
  27685. private _prepareEffect;
  27686. private _prepareDefines;
  27687. /**
  27688. * Force shader compilation
  27689. */
  27690. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27691. /**
  27692. * Initializes the uniform buffer layout for the shader.
  27693. */
  27694. buildUniformLayout(): void;
  27695. /**
  27696. * Unbinds the material from the mesh
  27697. */
  27698. unbind(): void;
  27699. /**
  27700. * Binds the submesh data.
  27701. * @param world - The world matrix.
  27702. * @param mesh - The BJS mesh.
  27703. * @param subMesh - A submesh of the BJS mesh.
  27704. */
  27705. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27706. /**
  27707. * Returns the animatable textures.
  27708. * @returns - Array of animatable textures.
  27709. */
  27710. getAnimatables(): IAnimatable[];
  27711. /**
  27712. * Returns the texture used for reflections.
  27713. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27714. */
  27715. private _getReflectionTexture;
  27716. /**
  27717. * Returns an array of the actively used textures.
  27718. * @returns - Array of BaseTextures
  27719. */
  27720. getActiveTextures(): BaseTexture[];
  27721. /**
  27722. * Checks to see if a texture is used in the material.
  27723. * @param texture - Base texture to use.
  27724. * @returns - Boolean specifying if a texture is used in the material.
  27725. */
  27726. hasTexture(texture: BaseTexture): boolean;
  27727. /**
  27728. * Sets the required values to the prepass renderer.
  27729. * @param prePassRenderer defines the prepass renderer to setup
  27730. */
  27731. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27732. /**
  27733. * Disposes the resources of the material.
  27734. * @param forceDisposeEffect - Forces the disposal of effects.
  27735. * @param forceDisposeTextures - Forces the disposal of all textures.
  27736. */
  27737. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27738. }
  27739. }
  27740. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  27741. import { Nullable } from "babylonjs/types";
  27742. import { Scene } from "babylonjs/scene";
  27743. import { Color3 } from "babylonjs/Maths/math.color";
  27744. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  27745. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27747. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  27748. /**
  27749. * The Physically based material of BJS.
  27750. *
  27751. * This offers the main features of a standard PBR material.
  27752. * For more information, please refer to the documentation :
  27753. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27754. */
  27755. export class PBRMaterial extends PBRBaseMaterial {
  27756. /**
  27757. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27758. */
  27759. static readonly PBRMATERIAL_OPAQUE: number;
  27760. /**
  27761. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27762. */
  27763. static readonly PBRMATERIAL_ALPHATEST: number;
  27764. /**
  27765. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27766. */
  27767. static readonly PBRMATERIAL_ALPHABLEND: number;
  27768. /**
  27769. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27770. * They are also discarded below the alpha cutoff threshold to improve performances.
  27771. */
  27772. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27773. /**
  27774. * Defines the default value of how much AO map is occluding the analytical lights
  27775. * (point spot...).
  27776. */
  27777. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27778. /**
  27779. * Intensity of the direct lights e.g. the four lights available in your scene.
  27780. * This impacts both the direct diffuse and specular highlights.
  27781. */
  27782. directIntensity: number;
  27783. /**
  27784. * Intensity of the emissive part of the material.
  27785. * This helps controlling the emissive effect without modifying the emissive color.
  27786. */
  27787. emissiveIntensity: number;
  27788. /**
  27789. * Intensity of the environment e.g. how much the environment will light the object
  27790. * either through harmonics for rough material or through the refelction for shiny ones.
  27791. */
  27792. environmentIntensity: number;
  27793. /**
  27794. * This is a special control allowing the reduction of the specular highlights coming from the
  27795. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27796. */
  27797. specularIntensity: number;
  27798. /**
  27799. * Debug Control allowing disabling the bump map on this material.
  27800. */
  27801. disableBumpMap: boolean;
  27802. /**
  27803. * AKA Diffuse Texture in standard nomenclature.
  27804. */
  27805. albedoTexture: BaseTexture;
  27806. /**
  27807. * AKA Occlusion Texture in other nomenclature.
  27808. */
  27809. ambientTexture: BaseTexture;
  27810. /**
  27811. * AKA Occlusion Texture Intensity in other nomenclature.
  27812. */
  27813. ambientTextureStrength: number;
  27814. /**
  27815. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27816. * 1 means it completely occludes it
  27817. * 0 mean it has no impact
  27818. */
  27819. ambientTextureImpactOnAnalyticalLights: number;
  27820. /**
  27821. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27822. */
  27823. opacityTexture: BaseTexture;
  27824. /**
  27825. * Stores the reflection values in a texture.
  27826. */
  27827. reflectionTexture: Nullable<BaseTexture>;
  27828. /**
  27829. * Stores the emissive values in a texture.
  27830. */
  27831. emissiveTexture: BaseTexture;
  27832. /**
  27833. * AKA Specular texture in other nomenclature.
  27834. */
  27835. reflectivityTexture: BaseTexture;
  27836. /**
  27837. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27838. */
  27839. metallicTexture: BaseTexture;
  27840. /**
  27841. * Specifies the metallic scalar of the metallic/roughness workflow.
  27842. * Can also be used to scale the metalness values of the metallic texture.
  27843. */
  27844. metallic: Nullable<number>;
  27845. /**
  27846. * Specifies the roughness scalar of the metallic/roughness workflow.
  27847. * Can also be used to scale the roughness values of the metallic texture.
  27848. */
  27849. roughness: Nullable<number>;
  27850. /**
  27851. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27852. * By default the indexOfrefraction is used to compute F0;
  27853. *
  27854. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27855. *
  27856. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27857. * F90 = metallicReflectanceColor;
  27858. */
  27859. metallicF0Factor: number;
  27860. /**
  27861. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27862. * By default the F90 is always 1;
  27863. *
  27864. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27865. *
  27866. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27867. * F90 = metallicReflectanceColor;
  27868. */
  27869. metallicReflectanceColor: Color3;
  27870. /**
  27871. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27872. * This is multiply against the scalar values defined in the material.
  27873. */
  27874. metallicReflectanceTexture: Nullable<BaseTexture>;
  27875. /**
  27876. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27877. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27878. */
  27879. microSurfaceTexture: BaseTexture;
  27880. /**
  27881. * Stores surface normal data used to displace a mesh in a texture.
  27882. */
  27883. bumpTexture: BaseTexture;
  27884. /**
  27885. * Stores the pre-calculated light information of a mesh in a texture.
  27886. */
  27887. lightmapTexture: BaseTexture;
  27888. /**
  27889. * Stores the refracted light information in a texture.
  27890. */
  27891. get refractionTexture(): Nullable<BaseTexture>;
  27892. set refractionTexture(value: Nullable<BaseTexture>);
  27893. /**
  27894. * The color of a material in ambient lighting.
  27895. */
  27896. ambientColor: Color3;
  27897. /**
  27898. * AKA Diffuse Color in other nomenclature.
  27899. */
  27900. albedoColor: Color3;
  27901. /**
  27902. * AKA Specular Color in other nomenclature.
  27903. */
  27904. reflectivityColor: Color3;
  27905. /**
  27906. * The color reflected from the material.
  27907. */
  27908. reflectionColor: Color3;
  27909. /**
  27910. * The color emitted from the material.
  27911. */
  27912. emissiveColor: Color3;
  27913. /**
  27914. * AKA Glossiness in other nomenclature.
  27915. */
  27916. microSurface: number;
  27917. /**
  27918. * Index of refraction of the material base layer.
  27919. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27920. *
  27921. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27922. *
  27923. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27924. */
  27925. get indexOfRefraction(): number;
  27926. set indexOfRefraction(value: number);
  27927. /**
  27928. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27929. */
  27930. get invertRefractionY(): boolean;
  27931. set invertRefractionY(value: boolean);
  27932. /**
  27933. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27934. * Materials half opaque for instance using refraction could benefit from this control.
  27935. */
  27936. get linkRefractionWithTransparency(): boolean;
  27937. set linkRefractionWithTransparency(value: boolean);
  27938. /**
  27939. * If true, the light map contains occlusion information instead of lighting info.
  27940. */
  27941. useLightmapAsShadowmap: boolean;
  27942. /**
  27943. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27944. */
  27945. useAlphaFromAlbedoTexture: boolean;
  27946. /**
  27947. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27948. */
  27949. forceAlphaTest: boolean;
  27950. /**
  27951. * Defines the alpha limits in alpha test mode.
  27952. */
  27953. alphaCutOff: number;
  27954. /**
  27955. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27956. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27957. */
  27958. useSpecularOverAlpha: boolean;
  27959. /**
  27960. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27961. */
  27962. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27963. /**
  27964. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27965. */
  27966. useRoughnessFromMetallicTextureAlpha: boolean;
  27967. /**
  27968. * Specifies if the metallic texture contains the roughness information in its green channel.
  27969. */
  27970. useRoughnessFromMetallicTextureGreen: boolean;
  27971. /**
  27972. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27973. */
  27974. useMetallnessFromMetallicTextureBlue: boolean;
  27975. /**
  27976. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27977. */
  27978. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27979. /**
  27980. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27981. */
  27982. useAmbientInGrayScale: boolean;
  27983. /**
  27984. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27985. * The material will try to infer what glossiness each pixel should be.
  27986. */
  27987. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27988. /**
  27989. * BJS is using an harcoded light falloff based on a manually sets up range.
  27990. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27991. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27992. */
  27993. get usePhysicalLightFalloff(): boolean;
  27994. /**
  27995. * BJS is using an harcoded light falloff based on a manually sets up range.
  27996. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27997. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27998. */
  27999. set usePhysicalLightFalloff(value: boolean);
  28000. /**
  28001. * In order to support the falloff compatibility with gltf, a special mode has been added
  28002. * to reproduce the gltf light falloff.
  28003. */
  28004. get useGLTFLightFalloff(): boolean;
  28005. /**
  28006. * In order to support the falloff compatibility with gltf, a special mode has been added
  28007. * to reproduce the gltf light falloff.
  28008. */
  28009. set useGLTFLightFalloff(value: boolean);
  28010. /**
  28011. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  28012. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  28013. */
  28014. useRadianceOverAlpha: boolean;
  28015. /**
  28016. * Allows using an object space normal map (instead of tangent space).
  28017. */
  28018. useObjectSpaceNormalMap: boolean;
  28019. /**
  28020. * Allows using the bump map in parallax mode.
  28021. */
  28022. useParallax: boolean;
  28023. /**
  28024. * Allows using the bump map in parallax occlusion mode.
  28025. */
  28026. useParallaxOcclusion: boolean;
  28027. /**
  28028. * Controls the scale bias of the parallax mode.
  28029. */
  28030. parallaxScaleBias: number;
  28031. /**
  28032. * If sets to true, disables all the lights affecting the material.
  28033. */
  28034. disableLighting: boolean;
  28035. /**
  28036. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  28037. */
  28038. forceIrradianceInFragment: boolean;
  28039. /**
  28040. * Number of Simultaneous lights allowed on the material.
  28041. */
  28042. maxSimultaneousLights: number;
  28043. /**
  28044. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28045. */
  28046. invertNormalMapX: boolean;
  28047. /**
  28048. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28049. */
  28050. invertNormalMapY: boolean;
  28051. /**
  28052. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28053. */
  28054. twoSidedLighting: boolean;
  28055. /**
  28056. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28057. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  28058. */
  28059. useAlphaFresnel: boolean;
  28060. /**
  28061. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28062. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  28063. */
  28064. useLinearAlphaFresnel: boolean;
  28065. /**
  28066. * Let user defines the brdf lookup texture used for IBL.
  28067. * A default 8bit version is embedded but you could point at :
  28068. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  28069. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  28070. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  28071. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  28072. */
  28073. environmentBRDFTexture: Nullable<BaseTexture>;
  28074. /**
  28075. * Force normal to face away from face.
  28076. */
  28077. forceNormalForward: boolean;
  28078. /**
  28079. * Enables specular anti aliasing in the PBR shader.
  28080. * It will both interacts on the Geometry for analytical and IBL lighting.
  28081. * It also prefilter the roughness map based on the bump values.
  28082. */
  28083. enableSpecularAntiAliasing: boolean;
  28084. /**
  28085. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28086. * makes the reflect vector face the model (under horizon).
  28087. */
  28088. useHorizonOcclusion: boolean;
  28089. /**
  28090. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28091. * too much the area relying on ambient texture to define their ambient occlusion.
  28092. */
  28093. useRadianceOcclusion: boolean;
  28094. /**
  28095. * If set to true, no lighting calculations will be applied.
  28096. */
  28097. unlit: boolean;
  28098. /**
  28099. * Gets the image processing configuration used either in this material.
  28100. */
  28101. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28102. /**
  28103. * Sets the Default image processing configuration used either in the this material.
  28104. *
  28105. * If sets to null, the scene one is in use.
  28106. */
  28107. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28108. /**
  28109. * Gets wether the color curves effect is enabled.
  28110. */
  28111. get cameraColorCurvesEnabled(): boolean;
  28112. /**
  28113. * Sets wether the color curves effect is enabled.
  28114. */
  28115. set cameraColorCurvesEnabled(value: boolean);
  28116. /**
  28117. * Gets wether the color grading effect is enabled.
  28118. */
  28119. get cameraColorGradingEnabled(): boolean;
  28120. /**
  28121. * Gets wether the color grading effect is enabled.
  28122. */
  28123. set cameraColorGradingEnabled(value: boolean);
  28124. /**
  28125. * Gets wether tonemapping is enabled or not.
  28126. */
  28127. get cameraToneMappingEnabled(): boolean;
  28128. /**
  28129. * Sets wether tonemapping is enabled or not
  28130. */
  28131. set cameraToneMappingEnabled(value: boolean);
  28132. /**
  28133. * The camera exposure used on this material.
  28134. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28135. * This corresponds to a photographic exposure.
  28136. */
  28137. get cameraExposure(): number;
  28138. /**
  28139. * The camera exposure used on this material.
  28140. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28141. * This corresponds to a photographic exposure.
  28142. */
  28143. set cameraExposure(value: number);
  28144. /**
  28145. * Gets The camera contrast used on this material.
  28146. */
  28147. get cameraContrast(): number;
  28148. /**
  28149. * Sets The camera contrast used on this material.
  28150. */
  28151. set cameraContrast(value: number);
  28152. /**
  28153. * Gets the Color Grading 2D Lookup Texture.
  28154. */
  28155. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28156. /**
  28157. * Sets the Color Grading 2D Lookup Texture.
  28158. */
  28159. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28160. /**
  28161. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28162. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28163. * 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;
  28164. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28165. */
  28166. get cameraColorCurves(): Nullable<ColorCurves>;
  28167. /**
  28168. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28169. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28170. * 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;
  28171. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28172. */
  28173. set cameraColorCurves(value: Nullable<ColorCurves>);
  28174. /**
  28175. * Instantiates a new PBRMaterial instance.
  28176. *
  28177. * @param name The material name
  28178. * @param scene The scene the material will be use in.
  28179. */
  28180. constructor(name: string, scene: Scene);
  28181. /**
  28182. * Returns the name of this material class.
  28183. */
  28184. getClassName(): string;
  28185. /**
  28186. * Makes a duplicate of the current material.
  28187. * @param name - name to use for the new material.
  28188. */
  28189. clone(name: string): PBRMaterial;
  28190. /**
  28191. * Serializes this PBR Material.
  28192. * @returns - An object with the serialized material.
  28193. */
  28194. serialize(): any;
  28195. /**
  28196. * Parses a PBR Material from a serialized object.
  28197. * @param source - Serialized object.
  28198. * @param scene - BJS scene instance.
  28199. * @param rootUrl - url for the scene object
  28200. * @returns - PBRMaterial
  28201. */
  28202. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28203. }
  28204. }
  28205. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28206. /** @hidden */
  28207. export var mrtFragmentDeclaration: {
  28208. name: string;
  28209. shader: string;
  28210. };
  28211. }
  28212. declare module "babylonjs/Shaders/geometry.fragment" {
  28213. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28214. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28215. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28216. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28217. /** @hidden */
  28218. export var geometryPixelShader: {
  28219. name: string;
  28220. shader: string;
  28221. };
  28222. }
  28223. declare module "babylonjs/Shaders/geometry.vertex" {
  28224. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28225. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28226. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28227. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28228. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28229. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28230. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28231. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28232. /** @hidden */
  28233. export var geometryVertexShader: {
  28234. name: string;
  28235. shader: string;
  28236. };
  28237. }
  28238. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28239. import { Matrix } from "babylonjs/Maths/math.vector";
  28240. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28241. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28242. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28243. import { Effect } from "babylonjs/Materials/effect";
  28244. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28245. import { Scene } from "babylonjs/scene";
  28246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28247. import { Nullable } from "babylonjs/types";
  28248. import "babylonjs/Shaders/geometry.fragment";
  28249. import "babylonjs/Shaders/geometry.vertex";
  28250. /** @hidden */
  28251. interface ISavedTransformationMatrix {
  28252. world: Matrix;
  28253. viewProjection: Matrix;
  28254. }
  28255. /**
  28256. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28257. */
  28258. export class GeometryBufferRenderer {
  28259. /**
  28260. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28261. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28262. */
  28263. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28264. /**
  28265. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28266. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28267. */
  28268. static readonly POSITION_TEXTURE_TYPE: number;
  28269. /**
  28270. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28271. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28272. */
  28273. static readonly VELOCITY_TEXTURE_TYPE: number;
  28274. /**
  28275. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28276. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28277. */
  28278. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28279. /**
  28280. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28281. * in order to compute objects velocities when enableVelocity is set to "true"
  28282. * @hidden
  28283. */
  28284. _previousTransformationMatrices: {
  28285. [index: number]: ISavedTransformationMatrix;
  28286. };
  28287. /**
  28288. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28289. * in order to compute objects velocities when enableVelocity is set to "true"
  28290. * @hidden
  28291. */
  28292. _previousBonesTransformationMatrices: {
  28293. [index: number]: Float32Array;
  28294. };
  28295. /**
  28296. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28297. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28298. */
  28299. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28300. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28301. renderTransparentMeshes: boolean;
  28302. private _scene;
  28303. private _resizeObserver;
  28304. private _multiRenderTarget;
  28305. private _ratio;
  28306. private _enablePosition;
  28307. private _enableVelocity;
  28308. private _enableReflectivity;
  28309. private _positionIndex;
  28310. private _velocityIndex;
  28311. private _reflectivityIndex;
  28312. private _depthNormalIndex;
  28313. private _linkedWithPrePass;
  28314. private _prePassRenderer;
  28315. private _attachments;
  28316. protected _effect: Effect;
  28317. protected _cachedDefines: string;
  28318. /**
  28319. * @hidden
  28320. * Sets up internal structures to share outputs with PrePassRenderer
  28321. * This method should only be called by the PrePassRenderer itself
  28322. */
  28323. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28324. /**
  28325. * @hidden
  28326. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28327. * This method should only be called by the PrePassRenderer itself
  28328. */
  28329. _unlinkPrePassRenderer(): void;
  28330. /**
  28331. * @hidden
  28332. * Resets the geometry buffer layout
  28333. */
  28334. _resetLayout(): void;
  28335. /**
  28336. * @hidden
  28337. * Replaces a texture in the geometry buffer renderer
  28338. * Useful when linking textures of the prepass renderer
  28339. */
  28340. _forceTextureType(geometryBufferType: number, index: number): void;
  28341. /**
  28342. * @hidden
  28343. * Sets texture attachments
  28344. * Useful when linking textures of the prepass renderer
  28345. */
  28346. _setAttachments(attachments: number[]): void;
  28347. /**
  28348. * @hidden
  28349. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28350. * Useful when linking textures of the prepass renderer
  28351. */
  28352. _linkInternalTexture(internalTexture: InternalTexture): void;
  28353. /**
  28354. * Gets the render list (meshes to be rendered) used in the G buffer.
  28355. */
  28356. get renderList(): Nullable<AbstractMesh[]>;
  28357. /**
  28358. * Set the render list (meshes to be rendered) used in the G buffer.
  28359. */
  28360. set renderList(meshes: Nullable<AbstractMesh[]>);
  28361. /**
  28362. * Gets wether or not G buffer are supported by the running hardware.
  28363. * This requires draw buffer supports
  28364. */
  28365. get isSupported(): boolean;
  28366. /**
  28367. * Returns the index of the given texture type in the G-Buffer textures array
  28368. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28369. * @returns the index of the given texture type in the G-Buffer textures array
  28370. */
  28371. getTextureIndex(textureType: number): number;
  28372. /**
  28373. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28374. */
  28375. get enablePosition(): boolean;
  28376. /**
  28377. * Sets whether or not objects positions are enabled for the G buffer.
  28378. */
  28379. set enablePosition(enable: boolean);
  28380. /**
  28381. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28382. */
  28383. get enableVelocity(): boolean;
  28384. /**
  28385. * Sets wether or not objects velocities are enabled for the G buffer.
  28386. */
  28387. set enableVelocity(enable: boolean);
  28388. /**
  28389. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28390. */
  28391. get enableReflectivity(): boolean;
  28392. /**
  28393. * Sets wether or not objects roughness are enabled for the G buffer.
  28394. */
  28395. set enableReflectivity(enable: boolean);
  28396. /**
  28397. * Gets the scene associated with the buffer.
  28398. */
  28399. get scene(): Scene;
  28400. /**
  28401. * Gets the ratio used by the buffer during its creation.
  28402. * How big is the buffer related to the main canvas.
  28403. */
  28404. get ratio(): number;
  28405. /** @hidden */
  28406. static _SceneComponentInitialization: (scene: Scene) => void;
  28407. /**
  28408. * Creates a new G Buffer for the scene
  28409. * @param scene The scene the buffer belongs to
  28410. * @param ratio How big is the buffer related to the main canvas.
  28411. */
  28412. constructor(scene: Scene, ratio?: number);
  28413. /**
  28414. * Checks wether everything is ready to render a submesh to the G buffer.
  28415. * @param subMesh the submesh to check readiness for
  28416. * @param useInstances is the mesh drawn using instance or not
  28417. * @returns true if ready otherwise false
  28418. */
  28419. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28420. /**
  28421. * Gets the current underlying G Buffer.
  28422. * @returns the buffer
  28423. */
  28424. getGBuffer(): MultiRenderTarget;
  28425. /**
  28426. * Gets the number of samples used to render the buffer (anti aliasing).
  28427. */
  28428. get samples(): number;
  28429. /**
  28430. * Sets the number of samples used to render the buffer (anti aliasing).
  28431. */
  28432. set samples(value: number);
  28433. /**
  28434. * Disposes the renderer and frees up associated resources.
  28435. */
  28436. dispose(): void;
  28437. private _assignRenderTargetIndices;
  28438. protected _createRenderTargets(): void;
  28439. private _copyBonesTransformationMatrices;
  28440. }
  28441. }
  28442. declare module "babylonjs/Rendering/prePassRenderer" {
  28443. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28444. import { Scene } from "babylonjs/scene";
  28445. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28446. import { Effect } from "babylonjs/Materials/effect";
  28447. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28449. import { Material } from "babylonjs/Materials/material";
  28450. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28451. /**
  28452. * Renders a pre pass of the scene
  28453. * This means every mesh in the scene will be rendered to a render target texture
  28454. * And then this texture will be composited to the rendering canvas with post processes
  28455. * It is necessary for effects like subsurface scattering or deferred shading
  28456. */
  28457. export class PrePassRenderer {
  28458. /** @hidden */
  28459. static _SceneComponentInitialization: (scene: Scene) => void;
  28460. private _textureFormats;
  28461. /**
  28462. * To save performance, we can excluded skinned meshes from the prepass
  28463. */
  28464. excludedSkinnedMesh: AbstractMesh[];
  28465. /**
  28466. * Force material to be excluded from the prepass
  28467. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28468. * and you don't want a material to show in the effect.
  28469. */
  28470. excludedMaterials: Material[];
  28471. private _textureIndices;
  28472. private _scene;
  28473. private _engine;
  28474. private _isDirty;
  28475. /**
  28476. * Number of textures in the multi render target texture where the scene is directly rendered
  28477. */
  28478. mrtCount: number;
  28479. /**
  28480. * The render target where the scene is directly rendered
  28481. */
  28482. prePassRT: MultiRenderTarget;
  28483. private _multiRenderAttachments;
  28484. private _defaultAttachments;
  28485. private _clearAttachments;
  28486. private _postProcesses;
  28487. private readonly _clearColor;
  28488. /**
  28489. * Image processing post process for composition
  28490. */
  28491. imageProcessingPostProcess: ImageProcessingPostProcess;
  28492. /**
  28493. * Configuration for prepass effects
  28494. */
  28495. private _effectConfigurations;
  28496. private _mrtFormats;
  28497. private _mrtLayout;
  28498. private _enabled;
  28499. /**
  28500. * Indicates if the prepass is enabled
  28501. */
  28502. get enabled(): boolean;
  28503. /**
  28504. * How many samples are used for MSAA of the scene render target
  28505. */
  28506. get samples(): number;
  28507. set samples(n: number);
  28508. private _geometryBuffer;
  28509. private _useGeometryBufferFallback;
  28510. /**
  28511. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28512. */
  28513. get useGeometryBufferFallback(): boolean;
  28514. set useGeometryBufferFallback(value: boolean);
  28515. /**
  28516. * Instanciates a prepass renderer
  28517. * @param scene The scene
  28518. */
  28519. constructor(scene: Scene);
  28520. private _initializeAttachments;
  28521. private _createCompositionEffect;
  28522. /**
  28523. * Indicates if rendering a prepass is supported
  28524. */
  28525. get isSupported(): boolean;
  28526. /**
  28527. * Sets the proper output textures to draw in the engine.
  28528. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28529. * @param subMesh Submesh on which the effect is applied
  28530. */
  28531. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28532. /**
  28533. * @hidden
  28534. */
  28535. _beforeCameraDraw(): void;
  28536. /**
  28537. * @hidden
  28538. */
  28539. _afterCameraDraw(): void;
  28540. private _checkRTSize;
  28541. private _bindFrameBuffer;
  28542. /**
  28543. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28544. */
  28545. clear(): void;
  28546. private _setState;
  28547. private _updateGeometryBufferLayout;
  28548. /**
  28549. * Adds an effect configuration to the prepass.
  28550. * If an effect has already been added, it won't add it twice and will return the configuration
  28551. * already present.
  28552. * @param cfg the effect configuration
  28553. * @return the effect configuration now used by the prepass
  28554. */
  28555. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28556. /**
  28557. * Returns the index of a texture in the multi render target texture array.
  28558. * @param type Texture type
  28559. * @return The index
  28560. */
  28561. getIndex(type: number): number;
  28562. private _enable;
  28563. private _disable;
  28564. private _resetLayout;
  28565. private _resetPostProcessChain;
  28566. private _bindPostProcessChain;
  28567. /**
  28568. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28569. */
  28570. markAsDirty(): void;
  28571. /**
  28572. * Enables a texture on the MultiRenderTarget for prepass
  28573. */
  28574. private _enableTextures;
  28575. private _update;
  28576. private _markAllMaterialsAsPrePassDirty;
  28577. /**
  28578. * Disposes the prepass renderer.
  28579. */
  28580. dispose(): void;
  28581. }
  28582. }
  28583. declare module "babylonjs/PostProcesses/postProcess" {
  28584. import { Nullable } from "babylonjs/types";
  28585. import { SmartArray } from "babylonjs/Misc/smartArray";
  28586. import { Observable } from "babylonjs/Misc/observable";
  28587. import { Vector2 } from "babylonjs/Maths/math.vector";
  28588. import { Camera } from "babylonjs/Cameras/camera";
  28589. import { Effect } from "babylonjs/Materials/effect";
  28590. import "babylonjs/Shaders/postprocess.vertex";
  28591. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28592. import { Engine } from "babylonjs/Engines/engine";
  28593. import { Color4 } from "babylonjs/Maths/math.color";
  28594. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28595. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28596. import { Scene } from "babylonjs/scene";
  28597. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28598. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28599. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28600. /**
  28601. * Size options for a post process
  28602. */
  28603. export type PostProcessOptions = {
  28604. width: number;
  28605. height: number;
  28606. };
  28607. /**
  28608. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28609. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28610. */
  28611. export class PostProcess {
  28612. /**
  28613. * Gets or sets the unique id of the post process
  28614. */
  28615. uniqueId: number;
  28616. /** Name of the PostProcess. */
  28617. name: string;
  28618. /**
  28619. * Width of the texture to apply the post process on
  28620. */
  28621. width: number;
  28622. /**
  28623. * Height of the texture to apply the post process on
  28624. */
  28625. height: number;
  28626. /**
  28627. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28628. */
  28629. nodeMaterialSource: Nullable<NodeMaterial>;
  28630. /**
  28631. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28632. * @hidden
  28633. */
  28634. _outputTexture: Nullable<InternalTexture>;
  28635. /**
  28636. * Sampling mode used by the shader
  28637. * See https://doc.babylonjs.com/classes/3.1/texture
  28638. */
  28639. renderTargetSamplingMode: number;
  28640. /**
  28641. * Clear color to use when screen clearing
  28642. */
  28643. clearColor: Color4;
  28644. /**
  28645. * If the buffer needs to be cleared before applying the post process. (default: true)
  28646. * Should be set to false if shader will overwrite all previous pixels.
  28647. */
  28648. autoClear: boolean;
  28649. /**
  28650. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28651. */
  28652. alphaMode: number;
  28653. /**
  28654. * Sets the setAlphaBlendConstants of the babylon engine
  28655. */
  28656. alphaConstants: Color4;
  28657. /**
  28658. * Animations to be used for the post processing
  28659. */
  28660. animations: import("babylonjs/Animations/animation").Animation[];
  28661. /**
  28662. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28663. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28664. */
  28665. enablePixelPerfectMode: boolean;
  28666. /**
  28667. * Force the postprocess to be applied without taking in account viewport
  28668. */
  28669. forceFullscreenViewport: boolean;
  28670. /**
  28671. * List of inspectable custom properties (used by the Inspector)
  28672. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28673. */
  28674. inspectableCustomProperties: IInspectable[];
  28675. /**
  28676. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28677. *
  28678. * | Value | Type | Description |
  28679. * | ----- | ----------------------------------- | ----------- |
  28680. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28681. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28682. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28683. *
  28684. */
  28685. scaleMode: number;
  28686. /**
  28687. * Force textures to be a power of two (default: false)
  28688. */
  28689. alwaysForcePOT: boolean;
  28690. private _samples;
  28691. /**
  28692. * Number of sample textures (default: 1)
  28693. */
  28694. get samples(): number;
  28695. set samples(n: number);
  28696. /**
  28697. * Modify the scale of the post process to be the same as the viewport (default: false)
  28698. */
  28699. adaptScaleToCurrentViewport: boolean;
  28700. private _camera;
  28701. protected _scene: Scene;
  28702. private _engine;
  28703. private _options;
  28704. private _reusable;
  28705. private _textureType;
  28706. private _textureFormat;
  28707. /**
  28708. * Smart array of input and output textures for the post process.
  28709. * @hidden
  28710. */
  28711. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28712. /**
  28713. * The index in _textures that corresponds to the output texture.
  28714. * @hidden
  28715. */
  28716. _currentRenderTextureInd: number;
  28717. private _effect;
  28718. private _samplers;
  28719. private _fragmentUrl;
  28720. private _vertexUrl;
  28721. private _parameters;
  28722. private _scaleRatio;
  28723. protected _indexParameters: any;
  28724. private _shareOutputWithPostProcess;
  28725. private _texelSize;
  28726. private _forcedOutputTexture;
  28727. /**
  28728. * Prepass configuration in case this post process needs a texture from prepass
  28729. * @hidden
  28730. */
  28731. _prePassEffectConfiguration: PrePassEffectConfiguration;
  28732. /**
  28733. * Returns the fragment url or shader name used in the post process.
  28734. * @returns the fragment url or name in the shader store.
  28735. */
  28736. getEffectName(): string;
  28737. /**
  28738. * An event triggered when the postprocess is activated.
  28739. */
  28740. onActivateObservable: Observable<Camera>;
  28741. private _onActivateObserver;
  28742. /**
  28743. * A function that is added to the onActivateObservable
  28744. */
  28745. set onActivate(callback: Nullable<(camera: Camera) => void>);
  28746. /**
  28747. * An event triggered when the postprocess changes its size.
  28748. */
  28749. onSizeChangedObservable: Observable<PostProcess>;
  28750. private _onSizeChangedObserver;
  28751. /**
  28752. * A function that is added to the onSizeChangedObservable
  28753. */
  28754. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  28755. /**
  28756. * An event triggered when the postprocess applies its effect.
  28757. */
  28758. onApplyObservable: Observable<Effect>;
  28759. private _onApplyObserver;
  28760. /**
  28761. * A function that is added to the onApplyObservable
  28762. */
  28763. set onApply(callback: (effect: Effect) => void);
  28764. /**
  28765. * An event triggered before rendering the postprocess
  28766. */
  28767. onBeforeRenderObservable: Observable<Effect>;
  28768. private _onBeforeRenderObserver;
  28769. /**
  28770. * A function that is added to the onBeforeRenderObservable
  28771. */
  28772. set onBeforeRender(callback: (effect: Effect) => void);
  28773. /**
  28774. * An event triggered after rendering the postprocess
  28775. */
  28776. onAfterRenderObservable: Observable<Effect>;
  28777. private _onAfterRenderObserver;
  28778. /**
  28779. * A function that is added to the onAfterRenderObservable
  28780. */
  28781. set onAfterRender(callback: (efect: Effect) => void);
  28782. /**
  28783. * 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
  28784. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28785. */
  28786. get inputTexture(): InternalTexture;
  28787. set inputTexture(value: InternalTexture);
  28788. /**
  28789. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  28790. * the only way to unset it is to use this function to restore its internal state
  28791. */
  28792. restoreDefaultInputTexture(): void;
  28793. /**
  28794. * Gets the camera which post process is applied to.
  28795. * @returns The camera the post process is applied to.
  28796. */
  28797. getCamera(): Camera;
  28798. /**
  28799. * Gets the texel size of the postprocess.
  28800. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28801. */
  28802. get texelSize(): Vector2;
  28803. /**
  28804. * Creates a new instance PostProcess
  28805. * @param name The name of the PostProcess.
  28806. * @param fragmentUrl The url of the fragment shader to be used.
  28807. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28808. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28809. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28810. * @param camera The camera to apply the render pass to.
  28811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28812. * @param engine The engine which the post process will be applied. (default: current engine)
  28813. * @param reusable If the post process can be reused on the same frame. (default: false)
  28814. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28815. * @param textureType Type of textures used when performing the post process. (default: 0)
  28816. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28817. * @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
  28818. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  28819. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  28820. */
  28821. 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);
  28822. /**
  28823. * Gets a string identifying the name of the class
  28824. * @returns "PostProcess" string
  28825. */
  28826. getClassName(): string;
  28827. /**
  28828. * Gets the engine which this post process belongs to.
  28829. * @returns The engine the post process was enabled with.
  28830. */
  28831. getEngine(): Engine;
  28832. /**
  28833. * The effect that is created when initializing the post process.
  28834. * @returns The created effect corresponding the the postprocess.
  28835. */
  28836. getEffect(): Effect;
  28837. /**
  28838. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28839. * @param postProcess The post process to share the output with.
  28840. * @returns This post process.
  28841. */
  28842. shareOutputWith(postProcess: PostProcess): PostProcess;
  28843. /**
  28844. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28845. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28846. */
  28847. useOwnOutput(): void;
  28848. /**
  28849. * Updates the effect with the current post process compile time values and recompiles the shader.
  28850. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28851. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28852. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28853. * @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
  28854. * @param onCompiled Called when the shader has been compiled.
  28855. * @param onError Called if there is an error when compiling a shader.
  28856. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28857. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28858. */
  28859. 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;
  28860. /**
  28861. * The post process is reusable if it can be used multiple times within one frame.
  28862. * @returns If the post process is reusable
  28863. */
  28864. isReusable(): boolean;
  28865. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28866. markTextureDirty(): void;
  28867. /**
  28868. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28869. * 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.
  28870. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28871. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28872. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28873. * @returns The target texture that was bound to be written to.
  28874. */
  28875. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28876. /**
  28877. * If the post process is supported.
  28878. */
  28879. get isSupported(): boolean;
  28880. /**
  28881. * The aspect ratio of the output texture.
  28882. */
  28883. get aspectRatio(): number;
  28884. /**
  28885. * Get a value indicating if the post-process is ready to be used
  28886. * @returns true if the post-process is ready (shader is compiled)
  28887. */
  28888. isReady(): boolean;
  28889. /**
  28890. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28891. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28892. */
  28893. apply(): Nullable<Effect>;
  28894. private _disposeTextures;
  28895. /**
  28896. * Sets the required values to the prepass renderer.
  28897. * @param prePassRenderer defines the prepass renderer to setup.
  28898. * @returns true if the pre pass is needed.
  28899. */
  28900. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28901. /**
  28902. * Disposes the post process.
  28903. * @param camera The camera to dispose the post process on.
  28904. */
  28905. dispose(camera?: Camera): void;
  28906. /**
  28907. * Serializes the particle system to a JSON object
  28908. * @returns the JSON object
  28909. */
  28910. serialize(): any;
  28911. /**
  28912. * Creates a material from parsed material data
  28913. * @param parsedPostProcess defines parsed post process data
  28914. * @param scene defines the hosting scene
  28915. * @param rootUrl defines the root URL to use to load textures
  28916. * @returns a new post process
  28917. */
  28918. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28919. }
  28920. }
  28921. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  28922. /** @hidden */
  28923. export var kernelBlurVaryingDeclaration: {
  28924. name: string;
  28925. shader: string;
  28926. };
  28927. }
  28928. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  28929. /** @hidden */
  28930. export var kernelBlurFragment: {
  28931. name: string;
  28932. shader: string;
  28933. };
  28934. }
  28935. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  28936. /** @hidden */
  28937. export var kernelBlurFragment2: {
  28938. name: string;
  28939. shader: string;
  28940. };
  28941. }
  28942. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  28943. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28944. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28945. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  28946. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  28947. /** @hidden */
  28948. export var kernelBlurPixelShader: {
  28949. name: string;
  28950. shader: string;
  28951. };
  28952. }
  28953. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  28954. /** @hidden */
  28955. export var kernelBlurVertex: {
  28956. name: string;
  28957. shader: string;
  28958. };
  28959. }
  28960. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  28961. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28962. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  28963. /** @hidden */
  28964. export var kernelBlurVertexShader: {
  28965. name: string;
  28966. shader: string;
  28967. };
  28968. }
  28969. declare module "babylonjs/PostProcesses/blurPostProcess" {
  28970. import { Vector2 } from "babylonjs/Maths/math.vector";
  28971. import { Nullable } from "babylonjs/types";
  28972. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  28973. import { Camera } from "babylonjs/Cameras/camera";
  28974. import { Effect } from "babylonjs/Materials/effect";
  28975. import { Engine } from "babylonjs/Engines/engine";
  28976. import "babylonjs/Shaders/kernelBlur.fragment";
  28977. import "babylonjs/Shaders/kernelBlur.vertex";
  28978. import { Scene } from "babylonjs/scene";
  28979. /**
  28980. * The Blur Post Process which blurs an image based on a kernel and direction.
  28981. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28982. */
  28983. export class BlurPostProcess extends PostProcess {
  28984. private blockCompilation;
  28985. protected _kernel: number;
  28986. protected _idealKernel: number;
  28987. protected _packedFloat: boolean;
  28988. private _staticDefines;
  28989. /** The direction in which to blur the image. */
  28990. direction: Vector2;
  28991. /**
  28992. * Sets the length in pixels of the blur sample region
  28993. */
  28994. set kernel(v: number);
  28995. /**
  28996. * Gets the length in pixels of the blur sample region
  28997. */
  28998. get kernel(): number;
  28999. /**
  29000. * Sets wether or not the blur needs to unpack/repack floats
  29001. */
  29002. set packedFloat(v: boolean);
  29003. /**
  29004. * Gets wether or not the blur is unpacking/repacking floats
  29005. */
  29006. get packedFloat(): boolean;
  29007. /**
  29008. * Gets a string identifying the name of the class
  29009. * @returns "BlurPostProcess" string
  29010. */
  29011. getClassName(): string;
  29012. /**
  29013. * Creates a new instance BlurPostProcess
  29014. * @param name The name of the effect.
  29015. * @param direction The direction in which to blur the image.
  29016. * @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.
  29017. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  29018. * @param camera The camera to apply the render pass to.
  29019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29020. * @param engine The engine which the post process will be applied. (default: current engine)
  29021. * @param reusable If the post process can be reused on the same frame. (default: false)
  29022. * @param textureType Type of textures used when performing the post process. (default: 0)
  29023. * @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)
  29024. */
  29025. 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);
  29026. /**
  29027. * Updates the effect with the current post process compile time values and recompiles the shader.
  29028. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29029. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29030. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29031. * @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
  29032. * @param onCompiled Called when the shader has been compiled.
  29033. * @param onError Called if there is an error when compiling a shader.
  29034. */
  29035. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29036. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29037. /**
  29038. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  29039. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  29040. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  29041. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  29042. * The gaps between physical kernels are compensated for in the weighting of the samples
  29043. * @param idealKernel Ideal blur kernel.
  29044. * @return Nearest best kernel.
  29045. */
  29046. protected _nearestBestKernel(idealKernel: number): number;
  29047. /**
  29048. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  29049. * @param x The point on the Gaussian distribution to sample.
  29050. * @return the value of the Gaussian function at x.
  29051. */
  29052. protected _gaussianWeight(x: number): number;
  29053. /**
  29054. * Generates a string that can be used as a floating point number in GLSL.
  29055. * @param x Value to print.
  29056. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  29057. * @return GLSL float string.
  29058. */
  29059. protected _glslFloat(x: number, decimalFigures?: number): string;
  29060. /** @hidden */
  29061. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  29062. }
  29063. }
  29064. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  29065. import { Scene } from "babylonjs/scene";
  29066. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29067. import { Plane } from "babylonjs/Maths/math.plane";
  29068. /**
  29069. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29070. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29071. * You can then easily use it as a reflectionTexture on a flat surface.
  29072. * In case the surface is not a plane, please consider relying on reflection probes.
  29073. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29074. */
  29075. export class MirrorTexture extends RenderTargetTexture {
  29076. private scene;
  29077. /**
  29078. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  29079. * 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.
  29080. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29081. */
  29082. mirrorPlane: Plane;
  29083. /**
  29084. * Define the blur ratio used to blur the reflection if needed.
  29085. */
  29086. set blurRatio(value: number);
  29087. get blurRatio(): number;
  29088. /**
  29089. * Define the adaptive blur kernel used to blur the reflection if needed.
  29090. * This will autocompute the closest best match for the `blurKernel`
  29091. */
  29092. set adaptiveBlurKernel(value: number);
  29093. /**
  29094. * Define the blur kernel used to blur the reflection if needed.
  29095. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29096. */
  29097. set blurKernel(value: number);
  29098. /**
  29099. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29100. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29101. */
  29102. set blurKernelX(value: number);
  29103. get blurKernelX(): number;
  29104. /**
  29105. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29106. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29107. */
  29108. set blurKernelY(value: number);
  29109. get blurKernelY(): number;
  29110. private _autoComputeBlurKernel;
  29111. protected _onRatioRescale(): void;
  29112. private _updateGammaSpace;
  29113. private _imageProcessingConfigChangeObserver;
  29114. private _transformMatrix;
  29115. private _mirrorMatrix;
  29116. private _savedViewMatrix;
  29117. private _blurX;
  29118. private _blurY;
  29119. private _adaptiveBlurKernel;
  29120. private _blurKernelX;
  29121. private _blurKernelY;
  29122. private _blurRatio;
  29123. /**
  29124. * Instantiates a Mirror Texture.
  29125. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29126. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29127. * You can then easily use it as a reflectionTexture on a flat surface.
  29128. * In case the surface is not a plane, please consider relying on reflection probes.
  29129. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29130. * @param name
  29131. * @param size
  29132. * @param scene
  29133. * @param generateMipMaps
  29134. * @param type
  29135. * @param samplingMode
  29136. * @param generateDepthBuffer
  29137. */
  29138. constructor(name: string, size: number | {
  29139. width: number;
  29140. height: number;
  29141. } | {
  29142. ratio: number;
  29143. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29144. private _preparePostProcesses;
  29145. /**
  29146. * Clone the mirror texture.
  29147. * @returns the cloned texture
  29148. */
  29149. clone(): MirrorTexture;
  29150. /**
  29151. * Serialize the texture to a JSON representation you could use in Parse later on
  29152. * @returns the serialized JSON representation
  29153. */
  29154. serialize(): any;
  29155. /**
  29156. * Dispose the texture and release its associated resources.
  29157. */
  29158. dispose(): void;
  29159. }
  29160. }
  29161. declare module "babylonjs/Materials/Textures/texture" {
  29162. import { Observable } from "babylonjs/Misc/observable";
  29163. import { Nullable } from "babylonjs/types";
  29164. import { Matrix } from "babylonjs/Maths/math.vector";
  29165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29166. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29167. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29168. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29169. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29170. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29171. import { Scene } from "babylonjs/scene";
  29172. /**
  29173. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29174. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29175. */
  29176. export class Texture extends BaseTexture {
  29177. /**
  29178. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29179. */
  29180. static SerializeBuffers: boolean;
  29181. /** @hidden */
  29182. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29183. /** @hidden */
  29184. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29185. /** @hidden */
  29186. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29187. /** nearest is mag = nearest and min = nearest and mip = linear */
  29188. static readonly NEAREST_SAMPLINGMODE: number;
  29189. /** nearest is mag = nearest and min = nearest and mip = linear */
  29190. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29192. static readonly BILINEAR_SAMPLINGMODE: number;
  29193. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29194. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29195. /** Trilinear is mag = linear and min = linear and mip = linear */
  29196. static readonly TRILINEAR_SAMPLINGMODE: number;
  29197. /** Trilinear is mag = linear and min = linear and mip = linear */
  29198. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29199. /** mag = nearest and min = nearest and mip = nearest */
  29200. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29201. /** mag = nearest and min = linear and mip = nearest */
  29202. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29203. /** mag = nearest and min = linear and mip = linear */
  29204. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29205. /** mag = nearest and min = linear and mip = none */
  29206. static readonly NEAREST_LINEAR: number;
  29207. /** mag = nearest and min = nearest and mip = none */
  29208. static readonly NEAREST_NEAREST: number;
  29209. /** mag = linear and min = nearest and mip = nearest */
  29210. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29211. /** mag = linear and min = nearest and mip = linear */
  29212. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29213. /** mag = linear and min = linear and mip = none */
  29214. static readonly LINEAR_LINEAR: number;
  29215. /** mag = linear and min = nearest and mip = none */
  29216. static readonly LINEAR_NEAREST: number;
  29217. /** Explicit coordinates mode */
  29218. static readonly EXPLICIT_MODE: number;
  29219. /** Spherical coordinates mode */
  29220. static readonly SPHERICAL_MODE: number;
  29221. /** Planar coordinates mode */
  29222. static readonly PLANAR_MODE: number;
  29223. /** Cubic coordinates mode */
  29224. static readonly CUBIC_MODE: number;
  29225. /** Projection coordinates mode */
  29226. static readonly PROJECTION_MODE: number;
  29227. /** Inverse Cubic coordinates mode */
  29228. static readonly SKYBOX_MODE: number;
  29229. /** Inverse Cubic coordinates mode */
  29230. static readonly INVCUBIC_MODE: number;
  29231. /** Equirectangular coordinates mode */
  29232. static readonly EQUIRECTANGULAR_MODE: number;
  29233. /** Equirectangular Fixed coordinates mode */
  29234. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29235. /** Equirectangular Fixed Mirrored coordinates mode */
  29236. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29237. /** Texture is not repeating outside of 0..1 UVs */
  29238. static readonly CLAMP_ADDRESSMODE: number;
  29239. /** Texture is repeating outside of 0..1 UVs */
  29240. static readonly WRAP_ADDRESSMODE: number;
  29241. /** Texture is repeating and mirrored */
  29242. static readonly MIRROR_ADDRESSMODE: number;
  29243. /**
  29244. * 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
  29245. */
  29246. static UseSerializedUrlIfAny: boolean;
  29247. /**
  29248. * Define the url of the texture.
  29249. */
  29250. url: Nullable<string>;
  29251. /**
  29252. * Define an offset on the texture to offset the u coordinates of the UVs
  29253. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29254. */
  29255. uOffset: number;
  29256. /**
  29257. * Define an offset on the texture to offset the v coordinates of the UVs
  29258. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29259. */
  29260. vOffset: number;
  29261. /**
  29262. * Define an offset on the texture to scale the u coordinates of the UVs
  29263. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29264. */
  29265. uScale: number;
  29266. /**
  29267. * Define an offset on the texture to scale the v coordinates of the UVs
  29268. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29269. */
  29270. vScale: number;
  29271. /**
  29272. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29273. * @see https://doc.babylonjs.com/how_to/more_materials
  29274. */
  29275. uAng: number;
  29276. /**
  29277. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29278. * @see https://doc.babylonjs.com/how_to/more_materials
  29279. */
  29280. vAng: number;
  29281. /**
  29282. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29283. * @see https://doc.babylonjs.com/how_to/more_materials
  29284. */
  29285. wAng: number;
  29286. /**
  29287. * Defines the center of rotation (U)
  29288. */
  29289. uRotationCenter: number;
  29290. /**
  29291. * Defines the center of rotation (V)
  29292. */
  29293. vRotationCenter: number;
  29294. /**
  29295. * Defines the center of rotation (W)
  29296. */
  29297. wRotationCenter: number;
  29298. /**
  29299. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29300. */
  29301. homogeneousRotationInUVTransform: boolean;
  29302. /**
  29303. * Are mip maps generated for this texture or not.
  29304. */
  29305. get noMipmap(): boolean;
  29306. /**
  29307. * List of inspectable custom properties (used by the Inspector)
  29308. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29309. */
  29310. inspectableCustomProperties: Nullable<IInspectable[]>;
  29311. private _noMipmap;
  29312. /** @hidden */
  29313. _invertY: boolean;
  29314. private _rowGenerationMatrix;
  29315. private _cachedTextureMatrix;
  29316. private _projectionModeMatrix;
  29317. private _t0;
  29318. private _t1;
  29319. private _t2;
  29320. private _cachedUOffset;
  29321. private _cachedVOffset;
  29322. private _cachedUScale;
  29323. private _cachedVScale;
  29324. private _cachedUAng;
  29325. private _cachedVAng;
  29326. private _cachedWAng;
  29327. private _cachedProjectionMatrixId;
  29328. private _cachedURotationCenter;
  29329. private _cachedVRotationCenter;
  29330. private _cachedWRotationCenter;
  29331. private _cachedHomogeneousRotationInUVTransform;
  29332. private _cachedCoordinatesMode;
  29333. /** @hidden */
  29334. protected _initialSamplingMode: number;
  29335. /** @hidden */
  29336. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29337. private _deleteBuffer;
  29338. protected _format: Nullable<number>;
  29339. private _delayedOnLoad;
  29340. private _delayedOnError;
  29341. private _mimeType?;
  29342. private _loaderOptions?;
  29343. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29344. get mimeType(): string | undefined;
  29345. /**
  29346. * Observable triggered once the texture has been loaded.
  29347. */
  29348. onLoadObservable: Observable<Texture>;
  29349. protected _isBlocking: boolean;
  29350. /**
  29351. * Is the texture preventing material to render while loading.
  29352. * If false, a default texture will be used instead of the loading one during the preparation step.
  29353. */
  29354. set isBlocking(value: boolean);
  29355. get isBlocking(): boolean;
  29356. /**
  29357. * Get the current sampling mode associated with the texture.
  29358. */
  29359. get samplingMode(): number;
  29360. /**
  29361. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29362. */
  29363. get invertY(): boolean;
  29364. /**
  29365. * Instantiates a new texture.
  29366. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29367. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29368. * @param url defines the url of the picture to load as a texture
  29369. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29370. * @param noMipmap defines if the texture will require mip maps or not
  29371. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29372. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29373. * @param onLoad defines a callback triggered when the texture has been loaded
  29374. * @param onError defines a callback triggered when an error occurred during the loading session
  29375. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29376. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29377. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29378. * @param mimeType defines an optional mime type information
  29379. * @param loaderOptions options to be passed to the loader
  29380. */
  29381. 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, loaderOptions?: any);
  29382. /**
  29383. * Update the url (and optional buffer) of this texture if url was null during construction.
  29384. * @param url the url of the texture
  29385. * @param buffer the buffer of the texture (defaults to null)
  29386. * @param onLoad callback called when the texture is loaded (defaults to null)
  29387. */
  29388. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29389. /**
  29390. * Finish the loading sequence of a texture flagged as delayed load.
  29391. * @hidden
  29392. */
  29393. delayLoad(): void;
  29394. private _prepareRowForTextureGeneration;
  29395. /**
  29396. * Checks if the texture has the same transform matrix than another texture
  29397. * @param texture texture to check against
  29398. * @returns true if the transforms are the same, else false
  29399. */
  29400. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  29401. /**
  29402. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29403. * @returns the transform matrix of the texture.
  29404. */
  29405. getTextureMatrix(uBase?: number): Matrix;
  29406. /**
  29407. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29408. * @returns The reflection texture transform
  29409. */
  29410. getReflectionTextureMatrix(): Matrix;
  29411. /**
  29412. * Clones the texture.
  29413. * @returns the cloned texture
  29414. */
  29415. clone(): Texture;
  29416. /**
  29417. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29418. * @returns The JSON representation of the texture
  29419. */
  29420. serialize(): any;
  29421. /**
  29422. * Get the current class name of the texture useful for serialization or dynamic coding.
  29423. * @returns "Texture"
  29424. */
  29425. getClassName(): string;
  29426. /**
  29427. * Dispose the texture and release its associated resources.
  29428. */
  29429. dispose(): void;
  29430. /**
  29431. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29432. * @param parsedTexture Define the JSON representation of the texture
  29433. * @param scene Define the scene the parsed texture should be instantiated in
  29434. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29435. * @returns The parsed texture if successful
  29436. */
  29437. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29438. /**
  29439. * Creates a texture from its base 64 representation.
  29440. * @param data Define the base64 payload without the data: prefix
  29441. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29442. * @param scene Define the scene the texture should belong to
  29443. * @param noMipmap Forces the texture to not create mip map information if true
  29444. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29445. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29446. * @param onLoad define a callback triggered when the texture has been loaded
  29447. * @param onError define a callback triggered when an error occurred during the loading session
  29448. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29449. * @returns the created texture
  29450. */
  29451. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29452. /**
  29453. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29454. * @param data Define the base64 payload without the data: prefix
  29455. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29456. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29457. * @param scene Define the scene the texture should belong to
  29458. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29459. * @param noMipmap Forces the texture to not create mip map information if true
  29460. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29461. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29462. * @param onLoad define a callback triggered when the texture has been loaded
  29463. * @param onError define a callback triggered when an error occurred during the loading session
  29464. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29465. * @returns the created texture
  29466. */
  29467. 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;
  29468. }
  29469. }
  29470. declare module "babylonjs/PostProcesses/postProcessManager" {
  29471. import { Nullable } from "babylonjs/types";
  29472. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29473. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29474. import { Scene } from "babylonjs/scene";
  29475. /**
  29476. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29477. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29478. */
  29479. export class PostProcessManager {
  29480. private _scene;
  29481. private _indexBuffer;
  29482. private _vertexBuffers;
  29483. /**
  29484. * Creates a new instance PostProcess
  29485. * @param scene The scene that the post process is associated with.
  29486. */
  29487. constructor(scene: Scene);
  29488. private _prepareBuffers;
  29489. private _buildIndexBuffer;
  29490. /**
  29491. * Rebuilds the vertex buffers of the manager.
  29492. * @hidden
  29493. */
  29494. _rebuild(): void;
  29495. /**
  29496. * Prepares a frame to be run through a post process.
  29497. * @param sourceTexture The input texture to the post procesess. (default: null)
  29498. * @param postProcesses An array of post processes to be run. (default: null)
  29499. * @returns True if the post processes were able to be run.
  29500. * @hidden
  29501. */
  29502. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29503. /**
  29504. * Manually render a set of post processes to a texture.
  29505. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29506. * @param postProcesses An array of post processes to be run.
  29507. * @param targetTexture The target texture to render to.
  29508. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29509. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29510. * @param lodLevel defines which lod of the texture to render to
  29511. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29512. */
  29513. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29514. /**
  29515. * Finalize the result of the output of the postprocesses.
  29516. * @param doNotPresent If true the result will not be displayed to the screen.
  29517. * @param targetTexture The target texture to render to.
  29518. * @param faceIndex The index of the face to bind the target texture to.
  29519. * @param postProcesses The array of post processes to render.
  29520. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29521. * @hidden
  29522. */
  29523. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29524. /**
  29525. * Disposes of the post process manager.
  29526. */
  29527. dispose(): void;
  29528. }
  29529. }
  29530. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29531. import { Observable } from "babylonjs/Misc/observable";
  29532. import { SmartArray } from "babylonjs/Misc/smartArray";
  29533. import { Nullable, Immutable } from "babylonjs/types";
  29534. import { Camera } from "babylonjs/Cameras/camera";
  29535. import { Scene } from "babylonjs/scene";
  29536. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29537. import { Color4 } from "babylonjs/Maths/math.color";
  29538. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29540. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29541. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29542. import { Texture } from "babylonjs/Materials/Textures/texture";
  29543. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29544. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29545. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29546. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29547. import { Engine } from "babylonjs/Engines/engine";
  29548. /**
  29549. * This Helps creating a texture that will be created from a camera in your scene.
  29550. * It is basically a dynamic texture that could be used to create special effects for instance.
  29551. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29552. */
  29553. export class RenderTargetTexture extends Texture {
  29554. /**
  29555. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29556. */
  29557. static readonly REFRESHRATE_RENDER_ONCE: number;
  29558. /**
  29559. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29560. */
  29561. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29562. /**
  29563. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29564. * the central point of your effect and can save a lot of performances.
  29565. */
  29566. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29567. /**
  29568. * Use this predicate to dynamically define the list of mesh you want to render.
  29569. * If set, the renderList property will be overwritten.
  29570. */
  29571. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29572. private _renderList;
  29573. /**
  29574. * Use this list to define the list of mesh you want to render.
  29575. */
  29576. get renderList(): Nullable<Array<AbstractMesh>>;
  29577. set renderList(value: Nullable<Array<AbstractMesh>>);
  29578. /**
  29579. * Use this function to overload the renderList array at rendering time.
  29580. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29581. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29582. * the cube (if the RTT is a cube, else layerOrFace=0).
  29583. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29584. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29585. * hold dummy elements!
  29586. */
  29587. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29588. private _hookArray;
  29589. /**
  29590. * Define if particles should be rendered in your texture.
  29591. */
  29592. renderParticles: boolean;
  29593. /**
  29594. * Define if sprites should be rendered in your texture.
  29595. */
  29596. renderSprites: boolean;
  29597. /**
  29598. * Define the camera used to render the texture.
  29599. */
  29600. activeCamera: Nullable<Camera>;
  29601. /**
  29602. * Override the mesh isReady function with your own one.
  29603. */
  29604. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29605. /**
  29606. * Override the render function of the texture with your own one.
  29607. */
  29608. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29609. /**
  29610. * Define if camera post processes should be use while rendering the texture.
  29611. */
  29612. useCameraPostProcesses: boolean;
  29613. /**
  29614. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29615. */
  29616. ignoreCameraViewport: boolean;
  29617. private _postProcessManager;
  29618. private _postProcesses;
  29619. private _resizeObserver;
  29620. /**
  29621. * An event triggered when the texture is unbind.
  29622. */
  29623. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29624. /**
  29625. * An event triggered when the texture is unbind.
  29626. */
  29627. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29628. private _onAfterUnbindObserver;
  29629. /**
  29630. * Set a after unbind callback in the texture.
  29631. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29632. */
  29633. set onAfterUnbind(callback: () => void);
  29634. /**
  29635. * An event triggered before rendering the texture
  29636. */
  29637. onBeforeRenderObservable: Observable<number>;
  29638. private _onBeforeRenderObserver;
  29639. /**
  29640. * Set a before render callback in the texture.
  29641. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29642. */
  29643. set onBeforeRender(callback: (faceIndex: number) => void);
  29644. /**
  29645. * An event triggered after rendering the texture
  29646. */
  29647. onAfterRenderObservable: Observable<number>;
  29648. private _onAfterRenderObserver;
  29649. /**
  29650. * Set a after render callback in the texture.
  29651. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29652. */
  29653. set onAfterRender(callback: (faceIndex: number) => void);
  29654. /**
  29655. * An event triggered after the texture clear
  29656. */
  29657. onClearObservable: Observable<Engine>;
  29658. private _onClearObserver;
  29659. /**
  29660. * Set a clear callback in the texture.
  29661. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29662. */
  29663. set onClear(callback: (Engine: Engine) => void);
  29664. /**
  29665. * An event triggered when the texture is resized.
  29666. */
  29667. onResizeObservable: Observable<RenderTargetTexture>;
  29668. /**
  29669. * Define the clear color of the Render Target if it should be different from the scene.
  29670. */
  29671. clearColor: Color4;
  29672. protected _size: number | {
  29673. width: number;
  29674. height: number;
  29675. layers?: number;
  29676. };
  29677. protected _initialSizeParameter: number | {
  29678. width: number;
  29679. height: number;
  29680. } | {
  29681. ratio: number;
  29682. };
  29683. protected _sizeRatio: Nullable<number>;
  29684. /** @hidden */
  29685. _generateMipMaps: boolean;
  29686. protected _renderingManager: RenderingManager;
  29687. /** @hidden */
  29688. _waitingRenderList?: string[];
  29689. protected _doNotChangeAspectRatio: boolean;
  29690. protected _currentRefreshId: number;
  29691. protected _refreshRate: number;
  29692. protected _textureMatrix: Matrix;
  29693. protected _samples: number;
  29694. protected _renderTargetOptions: RenderTargetCreationOptions;
  29695. /**
  29696. * Gets render target creation options that were used.
  29697. */
  29698. get renderTargetOptions(): RenderTargetCreationOptions;
  29699. protected _onRatioRescale(): void;
  29700. /**
  29701. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29702. * It must define where the camera used to render the texture is set
  29703. */
  29704. boundingBoxPosition: Vector3;
  29705. private _boundingBoxSize;
  29706. /**
  29707. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29708. * When defined, the cubemap will switch to local mode
  29709. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29710. * @example https://www.babylonjs-playground.com/#RNASML
  29711. */
  29712. set boundingBoxSize(value: Vector3);
  29713. get boundingBoxSize(): Vector3;
  29714. /**
  29715. * In case the RTT has been created with a depth texture, get the associated
  29716. * depth texture.
  29717. * Otherwise, return null.
  29718. */
  29719. get depthStencilTexture(): Nullable<InternalTexture>;
  29720. /**
  29721. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  29722. * or used a shadow, depth texture...
  29723. * @param name The friendly name of the texture
  29724. * @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)
  29725. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  29726. * @param generateMipMaps True if mip maps need to be generated after render.
  29727. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  29728. * @param type The type of the buffer in the RTT (int, half float, float...)
  29729. * @param isCube True if a cube texture needs to be created
  29730. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  29731. * @param generateDepthBuffer True to generate a depth buffer
  29732. * @param generateStencilBuffer True to generate a stencil buffer
  29733. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  29734. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  29735. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29736. */
  29737. constructor(name: string, size: number | {
  29738. width: number;
  29739. height: number;
  29740. layers?: number;
  29741. } | {
  29742. ratio: number;
  29743. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  29744. /**
  29745. * Creates a depth stencil texture.
  29746. * This is only available in WebGL 2 or with the depth texture extension available.
  29747. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  29748. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  29749. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  29750. */
  29751. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  29752. private _processSizeParameter;
  29753. /**
  29754. * Define the number of samples to use in case of MSAA.
  29755. * It defaults to one meaning no MSAA has been enabled.
  29756. */
  29757. get samples(): number;
  29758. set samples(value: number);
  29759. /**
  29760. * Resets the refresh counter of the texture and start bak from scratch.
  29761. * Could be useful to regenerate the texture if it is setup to render only once.
  29762. */
  29763. resetRefreshCounter(): void;
  29764. /**
  29765. * Define the refresh rate of the texture or the rendering frequency.
  29766. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  29767. */
  29768. get refreshRate(): number;
  29769. set refreshRate(value: number);
  29770. /**
  29771. * Adds a post process to the render target rendering passes.
  29772. * @param postProcess define the post process to add
  29773. */
  29774. addPostProcess(postProcess: PostProcess): void;
  29775. /**
  29776. * Clear all the post processes attached to the render target
  29777. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  29778. */
  29779. clearPostProcesses(dispose?: boolean): void;
  29780. /**
  29781. * Remove one of the post process from the list of attached post processes to the texture
  29782. * @param postProcess define the post process to remove from the list
  29783. */
  29784. removePostProcess(postProcess: PostProcess): void;
  29785. /** @hidden */
  29786. _shouldRender(): boolean;
  29787. /**
  29788. * Gets the actual render size of the texture.
  29789. * @returns the width of the render size
  29790. */
  29791. getRenderSize(): number;
  29792. /**
  29793. * Gets the actual render width of the texture.
  29794. * @returns the width of the render size
  29795. */
  29796. getRenderWidth(): number;
  29797. /**
  29798. * Gets the actual render height of the texture.
  29799. * @returns the height of the render size
  29800. */
  29801. getRenderHeight(): number;
  29802. /**
  29803. * Gets the actual number of layers of the texture.
  29804. * @returns the number of layers
  29805. */
  29806. getRenderLayers(): number;
  29807. /**
  29808. * Get if the texture can be rescaled or not.
  29809. */
  29810. get canRescale(): boolean;
  29811. /**
  29812. * Resize the texture using a ratio.
  29813. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  29814. */
  29815. scale(ratio: number): void;
  29816. /**
  29817. * Get the texture reflection matrix used to rotate/transform the reflection.
  29818. * @returns the reflection matrix
  29819. */
  29820. getReflectionTextureMatrix(): Matrix;
  29821. /**
  29822. * Resize the texture to a new desired size.
  29823. * Be carrefull as it will recreate all the data in the new texture.
  29824. * @param size Define the new size. It can be:
  29825. * - a number for squared texture,
  29826. * - an object containing { width: number, height: number }
  29827. * - or an object containing a ratio { ratio: number }
  29828. */
  29829. resize(size: number | {
  29830. width: number;
  29831. height: number;
  29832. } | {
  29833. ratio: number;
  29834. }): void;
  29835. private _defaultRenderListPrepared;
  29836. /**
  29837. * Renders all the objects from the render list into the texture.
  29838. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  29839. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  29840. */
  29841. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  29842. private _bestReflectionRenderTargetDimension;
  29843. private _prepareRenderingManager;
  29844. /**
  29845. * @hidden
  29846. * @param faceIndex face index to bind to if this is a cubetexture
  29847. * @param layer defines the index of the texture to bind in the array
  29848. */
  29849. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  29850. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  29851. private renderToTarget;
  29852. /**
  29853. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29854. * This allowed control for front to back rendering or reversly depending of the special needs.
  29855. *
  29856. * @param renderingGroupId The rendering group id corresponding to its index
  29857. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29858. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29859. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29860. */
  29861. 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;
  29862. /**
  29863. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29864. *
  29865. * @param renderingGroupId The rendering group id corresponding to its index
  29866. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29867. */
  29868. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  29869. /**
  29870. * Clones the texture.
  29871. * @returns the cloned texture
  29872. */
  29873. clone(): RenderTargetTexture;
  29874. /**
  29875. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29876. * @returns The JSON representation of the texture
  29877. */
  29878. serialize(): any;
  29879. /**
  29880. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  29881. */
  29882. disposeFramebufferObjects(): void;
  29883. /**
  29884. * Dispose the texture and release its associated resources.
  29885. */
  29886. dispose(): void;
  29887. /** @hidden */
  29888. _rebuild(): void;
  29889. /**
  29890. * Clear the info related to rendering groups preventing retention point in material dispose.
  29891. */
  29892. freeRenderingGroups(): void;
  29893. /**
  29894. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29895. * @returns the view count
  29896. */
  29897. getViewCount(): number;
  29898. }
  29899. }
  29900. declare module "babylonjs/Misc/guid" {
  29901. /**
  29902. * Class used to manipulate GUIDs
  29903. */
  29904. export class GUID {
  29905. /**
  29906. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29907. * Be aware Math.random() could cause collisions, but:
  29908. * "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"
  29909. * @returns a pseudo random id
  29910. */
  29911. static RandomId(): string;
  29912. }
  29913. }
  29914. declare module "babylonjs/Materials/shadowDepthWrapper" {
  29915. import { Nullable } from "babylonjs/types";
  29916. import { Scene } from "babylonjs/scene";
  29917. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29918. import { Material } from "babylonjs/Materials/material";
  29919. import { Effect } from "babylonjs/Materials/effect";
  29920. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  29921. /**
  29922. * Options to be used when creating a shadow depth material
  29923. */
  29924. export interface IIOptionShadowDepthMaterial {
  29925. /** Variables in the vertex shader code that need to have their names remapped.
  29926. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29927. * "var_name" should be either: worldPos or vNormalW
  29928. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29929. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29930. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29931. */
  29932. remappedVariables?: string[];
  29933. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29934. standalone?: boolean;
  29935. }
  29936. /**
  29937. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29938. */
  29939. export class ShadowDepthWrapper {
  29940. private _scene;
  29941. private _options?;
  29942. private _baseMaterial;
  29943. private _onEffectCreatedObserver;
  29944. private _subMeshToEffect;
  29945. private _subMeshToDepthEffect;
  29946. private _meshes;
  29947. /** @hidden */
  29948. _matriceNames: any;
  29949. /** Gets the standalone status of the wrapper */
  29950. get standalone(): boolean;
  29951. /** Gets the base material the wrapper is built upon */
  29952. get baseMaterial(): Material;
  29953. /**
  29954. * Instantiate a new shadow depth wrapper.
  29955. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29956. * generate the shadow depth map. For more information, please refer to the documentation:
  29957. * https://doc.babylonjs.com/babylon101/shadows
  29958. * @param baseMaterial Material to wrap
  29959. * @param scene Define the scene the material belongs to
  29960. * @param options Options used to create the wrapper
  29961. */
  29962. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29963. /**
  29964. * Gets the effect to use to generate the depth map
  29965. * @param subMesh subMesh to get the effect for
  29966. * @param shadowGenerator shadow generator to get the effect for
  29967. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29968. */
  29969. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29970. /**
  29971. * Specifies that the submesh is ready to be used for depth rendering
  29972. * @param subMesh submesh to check
  29973. * @param defines the list of defines to take into account when checking the effect
  29974. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29975. * @param useInstances specifies that instances should be used
  29976. * @returns a boolean indicating that the submesh is ready or not
  29977. */
  29978. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29979. /**
  29980. * Disposes the resources
  29981. */
  29982. dispose(): void;
  29983. private _makeEffect;
  29984. }
  29985. }
  29986. declare module "babylonjs/Materials/material" {
  29987. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29988. import { SmartArray } from "babylonjs/Misc/smartArray";
  29989. import { Observable } from "babylonjs/Misc/observable";
  29990. import { Nullable } from "babylonjs/types";
  29991. import { Scene } from "babylonjs/scene";
  29992. import { Matrix } from "babylonjs/Maths/math.vector";
  29993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29995. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29996. import { Effect } from "babylonjs/Materials/effect";
  29997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29998. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29999. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30000. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30001. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30002. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30003. import { Mesh } from "babylonjs/Meshes/mesh";
  30004. import { Animation } from "babylonjs/Animations/animation";
  30005. /**
  30006. * Options for compiling materials.
  30007. */
  30008. export interface IMaterialCompilationOptions {
  30009. /**
  30010. * Defines whether clip planes are enabled.
  30011. */
  30012. clipPlane: boolean;
  30013. /**
  30014. * Defines whether instances are enabled.
  30015. */
  30016. useInstances: boolean;
  30017. }
  30018. /**
  30019. * Options passed when calling customShaderNameResolve
  30020. */
  30021. export interface ICustomShaderNameResolveOptions {
  30022. /**
  30023. * 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
  30024. */
  30025. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30026. }
  30027. /**
  30028. * Base class for the main features of a material in Babylon.js
  30029. */
  30030. export class Material implements IAnimatable {
  30031. /**
  30032. * Returns the triangle fill mode
  30033. */
  30034. static readonly TriangleFillMode: number;
  30035. /**
  30036. * Returns the wireframe mode
  30037. */
  30038. static readonly WireFrameFillMode: number;
  30039. /**
  30040. * Returns the point fill mode
  30041. */
  30042. static readonly PointFillMode: number;
  30043. /**
  30044. * Returns the point list draw mode
  30045. */
  30046. static readonly PointListDrawMode: number;
  30047. /**
  30048. * Returns the line list draw mode
  30049. */
  30050. static readonly LineListDrawMode: number;
  30051. /**
  30052. * Returns the line loop draw mode
  30053. */
  30054. static readonly LineLoopDrawMode: number;
  30055. /**
  30056. * Returns the line strip draw mode
  30057. */
  30058. static readonly LineStripDrawMode: number;
  30059. /**
  30060. * Returns the triangle strip draw mode
  30061. */
  30062. static readonly TriangleStripDrawMode: number;
  30063. /**
  30064. * Returns the triangle fan draw mode
  30065. */
  30066. static readonly TriangleFanDrawMode: number;
  30067. /**
  30068. * Stores the clock-wise side orientation
  30069. */
  30070. static readonly ClockWiseSideOrientation: number;
  30071. /**
  30072. * Stores the counter clock-wise side orientation
  30073. */
  30074. static readonly CounterClockWiseSideOrientation: number;
  30075. /**
  30076. * The dirty texture flag value
  30077. */
  30078. static readonly TextureDirtyFlag: number;
  30079. /**
  30080. * The dirty light flag value
  30081. */
  30082. static readonly LightDirtyFlag: number;
  30083. /**
  30084. * The dirty fresnel flag value
  30085. */
  30086. static readonly FresnelDirtyFlag: number;
  30087. /**
  30088. * The dirty attribute flag value
  30089. */
  30090. static readonly AttributesDirtyFlag: number;
  30091. /**
  30092. * The dirty misc flag value
  30093. */
  30094. static readonly MiscDirtyFlag: number;
  30095. /**
  30096. * The dirty prepass flag value
  30097. */
  30098. static readonly PrePassDirtyFlag: number;
  30099. /**
  30100. * The all dirty flag value
  30101. */
  30102. static readonly AllDirtyFlag: number;
  30103. /**
  30104. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30105. */
  30106. static readonly MATERIAL_OPAQUE: number;
  30107. /**
  30108. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30109. */
  30110. static readonly MATERIAL_ALPHATEST: number;
  30111. /**
  30112. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30113. */
  30114. static readonly MATERIAL_ALPHABLEND: number;
  30115. /**
  30116. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30117. * They are also discarded below the alpha cutoff threshold to improve performances.
  30118. */
  30119. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30120. /**
  30121. * The Whiteout method is used to blend normals.
  30122. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30123. */
  30124. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30125. /**
  30126. * The Reoriented Normal Mapping method is used to blend normals.
  30127. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30128. */
  30129. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30130. /**
  30131. * Custom callback helping to override the default shader used in the material.
  30132. */
  30133. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30134. /**
  30135. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30136. */
  30137. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30138. /**
  30139. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30140. * This means that the material can keep using a previous shader while a new one is being compiled.
  30141. * This is mostly used when shader parallel compilation is supported (true by default)
  30142. */
  30143. allowShaderHotSwapping: boolean;
  30144. /**
  30145. * The ID of the material
  30146. */
  30147. id: string;
  30148. /**
  30149. * Gets or sets the unique id of the material
  30150. */
  30151. uniqueId: number;
  30152. /**
  30153. * The name of the material
  30154. */
  30155. name: string;
  30156. /**
  30157. * Gets or sets user defined metadata
  30158. */
  30159. metadata: any;
  30160. /**
  30161. * For internal use only. Please do not use.
  30162. */
  30163. reservedDataStore: any;
  30164. /**
  30165. * Specifies if the ready state should be checked on each call
  30166. */
  30167. checkReadyOnEveryCall: boolean;
  30168. /**
  30169. * Specifies if the ready state should be checked once
  30170. */
  30171. checkReadyOnlyOnce: boolean;
  30172. /**
  30173. * The state of the material
  30174. */
  30175. state: string;
  30176. /**
  30177. * If the material can be rendered to several textures with MRT extension
  30178. */
  30179. get canRenderToMRT(): boolean;
  30180. /**
  30181. * The alpha value of the material
  30182. */
  30183. protected _alpha: number;
  30184. /**
  30185. * List of inspectable custom properties (used by the Inspector)
  30186. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30187. */
  30188. inspectableCustomProperties: IInspectable[];
  30189. /**
  30190. * Sets the alpha value of the material
  30191. */
  30192. set alpha(value: number);
  30193. /**
  30194. * Gets the alpha value of the material
  30195. */
  30196. get alpha(): number;
  30197. /**
  30198. * Specifies if back face culling is enabled
  30199. */
  30200. protected _backFaceCulling: boolean;
  30201. /**
  30202. * Sets the back-face culling state
  30203. */
  30204. set backFaceCulling(value: boolean);
  30205. /**
  30206. * Gets the back-face culling state
  30207. */
  30208. get backFaceCulling(): boolean;
  30209. /**
  30210. * Stores the value for side orientation
  30211. */
  30212. sideOrientation: number;
  30213. /**
  30214. * Callback triggered when the material is compiled
  30215. */
  30216. onCompiled: Nullable<(effect: Effect) => void>;
  30217. /**
  30218. * Callback triggered when an error occurs
  30219. */
  30220. onError: Nullable<(effect: Effect, errors: string) => void>;
  30221. /**
  30222. * Callback triggered to get the render target textures
  30223. */
  30224. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30225. /**
  30226. * Gets a boolean indicating that current material needs to register RTT
  30227. */
  30228. get hasRenderTargetTextures(): boolean;
  30229. /**
  30230. * Specifies if the material should be serialized
  30231. */
  30232. doNotSerialize: boolean;
  30233. /**
  30234. * @hidden
  30235. */
  30236. _storeEffectOnSubMeshes: boolean;
  30237. /**
  30238. * Stores the animations for the material
  30239. */
  30240. animations: Nullable<Array<Animation>>;
  30241. /**
  30242. * An event triggered when the material is disposed
  30243. */
  30244. onDisposeObservable: Observable<Material>;
  30245. /**
  30246. * An observer which watches for dispose events
  30247. */
  30248. private _onDisposeObserver;
  30249. private _onUnBindObservable;
  30250. /**
  30251. * Called during a dispose event
  30252. */
  30253. set onDispose(callback: () => void);
  30254. private _onBindObservable;
  30255. /**
  30256. * An event triggered when the material is bound
  30257. */
  30258. get onBindObservable(): Observable<AbstractMesh>;
  30259. /**
  30260. * An observer which watches for bind events
  30261. */
  30262. private _onBindObserver;
  30263. /**
  30264. * Called during a bind event
  30265. */
  30266. set onBind(callback: (Mesh: AbstractMesh) => void);
  30267. /**
  30268. * An event triggered when the material is unbound
  30269. */
  30270. get onUnBindObservable(): Observable<Material>;
  30271. protected _onEffectCreatedObservable: Nullable<Observable<{
  30272. effect: Effect;
  30273. subMesh: Nullable<SubMesh>;
  30274. }>>;
  30275. /**
  30276. * An event triggered when the effect is (re)created
  30277. */
  30278. get onEffectCreatedObservable(): Observable<{
  30279. effect: Effect;
  30280. subMesh: Nullable<SubMesh>;
  30281. }>;
  30282. /**
  30283. * Stores the value of the alpha mode
  30284. */
  30285. private _alphaMode;
  30286. /**
  30287. * Sets the value of the alpha mode.
  30288. *
  30289. * | Value | Type | Description |
  30290. * | --- | --- | --- |
  30291. * | 0 | ALPHA_DISABLE | |
  30292. * | 1 | ALPHA_ADD | |
  30293. * | 2 | ALPHA_COMBINE | |
  30294. * | 3 | ALPHA_SUBTRACT | |
  30295. * | 4 | ALPHA_MULTIPLY | |
  30296. * | 5 | ALPHA_MAXIMIZED | |
  30297. * | 6 | ALPHA_ONEONE | |
  30298. * | 7 | ALPHA_PREMULTIPLIED | |
  30299. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30300. * | 9 | ALPHA_INTERPOLATE | |
  30301. * | 10 | ALPHA_SCREENMODE | |
  30302. *
  30303. */
  30304. set alphaMode(value: number);
  30305. /**
  30306. * Gets the value of the alpha mode
  30307. */
  30308. get alphaMode(): number;
  30309. /**
  30310. * Stores the state of the need depth pre-pass value
  30311. */
  30312. private _needDepthPrePass;
  30313. /**
  30314. * Sets the need depth pre-pass value
  30315. */
  30316. set needDepthPrePass(value: boolean);
  30317. /**
  30318. * Gets the depth pre-pass value
  30319. */
  30320. get needDepthPrePass(): boolean;
  30321. /**
  30322. * Specifies if depth writing should be disabled
  30323. */
  30324. disableDepthWrite: boolean;
  30325. /**
  30326. * Specifies if color writing should be disabled
  30327. */
  30328. disableColorWrite: boolean;
  30329. /**
  30330. * Specifies if depth writing should be forced
  30331. */
  30332. forceDepthWrite: boolean;
  30333. /**
  30334. * Specifies the depth function that should be used. 0 means the default engine function
  30335. */
  30336. depthFunction: number;
  30337. /**
  30338. * Specifies if there should be a separate pass for culling
  30339. */
  30340. separateCullingPass: boolean;
  30341. /**
  30342. * Stores the state specifing if fog should be enabled
  30343. */
  30344. private _fogEnabled;
  30345. /**
  30346. * Sets the state for enabling fog
  30347. */
  30348. set fogEnabled(value: boolean);
  30349. /**
  30350. * Gets the value of the fog enabled state
  30351. */
  30352. get fogEnabled(): boolean;
  30353. /**
  30354. * Stores the size of points
  30355. */
  30356. pointSize: number;
  30357. /**
  30358. * Stores the z offset value
  30359. */
  30360. zOffset: number;
  30361. get wireframe(): boolean;
  30362. /**
  30363. * Sets the state of wireframe mode
  30364. */
  30365. set wireframe(value: boolean);
  30366. /**
  30367. * Gets the value specifying if point clouds are enabled
  30368. */
  30369. get pointsCloud(): boolean;
  30370. /**
  30371. * Sets the state of point cloud mode
  30372. */
  30373. set pointsCloud(value: boolean);
  30374. /**
  30375. * Gets the material fill mode
  30376. */
  30377. get fillMode(): number;
  30378. /**
  30379. * Sets the material fill mode
  30380. */
  30381. set fillMode(value: number);
  30382. /**
  30383. * @hidden
  30384. * Stores the effects for the material
  30385. */
  30386. _effect: Nullable<Effect>;
  30387. /**
  30388. * Specifies if uniform buffers should be used
  30389. */
  30390. private _useUBO;
  30391. /**
  30392. * Stores a reference to the scene
  30393. */
  30394. private _scene;
  30395. /**
  30396. * Stores the fill mode state
  30397. */
  30398. private _fillMode;
  30399. /**
  30400. * Specifies if the depth write state should be cached
  30401. */
  30402. private _cachedDepthWriteState;
  30403. /**
  30404. * Specifies if the color write state should be cached
  30405. */
  30406. private _cachedColorWriteState;
  30407. /**
  30408. * Specifies if the depth function state should be cached
  30409. */
  30410. private _cachedDepthFunctionState;
  30411. /**
  30412. * Stores the uniform buffer
  30413. */
  30414. protected _uniformBuffer: UniformBuffer;
  30415. /** @hidden */
  30416. _indexInSceneMaterialArray: number;
  30417. /** @hidden */
  30418. meshMap: Nullable<{
  30419. [id: string]: AbstractMesh | undefined;
  30420. }>;
  30421. /**
  30422. * Creates a material instance
  30423. * @param name defines the name of the material
  30424. * @param scene defines the scene to reference
  30425. * @param doNotAdd specifies if the material should be added to the scene
  30426. */
  30427. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30428. /**
  30429. * Returns a string representation of the current material
  30430. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30431. * @returns a string with material information
  30432. */
  30433. toString(fullDetails?: boolean): string;
  30434. /**
  30435. * Gets the class name of the material
  30436. * @returns a string with the class name of the material
  30437. */
  30438. getClassName(): string;
  30439. /**
  30440. * Specifies if updates for the material been locked
  30441. */
  30442. get isFrozen(): boolean;
  30443. /**
  30444. * Locks updates for the material
  30445. */
  30446. freeze(): void;
  30447. /**
  30448. * Unlocks updates for the material
  30449. */
  30450. unfreeze(): void;
  30451. /**
  30452. * Specifies if the material is ready to be used
  30453. * @param mesh defines the mesh to check
  30454. * @param useInstances specifies if instances should be used
  30455. * @returns a boolean indicating if the material is ready to be used
  30456. */
  30457. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30458. /**
  30459. * Specifies that the submesh is ready to be used
  30460. * @param mesh defines the mesh to check
  30461. * @param subMesh defines which submesh to check
  30462. * @param useInstances specifies that instances should be used
  30463. * @returns a boolean indicating that the submesh is ready or not
  30464. */
  30465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30466. /**
  30467. * Returns the material effect
  30468. * @returns the effect associated with the material
  30469. */
  30470. getEffect(): Nullable<Effect>;
  30471. /**
  30472. * Returns the current scene
  30473. * @returns a Scene
  30474. */
  30475. getScene(): Scene;
  30476. /**
  30477. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30478. */
  30479. protected _forceAlphaTest: boolean;
  30480. /**
  30481. * The transparency mode of the material.
  30482. */
  30483. protected _transparencyMode: Nullable<number>;
  30484. /**
  30485. * Gets the current transparency mode.
  30486. */
  30487. get transparencyMode(): Nullable<number>;
  30488. /**
  30489. * Sets the transparency mode of the material.
  30490. *
  30491. * | Value | Type | Description |
  30492. * | ----- | ----------------------------------- | ----------- |
  30493. * | 0 | OPAQUE | |
  30494. * | 1 | ALPHATEST | |
  30495. * | 2 | ALPHABLEND | |
  30496. * | 3 | ALPHATESTANDBLEND | |
  30497. *
  30498. */
  30499. set transparencyMode(value: Nullable<number>);
  30500. /**
  30501. * Returns true if alpha blending should be disabled.
  30502. */
  30503. protected get _disableAlphaBlending(): boolean;
  30504. /**
  30505. * Specifies whether or not this material should be rendered in alpha blend mode.
  30506. * @returns a boolean specifying if alpha blending is needed
  30507. */
  30508. needAlphaBlending(): boolean;
  30509. /**
  30510. * Specifies if the mesh will require alpha blending
  30511. * @param mesh defines the mesh to check
  30512. * @returns a boolean specifying if alpha blending is needed for the mesh
  30513. */
  30514. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30515. /**
  30516. * Specifies whether or not this material should be rendered in alpha test mode.
  30517. * @returns a boolean specifying if an alpha test is needed.
  30518. */
  30519. needAlphaTesting(): boolean;
  30520. /**
  30521. * Specifies if material alpha testing should be turned on for the mesh
  30522. * @param mesh defines the mesh to check
  30523. */
  30524. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30525. /**
  30526. * Gets the texture used for the alpha test
  30527. * @returns the texture to use for alpha testing
  30528. */
  30529. getAlphaTestTexture(): Nullable<BaseTexture>;
  30530. /**
  30531. * Marks the material to indicate that it needs to be re-calculated
  30532. */
  30533. markDirty(): void;
  30534. /** @hidden */
  30535. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30536. /**
  30537. * Binds the material to the mesh
  30538. * @param world defines the world transformation matrix
  30539. * @param mesh defines the mesh to bind the material to
  30540. */
  30541. bind(world: Matrix, mesh?: Mesh): void;
  30542. /**
  30543. * Binds the submesh to the material
  30544. * @param world defines the world transformation matrix
  30545. * @param mesh defines the mesh containing the submesh
  30546. * @param subMesh defines the submesh to bind the material to
  30547. */
  30548. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30549. /**
  30550. * Binds the world matrix to the material
  30551. * @param world defines the world transformation matrix
  30552. */
  30553. bindOnlyWorldMatrix(world: Matrix): void;
  30554. /**
  30555. * Binds the scene's uniform buffer to the effect.
  30556. * @param effect defines the effect to bind to the scene uniform buffer
  30557. * @param sceneUbo defines the uniform buffer storing scene data
  30558. */
  30559. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30560. /**
  30561. * Binds the view matrix to the effect
  30562. * @param effect defines the effect to bind the view matrix to
  30563. */
  30564. bindView(effect: Effect): void;
  30565. /**
  30566. * Binds the view projection matrix to the effect
  30567. * @param effect defines the effect to bind the view projection matrix to
  30568. */
  30569. bindViewProjection(effect: Effect): void;
  30570. /**
  30571. * Processes to execute after binding the material to a mesh
  30572. * @param mesh defines the rendered mesh
  30573. */
  30574. protected _afterBind(mesh?: Mesh): void;
  30575. /**
  30576. * Unbinds the material from the mesh
  30577. */
  30578. unbind(): void;
  30579. /**
  30580. * Gets the active textures from the material
  30581. * @returns an array of textures
  30582. */
  30583. getActiveTextures(): BaseTexture[];
  30584. /**
  30585. * Specifies if the material uses a texture
  30586. * @param texture defines the texture to check against the material
  30587. * @returns a boolean specifying if the material uses the texture
  30588. */
  30589. hasTexture(texture: BaseTexture): boolean;
  30590. /**
  30591. * Makes a duplicate of the material, and gives it a new name
  30592. * @param name defines the new name for the duplicated material
  30593. * @returns the cloned material
  30594. */
  30595. clone(name: string): Nullable<Material>;
  30596. /**
  30597. * Gets the meshes bound to the material
  30598. * @returns an array of meshes bound to the material
  30599. */
  30600. getBindedMeshes(): AbstractMesh[];
  30601. /**
  30602. * Force shader compilation
  30603. * @param mesh defines the mesh associated with this material
  30604. * @param onCompiled defines a function to execute once the material is compiled
  30605. * @param options defines the options to configure the compilation
  30606. * @param onError defines a function to execute if the material fails compiling
  30607. */
  30608. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30609. /**
  30610. * Force shader compilation
  30611. * @param mesh defines the mesh that will use this material
  30612. * @param options defines additional options for compiling the shaders
  30613. * @returns a promise that resolves when the compilation completes
  30614. */
  30615. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30616. private static readonly _AllDirtyCallBack;
  30617. private static readonly _ImageProcessingDirtyCallBack;
  30618. private static readonly _TextureDirtyCallBack;
  30619. private static readonly _FresnelDirtyCallBack;
  30620. private static readonly _MiscDirtyCallBack;
  30621. private static readonly _PrePassDirtyCallBack;
  30622. private static readonly _LightsDirtyCallBack;
  30623. private static readonly _AttributeDirtyCallBack;
  30624. private static _FresnelAndMiscDirtyCallBack;
  30625. private static _TextureAndMiscDirtyCallBack;
  30626. private static readonly _DirtyCallbackArray;
  30627. private static readonly _RunDirtyCallBacks;
  30628. /**
  30629. * Marks a define in the material to indicate that it needs to be re-computed
  30630. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30631. */
  30632. markAsDirty(flag: number): void;
  30633. /**
  30634. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30635. * @param func defines a function which checks material defines against the submeshes
  30636. */
  30637. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30638. /**
  30639. * Indicates that the scene should check if the rendering now needs a prepass
  30640. */
  30641. protected _markScenePrePassDirty(): void;
  30642. /**
  30643. * Indicates that we need to re-calculated for all submeshes
  30644. */
  30645. protected _markAllSubMeshesAsAllDirty(): void;
  30646. /**
  30647. * Indicates that image processing needs to be re-calculated for all submeshes
  30648. */
  30649. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30650. /**
  30651. * Indicates that textures need to be re-calculated for all submeshes
  30652. */
  30653. protected _markAllSubMeshesAsTexturesDirty(): void;
  30654. /**
  30655. * Indicates that fresnel needs to be re-calculated for all submeshes
  30656. */
  30657. protected _markAllSubMeshesAsFresnelDirty(): void;
  30658. /**
  30659. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30660. */
  30661. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30662. /**
  30663. * Indicates that lights need to be re-calculated for all submeshes
  30664. */
  30665. protected _markAllSubMeshesAsLightsDirty(): void;
  30666. /**
  30667. * Indicates that attributes need to be re-calculated for all submeshes
  30668. */
  30669. protected _markAllSubMeshesAsAttributesDirty(): void;
  30670. /**
  30671. * Indicates that misc needs to be re-calculated for all submeshes
  30672. */
  30673. protected _markAllSubMeshesAsMiscDirty(): void;
  30674. /**
  30675. * Indicates that prepass needs to be re-calculated for all submeshes
  30676. */
  30677. protected _markAllSubMeshesAsPrePassDirty(): void;
  30678. /**
  30679. * Indicates that textures and misc need to be re-calculated for all submeshes
  30680. */
  30681. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30682. /**
  30683. * Sets the required values to the prepass renderer.
  30684. * @param prePassRenderer defines the prepass renderer to setup.
  30685. * @returns true if the pre pass is needed.
  30686. */
  30687. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30688. /**
  30689. * Disposes the material
  30690. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30691. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30692. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30693. */
  30694. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30695. /** @hidden */
  30696. private releaseVertexArrayObject;
  30697. /**
  30698. * Serializes this material
  30699. * @returns the serialized material object
  30700. */
  30701. serialize(): any;
  30702. /**
  30703. * Creates a material from parsed material data
  30704. * @param parsedMaterial defines parsed material data
  30705. * @param scene defines the hosting scene
  30706. * @param rootUrl defines the root URL to use to load textures
  30707. * @returns a new material
  30708. */
  30709. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30710. }
  30711. }
  30712. declare module "babylonjs/Materials/multiMaterial" {
  30713. import { Nullable } from "babylonjs/types";
  30714. import { Scene } from "babylonjs/scene";
  30715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30716. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30717. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30718. import { Material } from "babylonjs/Materials/material";
  30719. /**
  30720. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30721. * separate meshes. This can be use to improve performances.
  30722. * @see https://doc.babylonjs.com/how_to/multi_materials
  30723. */
  30724. export class MultiMaterial extends Material {
  30725. private _subMaterials;
  30726. /**
  30727. * Gets or Sets the list of Materials used within the multi material.
  30728. * They need to be ordered according to the submeshes order in the associated mesh
  30729. */
  30730. get subMaterials(): Nullable<Material>[];
  30731. set subMaterials(value: Nullable<Material>[]);
  30732. /**
  30733. * Function used to align with Node.getChildren()
  30734. * @returns the list of Materials used within the multi material
  30735. */
  30736. getChildren(): Nullable<Material>[];
  30737. /**
  30738. * Instantiates a new Multi Material
  30739. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30740. * separate meshes. This can be use to improve performances.
  30741. * @see https://doc.babylonjs.com/how_to/multi_materials
  30742. * @param name Define the name in the scene
  30743. * @param scene Define the scene the material belongs to
  30744. */
  30745. constructor(name: string, scene: Scene);
  30746. private _hookArray;
  30747. /**
  30748. * Get one of the submaterial by its index in the submaterials array
  30749. * @param index The index to look the sub material at
  30750. * @returns The Material if the index has been defined
  30751. */
  30752. getSubMaterial(index: number): Nullable<Material>;
  30753. /**
  30754. * Get the list of active textures for the whole sub materials list.
  30755. * @returns All the textures that will be used during the rendering
  30756. */
  30757. getActiveTextures(): BaseTexture[];
  30758. /**
  30759. * Gets the current class name of the material e.g. "MultiMaterial"
  30760. * Mainly use in serialization.
  30761. * @returns the class name
  30762. */
  30763. getClassName(): string;
  30764. /**
  30765. * Checks if the material is ready to render the requested sub mesh
  30766. * @param mesh Define the mesh the submesh belongs to
  30767. * @param subMesh Define the sub mesh to look readyness for
  30768. * @param useInstances Define whether or not the material is used with instances
  30769. * @returns true if ready, otherwise false
  30770. */
  30771. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30772. /**
  30773. * Clones the current material and its related sub materials
  30774. * @param name Define the name of the newly cloned material
  30775. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30776. * @returns the cloned material
  30777. */
  30778. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30779. /**
  30780. * Serializes the materials into a JSON representation.
  30781. * @returns the JSON representation
  30782. */
  30783. serialize(): any;
  30784. /**
  30785. * Dispose the material and release its associated resources
  30786. * @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)
  30787. * @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)
  30788. * @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)
  30789. */
  30790. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30791. /**
  30792. * Creates a MultiMaterial from parsed MultiMaterial data.
  30793. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30794. * @param scene defines the hosting scene
  30795. * @returns a new MultiMaterial
  30796. */
  30797. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30798. }
  30799. }
  30800. declare module "babylonjs/Meshes/subMesh" {
  30801. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  30802. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30803. import { Engine } from "babylonjs/Engines/engine";
  30804. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  30805. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  30806. import { Effect } from "babylonjs/Materials/effect";
  30807. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30808. import { Plane } from "babylonjs/Maths/math.plane";
  30809. import { Collider } from "babylonjs/Collisions/collider";
  30810. import { Material } from "babylonjs/Materials/material";
  30811. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30813. import { Mesh } from "babylonjs/Meshes/mesh";
  30814. import { Ray } from "babylonjs/Culling/ray";
  30815. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  30816. /**
  30817. * Defines a subdivision inside a mesh
  30818. */
  30819. export class SubMesh implements ICullable {
  30820. /** the material index to use */
  30821. materialIndex: number;
  30822. /** vertex index start */
  30823. verticesStart: number;
  30824. /** vertices count */
  30825. verticesCount: number;
  30826. /** index start */
  30827. indexStart: number;
  30828. /** indices count */
  30829. indexCount: number;
  30830. /** @hidden */
  30831. _materialDefines: Nullable<MaterialDefines>;
  30832. /** @hidden */
  30833. _materialEffect: Nullable<Effect>;
  30834. /** @hidden */
  30835. _effectOverride: Nullable<Effect>;
  30836. /**
  30837. * Gets material defines used by the effect associated to the sub mesh
  30838. */
  30839. get materialDefines(): Nullable<MaterialDefines>;
  30840. /**
  30841. * Sets material defines used by the effect associated to the sub mesh
  30842. */
  30843. set materialDefines(defines: Nullable<MaterialDefines>);
  30844. /**
  30845. * Gets associated effect
  30846. */
  30847. get effect(): Nullable<Effect>;
  30848. /**
  30849. * Sets associated effect (effect used to render this submesh)
  30850. * @param effect defines the effect to associate with
  30851. * @param defines defines the set of defines used to compile this effect
  30852. */
  30853. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30854. /** @hidden */
  30855. _linesIndexCount: number;
  30856. private _mesh;
  30857. private _renderingMesh;
  30858. private _boundingInfo;
  30859. private _linesIndexBuffer;
  30860. /** @hidden */
  30861. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30862. /** @hidden */
  30863. _trianglePlanes: Plane[];
  30864. /** @hidden */
  30865. _lastColliderTransformMatrix: Nullable<Matrix>;
  30866. /** @hidden */
  30867. _renderId: number;
  30868. /** @hidden */
  30869. _alphaIndex: number;
  30870. /** @hidden */
  30871. _distanceToCamera: number;
  30872. /** @hidden */
  30873. _id: number;
  30874. private _currentMaterial;
  30875. /**
  30876. * Add a new submesh to a mesh
  30877. * @param materialIndex defines the material index to use
  30878. * @param verticesStart defines vertex index start
  30879. * @param verticesCount defines vertices count
  30880. * @param indexStart defines index start
  30881. * @param indexCount defines indices count
  30882. * @param mesh defines the parent mesh
  30883. * @param renderingMesh defines an optional rendering mesh
  30884. * @param createBoundingBox defines if bounding box should be created for this submesh
  30885. * @returns the new submesh
  30886. */
  30887. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30888. /**
  30889. * Creates a new submesh
  30890. * @param materialIndex defines the material index to use
  30891. * @param verticesStart defines vertex index start
  30892. * @param verticesCount defines vertices count
  30893. * @param indexStart defines index start
  30894. * @param indexCount defines indices count
  30895. * @param mesh defines the parent mesh
  30896. * @param renderingMesh defines an optional rendering mesh
  30897. * @param createBoundingBox defines if bounding box should be created for this submesh
  30898. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30899. */
  30900. constructor(
  30901. /** the material index to use */
  30902. materialIndex: number,
  30903. /** vertex index start */
  30904. verticesStart: number,
  30905. /** vertices count */
  30906. verticesCount: number,
  30907. /** index start */
  30908. indexStart: number,
  30909. /** indices count */
  30910. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30911. /**
  30912. * Returns true if this submesh covers the entire parent mesh
  30913. * @ignorenaming
  30914. */
  30915. get IsGlobal(): boolean;
  30916. /**
  30917. * Returns the submesh BoudingInfo object
  30918. * @returns current bounding info (or mesh's one if the submesh is global)
  30919. */
  30920. getBoundingInfo(): BoundingInfo;
  30921. /**
  30922. * Sets the submesh BoundingInfo
  30923. * @param boundingInfo defines the new bounding info to use
  30924. * @returns the SubMesh
  30925. */
  30926. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30927. /**
  30928. * Returns the mesh of the current submesh
  30929. * @return the parent mesh
  30930. */
  30931. getMesh(): AbstractMesh;
  30932. /**
  30933. * Returns the rendering mesh of the submesh
  30934. * @returns the rendering mesh (could be different from parent mesh)
  30935. */
  30936. getRenderingMesh(): Mesh;
  30937. /**
  30938. * Returns the replacement mesh of the submesh
  30939. * @returns the replacement mesh (could be different from parent mesh)
  30940. */
  30941. getReplacementMesh(): Nullable<AbstractMesh>;
  30942. /**
  30943. * Returns the effective mesh of the submesh
  30944. * @returns the effective mesh (could be different from parent mesh)
  30945. */
  30946. getEffectiveMesh(): AbstractMesh;
  30947. /**
  30948. * Returns the submesh material
  30949. * @returns null or the current material
  30950. */
  30951. getMaterial(): Nullable<Material>;
  30952. private _IsMultiMaterial;
  30953. /**
  30954. * Sets a new updated BoundingInfo object to the submesh
  30955. * @param data defines an optional position array to use to determine the bounding info
  30956. * @returns the SubMesh
  30957. */
  30958. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30959. /** @hidden */
  30960. _checkCollision(collider: Collider): boolean;
  30961. /**
  30962. * Updates the submesh BoundingInfo
  30963. * @param world defines the world matrix to use to update the bounding info
  30964. * @returns the submesh
  30965. */
  30966. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30967. /**
  30968. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30969. * @param frustumPlanes defines the frustum planes
  30970. * @returns true if the submesh is intersecting with the frustum
  30971. */
  30972. isInFrustum(frustumPlanes: Plane[]): boolean;
  30973. /**
  30974. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30975. * @param frustumPlanes defines the frustum planes
  30976. * @returns true if the submesh is inside the frustum
  30977. */
  30978. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30979. /**
  30980. * Renders the submesh
  30981. * @param enableAlphaMode defines if alpha needs to be used
  30982. * @returns the submesh
  30983. */
  30984. render(enableAlphaMode: boolean): SubMesh;
  30985. /**
  30986. * @hidden
  30987. */
  30988. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30989. /**
  30990. * Checks if the submesh intersects with a ray
  30991. * @param ray defines the ray to test
  30992. * @returns true is the passed ray intersects the submesh bounding box
  30993. */
  30994. canIntersects(ray: Ray): boolean;
  30995. /**
  30996. * Intersects current submesh with a ray
  30997. * @param ray defines the ray to test
  30998. * @param positions defines mesh's positions array
  30999. * @param indices defines mesh's indices array
  31000. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31001. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31002. * @returns intersection info or null if no intersection
  31003. */
  31004. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31005. /** @hidden */
  31006. private _intersectLines;
  31007. /** @hidden */
  31008. private _intersectUnIndexedLines;
  31009. /** @hidden */
  31010. private _intersectTriangles;
  31011. /** @hidden */
  31012. private _intersectUnIndexedTriangles;
  31013. /** @hidden */
  31014. _rebuild(): void;
  31015. /**
  31016. * Creates a new submesh from the passed mesh
  31017. * @param newMesh defines the new hosting mesh
  31018. * @param newRenderingMesh defines an optional rendering mesh
  31019. * @returns the new submesh
  31020. */
  31021. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31022. /**
  31023. * Release associated resources
  31024. */
  31025. dispose(): void;
  31026. /**
  31027. * Gets the class name
  31028. * @returns the string "SubMesh".
  31029. */
  31030. getClassName(): string;
  31031. /**
  31032. * Creates a new submesh from indices data
  31033. * @param materialIndex the index of the main mesh material
  31034. * @param startIndex the index where to start the copy in the mesh indices array
  31035. * @param indexCount the number of indices to copy then from the startIndex
  31036. * @param mesh the main mesh to create the submesh from
  31037. * @param renderingMesh the optional rendering mesh
  31038. * @returns a new submesh
  31039. */
  31040. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31041. }
  31042. }
  31043. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31044. /**
  31045. * Class used to represent data loading progression
  31046. */
  31047. export class SceneLoaderFlags {
  31048. private static _ForceFullSceneLoadingForIncremental;
  31049. private static _ShowLoadingScreen;
  31050. private static _CleanBoneMatrixWeights;
  31051. private static _loggingLevel;
  31052. /**
  31053. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31054. */
  31055. static get ForceFullSceneLoadingForIncremental(): boolean;
  31056. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31057. /**
  31058. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31059. */
  31060. static get ShowLoadingScreen(): boolean;
  31061. static set ShowLoadingScreen(value: boolean);
  31062. /**
  31063. * Defines the current logging level (while loading the scene)
  31064. * @ignorenaming
  31065. */
  31066. static get loggingLevel(): number;
  31067. static set loggingLevel(value: number);
  31068. /**
  31069. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31070. */
  31071. static get CleanBoneMatrixWeights(): boolean;
  31072. static set CleanBoneMatrixWeights(value: boolean);
  31073. }
  31074. }
  31075. declare module "babylonjs/Meshes/geometry" {
  31076. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31077. import { Scene } from "babylonjs/scene";
  31078. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31079. import { Engine } from "babylonjs/Engines/engine";
  31080. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31081. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31082. import { Effect } from "babylonjs/Materials/effect";
  31083. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31084. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31085. import { Mesh } from "babylonjs/Meshes/mesh";
  31086. /**
  31087. * Class used to store geometry data (vertex buffers + index buffer)
  31088. */
  31089. export class Geometry implements IGetSetVerticesData {
  31090. /**
  31091. * Gets or sets the ID of the geometry
  31092. */
  31093. id: string;
  31094. /**
  31095. * Gets or sets the unique ID of the geometry
  31096. */
  31097. uniqueId: number;
  31098. /**
  31099. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31100. */
  31101. delayLoadState: number;
  31102. /**
  31103. * Gets the file containing the data to load when running in delay load state
  31104. */
  31105. delayLoadingFile: Nullable<string>;
  31106. /**
  31107. * Callback called when the geometry is updated
  31108. */
  31109. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31110. private _scene;
  31111. private _engine;
  31112. private _meshes;
  31113. private _totalVertices;
  31114. /** @hidden */
  31115. _indices: IndicesArray;
  31116. /** @hidden */
  31117. _vertexBuffers: {
  31118. [key: string]: VertexBuffer;
  31119. };
  31120. private _isDisposed;
  31121. private _extend;
  31122. private _boundingBias;
  31123. /** @hidden */
  31124. _delayInfo: Array<string>;
  31125. private _indexBuffer;
  31126. private _indexBufferIsUpdatable;
  31127. /** @hidden */
  31128. _boundingInfo: Nullable<BoundingInfo>;
  31129. /** @hidden */
  31130. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31131. /** @hidden */
  31132. _softwareSkinningFrameId: number;
  31133. private _vertexArrayObjects;
  31134. private _updatable;
  31135. /** @hidden */
  31136. _positions: Nullable<Vector3[]>;
  31137. /**
  31138. * 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
  31139. */
  31140. get boundingBias(): Vector2;
  31141. /**
  31142. * 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
  31143. */
  31144. set boundingBias(value: Vector2);
  31145. /**
  31146. * Static function used to attach a new empty geometry to a mesh
  31147. * @param mesh defines the mesh to attach the geometry to
  31148. * @returns the new Geometry
  31149. */
  31150. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31151. /** Get the list of meshes using this geometry */
  31152. get meshes(): Mesh[];
  31153. /**
  31154. * 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
  31155. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31156. */
  31157. useBoundingInfoFromGeometry: boolean;
  31158. /**
  31159. * Creates a new geometry
  31160. * @param id defines the unique ID
  31161. * @param scene defines the hosting scene
  31162. * @param vertexData defines the VertexData used to get geometry data
  31163. * @param updatable defines if geometry must be updatable (false by default)
  31164. * @param mesh defines the mesh that will be associated with the geometry
  31165. */
  31166. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31167. /**
  31168. * Gets the current extend of the geometry
  31169. */
  31170. get extend(): {
  31171. minimum: Vector3;
  31172. maximum: Vector3;
  31173. };
  31174. /**
  31175. * Gets the hosting scene
  31176. * @returns the hosting Scene
  31177. */
  31178. getScene(): Scene;
  31179. /**
  31180. * Gets the hosting engine
  31181. * @returns the hosting Engine
  31182. */
  31183. getEngine(): Engine;
  31184. /**
  31185. * Defines if the geometry is ready to use
  31186. * @returns true if the geometry is ready to be used
  31187. */
  31188. isReady(): boolean;
  31189. /**
  31190. * Gets a value indicating that the geometry should not be serialized
  31191. */
  31192. get doNotSerialize(): boolean;
  31193. /** @hidden */
  31194. _rebuild(): void;
  31195. /**
  31196. * Affects all geometry data in one call
  31197. * @param vertexData defines the geometry data
  31198. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31199. */
  31200. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31201. /**
  31202. * Set specific vertex data
  31203. * @param kind defines the data kind (Position, normal, etc...)
  31204. * @param data defines the vertex data to use
  31205. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31206. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31207. */
  31208. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31209. /**
  31210. * Removes a specific vertex data
  31211. * @param kind defines the data kind (Position, normal, etc...)
  31212. */
  31213. removeVerticesData(kind: string): void;
  31214. /**
  31215. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31216. * @param buffer defines the vertex buffer to use
  31217. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31218. */
  31219. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31220. /**
  31221. * Update a specific vertex buffer
  31222. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31223. * It will do nothing if the buffer is not updatable
  31224. * @param kind defines the data kind (Position, normal, etc...)
  31225. * @param data defines the data to use
  31226. * @param offset defines the offset in the target buffer where to store the data
  31227. * @param useBytes set to true if the offset is in bytes
  31228. */
  31229. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31230. /**
  31231. * Update a specific vertex buffer
  31232. * This function will create a new buffer if the current one is not updatable
  31233. * @param kind defines the data kind (Position, normal, etc...)
  31234. * @param data defines the data to use
  31235. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31236. */
  31237. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31238. private _updateBoundingInfo;
  31239. /** @hidden */
  31240. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31241. /**
  31242. * Gets total number of vertices
  31243. * @returns the total number of vertices
  31244. */
  31245. getTotalVertices(): number;
  31246. /**
  31247. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31248. * @param kind defines the data kind (Position, normal, etc...)
  31249. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31250. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31251. * @returns a float array containing vertex data
  31252. */
  31253. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31254. /**
  31255. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31256. * @param kind defines the data kind (Position, normal, etc...)
  31257. * @returns true if the vertex buffer with the specified kind is updatable
  31258. */
  31259. isVertexBufferUpdatable(kind: string): boolean;
  31260. /**
  31261. * Gets a specific vertex buffer
  31262. * @param kind defines the data kind (Position, normal, etc...)
  31263. * @returns a VertexBuffer
  31264. */
  31265. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31266. /**
  31267. * Returns all vertex buffers
  31268. * @return an object holding all vertex buffers indexed by kind
  31269. */
  31270. getVertexBuffers(): Nullable<{
  31271. [key: string]: VertexBuffer;
  31272. }>;
  31273. /**
  31274. * Gets a boolean indicating if specific vertex buffer is present
  31275. * @param kind defines the data kind (Position, normal, etc...)
  31276. * @returns true if data is present
  31277. */
  31278. isVerticesDataPresent(kind: string): boolean;
  31279. /**
  31280. * Gets a list of all attached data kinds (Position, normal, etc...)
  31281. * @returns a list of string containing all kinds
  31282. */
  31283. getVerticesDataKinds(): string[];
  31284. /**
  31285. * Update index buffer
  31286. * @param indices defines the indices to store in the index buffer
  31287. * @param offset defines the offset in the target buffer where to store the data
  31288. * @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)
  31289. */
  31290. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31291. /**
  31292. * Creates a new index buffer
  31293. * @param indices defines the indices to store in the index buffer
  31294. * @param totalVertices defines the total number of vertices (could be null)
  31295. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31296. */
  31297. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31298. /**
  31299. * Return the total number of indices
  31300. * @returns the total number of indices
  31301. */
  31302. getTotalIndices(): number;
  31303. /**
  31304. * Gets the index buffer array
  31305. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31306. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31307. * @returns the index buffer array
  31308. */
  31309. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31310. /**
  31311. * Gets the index buffer
  31312. * @return the index buffer
  31313. */
  31314. getIndexBuffer(): Nullable<DataBuffer>;
  31315. /** @hidden */
  31316. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31317. /**
  31318. * Release the associated resources for a specific mesh
  31319. * @param mesh defines the source mesh
  31320. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31321. */
  31322. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31323. /**
  31324. * Apply current geometry to a given mesh
  31325. * @param mesh defines the mesh to apply geometry to
  31326. */
  31327. applyToMesh(mesh: Mesh): void;
  31328. private _updateExtend;
  31329. private _applyToMesh;
  31330. private notifyUpdate;
  31331. /**
  31332. * Load the geometry if it was flagged as delay loaded
  31333. * @param scene defines the hosting scene
  31334. * @param onLoaded defines a callback called when the geometry is loaded
  31335. */
  31336. load(scene: Scene, onLoaded?: () => void): void;
  31337. private _queueLoad;
  31338. /**
  31339. * Invert the geometry to move from a right handed system to a left handed one.
  31340. */
  31341. toLeftHanded(): void;
  31342. /** @hidden */
  31343. _resetPointsArrayCache(): void;
  31344. /** @hidden */
  31345. _generatePointsArray(): boolean;
  31346. /**
  31347. * Gets a value indicating if the geometry is disposed
  31348. * @returns true if the geometry was disposed
  31349. */
  31350. isDisposed(): boolean;
  31351. private _disposeVertexArrayObjects;
  31352. /**
  31353. * Free all associated resources
  31354. */
  31355. dispose(): void;
  31356. /**
  31357. * Clone the current geometry into a new geometry
  31358. * @param id defines the unique ID of the new geometry
  31359. * @returns a new geometry object
  31360. */
  31361. copy(id: string): Geometry;
  31362. /**
  31363. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31364. * @return a JSON representation of the current geometry data (without the vertices data)
  31365. */
  31366. serialize(): any;
  31367. private toNumberArray;
  31368. /**
  31369. * Serialize all vertices data into a JSON oject
  31370. * @returns a JSON representation of the current geometry data
  31371. */
  31372. serializeVerticeData(): any;
  31373. /**
  31374. * Extracts a clone of a mesh geometry
  31375. * @param mesh defines the source mesh
  31376. * @param id defines the unique ID of the new geometry object
  31377. * @returns the new geometry object
  31378. */
  31379. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31380. /**
  31381. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31382. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31383. * Be aware Math.random() could cause collisions, but:
  31384. * "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"
  31385. * @returns a string containing a new GUID
  31386. */
  31387. static RandomId(): string;
  31388. /** @hidden */
  31389. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31390. private static _CleanMatricesWeights;
  31391. /**
  31392. * Create a new geometry from persisted data (Using .babylon file format)
  31393. * @param parsedVertexData defines the persisted data
  31394. * @param scene defines the hosting scene
  31395. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31396. * @returns the new geometry object
  31397. */
  31398. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31399. }
  31400. }
  31401. declare module "babylonjs/Meshes/mesh.vertexData" {
  31402. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31403. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31404. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31405. import { Geometry } from "babylonjs/Meshes/geometry";
  31406. import { Mesh } from "babylonjs/Meshes/mesh";
  31407. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31408. /**
  31409. * Define an interface for all classes that will get and set the data on vertices
  31410. */
  31411. export interface IGetSetVerticesData {
  31412. /**
  31413. * Gets a boolean indicating if specific vertex data is present
  31414. * @param kind defines the vertex data kind to use
  31415. * @returns true is data kind is present
  31416. */
  31417. isVerticesDataPresent(kind: string): boolean;
  31418. /**
  31419. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31420. * @param kind defines the data kind (Position, normal, etc...)
  31421. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31422. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31423. * @returns a float array containing vertex data
  31424. */
  31425. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31426. /**
  31427. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31428. * @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.
  31429. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31430. * @returns the indices array or an empty array if the mesh has no geometry
  31431. */
  31432. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31433. /**
  31434. * Set specific vertex data
  31435. * @param kind defines the data kind (Position, normal, etc...)
  31436. * @param data defines the vertex data to use
  31437. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31438. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31439. */
  31440. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31441. /**
  31442. * Update a specific associated vertex buffer
  31443. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31444. * - VertexBuffer.PositionKind
  31445. * - VertexBuffer.UVKind
  31446. * - VertexBuffer.UV2Kind
  31447. * - VertexBuffer.UV3Kind
  31448. * - VertexBuffer.UV4Kind
  31449. * - VertexBuffer.UV5Kind
  31450. * - VertexBuffer.UV6Kind
  31451. * - VertexBuffer.ColorKind
  31452. * - VertexBuffer.MatricesIndicesKind
  31453. * - VertexBuffer.MatricesIndicesExtraKind
  31454. * - VertexBuffer.MatricesWeightsKind
  31455. * - VertexBuffer.MatricesWeightsExtraKind
  31456. * @param data defines the data source
  31457. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31458. * @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)
  31459. */
  31460. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31461. /**
  31462. * Creates a new index buffer
  31463. * @param indices defines the indices to store in the index buffer
  31464. * @param totalVertices defines the total number of vertices (could be null)
  31465. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31466. */
  31467. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31468. }
  31469. /**
  31470. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31471. */
  31472. export class VertexData {
  31473. /**
  31474. * Mesh side orientation : usually the external or front surface
  31475. */
  31476. static readonly FRONTSIDE: number;
  31477. /**
  31478. * Mesh side orientation : usually the internal or back surface
  31479. */
  31480. static readonly BACKSIDE: number;
  31481. /**
  31482. * Mesh side orientation : both internal and external or front and back surfaces
  31483. */
  31484. static readonly DOUBLESIDE: number;
  31485. /**
  31486. * Mesh side orientation : by default, `FRONTSIDE`
  31487. */
  31488. static readonly DEFAULTSIDE: number;
  31489. /**
  31490. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31491. */
  31492. positions: Nullable<FloatArray>;
  31493. /**
  31494. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31495. */
  31496. normals: Nullable<FloatArray>;
  31497. /**
  31498. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31499. */
  31500. tangents: Nullable<FloatArray>;
  31501. /**
  31502. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31503. */
  31504. uvs: Nullable<FloatArray>;
  31505. /**
  31506. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31507. */
  31508. uvs2: Nullable<FloatArray>;
  31509. /**
  31510. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31511. */
  31512. uvs3: Nullable<FloatArray>;
  31513. /**
  31514. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31515. */
  31516. uvs4: Nullable<FloatArray>;
  31517. /**
  31518. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31519. */
  31520. uvs5: Nullable<FloatArray>;
  31521. /**
  31522. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31523. */
  31524. uvs6: Nullable<FloatArray>;
  31525. /**
  31526. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31527. */
  31528. colors: Nullable<FloatArray>;
  31529. /**
  31530. * 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).
  31531. */
  31532. matricesIndices: Nullable<FloatArray>;
  31533. /**
  31534. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31535. */
  31536. matricesWeights: Nullable<FloatArray>;
  31537. /**
  31538. * An array extending the number of possible indices
  31539. */
  31540. matricesIndicesExtra: Nullable<FloatArray>;
  31541. /**
  31542. * An array extending the number of possible weights when the number of indices is extended
  31543. */
  31544. matricesWeightsExtra: Nullable<FloatArray>;
  31545. /**
  31546. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31547. */
  31548. indices: Nullable<IndicesArray>;
  31549. /**
  31550. * Uses the passed data array to set the set the values for the specified kind of data
  31551. * @param data a linear array of floating numbers
  31552. * @param kind the type of data that is being set, eg positions, colors etc
  31553. */
  31554. set(data: FloatArray, kind: string): void;
  31555. /**
  31556. * Associates the vertexData to the passed Mesh.
  31557. * Sets it as updatable or not (default `false`)
  31558. * @param mesh the mesh the vertexData is applied to
  31559. * @param updatable when used and having the value true allows new data to update the vertexData
  31560. * @returns the VertexData
  31561. */
  31562. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31563. /**
  31564. * Associates the vertexData to the passed Geometry.
  31565. * Sets it as updatable or not (default `false`)
  31566. * @param geometry the geometry the vertexData is applied to
  31567. * @param updatable when used and having the value true allows new data to update the vertexData
  31568. * @returns VertexData
  31569. */
  31570. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31571. /**
  31572. * Updates the associated mesh
  31573. * @param mesh the mesh to be updated
  31574. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31575. * @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
  31576. * @returns VertexData
  31577. */
  31578. updateMesh(mesh: Mesh): VertexData;
  31579. /**
  31580. * Updates the associated geometry
  31581. * @param geometry the geometry to be updated
  31582. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31583. * @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
  31584. * @returns VertexData.
  31585. */
  31586. updateGeometry(geometry: Geometry): VertexData;
  31587. private _applyTo;
  31588. private _update;
  31589. /**
  31590. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31591. * @param matrix the transforming matrix
  31592. * @returns the VertexData
  31593. */
  31594. transform(matrix: Matrix): VertexData;
  31595. /**
  31596. * Merges the passed VertexData into the current one
  31597. * @param other the VertexData to be merged into the current one
  31598. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31599. * @returns the modified VertexData
  31600. */
  31601. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31602. private _mergeElement;
  31603. private _validate;
  31604. /**
  31605. * Serializes the VertexData
  31606. * @returns a serialized object
  31607. */
  31608. serialize(): any;
  31609. /**
  31610. * Extracts the vertexData from a mesh
  31611. * @param mesh the mesh from which to extract the VertexData
  31612. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31613. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31614. * @returns the object VertexData associated to the passed mesh
  31615. */
  31616. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31617. /**
  31618. * Extracts the vertexData from the geometry
  31619. * @param geometry the geometry from which to extract the VertexData
  31620. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31621. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31622. * @returns the object VertexData associated to the passed mesh
  31623. */
  31624. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31625. private static _ExtractFrom;
  31626. /**
  31627. * Creates the VertexData for a Ribbon
  31628. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31629. * * pathArray array of paths, each of which an array of successive Vector3
  31630. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31631. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31632. * * 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
  31633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31634. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  31635. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  31636. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31637. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31638. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31639. * @returns the VertexData of the ribbon
  31640. */
  31641. static CreateRibbon(options: {
  31642. pathArray: Vector3[][];
  31643. closeArray?: boolean;
  31644. closePath?: boolean;
  31645. offset?: number;
  31646. sideOrientation?: number;
  31647. frontUVs?: Vector4;
  31648. backUVs?: Vector4;
  31649. invertUV?: boolean;
  31650. uvs?: Vector2[];
  31651. colors?: Color4[];
  31652. }): VertexData;
  31653. /**
  31654. * Creates the VertexData for a box
  31655. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31656. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31657. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31658. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31659. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31660. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31661. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31662. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31663. * * 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)
  31664. * * 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)
  31665. * @returns the VertexData of the box
  31666. */
  31667. static CreateBox(options: {
  31668. size?: number;
  31669. width?: number;
  31670. height?: number;
  31671. depth?: number;
  31672. faceUV?: Vector4[];
  31673. faceColors?: Color4[];
  31674. sideOrientation?: number;
  31675. frontUVs?: Vector4;
  31676. backUVs?: Vector4;
  31677. }): VertexData;
  31678. /**
  31679. * Creates the VertexData for a tiled box
  31680. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31681. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31682. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31683. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31684. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31685. * @returns the VertexData of the box
  31686. */
  31687. static CreateTiledBox(options: {
  31688. pattern?: number;
  31689. width?: number;
  31690. height?: number;
  31691. depth?: number;
  31692. tileSize?: number;
  31693. tileWidth?: number;
  31694. tileHeight?: number;
  31695. alignHorizontal?: number;
  31696. alignVertical?: number;
  31697. faceUV?: Vector4[];
  31698. faceColors?: Color4[];
  31699. sideOrientation?: number;
  31700. }): VertexData;
  31701. /**
  31702. * Creates the VertexData for a tiled plane
  31703. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31704. * * pattern a limited pattern arrangement depending on the number
  31705. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31706. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31707. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  31708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31709. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  31710. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  31711. * @returns the VertexData of the tiled plane
  31712. */
  31713. static CreateTiledPlane(options: {
  31714. pattern?: number;
  31715. tileSize?: number;
  31716. tileWidth?: number;
  31717. tileHeight?: number;
  31718. size?: number;
  31719. width?: number;
  31720. height?: number;
  31721. alignHorizontal?: number;
  31722. alignVertical?: number;
  31723. sideOrientation?: number;
  31724. frontUVs?: Vector4;
  31725. backUVs?: Vector4;
  31726. }): VertexData;
  31727. /**
  31728. * Creates the VertexData for an ellipsoid, defaults to a sphere
  31729. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31730. * * segments sets the number of horizontal strips optional, default 32
  31731. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  31732. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  31733. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  31734. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  31735. * * 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
  31736. * * 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
  31737. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31738. * * 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)
  31739. * * 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)
  31740. * @returns the VertexData of the ellipsoid
  31741. */
  31742. static CreateSphere(options: {
  31743. segments?: number;
  31744. diameter?: number;
  31745. diameterX?: number;
  31746. diameterY?: number;
  31747. diameterZ?: number;
  31748. arc?: number;
  31749. slice?: number;
  31750. sideOrientation?: number;
  31751. frontUVs?: Vector4;
  31752. backUVs?: Vector4;
  31753. }): VertexData;
  31754. /**
  31755. * Creates the VertexData for a cylinder, cone or prism
  31756. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31757. * * height sets the height (y direction) of the cylinder, optional, default 2
  31758. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  31759. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  31760. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  31761. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31762. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  31763. * * 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
  31764. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31765. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31766. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  31767. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  31768. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31769. * * 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)
  31770. * * 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)
  31771. * @returns the VertexData of the cylinder, cone or prism
  31772. */
  31773. static CreateCylinder(options: {
  31774. height?: number;
  31775. diameterTop?: number;
  31776. diameterBottom?: number;
  31777. diameter?: number;
  31778. tessellation?: number;
  31779. subdivisions?: number;
  31780. arc?: number;
  31781. faceColors?: Color4[];
  31782. faceUV?: Vector4[];
  31783. hasRings?: boolean;
  31784. enclose?: boolean;
  31785. sideOrientation?: number;
  31786. frontUVs?: Vector4;
  31787. backUVs?: Vector4;
  31788. }): VertexData;
  31789. /**
  31790. * Creates the VertexData for a torus
  31791. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31792. * * diameter the diameter of the torus, optional default 1
  31793. * * thickness the diameter of the tube forming the torus, optional default 0.5
  31794. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31796. * * 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)
  31797. * * 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)
  31798. * @returns the VertexData of the torus
  31799. */
  31800. static CreateTorus(options: {
  31801. diameter?: number;
  31802. thickness?: number;
  31803. tessellation?: number;
  31804. sideOrientation?: number;
  31805. frontUVs?: Vector4;
  31806. backUVs?: Vector4;
  31807. }): VertexData;
  31808. /**
  31809. * Creates the VertexData of the LineSystem
  31810. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  31811. * - lines an array of lines, each line being an array of successive Vector3
  31812. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  31813. * @returns the VertexData of the LineSystem
  31814. */
  31815. static CreateLineSystem(options: {
  31816. lines: Vector3[][];
  31817. colors?: Nullable<Color4[][]>;
  31818. }): VertexData;
  31819. /**
  31820. * Create the VertexData for a DashedLines
  31821. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  31822. * - points an array successive Vector3
  31823. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  31824. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  31825. * - dashNb the intended total number of dashes, optional, default 200
  31826. * @returns the VertexData for the DashedLines
  31827. */
  31828. static CreateDashedLines(options: {
  31829. points: Vector3[];
  31830. dashSize?: number;
  31831. gapSize?: number;
  31832. dashNb?: number;
  31833. }): VertexData;
  31834. /**
  31835. * Creates the VertexData for a Ground
  31836. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31837. * - width the width (x direction) of the ground, optional, default 1
  31838. * - height the height (z direction) of the ground, optional, default 1
  31839. * - subdivisions the number of subdivisions per side, optional, default 1
  31840. * @returns the VertexData of the Ground
  31841. */
  31842. static CreateGround(options: {
  31843. width?: number;
  31844. height?: number;
  31845. subdivisions?: number;
  31846. subdivisionsX?: number;
  31847. subdivisionsY?: number;
  31848. }): VertexData;
  31849. /**
  31850. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  31851. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31852. * * xmin the ground minimum X coordinate, optional, default -1
  31853. * * zmin the ground minimum Z coordinate, optional, default -1
  31854. * * xmax the ground maximum X coordinate, optional, default 1
  31855. * * zmax the ground maximum Z coordinate, optional, default 1
  31856. * * 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}
  31857. * * 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}
  31858. * @returns the VertexData of the TiledGround
  31859. */
  31860. static CreateTiledGround(options: {
  31861. xmin: number;
  31862. zmin: number;
  31863. xmax: number;
  31864. zmax: number;
  31865. subdivisions?: {
  31866. w: number;
  31867. h: number;
  31868. };
  31869. precision?: {
  31870. w: number;
  31871. h: number;
  31872. };
  31873. }): VertexData;
  31874. /**
  31875. * Creates the VertexData of the Ground designed from a heightmap
  31876. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  31877. * * width the width (x direction) of the ground
  31878. * * height the height (z direction) of the ground
  31879. * * subdivisions the number of subdivisions per side
  31880. * * minHeight the minimum altitude on the ground, optional, default 0
  31881. * * maxHeight the maximum altitude on the ground, optional default 1
  31882. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  31883. * * buffer the array holding the image color data
  31884. * * bufferWidth the width of image
  31885. * * bufferHeight the height of image
  31886. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  31887. * @returns the VertexData of the Ground designed from a heightmap
  31888. */
  31889. static CreateGroundFromHeightMap(options: {
  31890. width: number;
  31891. height: number;
  31892. subdivisions: number;
  31893. minHeight: number;
  31894. maxHeight: number;
  31895. colorFilter: Color3;
  31896. buffer: Uint8Array;
  31897. bufferWidth: number;
  31898. bufferHeight: number;
  31899. alphaFilter: number;
  31900. }): VertexData;
  31901. /**
  31902. * Creates the VertexData for a Plane
  31903. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  31904. * * size sets the width and height of the plane to the value of size, optional default 1
  31905. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  31906. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  31907. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31908. * * 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)
  31909. * * 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)
  31910. * @returns the VertexData of the box
  31911. */
  31912. static CreatePlane(options: {
  31913. size?: number;
  31914. width?: number;
  31915. height?: number;
  31916. sideOrientation?: number;
  31917. frontUVs?: Vector4;
  31918. backUVs?: Vector4;
  31919. }): VertexData;
  31920. /**
  31921. * Creates the VertexData of the Disc or regular Polygon
  31922. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  31923. * * radius the radius of the disc, optional default 0.5
  31924. * * tessellation the number of polygon sides, optional, default 64
  31925. * * 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
  31926. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31927. * * 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)
  31928. * * 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)
  31929. * @returns the VertexData of the box
  31930. */
  31931. static CreateDisc(options: {
  31932. radius?: number;
  31933. tessellation?: number;
  31934. arc?: number;
  31935. sideOrientation?: number;
  31936. frontUVs?: Vector4;
  31937. backUVs?: Vector4;
  31938. }): VertexData;
  31939. /**
  31940. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  31941. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  31942. * @param polygon a mesh built from polygonTriangulation.build()
  31943. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31944. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31945. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31946. * @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)
  31947. * @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)
  31948. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31949. * @returns the VertexData of the Polygon
  31950. */
  31951. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31952. /**
  31953. * Creates the VertexData of the IcoSphere
  31954. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31955. * * radius the radius of the IcoSphere, optional default 1
  31956. * * radiusX allows stretching in the x direction, optional, default radius
  31957. * * radiusY allows stretching in the y direction, optional, default radius
  31958. * * radiusZ allows stretching in the z direction, optional, default radius
  31959. * * flat when true creates a flat shaded mesh, optional, default true
  31960. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31961. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31962. * * 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)
  31963. * * 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)
  31964. * @returns the VertexData of the IcoSphere
  31965. */
  31966. static CreateIcoSphere(options: {
  31967. radius?: number;
  31968. radiusX?: number;
  31969. radiusY?: number;
  31970. radiusZ?: number;
  31971. flat?: boolean;
  31972. subdivisions?: number;
  31973. sideOrientation?: number;
  31974. frontUVs?: Vector4;
  31975. backUVs?: Vector4;
  31976. }): VertexData;
  31977. /**
  31978. * Creates the VertexData for a Polyhedron
  31979. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31980. * * type provided types are:
  31981. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31982. * * 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)
  31983. * * size the size of the IcoSphere, optional default 1
  31984. * * sizeX allows stretching in the x direction, optional, default size
  31985. * * sizeY allows stretching in the y direction, optional, default size
  31986. * * sizeZ allows stretching in the z direction, optional, default size
  31987. * * 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
  31988. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31989. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31990. * * flat when true creates a flat shaded mesh, optional, default true
  31991. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31993. * * 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)
  31994. * * 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)
  31995. * @returns the VertexData of the Polyhedron
  31996. */
  31997. static CreatePolyhedron(options: {
  31998. type?: number;
  31999. size?: number;
  32000. sizeX?: number;
  32001. sizeY?: number;
  32002. sizeZ?: number;
  32003. custom?: any;
  32004. faceUV?: Vector4[];
  32005. faceColors?: Color4[];
  32006. flat?: boolean;
  32007. sideOrientation?: number;
  32008. frontUVs?: Vector4;
  32009. backUVs?: Vector4;
  32010. }): VertexData;
  32011. /**
  32012. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  32013. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  32014. * @returns the VertexData of the Capsule
  32015. */
  32016. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  32017. /**
  32018. * Creates the VertexData for a TorusKnot
  32019. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  32020. * * radius the radius of the torus knot, optional, default 2
  32021. * * tube the thickness of the tube, optional, default 0.5
  32022. * * radialSegments the number of sides on each tube segments, optional, default 32
  32023. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  32024. * * p the number of windings around the z axis, optional, default 2
  32025. * * q the number of windings around the x axis, optional, default 3
  32026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32027. * * 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)
  32028. * * 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)
  32029. * @returns the VertexData of the Torus Knot
  32030. */
  32031. static CreateTorusKnot(options: {
  32032. radius?: number;
  32033. tube?: number;
  32034. radialSegments?: number;
  32035. tubularSegments?: number;
  32036. p?: number;
  32037. q?: number;
  32038. sideOrientation?: number;
  32039. frontUVs?: Vector4;
  32040. backUVs?: Vector4;
  32041. }): VertexData;
  32042. /**
  32043. * Compute normals for given positions and indices
  32044. * @param positions an array of vertex positions, [...., x, y, z, ......]
  32045. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  32046. * @param normals an array of vertex normals, [...., x, y, z, ......]
  32047. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  32048. * * facetNormals : optional array of facet normals (vector3)
  32049. * * facetPositions : optional array of facet positions (vector3)
  32050. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  32051. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  32052. * * bInfo : optional bounding info, required for facetPartitioning computation
  32053. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  32054. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  32055. * * useRightHandedSystem: optional boolean to for right handed system computation
  32056. * * depthSort : optional boolean to enable the facet depth sort computation
  32057. * * distanceTo : optional Vector3 to compute the facet depth from this location
  32058. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  32059. */
  32060. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  32061. facetNormals?: any;
  32062. facetPositions?: any;
  32063. facetPartitioning?: any;
  32064. ratio?: number;
  32065. bInfo?: any;
  32066. bbSize?: Vector3;
  32067. subDiv?: any;
  32068. useRightHandedSystem?: boolean;
  32069. depthSort?: boolean;
  32070. distanceTo?: Vector3;
  32071. depthSortedFacets?: any;
  32072. }): void;
  32073. /** @hidden */
  32074. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  32075. /**
  32076. * Applies VertexData created from the imported parameters to the geometry
  32077. * @param parsedVertexData the parsed data from an imported file
  32078. * @param geometry the geometry to apply the VertexData to
  32079. */
  32080. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  32081. }
  32082. }
  32083. declare module "babylonjs/Morph/morphTarget" {
  32084. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32085. import { Observable } from "babylonjs/Misc/observable";
  32086. import { Nullable, FloatArray } from "babylonjs/types";
  32087. import { Scene } from "babylonjs/scene";
  32088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32089. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32090. /**
  32091. * Defines a target to use with MorphTargetManager
  32092. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32093. */
  32094. export class MorphTarget implements IAnimatable {
  32095. /** defines the name of the target */
  32096. name: string;
  32097. /**
  32098. * Gets or sets the list of animations
  32099. */
  32100. animations: import("babylonjs/Animations/animation").Animation[];
  32101. private _scene;
  32102. private _positions;
  32103. private _normals;
  32104. private _tangents;
  32105. private _uvs;
  32106. private _influence;
  32107. private _uniqueId;
  32108. /**
  32109. * Observable raised when the influence changes
  32110. */
  32111. onInfluenceChanged: Observable<boolean>;
  32112. /** @hidden */
  32113. _onDataLayoutChanged: Observable<void>;
  32114. /**
  32115. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32116. */
  32117. get influence(): number;
  32118. set influence(influence: number);
  32119. /**
  32120. * Gets or sets the id of the morph Target
  32121. */
  32122. id: string;
  32123. private _animationPropertiesOverride;
  32124. /**
  32125. * Gets or sets the animation properties override
  32126. */
  32127. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32128. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32129. /**
  32130. * Creates a new MorphTarget
  32131. * @param name defines the name of the target
  32132. * @param influence defines the influence to use
  32133. * @param scene defines the scene the morphtarget belongs to
  32134. */
  32135. constructor(
  32136. /** defines the name of the target */
  32137. name: string, influence?: number, scene?: Nullable<Scene>);
  32138. /**
  32139. * Gets the unique ID of this manager
  32140. */
  32141. get uniqueId(): number;
  32142. /**
  32143. * Gets a boolean defining if the target contains position data
  32144. */
  32145. get hasPositions(): boolean;
  32146. /**
  32147. * Gets a boolean defining if the target contains normal data
  32148. */
  32149. get hasNormals(): boolean;
  32150. /**
  32151. * Gets a boolean defining if the target contains tangent data
  32152. */
  32153. get hasTangents(): boolean;
  32154. /**
  32155. * Gets a boolean defining if the target contains texture coordinates data
  32156. */
  32157. get hasUVs(): boolean;
  32158. /**
  32159. * Affects position data to this target
  32160. * @param data defines the position data to use
  32161. */
  32162. setPositions(data: Nullable<FloatArray>): void;
  32163. /**
  32164. * Gets the position data stored in this target
  32165. * @returns a FloatArray containing the position data (or null if not present)
  32166. */
  32167. getPositions(): Nullable<FloatArray>;
  32168. /**
  32169. * Affects normal data to this target
  32170. * @param data defines the normal data to use
  32171. */
  32172. setNormals(data: Nullable<FloatArray>): void;
  32173. /**
  32174. * Gets the normal data stored in this target
  32175. * @returns a FloatArray containing the normal data (or null if not present)
  32176. */
  32177. getNormals(): Nullable<FloatArray>;
  32178. /**
  32179. * Affects tangent data to this target
  32180. * @param data defines the tangent data to use
  32181. */
  32182. setTangents(data: Nullable<FloatArray>): void;
  32183. /**
  32184. * Gets the tangent data stored in this target
  32185. * @returns a FloatArray containing the tangent data (or null if not present)
  32186. */
  32187. getTangents(): Nullable<FloatArray>;
  32188. /**
  32189. * Affects texture coordinates data to this target
  32190. * @param data defines the texture coordinates data to use
  32191. */
  32192. setUVs(data: Nullable<FloatArray>): void;
  32193. /**
  32194. * Gets the texture coordinates data stored in this target
  32195. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32196. */
  32197. getUVs(): Nullable<FloatArray>;
  32198. /**
  32199. * Clone the current target
  32200. * @returns a new MorphTarget
  32201. */
  32202. clone(): MorphTarget;
  32203. /**
  32204. * Serializes the current target into a Serialization object
  32205. * @returns the serialized object
  32206. */
  32207. serialize(): any;
  32208. /**
  32209. * Returns the string "MorphTarget"
  32210. * @returns "MorphTarget"
  32211. */
  32212. getClassName(): string;
  32213. /**
  32214. * Creates a new target from serialized data
  32215. * @param serializationObject defines the serialized data to use
  32216. * @returns a new MorphTarget
  32217. */
  32218. static Parse(serializationObject: any): MorphTarget;
  32219. /**
  32220. * Creates a MorphTarget from mesh data
  32221. * @param mesh defines the source mesh
  32222. * @param name defines the name to use for the new target
  32223. * @param influence defines the influence to attach to the target
  32224. * @returns a new MorphTarget
  32225. */
  32226. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32227. }
  32228. }
  32229. declare module "babylonjs/Morph/morphTargetManager" {
  32230. import { Nullable } from "babylonjs/types";
  32231. import { Scene } from "babylonjs/scene";
  32232. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32233. /**
  32234. * This class is used to deform meshes using morphing between different targets
  32235. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32236. */
  32237. export class MorphTargetManager {
  32238. private _targets;
  32239. private _targetInfluenceChangedObservers;
  32240. private _targetDataLayoutChangedObservers;
  32241. private _activeTargets;
  32242. private _scene;
  32243. private _influences;
  32244. private _supportsNormals;
  32245. private _supportsTangents;
  32246. private _supportsUVs;
  32247. private _vertexCount;
  32248. private _uniqueId;
  32249. private _tempInfluences;
  32250. /**
  32251. * Gets or sets a boolean indicating if normals must be morphed
  32252. */
  32253. enableNormalMorphing: boolean;
  32254. /**
  32255. * Gets or sets a boolean indicating if tangents must be morphed
  32256. */
  32257. enableTangentMorphing: boolean;
  32258. /**
  32259. * Gets or sets a boolean indicating if UV must be morphed
  32260. */
  32261. enableUVMorphing: boolean;
  32262. /**
  32263. * Creates a new MorphTargetManager
  32264. * @param scene defines the current scene
  32265. */
  32266. constructor(scene?: Nullable<Scene>);
  32267. /**
  32268. * Gets the unique ID of this manager
  32269. */
  32270. get uniqueId(): number;
  32271. /**
  32272. * Gets the number of vertices handled by this manager
  32273. */
  32274. get vertexCount(): number;
  32275. /**
  32276. * Gets a boolean indicating if this manager supports morphing of normals
  32277. */
  32278. get supportsNormals(): boolean;
  32279. /**
  32280. * Gets a boolean indicating if this manager supports morphing of tangents
  32281. */
  32282. get supportsTangents(): boolean;
  32283. /**
  32284. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32285. */
  32286. get supportsUVs(): boolean;
  32287. /**
  32288. * Gets the number of targets stored in this manager
  32289. */
  32290. get numTargets(): number;
  32291. /**
  32292. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32293. */
  32294. get numInfluencers(): number;
  32295. /**
  32296. * Gets the list of influences (one per target)
  32297. */
  32298. get influences(): Float32Array;
  32299. /**
  32300. * Gets the active target at specified index. An active target is a target with an influence > 0
  32301. * @param index defines the index to check
  32302. * @returns the requested target
  32303. */
  32304. getActiveTarget(index: number): MorphTarget;
  32305. /**
  32306. * Gets the target at specified index
  32307. * @param index defines the index to check
  32308. * @returns the requested target
  32309. */
  32310. getTarget(index: number): MorphTarget;
  32311. /**
  32312. * Add a new target to this manager
  32313. * @param target defines the target to add
  32314. */
  32315. addTarget(target: MorphTarget): void;
  32316. /**
  32317. * Removes a target from the manager
  32318. * @param target defines the target to remove
  32319. */
  32320. removeTarget(target: MorphTarget): void;
  32321. /**
  32322. * Clone the current manager
  32323. * @returns a new MorphTargetManager
  32324. */
  32325. clone(): MorphTargetManager;
  32326. /**
  32327. * Serializes the current manager into a Serialization object
  32328. * @returns the serialized object
  32329. */
  32330. serialize(): any;
  32331. private _syncActiveTargets;
  32332. /**
  32333. * Syncrhonize the targets with all the meshes using this morph target manager
  32334. */
  32335. synchronize(): void;
  32336. /**
  32337. * Creates a new MorphTargetManager from serialized data
  32338. * @param serializationObject defines the serialized data
  32339. * @param scene defines the hosting scene
  32340. * @returns the new MorphTargetManager
  32341. */
  32342. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32343. }
  32344. }
  32345. declare module "babylonjs/Meshes/meshLODLevel" {
  32346. import { Mesh } from "babylonjs/Meshes/mesh";
  32347. import { Nullable } from "babylonjs/types";
  32348. /**
  32349. * Class used to represent a specific level of detail of a mesh
  32350. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32351. */
  32352. export class MeshLODLevel {
  32353. /** Defines the distance where this level should start being displayed */
  32354. distance: number;
  32355. /** Defines the mesh to use to render this level */
  32356. mesh: Nullable<Mesh>;
  32357. /**
  32358. * Creates a new LOD level
  32359. * @param distance defines the distance where this level should star being displayed
  32360. * @param mesh defines the mesh to use to render this level
  32361. */
  32362. constructor(
  32363. /** Defines the distance where this level should start being displayed */
  32364. distance: number,
  32365. /** Defines the mesh to use to render this level */
  32366. mesh: Nullable<Mesh>);
  32367. }
  32368. }
  32369. declare module "babylonjs/Misc/canvasGenerator" {
  32370. /**
  32371. * Helper class used to generate a canvas to manipulate images
  32372. */
  32373. export class CanvasGenerator {
  32374. /**
  32375. * Create a new canvas (or offscreen canvas depending on the context)
  32376. * @param width defines the expected width
  32377. * @param height defines the expected height
  32378. * @return a new canvas or offscreen canvas
  32379. */
  32380. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32381. }
  32382. }
  32383. declare module "babylonjs/Meshes/groundMesh" {
  32384. import { Scene } from "babylonjs/scene";
  32385. import { Vector3 } from "babylonjs/Maths/math.vector";
  32386. import { Mesh } from "babylonjs/Meshes/mesh";
  32387. /**
  32388. * Mesh representing the gorund
  32389. */
  32390. export class GroundMesh extends Mesh {
  32391. /** If octree should be generated */
  32392. generateOctree: boolean;
  32393. private _heightQuads;
  32394. /** @hidden */
  32395. _subdivisionsX: number;
  32396. /** @hidden */
  32397. _subdivisionsY: number;
  32398. /** @hidden */
  32399. _width: number;
  32400. /** @hidden */
  32401. _height: number;
  32402. /** @hidden */
  32403. _minX: number;
  32404. /** @hidden */
  32405. _maxX: number;
  32406. /** @hidden */
  32407. _minZ: number;
  32408. /** @hidden */
  32409. _maxZ: number;
  32410. constructor(name: string, scene: Scene);
  32411. /**
  32412. * "GroundMesh"
  32413. * @returns "GroundMesh"
  32414. */
  32415. getClassName(): string;
  32416. /**
  32417. * The minimum of x and y subdivisions
  32418. */
  32419. get subdivisions(): number;
  32420. /**
  32421. * X subdivisions
  32422. */
  32423. get subdivisionsX(): number;
  32424. /**
  32425. * Y subdivisions
  32426. */
  32427. get subdivisionsY(): number;
  32428. /**
  32429. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32430. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32431. * @param chunksCount the number of subdivisions for x and y
  32432. * @param octreeBlocksSize (Default: 32)
  32433. */
  32434. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32435. /**
  32436. * Returns a height (y) value in the Worl system :
  32437. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32438. * @param x x coordinate
  32439. * @param z z coordinate
  32440. * @returns the ground y position if (x, z) are outside the ground surface.
  32441. */
  32442. getHeightAtCoordinates(x: number, z: number): number;
  32443. /**
  32444. * Returns a normalized vector (Vector3) orthogonal to the ground
  32445. * at the ground coordinates (x, z) expressed in the World system.
  32446. * @param x x coordinate
  32447. * @param z z coordinate
  32448. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32449. */
  32450. getNormalAtCoordinates(x: number, z: number): Vector3;
  32451. /**
  32452. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32453. * at the ground coordinates (x, z) expressed in the World system.
  32454. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32455. * @param x x coordinate
  32456. * @param z z coordinate
  32457. * @param ref vector to store the result
  32458. * @returns the GroundMesh.
  32459. */
  32460. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32461. /**
  32462. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32463. * if the ground has been updated.
  32464. * This can be used in the render loop.
  32465. * @returns the GroundMesh.
  32466. */
  32467. updateCoordinateHeights(): GroundMesh;
  32468. private _getFacetAt;
  32469. private _initHeightQuads;
  32470. private _computeHeightQuads;
  32471. /**
  32472. * Serializes this ground mesh
  32473. * @param serializationObject object to write serialization to
  32474. */
  32475. serialize(serializationObject: any): void;
  32476. /**
  32477. * Parses a serialized ground mesh
  32478. * @param parsedMesh the serialized mesh
  32479. * @param scene the scene to create the ground mesh in
  32480. * @returns the created ground mesh
  32481. */
  32482. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32483. }
  32484. }
  32485. declare module "babylonjs/Physics/physicsJoint" {
  32486. import { Vector3 } from "babylonjs/Maths/math.vector";
  32487. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32488. /**
  32489. * Interface for Physics-Joint data
  32490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32491. */
  32492. export interface PhysicsJointData {
  32493. /**
  32494. * The main pivot of the joint
  32495. */
  32496. mainPivot?: Vector3;
  32497. /**
  32498. * The connected pivot of the joint
  32499. */
  32500. connectedPivot?: Vector3;
  32501. /**
  32502. * The main axis of the joint
  32503. */
  32504. mainAxis?: Vector3;
  32505. /**
  32506. * The connected axis of the joint
  32507. */
  32508. connectedAxis?: Vector3;
  32509. /**
  32510. * The collision of the joint
  32511. */
  32512. collision?: boolean;
  32513. /**
  32514. * Native Oimo/Cannon/Energy data
  32515. */
  32516. nativeParams?: any;
  32517. }
  32518. /**
  32519. * This is a holder class for the physics joint created by the physics plugin
  32520. * It holds a set of functions to control the underlying joint
  32521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32522. */
  32523. export class PhysicsJoint {
  32524. /**
  32525. * The type of the physics joint
  32526. */
  32527. type: number;
  32528. /**
  32529. * The data for the physics joint
  32530. */
  32531. jointData: PhysicsJointData;
  32532. private _physicsJoint;
  32533. protected _physicsPlugin: IPhysicsEnginePlugin;
  32534. /**
  32535. * Initializes the physics joint
  32536. * @param type The type of the physics joint
  32537. * @param jointData The data for the physics joint
  32538. */
  32539. constructor(
  32540. /**
  32541. * The type of the physics joint
  32542. */
  32543. type: number,
  32544. /**
  32545. * The data for the physics joint
  32546. */
  32547. jointData: PhysicsJointData);
  32548. /**
  32549. * Gets the physics joint
  32550. */
  32551. get physicsJoint(): any;
  32552. /**
  32553. * Sets the physics joint
  32554. */
  32555. set physicsJoint(newJoint: any);
  32556. /**
  32557. * Sets the physics plugin
  32558. */
  32559. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32560. /**
  32561. * Execute a function that is physics-plugin specific.
  32562. * @param {Function} func the function that will be executed.
  32563. * It accepts two parameters: the physics world and the physics joint
  32564. */
  32565. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32566. /**
  32567. * Distance-Joint type
  32568. */
  32569. static DistanceJoint: number;
  32570. /**
  32571. * Hinge-Joint type
  32572. */
  32573. static HingeJoint: number;
  32574. /**
  32575. * Ball-and-Socket joint type
  32576. */
  32577. static BallAndSocketJoint: number;
  32578. /**
  32579. * Wheel-Joint type
  32580. */
  32581. static WheelJoint: number;
  32582. /**
  32583. * Slider-Joint type
  32584. */
  32585. static SliderJoint: number;
  32586. /**
  32587. * Prismatic-Joint type
  32588. */
  32589. static PrismaticJoint: number;
  32590. /**
  32591. * Universal-Joint type
  32592. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32593. */
  32594. static UniversalJoint: number;
  32595. /**
  32596. * Hinge-Joint 2 type
  32597. */
  32598. static Hinge2Joint: number;
  32599. /**
  32600. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32601. */
  32602. static PointToPointJoint: number;
  32603. /**
  32604. * Spring-Joint type
  32605. */
  32606. static SpringJoint: number;
  32607. /**
  32608. * Lock-Joint type
  32609. */
  32610. static LockJoint: number;
  32611. }
  32612. /**
  32613. * A class representing a physics distance joint
  32614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32615. */
  32616. export class DistanceJoint extends PhysicsJoint {
  32617. /**
  32618. *
  32619. * @param jointData The data for the Distance-Joint
  32620. */
  32621. constructor(jointData: DistanceJointData);
  32622. /**
  32623. * Update the predefined distance.
  32624. * @param maxDistance The maximum preferred distance
  32625. * @param minDistance The minimum preferred distance
  32626. */
  32627. updateDistance(maxDistance: number, minDistance?: number): void;
  32628. }
  32629. /**
  32630. * Represents a Motor-Enabled Joint
  32631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32632. */
  32633. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32634. /**
  32635. * Initializes the Motor-Enabled Joint
  32636. * @param type The type of the joint
  32637. * @param jointData The physica joint data for the joint
  32638. */
  32639. constructor(type: number, jointData: PhysicsJointData);
  32640. /**
  32641. * Set the motor values.
  32642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32643. * @param force the force to apply
  32644. * @param maxForce max force for this motor.
  32645. */
  32646. setMotor(force?: number, maxForce?: number): void;
  32647. /**
  32648. * Set the motor's limits.
  32649. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32650. * @param upperLimit The upper limit of the motor
  32651. * @param lowerLimit The lower limit of the motor
  32652. */
  32653. setLimit(upperLimit: number, lowerLimit?: number): void;
  32654. }
  32655. /**
  32656. * This class represents a single physics Hinge-Joint
  32657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32658. */
  32659. export class HingeJoint extends MotorEnabledJoint {
  32660. /**
  32661. * Initializes the Hinge-Joint
  32662. * @param jointData The joint data for the Hinge-Joint
  32663. */
  32664. constructor(jointData: PhysicsJointData);
  32665. /**
  32666. * Set the motor values.
  32667. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32668. * @param {number} force the force to apply
  32669. * @param {number} maxForce max force for this motor.
  32670. */
  32671. setMotor(force?: number, maxForce?: number): void;
  32672. /**
  32673. * Set the motor's limits.
  32674. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32675. * @param upperLimit The upper limit of the motor
  32676. * @param lowerLimit The lower limit of the motor
  32677. */
  32678. setLimit(upperLimit: number, lowerLimit?: number): void;
  32679. }
  32680. /**
  32681. * This class represents a dual hinge physics joint (same as wheel joint)
  32682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32683. */
  32684. export class Hinge2Joint extends MotorEnabledJoint {
  32685. /**
  32686. * Initializes the Hinge2-Joint
  32687. * @param jointData The joint data for the Hinge2-Joint
  32688. */
  32689. constructor(jointData: PhysicsJointData);
  32690. /**
  32691. * Set the motor values.
  32692. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32693. * @param {number} targetSpeed the speed the motor is to reach
  32694. * @param {number} maxForce max force for this motor.
  32695. * @param {motorIndex} the motor's index, 0 or 1.
  32696. */
  32697. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32698. /**
  32699. * Set the motor limits.
  32700. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32701. * @param {number} upperLimit the upper limit
  32702. * @param {number} lowerLimit lower limit
  32703. * @param {motorIndex} the motor's index, 0 or 1.
  32704. */
  32705. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32706. }
  32707. /**
  32708. * Interface for a motor enabled joint
  32709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32710. */
  32711. export interface IMotorEnabledJoint {
  32712. /**
  32713. * Physics joint
  32714. */
  32715. physicsJoint: any;
  32716. /**
  32717. * Sets the motor of the motor-enabled joint
  32718. * @param force The force of the motor
  32719. * @param maxForce The maximum force of the motor
  32720. * @param motorIndex The index of the motor
  32721. */
  32722. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32723. /**
  32724. * Sets the limit of the motor
  32725. * @param upperLimit The upper limit of the motor
  32726. * @param lowerLimit The lower limit of the motor
  32727. * @param motorIndex The index of the motor
  32728. */
  32729. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32730. }
  32731. /**
  32732. * Joint data for a Distance-Joint
  32733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32734. */
  32735. export interface DistanceJointData extends PhysicsJointData {
  32736. /**
  32737. * Max distance the 2 joint objects can be apart
  32738. */
  32739. maxDistance: number;
  32740. }
  32741. /**
  32742. * Joint data from a spring joint
  32743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32744. */
  32745. export interface SpringJointData extends PhysicsJointData {
  32746. /**
  32747. * Length of the spring
  32748. */
  32749. length: number;
  32750. /**
  32751. * Stiffness of the spring
  32752. */
  32753. stiffness: number;
  32754. /**
  32755. * Damping of the spring
  32756. */
  32757. damping: number;
  32758. /** this callback will be called when applying the force to the impostors. */
  32759. forceApplicationCallback: () => void;
  32760. }
  32761. }
  32762. declare module "babylonjs/Physics/physicsRaycastResult" {
  32763. import { Vector3 } from "babylonjs/Maths/math.vector";
  32764. /**
  32765. * Holds the data for the raycast result
  32766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32767. */
  32768. export class PhysicsRaycastResult {
  32769. private _hasHit;
  32770. private _hitDistance;
  32771. private _hitNormalWorld;
  32772. private _hitPointWorld;
  32773. private _rayFromWorld;
  32774. private _rayToWorld;
  32775. /**
  32776. * Gets if there was a hit
  32777. */
  32778. get hasHit(): boolean;
  32779. /**
  32780. * Gets the distance from the hit
  32781. */
  32782. get hitDistance(): number;
  32783. /**
  32784. * Gets the hit normal/direction in the world
  32785. */
  32786. get hitNormalWorld(): Vector3;
  32787. /**
  32788. * Gets the hit point in the world
  32789. */
  32790. get hitPointWorld(): Vector3;
  32791. /**
  32792. * Gets the ray "start point" of the ray in the world
  32793. */
  32794. get rayFromWorld(): Vector3;
  32795. /**
  32796. * Gets the ray "end point" of the ray in the world
  32797. */
  32798. get rayToWorld(): Vector3;
  32799. /**
  32800. * Sets the hit data (normal & point in world space)
  32801. * @param hitNormalWorld defines the normal in world space
  32802. * @param hitPointWorld defines the point in world space
  32803. */
  32804. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32805. /**
  32806. * Sets the distance from the start point to the hit point
  32807. * @param distance
  32808. */
  32809. setHitDistance(distance: number): void;
  32810. /**
  32811. * Calculates the distance manually
  32812. */
  32813. calculateHitDistance(): void;
  32814. /**
  32815. * Resets all the values to default
  32816. * @param from The from point on world space
  32817. * @param to The to point on world space
  32818. */
  32819. reset(from?: Vector3, to?: Vector3): void;
  32820. }
  32821. /**
  32822. * Interface for the size containing width and height
  32823. */
  32824. interface IXYZ {
  32825. /**
  32826. * X
  32827. */
  32828. x: number;
  32829. /**
  32830. * Y
  32831. */
  32832. y: number;
  32833. /**
  32834. * Z
  32835. */
  32836. z: number;
  32837. }
  32838. }
  32839. declare module "babylonjs/Physics/IPhysicsEngine" {
  32840. import { Nullable } from "babylonjs/types";
  32841. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32843. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32844. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32845. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32846. /**
  32847. * Interface used to describe a physics joint
  32848. */
  32849. export interface PhysicsImpostorJoint {
  32850. /** Defines the main impostor to which the joint is linked */
  32851. mainImpostor: PhysicsImpostor;
  32852. /** Defines the impostor that is connected to the main impostor using this joint */
  32853. connectedImpostor: PhysicsImpostor;
  32854. /** Defines the joint itself */
  32855. joint: PhysicsJoint;
  32856. }
  32857. /** @hidden */
  32858. export interface IPhysicsEnginePlugin {
  32859. world: any;
  32860. name: string;
  32861. setGravity(gravity: Vector3): void;
  32862. setTimeStep(timeStep: number): void;
  32863. getTimeStep(): number;
  32864. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32865. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32866. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32867. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32868. removePhysicsBody(impostor: PhysicsImpostor): void;
  32869. generateJoint(joint: PhysicsImpostorJoint): void;
  32870. removeJoint(joint: PhysicsImpostorJoint): void;
  32871. isSupported(): boolean;
  32872. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32873. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32874. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32875. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32876. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32877. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32878. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32879. getBodyMass(impostor: PhysicsImpostor): number;
  32880. getBodyFriction(impostor: PhysicsImpostor): number;
  32881. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32882. getBodyRestitution(impostor: PhysicsImpostor): number;
  32883. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32884. getBodyPressure?(impostor: PhysicsImpostor): number;
  32885. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32886. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32887. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32888. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32889. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32890. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32891. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32892. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32893. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32894. sleepBody(impostor: PhysicsImpostor): void;
  32895. wakeUpBody(impostor: PhysicsImpostor): void;
  32896. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32897. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32898. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32899. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32900. getRadius(impostor: PhysicsImpostor): number;
  32901. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32902. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32903. dispose(): void;
  32904. }
  32905. /**
  32906. * Interface used to define a physics engine
  32907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32908. */
  32909. export interface IPhysicsEngine {
  32910. /**
  32911. * Gets the gravity vector used by the simulation
  32912. */
  32913. gravity: Vector3;
  32914. /**
  32915. * Sets the gravity vector used by the simulation
  32916. * @param gravity defines the gravity vector to use
  32917. */
  32918. setGravity(gravity: Vector3): void;
  32919. /**
  32920. * Set the time step of the physics engine.
  32921. * Default is 1/60.
  32922. * To slow it down, enter 1/600 for example.
  32923. * To speed it up, 1/30
  32924. * @param newTimeStep the new timestep to apply to this world.
  32925. */
  32926. setTimeStep(newTimeStep: number): void;
  32927. /**
  32928. * Get the time step of the physics engine.
  32929. * @returns the current time step
  32930. */
  32931. getTimeStep(): number;
  32932. /**
  32933. * Set the sub time step of the physics engine.
  32934. * Default is 0 meaning there is no sub steps
  32935. * To increase physics resolution precision, set a small value (like 1 ms)
  32936. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32937. */
  32938. setSubTimeStep(subTimeStep: number): void;
  32939. /**
  32940. * Get the sub time step of the physics engine.
  32941. * @returns the current sub time step
  32942. */
  32943. getSubTimeStep(): number;
  32944. /**
  32945. * Release all resources
  32946. */
  32947. dispose(): void;
  32948. /**
  32949. * Gets the name of the current physics plugin
  32950. * @returns the name of the plugin
  32951. */
  32952. getPhysicsPluginName(): string;
  32953. /**
  32954. * Adding a new impostor for the impostor tracking.
  32955. * This will be done by the impostor itself.
  32956. * @param impostor the impostor to add
  32957. */
  32958. addImpostor(impostor: PhysicsImpostor): void;
  32959. /**
  32960. * Remove an impostor from the engine.
  32961. * This impostor and its mesh will not longer be updated by the physics engine.
  32962. * @param impostor the impostor to remove
  32963. */
  32964. removeImpostor(impostor: PhysicsImpostor): void;
  32965. /**
  32966. * Add a joint to the physics engine
  32967. * @param mainImpostor defines the main impostor to which the joint is added.
  32968. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32969. * @param joint defines the joint that will connect both impostors.
  32970. */
  32971. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32972. /**
  32973. * Removes a joint from the simulation
  32974. * @param mainImpostor defines the impostor used with the joint
  32975. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32976. * @param joint defines the joint to remove
  32977. */
  32978. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32979. /**
  32980. * Gets the current plugin used to run the simulation
  32981. * @returns current plugin
  32982. */
  32983. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32984. /**
  32985. * Gets the list of physic impostors
  32986. * @returns an array of PhysicsImpostor
  32987. */
  32988. getImpostors(): Array<PhysicsImpostor>;
  32989. /**
  32990. * Gets the impostor for a physics enabled object
  32991. * @param object defines the object impersonated by the impostor
  32992. * @returns the PhysicsImpostor or null if not found
  32993. */
  32994. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32995. /**
  32996. * Gets the impostor for a physics body object
  32997. * @param body defines physics body used by the impostor
  32998. * @returns the PhysicsImpostor or null if not found
  32999. */
  33000. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33001. /**
  33002. * Does a raycast in the physics world
  33003. * @param from when should the ray start?
  33004. * @param to when should the ray end?
  33005. * @returns PhysicsRaycastResult
  33006. */
  33007. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33008. /**
  33009. * Called by the scene. No need to call it.
  33010. * @param delta defines the timespam between frames
  33011. */
  33012. _step(delta: number): void;
  33013. }
  33014. }
  33015. declare module "babylonjs/Physics/physicsImpostor" {
  33016. import { Nullable, IndicesArray } from "babylonjs/types";
  33017. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33018. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33020. import { Scene } from "babylonjs/scene";
  33021. import { Bone } from "babylonjs/Bones/bone";
  33022. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33023. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33024. import { Space } from "babylonjs/Maths/math.axis";
  33025. /**
  33026. * The interface for the physics imposter parameters
  33027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33028. */
  33029. export interface PhysicsImpostorParameters {
  33030. /**
  33031. * The mass of the physics imposter
  33032. */
  33033. mass: number;
  33034. /**
  33035. * The friction of the physics imposter
  33036. */
  33037. friction?: number;
  33038. /**
  33039. * The coefficient of restitution of the physics imposter
  33040. */
  33041. restitution?: number;
  33042. /**
  33043. * The native options of the physics imposter
  33044. */
  33045. nativeOptions?: any;
  33046. /**
  33047. * Specifies if the parent should be ignored
  33048. */
  33049. ignoreParent?: boolean;
  33050. /**
  33051. * Specifies if bi-directional transformations should be disabled
  33052. */
  33053. disableBidirectionalTransformation?: boolean;
  33054. /**
  33055. * The pressure inside the physics imposter, soft object only
  33056. */
  33057. pressure?: number;
  33058. /**
  33059. * The stiffness the physics imposter, soft object only
  33060. */
  33061. stiffness?: number;
  33062. /**
  33063. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33064. */
  33065. velocityIterations?: number;
  33066. /**
  33067. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33068. */
  33069. positionIterations?: number;
  33070. /**
  33071. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33072. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33073. * Add to fix multiple points
  33074. */
  33075. fixedPoints?: number;
  33076. /**
  33077. * The collision margin around a soft object
  33078. */
  33079. margin?: number;
  33080. /**
  33081. * The collision margin around a soft object
  33082. */
  33083. damping?: number;
  33084. /**
  33085. * The path for a rope based on an extrusion
  33086. */
  33087. path?: any;
  33088. /**
  33089. * The shape of an extrusion used for a rope based on an extrusion
  33090. */
  33091. shape?: any;
  33092. }
  33093. /**
  33094. * Interface for a physics-enabled object
  33095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33096. */
  33097. export interface IPhysicsEnabledObject {
  33098. /**
  33099. * The position of the physics-enabled object
  33100. */
  33101. position: Vector3;
  33102. /**
  33103. * The rotation of the physics-enabled object
  33104. */
  33105. rotationQuaternion: Nullable<Quaternion>;
  33106. /**
  33107. * The scale of the physics-enabled object
  33108. */
  33109. scaling: Vector3;
  33110. /**
  33111. * The rotation of the physics-enabled object
  33112. */
  33113. rotation?: Vector3;
  33114. /**
  33115. * The parent of the physics-enabled object
  33116. */
  33117. parent?: any;
  33118. /**
  33119. * The bounding info of the physics-enabled object
  33120. * @returns The bounding info of the physics-enabled object
  33121. */
  33122. getBoundingInfo(): BoundingInfo;
  33123. /**
  33124. * Computes the world matrix
  33125. * @param force Specifies if the world matrix should be computed by force
  33126. * @returns A world matrix
  33127. */
  33128. computeWorldMatrix(force: boolean): Matrix;
  33129. /**
  33130. * Gets the world matrix
  33131. * @returns A world matrix
  33132. */
  33133. getWorldMatrix?(): Matrix;
  33134. /**
  33135. * Gets the child meshes
  33136. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33137. * @returns An array of abstract meshes
  33138. */
  33139. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33140. /**
  33141. * Gets the vertex data
  33142. * @param kind The type of vertex data
  33143. * @returns A nullable array of numbers, or a float32 array
  33144. */
  33145. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33146. /**
  33147. * Gets the indices from the mesh
  33148. * @returns A nullable array of index arrays
  33149. */
  33150. getIndices?(): Nullable<IndicesArray>;
  33151. /**
  33152. * Gets the scene from the mesh
  33153. * @returns the indices array or null
  33154. */
  33155. getScene?(): Scene;
  33156. /**
  33157. * Gets the absolute position from the mesh
  33158. * @returns the absolute position
  33159. */
  33160. getAbsolutePosition(): Vector3;
  33161. /**
  33162. * Gets the absolute pivot point from the mesh
  33163. * @returns the absolute pivot point
  33164. */
  33165. getAbsolutePivotPoint(): Vector3;
  33166. /**
  33167. * Rotates the mesh
  33168. * @param axis The axis of rotation
  33169. * @param amount The amount of rotation
  33170. * @param space The space of the rotation
  33171. * @returns The rotation transform node
  33172. */
  33173. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33174. /**
  33175. * Translates the mesh
  33176. * @param axis The axis of translation
  33177. * @param distance The distance of translation
  33178. * @param space The space of the translation
  33179. * @returns The transform node
  33180. */
  33181. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33182. /**
  33183. * Sets the absolute position of the mesh
  33184. * @param absolutePosition The absolute position of the mesh
  33185. * @returns The transform node
  33186. */
  33187. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33188. /**
  33189. * Gets the class name of the mesh
  33190. * @returns The class name
  33191. */
  33192. getClassName(): string;
  33193. }
  33194. /**
  33195. * Represents a physics imposter
  33196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33197. */
  33198. export class PhysicsImpostor {
  33199. /**
  33200. * The physics-enabled object used as the physics imposter
  33201. */
  33202. object: IPhysicsEnabledObject;
  33203. /**
  33204. * The type of the physics imposter
  33205. */
  33206. type: number;
  33207. private _options;
  33208. private _scene?;
  33209. /**
  33210. * The default object size of the imposter
  33211. */
  33212. static DEFAULT_OBJECT_SIZE: Vector3;
  33213. /**
  33214. * The identity quaternion of the imposter
  33215. */
  33216. static IDENTITY_QUATERNION: Quaternion;
  33217. /** @hidden */
  33218. _pluginData: any;
  33219. private _physicsEngine;
  33220. private _physicsBody;
  33221. private _bodyUpdateRequired;
  33222. private _onBeforePhysicsStepCallbacks;
  33223. private _onAfterPhysicsStepCallbacks;
  33224. /** @hidden */
  33225. _onPhysicsCollideCallbacks: Array<{
  33226. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33227. otherImpostors: Array<PhysicsImpostor>;
  33228. }>;
  33229. private _deltaPosition;
  33230. private _deltaRotation;
  33231. private _deltaRotationConjugated;
  33232. /** @hidden */
  33233. _isFromLine: boolean;
  33234. private _parent;
  33235. private _isDisposed;
  33236. private static _tmpVecs;
  33237. private static _tmpQuat;
  33238. /**
  33239. * Specifies if the physics imposter is disposed
  33240. */
  33241. get isDisposed(): boolean;
  33242. /**
  33243. * Gets the mass of the physics imposter
  33244. */
  33245. get mass(): number;
  33246. set mass(value: number);
  33247. /**
  33248. * Gets the coefficient of friction
  33249. */
  33250. get friction(): number;
  33251. /**
  33252. * Sets the coefficient of friction
  33253. */
  33254. set friction(value: number);
  33255. /**
  33256. * Gets the coefficient of restitution
  33257. */
  33258. get restitution(): number;
  33259. /**
  33260. * Sets the coefficient of restitution
  33261. */
  33262. set restitution(value: number);
  33263. /**
  33264. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33265. */
  33266. get pressure(): number;
  33267. /**
  33268. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33269. */
  33270. set pressure(value: number);
  33271. /**
  33272. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33273. */
  33274. get stiffness(): number;
  33275. /**
  33276. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33277. */
  33278. set stiffness(value: number);
  33279. /**
  33280. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33281. */
  33282. get velocityIterations(): number;
  33283. /**
  33284. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33285. */
  33286. set velocityIterations(value: number);
  33287. /**
  33288. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33289. */
  33290. get positionIterations(): number;
  33291. /**
  33292. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33293. */
  33294. set positionIterations(value: number);
  33295. /**
  33296. * The unique id of the physics imposter
  33297. * set by the physics engine when adding this impostor to the array
  33298. */
  33299. uniqueId: number;
  33300. /**
  33301. * @hidden
  33302. */
  33303. soft: boolean;
  33304. /**
  33305. * @hidden
  33306. */
  33307. segments: number;
  33308. private _joints;
  33309. /**
  33310. * Initializes the physics imposter
  33311. * @param object The physics-enabled object used as the physics imposter
  33312. * @param type The type of the physics imposter
  33313. * @param _options The options for the physics imposter
  33314. * @param _scene The Babylon scene
  33315. */
  33316. constructor(
  33317. /**
  33318. * The physics-enabled object used as the physics imposter
  33319. */
  33320. object: IPhysicsEnabledObject,
  33321. /**
  33322. * The type of the physics imposter
  33323. */
  33324. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33325. /**
  33326. * This function will completly initialize this impostor.
  33327. * It will create a new body - but only if this mesh has no parent.
  33328. * If it has, this impostor will not be used other than to define the impostor
  33329. * of the child mesh.
  33330. * @hidden
  33331. */
  33332. _init(): void;
  33333. private _getPhysicsParent;
  33334. /**
  33335. * Should a new body be generated.
  33336. * @returns boolean specifying if body initialization is required
  33337. */
  33338. isBodyInitRequired(): boolean;
  33339. /**
  33340. * Sets the updated scaling
  33341. * @param updated Specifies if the scaling is updated
  33342. */
  33343. setScalingUpdated(): void;
  33344. /**
  33345. * Force a regeneration of this or the parent's impostor's body.
  33346. * Use under cautious - This will remove all joints already implemented.
  33347. */
  33348. forceUpdate(): void;
  33349. /**
  33350. * Gets the body that holds this impostor. Either its own, or its parent.
  33351. */
  33352. get physicsBody(): any;
  33353. /**
  33354. * Get the parent of the physics imposter
  33355. * @returns Physics imposter or null
  33356. */
  33357. get parent(): Nullable<PhysicsImpostor>;
  33358. /**
  33359. * Sets the parent of the physics imposter
  33360. */
  33361. set parent(value: Nullable<PhysicsImpostor>);
  33362. /**
  33363. * Set the physics body. Used mainly by the physics engine/plugin
  33364. */
  33365. set physicsBody(physicsBody: any);
  33366. /**
  33367. * Resets the update flags
  33368. */
  33369. resetUpdateFlags(): void;
  33370. /**
  33371. * Gets the object extend size
  33372. * @returns the object extend size
  33373. */
  33374. getObjectExtendSize(): Vector3;
  33375. /**
  33376. * Gets the object center
  33377. * @returns The object center
  33378. */
  33379. getObjectCenter(): Vector3;
  33380. /**
  33381. * Get a specific parameter from the options parameters
  33382. * @param paramName The object parameter name
  33383. * @returns The object parameter
  33384. */
  33385. getParam(paramName: string): any;
  33386. /**
  33387. * Sets a specific parameter in the options given to the physics plugin
  33388. * @param paramName The parameter name
  33389. * @param value The value of the parameter
  33390. */
  33391. setParam(paramName: string, value: number): void;
  33392. /**
  33393. * Specifically change the body's mass option. Won't recreate the physics body object
  33394. * @param mass The mass of the physics imposter
  33395. */
  33396. setMass(mass: number): void;
  33397. /**
  33398. * Gets the linear velocity
  33399. * @returns linear velocity or null
  33400. */
  33401. getLinearVelocity(): Nullable<Vector3>;
  33402. /**
  33403. * Sets the linear velocity
  33404. * @param velocity linear velocity or null
  33405. */
  33406. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33407. /**
  33408. * Gets the angular velocity
  33409. * @returns angular velocity or null
  33410. */
  33411. getAngularVelocity(): Nullable<Vector3>;
  33412. /**
  33413. * Sets the angular velocity
  33414. * @param velocity The velocity or null
  33415. */
  33416. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33417. /**
  33418. * Execute a function with the physics plugin native code
  33419. * Provide a function the will have two variables - the world object and the physics body object
  33420. * @param func The function to execute with the physics plugin native code
  33421. */
  33422. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33423. /**
  33424. * Register a function that will be executed before the physics world is stepping forward
  33425. * @param func The function to execute before the physics world is stepped forward
  33426. */
  33427. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33428. /**
  33429. * Unregister a function that will be executed before the physics world is stepping forward
  33430. * @param func The function to execute before the physics world is stepped forward
  33431. */
  33432. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33433. /**
  33434. * Register a function that will be executed after the physics step
  33435. * @param func The function to execute after physics step
  33436. */
  33437. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33438. /**
  33439. * Unregisters a function that will be executed after the physics step
  33440. * @param func The function to execute after physics step
  33441. */
  33442. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33443. /**
  33444. * register a function that will be executed when this impostor collides against a different body
  33445. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33446. * @param func Callback that is executed on collision
  33447. */
  33448. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33449. /**
  33450. * Unregisters the physics imposter on contact
  33451. * @param collideAgainst The physics object to collide against
  33452. * @param func Callback to execute on collision
  33453. */
  33454. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33455. private _tmpQuat;
  33456. private _tmpQuat2;
  33457. /**
  33458. * Get the parent rotation
  33459. * @returns The parent rotation
  33460. */
  33461. getParentsRotation(): Quaternion;
  33462. /**
  33463. * this function is executed by the physics engine.
  33464. */
  33465. beforeStep: () => void;
  33466. /**
  33467. * this function is executed by the physics engine
  33468. */
  33469. afterStep: () => void;
  33470. /**
  33471. * Legacy collision detection event support
  33472. */
  33473. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33474. /**
  33475. * event and body object due to cannon's event-based architecture.
  33476. */
  33477. onCollide: (e: {
  33478. body: any;
  33479. point: Nullable<Vector3>;
  33480. }) => void;
  33481. /**
  33482. * Apply a force
  33483. * @param force The force to apply
  33484. * @param contactPoint The contact point for the force
  33485. * @returns The physics imposter
  33486. */
  33487. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33488. /**
  33489. * Apply an impulse
  33490. * @param force The impulse force
  33491. * @param contactPoint The contact point for the impulse force
  33492. * @returns The physics imposter
  33493. */
  33494. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33495. /**
  33496. * A help function to create a joint
  33497. * @param otherImpostor A physics imposter used to create a joint
  33498. * @param jointType The type of joint
  33499. * @param jointData The data for the joint
  33500. * @returns The physics imposter
  33501. */
  33502. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33503. /**
  33504. * Add a joint to this impostor with a different impostor
  33505. * @param otherImpostor A physics imposter used to add a joint
  33506. * @param joint The joint to add
  33507. * @returns The physics imposter
  33508. */
  33509. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33510. /**
  33511. * Add an anchor to a cloth impostor
  33512. * @param otherImpostor rigid impostor to anchor to
  33513. * @param width ratio across width from 0 to 1
  33514. * @param height ratio up height from 0 to 1
  33515. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33516. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33517. * @returns impostor the soft imposter
  33518. */
  33519. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33520. /**
  33521. * Add a hook to a rope impostor
  33522. * @param otherImpostor rigid impostor to anchor to
  33523. * @param length ratio across rope from 0 to 1
  33524. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33525. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33526. * @returns impostor the rope imposter
  33527. */
  33528. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33529. /**
  33530. * Will keep this body still, in a sleep mode.
  33531. * @returns the physics imposter
  33532. */
  33533. sleep(): PhysicsImpostor;
  33534. /**
  33535. * Wake the body up.
  33536. * @returns The physics imposter
  33537. */
  33538. wakeUp(): PhysicsImpostor;
  33539. /**
  33540. * Clones the physics imposter
  33541. * @param newObject The physics imposter clones to this physics-enabled object
  33542. * @returns A nullable physics imposter
  33543. */
  33544. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33545. /**
  33546. * Disposes the physics imposter
  33547. */
  33548. dispose(): void;
  33549. /**
  33550. * Sets the delta position
  33551. * @param position The delta position amount
  33552. */
  33553. setDeltaPosition(position: Vector3): void;
  33554. /**
  33555. * Sets the delta rotation
  33556. * @param rotation The delta rotation amount
  33557. */
  33558. setDeltaRotation(rotation: Quaternion): void;
  33559. /**
  33560. * Gets the box size of the physics imposter and stores the result in the input parameter
  33561. * @param result Stores the box size
  33562. * @returns The physics imposter
  33563. */
  33564. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33565. /**
  33566. * Gets the radius of the physics imposter
  33567. * @returns Radius of the physics imposter
  33568. */
  33569. getRadius(): number;
  33570. /**
  33571. * Sync a bone with this impostor
  33572. * @param bone The bone to sync to the impostor.
  33573. * @param boneMesh The mesh that the bone is influencing.
  33574. * @param jointPivot The pivot of the joint / bone in local space.
  33575. * @param distToJoint Optional distance from the impostor to the joint.
  33576. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33577. */
  33578. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33579. /**
  33580. * Sync impostor to a bone
  33581. * @param bone The bone that the impostor will be synced to.
  33582. * @param boneMesh The mesh that the bone is influencing.
  33583. * @param jointPivot The pivot of the joint / bone in local space.
  33584. * @param distToJoint Optional distance from the impostor to the joint.
  33585. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33586. * @param boneAxis Optional vector3 axis the bone is aligned with
  33587. */
  33588. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33589. /**
  33590. * No-Imposter type
  33591. */
  33592. static NoImpostor: number;
  33593. /**
  33594. * Sphere-Imposter type
  33595. */
  33596. static SphereImpostor: number;
  33597. /**
  33598. * Box-Imposter type
  33599. */
  33600. static BoxImpostor: number;
  33601. /**
  33602. * Plane-Imposter type
  33603. */
  33604. static PlaneImpostor: number;
  33605. /**
  33606. * Mesh-imposter type
  33607. */
  33608. static MeshImpostor: number;
  33609. /**
  33610. * Capsule-Impostor type (Ammo.js plugin only)
  33611. */
  33612. static CapsuleImpostor: number;
  33613. /**
  33614. * Cylinder-Imposter type
  33615. */
  33616. static CylinderImpostor: number;
  33617. /**
  33618. * Particle-Imposter type
  33619. */
  33620. static ParticleImpostor: number;
  33621. /**
  33622. * Heightmap-Imposter type
  33623. */
  33624. static HeightmapImpostor: number;
  33625. /**
  33626. * ConvexHull-Impostor type (Ammo.js plugin only)
  33627. */
  33628. static ConvexHullImpostor: number;
  33629. /**
  33630. * Custom-Imposter type (Ammo.js plugin only)
  33631. */
  33632. static CustomImpostor: number;
  33633. /**
  33634. * Rope-Imposter type
  33635. */
  33636. static RopeImpostor: number;
  33637. /**
  33638. * Cloth-Imposter type
  33639. */
  33640. static ClothImpostor: number;
  33641. /**
  33642. * Softbody-Imposter type
  33643. */
  33644. static SoftbodyImpostor: number;
  33645. }
  33646. }
  33647. declare module "babylonjs/Meshes/mesh" {
  33648. import { Observable } from "babylonjs/Misc/observable";
  33649. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33650. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33651. import { Camera } from "babylonjs/Cameras/camera";
  33652. import { Scene } from "babylonjs/scene";
  33653. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33654. import { Color4 } from "babylonjs/Maths/math.color";
  33655. import { Engine } from "babylonjs/Engines/engine";
  33656. import { Node } from "babylonjs/node";
  33657. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33658. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33659. import { Buffer } from "babylonjs/Meshes/buffer";
  33660. import { Geometry } from "babylonjs/Meshes/geometry";
  33661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33662. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33663. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33664. import { Effect } from "babylonjs/Materials/effect";
  33665. import { Material } from "babylonjs/Materials/material";
  33666. import { Skeleton } from "babylonjs/Bones/skeleton";
  33667. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33668. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33669. import { Path3D } from "babylonjs/Maths/math.path";
  33670. import { Plane } from "babylonjs/Maths/math.plane";
  33671. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33672. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33673. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33674. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33675. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33676. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33677. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33678. /**
  33679. * @hidden
  33680. **/
  33681. export class _CreationDataStorage {
  33682. closePath?: boolean;
  33683. closeArray?: boolean;
  33684. idx: number[];
  33685. dashSize: number;
  33686. gapSize: number;
  33687. path3D: Path3D;
  33688. pathArray: Vector3[][];
  33689. arc: number;
  33690. radius: number;
  33691. cap: number;
  33692. tessellation: number;
  33693. }
  33694. /**
  33695. * @hidden
  33696. **/
  33697. class _InstanceDataStorage {
  33698. visibleInstances: any;
  33699. batchCache: _InstancesBatch;
  33700. instancesBufferSize: number;
  33701. instancesBuffer: Nullable<Buffer>;
  33702. instancesData: Float32Array;
  33703. overridenInstanceCount: number;
  33704. isFrozen: boolean;
  33705. previousBatch: Nullable<_InstancesBatch>;
  33706. hardwareInstancedRendering: boolean;
  33707. sideOrientation: number;
  33708. manualUpdate: boolean;
  33709. previousRenderId: number;
  33710. }
  33711. /**
  33712. * @hidden
  33713. **/
  33714. export class _InstancesBatch {
  33715. mustReturn: boolean;
  33716. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33717. renderSelf: boolean[];
  33718. hardwareInstancedRendering: boolean[];
  33719. }
  33720. /**
  33721. * @hidden
  33722. **/
  33723. class _ThinInstanceDataStorage {
  33724. instancesCount: number;
  33725. matrixBuffer: Nullable<Buffer>;
  33726. matrixBufferSize: number;
  33727. matrixData: Nullable<Float32Array>;
  33728. boundingVectors: Array<Vector3>;
  33729. worldMatrices: Nullable<Matrix[]>;
  33730. }
  33731. /**
  33732. * Class used to represent renderable models
  33733. */
  33734. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33735. /**
  33736. * Mesh side orientation : usually the external or front surface
  33737. */
  33738. static readonly FRONTSIDE: number;
  33739. /**
  33740. * Mesh side orientation : usually the internal or back surface
  33741. */
  33742. static readonly BACKSIDE: number;
  33743. /**
  33744. * Mesh side orientation : both internal and external or front and back surfaces
  33745. */
  33746. static readonly DOUBLESIDE: number;
  33747. /**
  33748. * Mesh side orientation : by default, `FRONTSIDE`
  33749. */
  33750. static readonly DEFAULTSIDE: number;
  33751. /**
  33752. * Mesh cap setting : no cap
  33753. */
  33754. static readonly NO_CAP: number;
  33755. /**
  33756. * Mesh cap setting : one cap at the beginning of the mesh
  33757. */
  33758. static readonly CAP_START: number;
  33759. /**
  33760. * Mesh cap setting : one cap at the end of the mesh
  33761. */
  33762. static readonly CAP_END: number;
  33763. /**
  33764. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33765. */
  33766. static readonly CAP_ALL: number;
  33767. /**
  33768. * Mesh pattern setting : no flip or rotate
  33769. */
  33770. static readonly NO_FLIP: number;
  33771. /**
  33772. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33773. */
  33774. static readonly FLIP_TILE: number;
  33775. /**
  33776. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33777. */
  33778. static readonly ROTATE_TILE: number;
  33779. /**
  33780. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33781. */
  33782. static readonly FLIP_ROW: number;
  33783. /**
  33784. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33785. */
  33786. static readonly ROTATE_ROW: number;
  33787. /**
  33788. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33789. */
  33790. static readonly FLIP_N_ROTATE_TILE: number;
  33791. /**
  33792. * Mesh pattern setting : rotate pattern and rotate
  33793. */
  33794. static readonly FLIP_N_ROTATE_ROW: number;
  33795. /**
  33796. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33797. */
  33798. static readonly CENTER: number;
  33799. /**
  33800. * Mesh tile positioning : part tiles on left
  33801. */
  33802. static readonly LEFT: number;
  33803. /**
  33804. * Mesh tile positioning : part tiles on right
  33805. */
  33806. static readonly RIGHT: number;
  33807. /**
  33808. * Mesh tile positioning : part tiles on top
  33809. */
  33810. static readonly TOP: number;
  33811. /**
  33812. * Mesh tile positioning : part tiles on bottom
  33813. */
  33814. static readonly BOTTOM: number;
  33815. /**
  33816. * Gets the default side orientation.
  33817. * @param orientation the orientation to value to attempt to get
  33818. * @returns the default orientation
  33819. * @hidden
  33820. */
  33821. static _GetDefaultSideOrientation(orientation?: number): number;
  33822. private _internalMeshDataInfo;
  33823. get computeBonesUsingShaders(): boolean;
  33824. set computeBonesUsingShaders(value: boolean);
  33825. /**
  33826. * An event triggered before rendering the mesh
  33827. */
  33828. get onBeforeRenderObservable(): Observable<Mesh>;
  33829. /**
  33830. * An event triggered before binding the mesh
  33831. */
  33832. get onBeforeBindObservable(): Observable<Mesh>;
  33833. /**
  33834. * An event triggered after rendering the mesh
  33835. */
  33836. get onAfterRenderObservable(): Observable<Mesh>;
  33837. /**
  33838. * An event triggered before drawing the mesh
  33839. */
  33840. get onBeforeDrawObservable(): Observable<Mesh>;
  33841. private _onBeforeDrawObserver;
  33842. /**
  33843. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33844. */
  33845. set onBeforeDraw(callback: () => void);
  33846. get hasInstances(): boolean;
  33847. get hasThinInstances(): boolean;
  33848. /**
  33849. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33850. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33851. */
  33852. delayLoadState: number;
  33853. /**
  33854. * Gets the list of instances created from this mesh
  33855. * it is not supposed to be modified manually.
  33856. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33857. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33858. */
  33859. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33860. /**
  33861. * Gets the file containing delay loading data for this mesh
  33862. */
  33863. delayLoadingFile: string;
  33864. /** @hidden */
  33865. _binaryInfo: any;
  33866. /**
  33867. * User defined function used to change how LOD level selection is done
  33868. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33869. */
  33870. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33871. /**
  33872. * Gets or sets the morph target manager
  33873. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33874. */
  33875. get morphTargetManager(): Nullable<MorphTargetManager>;
  33876. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33877. /** @hidden */
  33878. _creationDataStorage: Nullable<_CreationDataStorage>;
  33879. /** @hidden */
  33880. _geometry: Nullable<Geometry>;
  33881. /** @hidden */
  33882. _delayInfo: Array<string>;
  33883. /** @hidden */
  33884. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33885. /** @hidden */
  33886. _instanceDataStorage: _InstanceDataStorage;
  33887. /** @hidden */
  33888. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33889. private _effectiveMaterial;
  33890. /** @hidden */
  33891. _shouldGenerateFlatShading: boolean;
  33892. /** @hidden */
  33893. _originalBuilderSideOrientation: number;
  33894. /**
  33895. * Use this property to change the original side orientation defined at construction time
  33896. */
  33897. overrideMaterialSideOrientation: Nullable<number>;
  33898. /**
  33899. * Gets the source mesh (the one used to clone this one from)
  33900. */
  33901. get source(): Nullable<Mesh>;
  33902. /**
  33903. * Gets the list of clones of this mesh
  33904. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33905. * Note that useClonedMeshMap=true is the default setting
  33906. */
  33907. get cloneMeshMap(): Nullable<{
  33908. [id: string]: Mesh | undefined;
  33909. }>;
  33910. /**
  33911. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33912. */
  33913. get isUnIndexed(): boolean;
  33914. set isUnIndexed(value: boolean);
  33915. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33916. get worldMatrixInstancedBuffer(): Float32Array;
  33917. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33918. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33919. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33920. /**
  33921. * @constructor
  33922. * @param name The value used by scene.getMeshByName() to do a lookup.
  33923. * @param scene The scene to add this mesh to.
  33924. * @param parent The parent of this mesh, if it has one
  33925. * @param source An optional Mesh from which geometry is shared, cloned.
  33926. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33927. * When false, achieved by calling a clone(), also passing False.
  33928. * This will make creation of children, recursive.
  33929. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33930. */
  33931. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33932. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33933. doNotInstantiate: boolean;
  33934. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33935. /**
  33936. * Gets the class name
  33937. * @returns the string "Mesh".
  33938. */
  33939. getClassName(): string;
  33940. /** @hidden */
  33941. get _isMesh(): boolean;
  33942. /**
  33943. * Returns a description of this mesh
  33944. * @param fullDetails define if full details about this mesh must be used
  33945. * @returns a descriptive string representing this mesh
  33946. */
  33947. toString(fullDetails?: boolean): string;
  33948. /** @hidden */
  33949. _unBindEffect(): void;
  33950. /**
  33951. * Gets a boolean indicating if this mesh has LOD
  33952. */
  33953. get hasLODLevels(): boolean;
  33954. /**
  33955. * Gets the list of MeshLODLevel associated with the current mesh
  33956. * @returns an array of MeshLODLevel
  33957. */
  33958. getLODLevels(): MeshLODLevel[];
  33959. private _sortLODLevels;
  33960. /**
  33961. * Add a mesh as LOD level triggered at the given distance.
  33962. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33963. * @param distance The distance from the center of the object to show this level
  33964. * @param mesh The mesh to be added as LOD level (can be null)
  33965. * @return This mesh (for chaining)
  33966. */
  33967. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33968. /**
  33969. * Returns the LOD level mesh at the passed distance or null if not found.
  33970. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33971. * @param distance The distance from the center of the object to show this level
  33972. * @returns a Mesh or `null`
  33973. */
  33974. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33975. /**
  33976. * Remove a mesh from the LOD array
  33977. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33978. * @param mesh defines the mesh to be removed
  33979. * @return This mesh (for chaining)
  33980. */
  33981. removeLODLevel(mesh: Mesh): Mesh;
  33982. /**
  33983. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33984. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33985. * @param camera defines the camera to use to compute distance
  33986. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33987. * @return This mesh (for chaining)
  33988. */
  33989. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33990. /**
  33991. * Gets the mesh internal Geometry object
  33992. */
  33993. get geometry(): Nullable<Geometry>;
  33994. /**
  33995. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33996. * @returns the total number of vertices
  33997. */
  33998. getTotalVertices(): number;
  33999. /**
  34000. * Returns the content of an associated vertex buffer
  34001. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34002. * - VertexBuffer.PositionKind
  34003. * - VertexBuffer.UVKind
  34004. * - VertexBuffer.UV2Kind
  34005. * - VertexBuffer.UV3Kind
  34006. * - VertexBuffer.UV4Kind
  34007. * - VertexBuffer.UV5Kind
  34008. * - VertexBuffer.UV6Kind
  34009. * - VertexBuffer.ColorKind
  34010. * - VertexBuffer.MatricesIndicesKind
  34011. * - VertexBuffer.MatricesIndicesExtraKind
  34012. * - VertexBuffer.MatricesWeightsKind
  34013. * - VertexBuffer.MatricesWeightsExtraKind
  34014. * @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
  34015. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34016. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34017. */
  34018. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34019. /**
  34020. * Returns the mesh VertexBuffer object from the requested `kind`
  34021. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34022. * - VertexBuffer.PositionKind
  34023. * - VertexBuffer.NormalKind
  34024. * - VertexBuffer.UVKind
  34025. * - VertexBuffer.UV2Kind
  34026. * - VertexBuffer.UV3Kind
  34027. * - VertexBuffer.UV4Kind
  34028. * - VertexBuffer.UV5Kind
  34029. * - VertexBuffer.UV6Kind
  34030. * - VertexBuffer.ColorKind
  34031. * - VertexBuffer.MatricesIndicesKind
  34032. * - VertexBuffer.MatricesIndicesExtraKind
  34033. * - VertexBuffer.MatricesWeightsKind
  34034. * - VertexBuffer.MatricesWeightsExtraKind
  34035. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34036. */
  34037. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34038. /**
  34039. * Tests if a specific vertex buffer is associated with this mesh
  34040. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34041. * - VertexBuffer.PositionKind
  34042. * - VertexBuffer.NormalKind
  34043. * - VertexBuffer.UVKind
  34044. * - VertexBuffer.UV2Kind
  34045. * - VertexBuffer.UV3Kind
  34046. * - VertexBuffer.UV4Kind
  34047. * - VertexBuffer.UV5Kind
  34048. * - VertexBuffer.UV6Kind
  34049. * - VertexBuffer.ColorKind
  34050. * - VertexBuffer.MatricesIndicesKind
  34051. * - VertexBuffer.MatricesIndicesExtraKind
  34052. * - VertexBuffer.MatricesWeightsKind
  34053. * - VertexBuffer.MatricesWeightsExtraKind
  34054. * @returns a boolean
  34055. */
  34056. isVerticesDataPresent(kind: string): boolean;
  34057. /**
  34058. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34059. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34060. * - VertexBuffer.PositionKind
  34061. * - VertexBuffer.UVKind
  34062. * - VertexBuffer.UV2Kind
  34063. * - VertexBuffer.UV3Kind
  34064. * - VertexBuffer.UV4Kind
  34065. * - VertexBuffer.UV5Kind
  34066. * - VertexBuffer.UV6Kind
  34067. * - VertexBuffer.ColorKind
  34068. * - VertexBuffer.MatricesIndicesKind
  34069. * - VertexBuffer.MatricesIndicesExtraKind
  34070. * - VertexBuffer.MatricesWeightsKind
  34071. * - VertexBuffer.MatricesWeightsExtraKind
  34072. * @returns a boolean
  34073. */
  34074. isVertexBufferUpdatable(kind: string): boolean;
  34075. /**
  34076. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34077. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34078. * - VertexBuffer.PositionKind
  34079. * - VertexBuffer.NormalKind
  34080. * - VertexBuffer.UVKind
  34081. * - VertexBuffer.UV2Kind
  34082. * - VertexBuffer.UV3Kind
  34083. * - VertexBuffer.UV4Kind
  34084. * - VertexBuffer.UV5Kind
  34085. * - VertexBuffer.UV6Kind
  34086. * - VertexBuffer.ColorKind
  34087. * - VertexBuffer.MatricesIndicesKind
  34088. * - VertexBuffer.MatricesIndicesExtraKind
  34089. * - VertexBuffer.MatricesWeightsKind
  34090. * - VertexBuffer.MatricesWeightsExtraKind
  34091. * @returns an array of strings
  34092. */
  34093. getVerticesDataKinds(): string[];
  34094. /**
  34095. * Returns a positive integer : the total number of indices in this mesh geometry.
  34096. * @returns the numner of indices or zero if the mesh has no geometry.
  34097. */
  34098. getTotalIndices(): number;
  34099. /**
  34100. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34101. * @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.
  34102. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34103. * @returns the indices array or an empty array if the mesh has no geometry
  34104. */
  34105. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34106. get isBlocked(): boolean;
  34107. /**
  34108. * Determine if the current mesh is ready to be rendered
  34109. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34110. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34111. * @returns true if all associated assets are ready (material, textures, shaders)
  34112. */
  34113. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34114. /**
  34115. * 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.
  34116. */
  34117. get areNormalsFrozen(): boolean;
  34118. /**
  34119. * 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.
  34120. * @returns the current mesh
  34121. */
  34122. freezeNormals(): Mesh;
  34123. /**
  34124. * 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
  34125. * @returns the current mesh
  34126. */
  34127. unfreezeNormals(): Mesh;
  34128. /**
  34129. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34130. */
  34131. set overridenInstanceCount(count: number);
  34132. /** @hidden */
  34133. _preActivate(): Mesh;
  34134. /** @hidden */
  34135. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34136. /** @hidden */
  34137. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34138. protected _afterComputeWorldMatrix(): void;
  34139. /** @hidden */
  34140. _postActivate(): void;
  34141. /**
  34142. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34143. * This means the mesh underlying bounding box and sphere are recomputed.
  34144. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34145. * @returns the current mesh
  34146. */
  34147. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34148. /** @hidden */
  34149. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34150. /**
  34151. * This function will subdivide the mesh into multiple submeshes
  34152. * @param count defines the expected number of submeshes
  34153. */
  34154. subdivide(count: number): void;
  34155. /**
  34156. * Copy a FloatArray into a specific associated vertex buffer
  34157. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34158. * - VertexBuffer.PositionKind
  34159. * - VertexBuffer.UVKind
  34160. * - VertexBuffer.UV2Kind
  34161. * - VertexBuffer.UV3Kind
  34162. * - VertexBuffer.UV4Kind
  34163. * - VertexBuffer.UV5Kind
  34164. * - VertexBuffer.UV6Kind
  34165. * - VertexBuffer.ColorKind
  34166. * - VertexBuffer.MatricesIndicesKind
  34167. * - VertexBuffer.MatricesIndicesExtraKind
  34168. * - VertexBuffer.MatricesWeightsKind
  34169. * - VertexBuffer.MatricesWeightsExtraKind
  34170. * @param data defines the data source
  34171. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34172. * @param stride defines the data stride size (can be null)
  34173. * @returns the current mesh
  34174. */
  34175. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34176. /**
  34177. * Delete a vertex buffer associated with this mesh
  34178. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34179. * - VertexBuffer.PositionKind
  34180. * - VertexBuffer.UVKind
  34181. * - VertexBuffer.UV2Kind
  34182. * - VertexBuffer.UV3Kind
  34183. * - VertexBuffer.UV4Kind
  34184. * - VertexBuffer.UV5Kind
  34185. * - VertexBuffer.UV6Kind
  34186. * - VertexBuffer.ColorKind
  34187. * - VertexBuffer.MatricesIndicesKind
  34188. * - VertexBuffer.MatricesIndicesExtraKind
  34189. * - VertexBuffer.MatricesWeightsKind
  34190. * - VertexBuffer.MatricesWeightsExtraKind
  34191. */
  34192. removeVerticesData(kind: string): void;
  34193. /**
  34194. * Flags an associated vertex buffer as updatable
  34195. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34196. * - VertexBuffer.PositionKind
  34197. * - VertexBuffer.UVKind
  34198. * - VertexBuffer.UV2Kind
  34199. * - VertexBuffer.UV3Kind
  34200. * - VertexBuffer.UV4Kind
  34201. * - VertexBuffer.UV5Kind
  34202. * - VertexBuffer.UV6Kind
  34203. * - VertexBuffer.ColorKind
  34204. * - VertexBuffer.MatricesIndicesKind
  34205. * - VertexBuffer.MatricesIndicesExtraKind
  34206. * - VertexBuffer.MatricesWeightsKind
  34207. * - VertexBuffer.MatricesWeightsExtraKind
  34208. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34209. */
  34210. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34211. /**
  34212. * Sets the mesh global Vertex Buffer
  34213. * @param buffer defines the buffer to use
  34214. * @returns the current mesh
  34215. */
  34216. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34217. /**
  34218. * Update a specific associated vertex buffer
  34219. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34220. * - VertexBuffer.PositionKind
  34221. * - VertexBuffer.UVKind
  34222. * - VertexBuffer.UV2Kind
  34223. * - VertexBuffer.UV3Kind
  34224. * - VertexBuffer.UV4Kind
  34225. * - VertexBuffer.UV5Kind
  34226. * - VertexBuffer.UV6Kind
  34227. * - VertexBuffer.ColorKind
  34228. * - VertexBuffer.MatricesIndicesKind
  34229. * - VertexBuffer.MatricesIndicesExtraKind
  34230. * - VertexBuffer.MatricesWeightsKind
  34231. * - VertexBuffer.MatricesWeightsExtraKind
  34232. * @param data defines the data source
  34233. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34234. * @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)
  34235. * @returns the current mesh
  34236. */
  34237. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34238. /**
  34239. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34240. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34241. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34242. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34243. * @returns the current mesh
  34244. */
  34245. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34246. /**
  34247. * Creates a un-shared specific occurence of the geometry for the mesh.
  34248. * @returns the current mesh
  34249. */
  34250. makeGeometryUnique(): Mesh;
  34251. /**
  34252. * Set the index buffer of this mesh
  34253. * @param indices defines the source data
  34254. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34255. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34256. * @returns the current mesh
  34257. */
  34258. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34259. /**
  34260. * Update the current index buffer
  34261. * @param indices defines the source data
  34262. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34263. * @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)
  34264. * @returns the current mesh
  34265. */
  34266. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34267. /**
  34268. * Invert the geometry to move from a right handed system to a left handed one.
  34269. * @returns the current mesh
  34270. */
  34271. toLeftHanded(): Mesh;
  34272. /** @hidden */
  34273. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34274. /** @hidden */
  34275. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34276. /**
  34277. * Registers for this mesh a javascript function called just before the rendering process
  34278. * @param func defines the function to call before rendering this mesh
  34279. * @returns the current mesh
  34280. */
  34281. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34282. /**
  34283. * Disposes a previously registered javascript function called before the rendering
  34284. * @param func defines the function to remove
  34285. * @returns the current mesh
  34286. */
  34287. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34288. /**
  34289. * Registers for this mesh a javascript function called just after the rendering is complete
  34290. * @param func defines the function to call after rendering this mesh
  34291. * @returns the current mesh
  34292. */
  34293. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34294. /**
  34295. * Disposes a previously registered javascript function called after the rendering.
  34296. * @param func defines the function to remove
  34297. * @returns the current mesh
  34298. */
  34299. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34300. /** @hidden */
  34301. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34302. /** @hidden */
  34303. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34304. /** @hidden */
  34305. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34306. /** @hidden */
  34307. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34308. /** @hidden */
  34309. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34310. /** @hidden */
  34311. _rebuild(): void;
  34312. /** @hidden */
  34313. _freeze(): void;
  34314. /** @hidden */
  34315. _unFreeze(): void;
  34316. /**
  34317. * 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
  34318. * @param subMesh defines the subMesh to render
  34319. * @param enableAlphaMode defines if alpha mode can be changed
  34320. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34321. * @returns the current mesh
  34322. */
  34323. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34324. private _onBeforeDraw;
  34325. /**
  34326. * Renormalize the mesh and patch it up if there are no weights
  34327. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34328. * However in the case of zero weights then we set just a single influence to 1.
  34329. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34330. */
  34331. cleanMatrixWeights(): void;
  34332. private normalizeSkinFourWeights;
  34333. private normalizeSkinWeightsAndExtra;
  34334. /**
  34335. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34336. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34337. * the user know there was an issue with importing the mesh
  34338. * @returns a validation object with skinned, valid and report string
  34339. */
  34340. validateSkinning(): {
  34341. skinned: boolean;
  34342. valid: boolean;
  34343. report: string;
  34344. };
  34345. /** @hidden */
  34346. _checkDelayState(): Mesh;
  34347. private _queueLoad;
  34348. /**
  34349. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34350. * A mesh is in the frustum if its bounding box intersects the frustum
  34351. * @param frustumPlanes defines the frustum to test
  34352. * @returns true if the mesh is in the frustum planes
  34353. */
  34354. isInFrustum(frustumPlanes: Plane[]): boolean;
  34355. /**
  34356. * Sets the mesh material by the material or multiMaterial `id` property
  34357. * @param id is a string identifying the material or the multiMaterial
  34358. * @returns the current mesh
  34359. */
  34360. setMaterialByID(id: string): Mesh;
  34361. /**
  34362. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34363. * @returns an array of IAnimatable
  34364. */
  34365. getAnimatables(): IAnimatable[];
  34366. /**
  34367. * Modifies the mesh geometry according to the passed transformation matrix.
  34368. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34369. * The mesh normals are modified using the same transformation.
  34370. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34371. * @param transform defines the transform matrix to use
  34372. * @see https://doc.babylonjs.com/resources/baking_transformations
  34373. * @returns the current mesh
  34374. */
  34375. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34376. /**
  34377. * Modifies the mesh geometry according to its own current World Matrix.
  34378. * The mesh World Matrix is then reset.
  34379. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34380. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34381. * @see https://doc.babylonjs.com/resources/baking_transformations
  34382. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34383. * @returns the current mesh
  34384. */
  34385. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34386. /** @hidden */
  34387. get _positions(): Nullable<Vector3[]>;
  34388. /** @hidden */
  34389. _resetPointsArrayCache(): Mesh;
  34390. /** @hidden */
  34391. _generatePointsArray(): boolean;
  34392. /**
  34393. * Returns a new Mesh object generated from the current mesh properties.
  34394. * This method must not get confused with createInstance()
  34395. * @param name is a string, the name given to the new mesh
  34396. * @param newParent can be any Node object (default `null`)
  34397. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34398. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34399. * @returns a new mesh
  34400. */
  34401. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34402. /**
  34403. * Releases resources associated with this mesh.
  34404. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34405. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34406. */
  34407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34408. /** @hidden */
  34409. _disposeInstanceSpecificData(): void;
  34410. /** @hidden */
  34411. _disposeThinInstanceSpecificData(): void;
  34412. /**
  34413. * Modifies the mesh geometry according to a displacement map.
  34414. * 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.
  34415. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34416. * @param url is a string, the URL from the image file is to be downloaded.
  34417. * @param minHeight is the lower limit of the displacement.
  34418. * @param maxHeight is the upper limit of the displacement.
  34419. * @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.
  34420. * @param uvOffset is an optional vector2 used to offset UV.
  34421. * @param uvScale is an optional vector2 used to scale UV.
  34422. * @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.
  34423. * @returns the Mesh.
  34424. */
  34425. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34426. /**
  34427. * Modifies the mesh geometry according to a displacementMap buffer.
  34428. * 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.
  34429. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34430. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34431. * @param heightMapWidth is the width of the buffer image.
  34432. * @param heightMapHeight is the height of the buffer image.
  34433. * @param minHeight is the lower limit of the displacement.
  34434. * @param maxHeight is the upper limit of the displacement.
  34435. * @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.
  34436. * @param uvOffset is an optional vector2 used to offset UV.
  34437. * @param uvScale is an optional vector2 used to scale UV.
  34438. * @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.
  34439. * @returns the Mesh.
  34440. */
  34441. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34442. /**
  34443. * Modify the mesh to get a flat shading rendering.
  34444. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34445. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34446. * @returns current mesh
  34447. */
  34448. convertToFlatShadedMesh(): Mesh;
  34449. /**
  34450. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34451. * In other words, more vertices, no more indices and a single bigger VBO.
  34452. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34453. * @returns current mesh
  34454. */
  34455. convertToUnIndexedMesh(): Mesh;
  34456. /**
  34457. * Inverses facet orientations.
  34458. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34459. * @param flipNormals will also inverts the normals
  34460. * @returns current mesh
  34461. */
  34462. flipFaces(flipNormals?: boolean): Mesh;
  34463. /**
  34464. * Increase the number of facets and hence vertices in a mesh
  34465. * Vertex normals are interpolated from existing vertex normals
  34466. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34467. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34468. */
  34469. increaseVertices(numberPerEdge: number): void;
  34470. /**
  34471. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34472. * This will undo any application of covertToFlatShadedMesh
  34473. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34474. */
  34475. forceSharedVertices(): void;
  34476. /** @hidden */
  34477. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34478. /** @hidden */
  34479. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34480. /**
  34481. * Creates a new InstancedMesh object from the mesh model.
  34482. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34483. * @param name defines the name of the new instance
  34484. * @returns a new InstancedMesh
  34485. */
  34486. createInstance(name: string): InstancedMesh;
  34487. /**
  34488. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34489. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34490. * @returns the current mesh
  34491. */
  34492. synchronizeInstances(): Mesh;
  34493. /**
  34494. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34495. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34496. * This should be used together with the simplification to avoid disappearing triangles.
  34497. * @param successCallback an optional success callback to be called after the optimization finished.
  34498. * @returns the current mesh
  34499. */
  34500. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34501. /**
  34502. * Serialize current mesh
  34503. * @param serializationObject defines the object which will receive the serialization data
  34504. */
  34505. serialize(serializationObject: any): void;
  34506. /** @hidden */
  34507. _syncGeometryWithMorphTargetManager(): void;
  34508. /** @hidden */
  34509. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34510. /**
  34511. * Returns a new Mesh object parsed from the source provided.
  34512. * @param parsedMesh is the source
  34513. * @param scene defines the hosting scene
  34514. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34515. * @returns a new Mesh
  34516. */
  34517. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34518. /**
  34519. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34520. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34521. * @param name defines the name of the mesh to create
  34522. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34523. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34524. * @param closePath creates a seam between the first and the last points of each path of the path array
  34525. * @param offset is taken in account only if the `pathArray` is containing a single path
  34526. * @param scene defines the hosting scene
  34527. * @param updatable defines if the mesh must be flagged as updatable
  34528. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34529. * @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)
  34530. * @returns a new Mesh
  34531. */
  34532. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34533. /**
  34534. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34535. * @param name defines the name of the mesh to create
  34536. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34537. * @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
  34538. * @param scene defines the hosting scene
  34539. * @param updatable defines if the mesh must be flagged as updatable
  34540. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34541. * @returns a new Mesh
  34542. */
  34543. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34544. /**
  34545. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34546. * @param name defines the name of the mesh to create
  34547. * @param size sets the size (float) of each box side (default 1)
  34548. * @param scene defines the hosting scene
  34549. * @param updatable defines if the mesh must be flagged as updatable
  34550. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34551. * @returns a new Mesh
  34552. */
  34553. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34554. /**
  34555. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34556. * @param name defines the name of the mesh to create
  34557. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34558. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34559. * @param scene defines the hosting scene
  34560. * @param updatable defines if the mesh must be flagged as updatable
  34561. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34562. * @returns a new Mesh
  34563. */
  34564. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34565. /**
  34566. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34567. * @param name defines the name of the mesh to create
  34568. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34569. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34570. * @param scene defines the hosting scene
  34571. * @returns a new Mesh
  34572. */
  34573. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34574. /**
  34575. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34576. * @param name defines the name of the mesh to create
  34577. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34578. * @param diameterTop set the top cap diameter (floats, default 1)
  34579. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34580. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34581. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34582. * @param scene defines the hosting scene
  34583. * @param updatable defines if the mesh must be flagged as updatable
  34584. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34585. * @returns a new Mesh
  34586. */
  34587. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34588. /**
  34589. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34590. * @param name defines the name of the mesh to create
  34591. * @param diameter sets the diameter size (float) of the torus (default 1)
  34592. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34593. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34594. * @param scene defines the hosting scene
  34595. * @param updatable defines if the mesh must be flagged as updatable
  34596. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34597. * @returns a new Mesh
  34598. */
  34599. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34600. /**
  34601. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34602. * @param name defines the name of the mesh to create
  34603. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34604. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34605. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34606. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34607. * @param p the number of windings on X axis (positive integers, default 2)
  34608. * @param q the number of windings on Y axis (positive integers, default 3)
  34609. * @param scene defines the hosting scene
  34610. * @param updatable defines if the mesh must be flagged as updatable
  34611. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34612. * @returns a new Mesh
  34613. */
  34614. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34615. /**
  34616. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34617. * @param name defines the name of the mesh to create
  34618. * @param points is an array successive Vector3
  34619. * @param scene defines the hosting scene
  34620. * @param updatable defines if the mesh must be flagged as updatable
  34621. * @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).
  34622. * @returns a new Mesh
  34623. */
  34624. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34625. /**
  34626. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34627. * @param name defines the name of the mesh to create
  34628. * @param points is an array successive Vector3
  34629. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34630. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34631. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34632. * @param scene defines the hosting scene
  34633. * @param updatable defines if the mesh must be flagged as updatable
  34634. * @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)
  34635. * @returns a new Mesh
  34636. */
  34637. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34638. /**
  34639. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34640. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34641. * 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.
  34642. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34643. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34644. * Remember you can only change the shape positions, not their number when updating a polygon.
  34645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34646. * @param name defines the name of the mesh to create
  34647. * @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
  34648. * @param scene defines the hosting scene
  34649. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34650. * @param updatable defines if the mesh must be flagged as updatable
  34651. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34652. * @param earcutInjection can be used to inject your own earcut reference
  34653. * @returns a new Mesh
  34654. */
  34655. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34656. /**
  34657. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34659. * @param name defines the name of the mesh to create
  34660. * @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
  34661. * @param depth defines the height of extrusion
  34662. * @param scene defines the hosting scene
  34663. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34664. * @param updatable defines if the mesh must be flagged as updatable
  34665. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34666. * @param earcutInjection can be used to inject your own earcut reference
  34667. * @returns a new Mesh
  34668. */
  34669. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34670. /**
  34671. * Creates an extruded shape mesh.
  34672. * 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
  34673. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34674. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34675. * @param name defines the name of the mesh to create
  34676. * @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
  34677. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34678. * @param scale is the value to scale the shape
  34679. * @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
  34680. * @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
  34681. * @param scene defines the hosting scene
  34682. * @param updatable defines if the mesh must be flagged as updatable
  34683. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34684. * @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)
  34685. * @returns a new Mesh
  34686. */
  34687. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34688. /**
  34689. * Creates an custom extruded shape mesh.
  34690. * The custom extrusion is a parametric shape.
  34691. * It has no predefined shape. Its final shape will depend on the input parameters.
  34692. * Please consider using the same method from the MeshBuilder class instead
  34693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34694. * @param name defines the name of the mesh to create
  34695. * @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
  34696. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34697. * @param scaleFunction is a custom Javascript function called on each path point
  34698. * @param rotationFunction is a custom Javascript function called on each path point
  34699. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34700. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34701. * @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
  34702. * @param scene defines the hosting scene
  34703. * @param updatable defines if the mesh must be flagged as updatable
  34704. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34705. * @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)
  34706. * @returns a new Mesh
  34707. */
  34708. 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;
  34709. /**
  34710. * Creates lathe mesh.
  34711. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34712. * Please consider using the same method from the MeshBuilder class instead
  34713. * @param name defines the name of the mesh to create
  34714. * @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
  34715. * @param radius is the radius value of the lathe
  34716. * @param tessellation is the side number of the lathe.
  34717. * @param scene defines the hosting scene
  34718. * @param updatable defines if the mesh must be flagged as updatable
  34719. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34720. * @returns a new Mesh
  34721. */
  34722. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34723. /**
  34724. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34725. * @param name defines the name of the mesh to create
  34726. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34727. * @param scene defines the hosting scene
  34728. * @param updatable defines if the mesh must be flagged as updatable
  34729. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34730. * @returns a new Mesh
  34731. */
  34732. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34733. /**
  34734. * Creates a ground mesh.
  34735. * Please consider using the same method from the MeshBuilder class instead
  34736. * @param name defines the name of the mesh to create
  34737. * @param width set the width of the ground
  34738. * @param height set the height of the ground
  34739. * @param subdivisions sets the number of subdivisions per side
  34740. * @param scene defines the hosting scene
  34741. * @param updatable defines if the mesh must be flagged as updatable
  34742. * @returns a new Mesh
  34743. */
  34744. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34745. /**
  34746. * Creates a tiled ground mesh.
  34747. * Please consider using the same method from the MeshBuilder class instead
  34748. * @param name defines the name of the mesh to create
  34749. * @param xmin set the ground minimum X coordinate
  34750. * @param zmin set the ground minimum Y coordinate
  34751. * @param xmax set the ground maximum X coordinate
  34752. * @param zmax set the ground maximum Z coordinate
  34753. * @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
  34754. * @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
  34755. * @param scene defines the hosting scene
  34756. * @param updatable defines if the mesh must be flagged as updatable
  34757. * @returns a new Mesh
  34758. */
  34759. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34760. w: number;
  34761. h: number;
  34762. }, precision: {
  34763. w: number;
  34764. h: number;
  34765. }, scene: Scene, updatable?: boolean): Mesh;
  34766. /**
  34767. * Creates a ground mesh from a height map.
  34768. * Please consider using the same method from the MeshBuilder class instead
  34769. * @see https://doc.babylonjs.com/babylon101/height_map
  34770. * @param name defines the name of the mesh to create
  34771. * @param url sets the URL of the height map image resource
  34772. * @param width set the ground width size
  34773. * @param height set the ground height size
  34774. * @param subdivisions sets the number of subdivision per side
  34775. * @param minHeight is the minimum altitude on the ground
  34776. * @param maxHeight is the maximum altitude on the ground
  34777. * @param scene defines the hosting scene
  34778. * @param updatable defines if the mesh must be flagged as updatable
  34779. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34780. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34781. * @returns a new Mesh
  34782. */
  34783. 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;
  34784. /**
  34785. * Creates a tube mesh.
  34786. * The tube is a parametric shape.
  34787. * It has no predefined shape. Its final shape will depend on the input parameters.
  34788. * Please consider using the same method from the MeshBuilder class instead
  34789. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34790. * @param name defines the name of the mesh to create
  34791. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34792. * @param radius sets the tube radius size
  34793. * @param tessellation is the number of sides on the tubular surface
  34794. * @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
  34795. * @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
  34796. * @param scene defines the hosting scene
  34797. * @param updatable defines if the mesh must be flagged as updatable
  34798. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34799. * @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)
  34800. * @returns a new Mesh
  34801. */
  34802. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34803. (i: number, distance: number): number;
  34804. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34805. /**
  34806. * Creates a polyhedron mesh.
  34807. * Please consider using the same method from the MeshBuilder class instead.
  34808. * * 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
  34809. * * The parameter `size` (positive float, default 1) sets the polygon size
  34810. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34811. * * 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`
  34812. * * 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
  34813. * * 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)`)
  34814. * * 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
  34815. * * 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
  34816. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34819. * @param name defines the name of the mesh to create
  34820. * @param options defines the options used to create the mesh
  34821. * @param scene defines the hosting scene
  34822. * @returns a new Mesh
  34823. */
  34824. static CreatePolyhedron(name: string, options: {
  34825. type?: number;
  34826. size?: number;
  34827. sizeX?: number;
  34828. sizeY?: number;
  34829. sizeZ?: number;
  34830. custom?: any;
  34831. faceUV?: Vector4[];
  34832. faceColors?: Color4[];
  34833. updatable?: boolean;
  34834. sideOrientation?: number;
  34835. }, scene: Scene): Mesh;
  34836. /**
  34837. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34838. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34839. * * 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`)
  34840. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34841. * * 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
  34842. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34845. * @param name defines the name of the mesh
  34846. * @param options defines the options used to create the mesh
  34847. * @param scene defines the hosting scene
  34848. * @returns a new Mesh
  34849. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34850. */
  34851. static CreateIcoSphere(name: string, options: {
  34852. radius?: number;
  34853. flat?: boolean;
  34854. subdivisions?: number;
  34855. sideOrientation?: number;
  34856. updatable?: boolean;
  34857. }, scene: Scene): Mesh;
  34858. /**
  34859. * Creates a decal mesh.
  34860. * Please consider using the same method from the MeshBuilder class instead.
  34861. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34862. * @param name defines the name of the mesh
  34863. * @param sourceMesh defines the mesh receiving the decal
  34864. * @param position sets the position of the decal in world coordinates
  34865. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34866. * @param size sets the decal scaling
  34867. * @param angle sets the angle to rotate the decal
  34868. * @returns a new Mesh
  34869. */
  34870. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34871. /** Creates a Capsule Mesh
  34872. * @param name defines the name of the mesh.
  34873. * @param options the constructors options used to shape the mesh.
  34874. * @param scene defines the scene the mesh is scoped to.
  34875. * @returns the capsule mesh
  34876. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34877. */
  34878. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34879. /**
  34880. * Prepare internal position array for software CPU skinning
  34881. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34882. */
  34883. setPositionsForCPUSkinning(): Float32Array;
  34884. /**
  34885. * Prepare internal normal array for software CPU skinning
  34886. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34887. */
  34888. setNormalsForCPUSkinning(): Float32Array;
  34889. /**
  34890. * Updates the vertex buffer by applying transformation from the bones
  34891. * @param skeleton defines the skeleton to apply to current mesh
  34892. * @returns the current mesh
  34893. */
  34894. applySkeleton(skeleton: Skeleton): Mesh;
  34895. /**
  34896. * 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
  34897. * @param meshes defines the list of meshes to scan
  34898. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34899. */
  34900. static MinMax(meshes: AbstractMesh[]): {
  34901. min: Vector3;
  34902. max: Vector3;
  34903. };
  34904. /**
  34905. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34906. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34907. * @returns a vector3
  34908. */
  34909. static Center(meshesOrMinMaxVector: {
  34910. min: Vector3;
  34911. max: Vector3;
  34912. } | AbstractMesh[]): Vector3;
  34913. /**
  34914. * Merge the array of meshes into a single mesh for performance reasons.
  34915. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34916. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34917. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34918. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34919. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34920. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34921. * @returns a new mesh
  34922. */
  34923. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34924. /** @hidden */
  34925. addInstance(instance: InstancedMesh): void;
  34926. /** @hidden */
  34927. removeInstance(instance: InstancedMesh): void;
  34928. }
  34929. }
  34930. declare module "babylonjs/Cameras/camera" {
  34931. import { SmartArray } from "babylonjs/Misc/smartArray";
  34932. import { Observable } from "babylonjs/Misc/observable";
  34933. import { Nullable } from "babylonjs/types";
  34934. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34935. import { Scene } from "babylonjs/scene";
  34936. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  34937. import { Node } from "babylonjs/node";
  34938. import { Mesh } from "babylonjs/Meshes/mesh";
  34939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34940. import { ICullable } from "babylonjs/Culling/boundingInfo";
  34941. import { Viewport } from "babylonjs/Maths/math.viewport";
  34942. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34943. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34944. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  34945. import { Ray } from "babylonjs/Culling/ray";
  34946. /**
  34947. * This is the base class of all the camera used in the application.
  34948. * @see https://doc.babylonjs.com/features/cameras
  34949. */
  34950. export class Camera extends Node {
  34951. /** @hidden */
  34952. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  34953. /**
  34954. * This is the default projection mode used by the cameras.
  34955. * It helps recreating a feeling of perspective and better appreciate depth.
  34956. * This is the best way to simulate real life cameras.
  34957. */
  34958. static readonly PERSPECTIVE_CAMERA: number;
  34959. /**
  34960. * This helps creating camera with an orthographic mode.
  34961. * 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.
  34962. */
  34963. static readonly ORTHOGRAPHIC_CAMERA: number;
  34964. /**
  34965. * This is the default FOV mode for perspective cameras.
  34966. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  34967. */
  34968. static readonly FOVMODE_VERTICAL_FIXED: number;
  34969. /**
  34970. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  34971. */
  34972. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  34973. /**
  34974. * This specifies ther is no need for a camera rig.
  34975. * Basically only one eye is rendered corresponding to the camera.
  34976. */
  34977. static readonly RIG_MODE_NONE: number;
  34978. /**
  34979. * Simulates a camera Rig with one blue eye and one red eye.
  34980. * This can be use with 3d blue and red glasses.
  34981. */
  34982. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  34983. /**
  34984. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  34985. */
  34986. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  34987. /**
  34988. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  34989. */
  34990. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  34991. /**
  34992. * Defines that both eyes of the camera will be rendered over under each other.
  34993. */
  34994. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  34995. /**
  34996. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  34997. */
  34998. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  34999. /**
  35000. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  35001. */
  35002. static readonly RIG_MODE_VR: number;
  35003. /**
  35004. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  35005. */
  35006. static readonly RIG_MODE_WEBVR: number;
  35007. /**
  35008. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  35009. */
  35010. static readonly RIG_MODE_CUSTOM: number;
  35011. /**
  35012. * Defines if by default attaching controls should prevent the default javascript event to continue.
  35013. */
  35014. static ForceAttachControlToAlwaysPreventDefault: boolean;
  35015. /**
  35016. * Define the input manager associated with the camera.
  35017. */
  35018. inputs: CameraInputsManager<Camera>;
  35019. /** @hidden */
  35020. _position: Vector3;
  35021. /**
  35022. * Define the current local position of the camera in the scene
  35023. */
  35024. get position(): Vector3;
  35025. set position(newPosition: Vector3);
  35026. protected _upVector: Vector3;
  35027. /**
  35028. * The vector the camera should consider as up.
  35029. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  35030. */
  35031. set upVector(vec: Vector3);
  35032. get upVector(): Vector3;
  35033. /**
  35034. * Define the current limit on the left side for an orthographic camera
  35035. * In scene unit
  35036. */
  35037. orthoLeft: Nullable<number>;
  35038. /**
  35039. * Define the current limit on the right side for an orthographic camera
  35040. * In scene unit
  35041. */
  35042. orthoRight: Nullable<number>;
  35043. /**
  35044. * Define the current limit on the bottom side for an orthographic camera
  35045. * In scene unit
  35046. */
  35047. orthoBottom: Nullable<number>;
  35048. /**
  35049. * Define the current limit on the top side for an orthographic camera
  35050. * In scene unit
  35051. */
  35052. orthoTop: Nullable<number>;
  35053. /**
  35054. * Field Of View is set in Radians. (default is 0.8)
  35055. */
  35056. fov: number;
  35057. /**
  35058. * Define the minimum distance the camera can see from.
  35059. * This is important to note that the depth buffer are not infinite and the closer it starts
  35060. * the more your scene might encounter depth fighting issue.
  35061. */
  35062. minZ: number;
  35063. /**
  35064. * Define the maximum distance the camera can see to.
  35065. * This is important to note that the depth buffer are not infinite and the further it end
  35066. * the more your scene might encounter depth fighting issue.
  35067. */
  35068. maxZ: number;
  35069. /**
  35070. * Define the default inertia of the camera.
  35071. * This helps giving a smooth feeling to the camera movement.
  35072. */
  35073. inertia: number;
  35074. /**
  35075. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  35076. */
  35077. mode: number;
  35078. /**
  35079. * Define whether the camera is intermediate.
  35080. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  35081. */
  35082. isIntermediate: boolean;
  35083. /**
  35084. * Define the viewport of the camera.
  35085. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  35086. */
  35087. viewport: Viewport;
  35088. /**
  35089. * Restricts the camera to viewing objects with the same layerMask.
  35090. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  35091. */
  35092. layerMask: number;
  35093. /**
  35094. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35095. */
  35096. fovMode: number;
  35097. /**
  35098. * Rig mode of the camera.
  35099. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35100. * This is normally controlled byt the camera themselves as internal use.
  35101. */
  35102. cameraRigMode: number;
  35103. /**
  35104. * Defines the distance between both "eyes" in case of a RIG
  35105. */
  35106. interaxialDistance: number;
  35107. /**
  35108. * Defines if stereoscopic rendering is done side by side or over under.
  35109. */
  35110. isStereoscopicSideBySide: boolean;
  35111. /**
  35112. * 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
  35113. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35114. * else in the scene. (Eg. security camera)
  35115. *
  35116. * 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)
  35117. */
  35118. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35119. /**
  35120. * When set, the camera will render to this render target instead of the default canvas
  35121. *
  35122. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35123. */
  35124. outputRenderTarget: Nullable<RenderTargetTexture>;
  35125. /**
  35126. * Observable triggered when the camera view matrix has changed.
  35127. */
  35128. onViewMatrixChangedObservable: Observable<Camera>;
  35129. /**
  35130. * Observable triggered when the camera Projection matrix has changed.
  35131. */
  35132. onProjectionMatrixChangedObservable: Observable<Camera>;
  35133. /**
  35134. * Observable triggered when the inputs have been processed.
  35135. */
  35136. onAfterCheckInputsObservable: Observable<Camera>;
  35137. /**
  35138. * Observable triggered when reset has been called and applied to the camera.
  35139. */
  35140. onRestoreStateObservable: Observable<Camera>;
  35141. /**
  35142. * Is this camera a part of a rig system?
  35143. */
  35144. isRigCamera: boolean;
  35145. /**
  35146. * If isRigCamera set to true this will be set with the parent camera.
  35147. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35148. */
  35149. rigParent?: Camera;
  35150. /** @hidden */
  35151. _cameraRigParams: any;
  35152. /** @hidden */
  35153. _rigCameras: Camera[];
  35154. /** @hidden */
  35155. _rigPostProcess: Nullable<PostProcess>;
  35156. protected _webvrViewMatrix: Matrix;
  35157. /** @hidden */
  35158. _skipRendering: boolean;
  35159. /** @hidden */
  35160. _projectionMatrix: Matrix;
  35161. /** @hidden */
  35162. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35163. /** @hidden */
  35164. _activeMeshes: SmartArray<AbstractMesh>;
  35165. protected _globalPosition: Vector3;
  35166. /** @hidden */
  35167. _computedViewMatrix: Matrix;
  35168. private _doNotComputeProjectionMatrix;
  35169. private _transformMatrix;
  35170. private _frustumPlanes;
  35171. private _refreshFrustumPlanes;
  35172. private _storedFov;
  35173. private _stateStored;
  35174. /**
  35175. * Instantiates a new camera object.
  35176. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35177. * @see https://doc.babylonjs.com/features/cameras
  35178. * @param name Defines the name of the camera in the scene
  35179. * @param position Defines the position of the camera
  35180. * @param scene Defines the scene the camera belongs too
  35181. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35182. */
  35183. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35184. /**
  35185. * Store current camera state (fov, position, etc..)
  35186. * @returns the camera
  35187. */
  35188. storeState(): Camera;
  35189. /**
  35190. * Restores the camera state values if it has been stored. You must call storeState() first
  35191. */
  35192. protected _restoreStateValues(): boolean;
  35193. /**
  35194. * Restored camera state. You must call storeState() first.
  35195. * @returns true if restored and false otherwise
  35196. */
  35197. restoreState(): boolean;
  35198. /**
  35199. * Gets the class name of the camera.
  35200. * @returns the class name
  35201. */
  35202. getClassName(): string;
  35203. /** @hidden */
  35204. readonly _isCamera: boolean;
  35205. /**
  35206. * Gets a string representation of the camera useful for debug purpose.
  35207. * @param fullDetails Defines that a more verboe level of logging is required
  35208. * @returns the string representation
  35209. */
  35210. toString(fullDetails?: boolean): string;
  35211. /**
  35212. * Gets the current world space position of the camera.
  35213. */
  35214. get globalPosition(): Vector3;
  35215. /**
  35216. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35217. * @returns the active meshe list
  35218. */
  35219. getActiveMeshes(): SmartArray<AbstractMesh>;
  35220. /**
  35221. * Check whether a mesh is part of the current active mesh list of the camera
  35222. * @param mesh Defines the mesh to check
  35223. * @returns true if active, false otherwise
  35224. */
  35225. isActiveMesh(mesh: Mesh): boolean;
  35226. /**
  35227. * Is this camera ready to be used/rendered
  35228. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35229. * @return true if the camera is ready
  35230. */
  35231. isReady(completeCheck?: boolean): boolean;
  35232. /** @hidden */
  35233. _initCache(): void;
  35234. /** @hidden */
  35235. _updateCache(ignoreParentClass?: boolean): void;
  35236. /** @hidden */
  35237. _isSynchronized(): boolean;
  35238. /** @hidden */
  35239. _isSynchronizedViewMatrix(): boolean;
  35240. /** @hidden */
  35241. _isSynchronizedProjectionMatrix(): boolean;
  35242. /**
  35243. * Attach the input controls to a specific dom element to get the input from.
  35244. * @param element Defines the element the controls should be listened from
  35245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35246. */
  35247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35248. /**
  35249. * Detach the current controls from the specified dom element.
  35250. * @param element Defines the element to stop listening the inputs from
  35251. */
  35252. detachControl(element: HTMLElement): void;
  35253. /**
  35254. * Update the camera state according to the different inputs gathered during the frame.
  35255. */
  35256. update(): void;
  35257. /** @hidden */
  35258. _checkInputs(): void;
  35259. /** @hidden */
  35260. get rigCameras(): Camera[];
  35261. /**
  35262. * Gets the post process used by the rig cameras
  35263. */
  35264. get rigPostProcess(): Nullable<PostProcess>;
  35265. /**
  35266. * Internal, gets the first post proces.
  35267. * @returns the first post process to be run on this camera.
  35268. */
  35269. _getFirstPostProcess(): Nullable<PostProcess>;
  35270. private _cascadePostProcessesToRigCams;
  35271. /**
  35272. * Attach a post process to the camera.
  35273. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35274. * @param postProcess The post process to attach to the camera
  35275. * @param insertAt The position of the post process in case several of them are in use in the scene
  35276. * @returns the position the post process has been inserted at
  35277. */
  35278. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35279. /**
  35280. * Detach a post process to the camera.
  35281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35282. * @param postProcess The post process to detach from the camera
  35283. */
  35284. detachPostProcess(postProcess: PostProcess): void;
  35285. /**
  35286. * Gets the current world matrix of the camera
  35287. */
  35288. getWorldMatrix(): Matrix;
  35289. /** @hidden */
  35290. _getViewMatrix(): Matrix;
  35291. /**
  35292. * Gets the current view matrix of the camera.
  35293. * @param force forces the camera to recompute the matrix without looking at the cached state
  35294. * @returns the view matrix
  35295. */
  35296. getViewMatrix(force?: boolean): Matrix;
  35297. /**
  35298. * Freeze the projection matrix.
  35299. * It will prevent the cache check of the camera projection compute and can speed up perf
  35300. * if no parameter of the camera are meant to change
  35301. * @param projection Defines manually a projection if necessary
  35302. */
  35303. freezeProjectionMatrix(projection?: Matrix): void;
  35304. /**
  35305. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35306. */
  35307. unfreezeProjectionMatrix(): void;
  35308. /**
  35309. * Gets the current projection matrix of the camera.
  35310. * @param force forces the camera to recompute the matrix without looking at the cached state
  35311. * @returns the projection matrix
  35312. */
  35313. getProjectionMatrix(force?: boolean): Matrix;
  35314. /**
  35315. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35316. * @returns a Matrix
  35317. */
  35318. getTransformationMatrix(): Matrix;
  35319. private _updateFrustumPlanes;
  35320. /**
  35321. * Checks if a cullable object (mesh...) is in the camera frustum
  35322. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35323. * @param target The object to check
  35324. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35325. * @returns true if the object is in frustum otherwise false
  35326. */
  35327. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35328. /**
  35329. * Checks if a cullable object (mesh...) is in the camera frustum
  35330. * Unlike isInFrustum this cheks the full bounding box
  35331. * @param target The object to check
  35332. * @returns true if the object is in frustum otherwise false
  35333. */
  35334. isCompletelyInFrustum(target: ICullable): boolean;
  35335. /**
  35336. * Gets a ray in the forward direction from the camera.
  35337. * @param length Defines the length of the ray to create
  35338. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35339. * @param origin Defines the start point of the ray which defaults to the camera position
  35340. * @returns the forward ray
  35341. */
  35342. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35343. /**
  35344. * Gets a ray in the forward direction from the camera.
  35345. * @param refRay the ray to (re)use when setting the values
  35346. * @param length Defines the length of the ray to create
  35347. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35348. * @param origin Defines the start point of the ray which defaults to the camera position
  35349. * @returns the forward ray
  35350. */
  35351. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35352. /**
  35353. * Releases resources associated with this node.
  35354. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35355. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35356. */
  35357. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35358. /** @hidden */
  35359. _isLeftCamera: boolean;
  35360. /**
  35361. * Gets the left camera of a rig setup in case of Rigged Camera
  35362. */
  35363. get isLeftCamera(): boolean;
  35364. /** @hidden */
  35365. _isRightCamera: boolean;
  35366. /**
  35367. * Gets the right camera of a rig setup in case of Rigged Camera
  35368. */
  35369. get isRightCamera(): boolean;
  35370. /**
  35371. * Gets the left camera of a rig setup in case of Rigged Camera
  35372. */
  35373. get leftCamera(): Nullable<FreeCamera>;
  35374. /**
  35375. * Gets the right camera of a rig setup in case of Rigged Camera
  35376. */
  35377. get rightCamera(): Nullable<FreeCamera>;
  35378. /**
  35379. * Gets the left camera target of a rig setup in case of Rigged Camera
  35380. * @returns the target position
  35381. */
  35382. getLeftTarget(): Nullable<Vector3>;
  35383. /**
  35384. * Gets the right camera target of a rig setup in case of Rigged Camera
  35385. * @returns the target position
  35386. */
  35387. getRightTarget(): Nullable<Vector3>;
  35388. /**
  35389. * @hidden
  35390. */
  35391. setCameraRigMode(mode: number, rigParams: any): void;
  35392. /** @hidden */
  35393. static _setStereoscopicRigMode(camera: Camera): void;
  35394. /** @hidden */
  35395. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35396. /** @hidden */
  35397. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35398. /** @hidden */
  35399. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35400. /** @hidden */
  35401. _getVRProjectionMatrix(): Matrix;
  35402. protected _updateCameraRotationMatrix(): void;
  35403. protected _updateWebVRCameraRotationMatrix(): void;
  35404. /**
  35405. * This function MUST be overwritten by the different WebVR cameras available.
  35406. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35407. * @hidden
  35408. */
  35409. _getWebVRProjectionMatrix(): Matrix;
  35410. /**
  35411. * This function MUST be overwritten by the different WebVR cameras available.
  35412. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35413. * @hidden
  35414. */
  35415. _getWebVRViewMatrix(): Matrix;
  35416. /** @hidden */
  35417. setCameraRigParameter(name: string, value: any): void;
  35418. /**
  35419. * needs to be overridden by children so sub has required properties to be copied
  35420. * @hidden
  35421. */
  35422. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35423. /**
  35424. * May need to be overridden by children
  35425. * @hidden
  35426. */
  35427. _updateRigCameras(): void;
  35428. /** @hidden */
  35429. _setupInputs(): void;
  35430. /**
  35431. * Serialiaze the camera setup to a json represention
  35432. * @returns the JSON representation
  35433. */
  35434. serialize(): any;
  35435. /**
  35436. * Clones the current camera.
  35437. * @param name The cloned camera name
  35438. * @returns the cloned camera
  35439. */
  35440. clone(name: string): Camera;
  35441. /**
  35442. * Gets the direction of the camera relative to a given local axis.
  35443. * @param localAxis Defines the reference axis to provide a relative direction.
  35444. * @return the direction
  35445. */
  35446. getDirection(localAxis: Vector3): Vector3;
  35447. /**
  35448. * Returns the current camera absolute rotation
  35449. */
  35450. get absoluteRotation(): Quaternion;
  35451. /**
  35452. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35453. * @param localAxis Defines the reference axis to provide a relative direction.
  35454. * @param result Defines the vector to store the result in
  35455. */
  35456. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35457. /**
  35458. * Gets a camera constructor for a given camera type
  35459. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35460. * @param name The name of the camera the result will be able to instantiate
  35461. * @param scene The scene the result will construct the camera in
  35462. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35463. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35464. * @returns a factory method to construc the camera
  35465. */
  35466. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35467. /**
  35468. * Compute the world matrix of the camera.
  35469. * @returns the camera world matrix
  35470. */
  35471. computeWorldMatrix(): Matrix;
  35472. /**
  35473. * Parse a JSON and creates the camera from the parsed information
  35474. * @param parsedCamera The JSON to parse
  35475. * @param scene The scene to instantiate the camera in
  35476. * @returns the newly constructed camera
  35477. */
  35478. static Parse(parsedCamera: any, scene: Scene): Camera;
  35479. }
  35480. }
  35481. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35482. import { Nullable } from "babylonjs/types";
  35483. import { Scene } from "babylonjs/scene";
  35484. import { Vector4 } from "babylonjs/Maths/math.vector";
  35485. import { Mesh } from "babylonjs/Meshes/mesh";
  35486. /**
  35487. * Class containing static functions to help procedurally build meshes
  35488. */
  35489. export class DiscBuilder {
  35490. /**
  35491. * Creates a plane polygonal mesh. By default, this is a disc
  35492. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35493. * * 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
  35494. * * 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
  35495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35498. * @param name defines the name of the mesh
  35499. * @param options defines the options used to create the mesh
  35500. * @param scene defines the hosting scene
  35501. * @returns the plane polygonal mesh
  35502. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35503. */
  35504. static CreateDisc(name: string, options: {
  35505. radius?: number;
  35506. tessellation?: number;
  35507. arc?: number;
  35508. updatable?: boolean;
  35509. sideOrientation?: number;
  35510. frontUVs?: Vector4;
  35511. backUVs?: Vector4;
  35512. }, scene?: Nullable<Scene>): Mesh;
  35513. }
  35514. }
  35515. declare module "babylonjs/Particles/solidParticleSystem" {
  35516. import { Nullable } from "babylonjs/types";
  35517. import { Mesh } from "babylonjs/Meshes/mesh";
  35518. import { Scene, IDisposable } from "babylonjs/scene";
  35519. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35520. import { Material } from "babylonjs/Materials/material";
  35521. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35522. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35523. /**
  35524. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35525. *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.
  35526. * The SPS is also a particle system. It provides some methods to manage the particles.
  35527. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35528. *
  35529. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35530. */
  35531. export class SolidParticleSystem implements IDisposable {
  35532. /**
  35533. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35534. * Example : var p = SPS.particles[i];
  35535. */
  35536. particles: SolidParticle[];
  35537. /**
  35538. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35539. */
  35540. nbParticles: number;
  35541. /**
  35542. * If the particles must ever face the camera (default false). Useful for planar particles.
  35543. */
  35544. billboard: boolean;
  35545. /**
  35546. * Recompute normals when adding a shape
  35547. */
  35548. recomputeNormals: boolean;
  35549. /**
  35550. * This a counter ofr your own usage. It's not set by any SPS functions.
  35551. */
  35552. counter: number;
  35553. /**
  35554. * The SPS name. This name is also given to the underlying mesh.
  35555. */
  35556. name: string;
  35557. /**
  35558. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35559. */
  35560. mesh: Mesh;
  35561. /**
  35562. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35563. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35564. */
  35565. vars: any;
  35566. /**
  35567. * This array is populated when the SPS is set as 'pickable'.
  35568. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35569. * Each element of this array is an object `{idx: int, faceId: int}`.
  35570. * `idx` is the picked particle index in the `SPS.particles` array
  35571. * `faceId` is the picked face index counted within this particle.
  35572. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35573. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35574. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35575. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35576. */
  35577. pickedParticles: {
  35578. idx: number;
  35579. faceId: number;
  35580. }[];
  35581. /**
  35582. * This array is populated when the SPS is set as 'pickable'
  35583. * Each key of this array is a submesh index.
  35584. * Each element of this array is a second array defined like this :
  35585. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35586. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35587. * `idx` is the picked particle index in the `SPS.particles` array
  35588. * `faceId` is the picked face index counted within this particle.
  35589. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35590. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35591. */
  35592. pickedBySubMesh: {
  35593. idx: number;
  35594. faceId: number;
  35595. }[][];
  35596. /**
  35597. * This array is populated when `enableDepthSort` is set to true.
  35598. * Each element of this array is an instance of the class DepthSortedParticle.
  35599. */
  35600. depthSortedParticles: DepthSortedParticle[];
  35601. /**
  35602. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35603. * @hidden
  35604. */
  35605. _bSphereOnly: boolean;
  35606. /**
  35607. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35608. * @hidden
  35609. */
  35610. _bSphereRadiusFactor: number;
  35611. private _scene;
  35612. private _positions;
  35613. private _indices;
  35614. private _normals;
  35615. private _colors;
  35616. private _uvs;
  35617. private _indices32;
  35618. private _positions32;
  35619. private _normals32;
  35620. private _fixedNormal32;
  35621. private _colors32;
  35622. private _uvs32;
  35623. private _index;
  35624. private _updatable;
  35625. private _pickable;
  35626. private _isVisibilityBoxLocked;
  35627. private _alwaysVisible;
  35628. private _depthSort;
  35629. private _expandable;
  35630. private _shapeCounter;
  35631. private _copy;
  35632. private _color;
  35633. private _computeParticleColor;
  35634. private _computeParticleTexture;
  35635. private _computeParticleRotation;
  35636. private _computeParticleVertex;
  35637. private _computeBoundingBox;
  35638. private _depthSortParticles;
  35639. private _camera;
  35640. private _mustUnrotateFixedNormals;
  35641. private _particlesIntersect;
  35642. private _needs32Bits;
  35643. private _isNotBuilt;
  35644. private _lastParticleId;
  35645. private _idxOfId;
  35646. private _multimaterialEnabled;
  35647. private _useModelMaterial;
  35648. private _indicesByMaterial;
  35649. private _materialIndexes;
  35650. private _depthSortFunction;
  35651. private _materialSortFunction;
  35652. private _materials;
  35653. private _multimaterial;
  35654. private _materialIndexesById;
  35655. private _defaultMaterial;
  35656. private _autoUpdateSubMeshes;
  35657. private _tmpVertex;
  35658. /**
  35659. * Creates a SPS (Solid Particle System) object.
  35660. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35661. * @param scene (Scene) is the scene in which the SPS is added.
  35662. * @param options defines the options of the sps e.g.
  35663. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35664. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35665. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35666. * * 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.
  35667. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35668. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35669. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35670. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35671. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35672. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35673. */
  35674. constructor(name: string, scene: Scene, options?: {
  35675. updatable?: boolean;
  35676. isPickable?: boolean;
  35677. enableDepthSort?: boolean;
  35678. particleIntersection?: boolean;
  35679. boundingSphereOnly?: boolean;
  35680. bSphereRadiusFactor?: number;
  35681. expandable?: boolean;
  35682. useModelMaterial?: boolean;
  35683. enableMultiMaterial?: boolean;
  35684. });
  35685. /**
  35686. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35687. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35688. * @returns the created mesh
  35689. */
  35690. buildMesh(): Mesh;
  35691. /**
  35692. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35693. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35694. * Thus the particles generated from `digest()` have their property `position` set yet.
  35695. * @param mesh ( Mesh ) is the mesh to be digested
  35696. * @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
  35697. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35698. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35699. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35700. * @returns the current SPS
  35701. */
  35702. digest(mesh: Mesh, options?: {
  35703. facetNb?: number;
  35704. number?: number;
  35705. delta?: number;
  35706. storage?: [];
  35707. }): SolidParticleSystem;
  35708. /**
  35709. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35710. * @hidden
  35711. */
  35712. private _unrotateFixedNormals;
  35713. /**
  35714. * Resets the temporary working copy particle
  35715. * @hidden
  35716. */
  35717. private _resetCopy;
  35718. /**
  35719. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35720. * @param p the current index in the positions array to be updated
  35721. * @param ind the current index in the indices array
  35722. * @param shape a Vector3 array, the shape geometry
  35723. * @param positions the positions array to be updated
  35724. * @param meshInd the shape indices array
  35725. * @param indices the indices array to be updated
  35726. * @param meshUV the shape uv array
  35727. * @param uvs the uv array to be updated
  35728. * @param meshCol the shape color array
  35729. * @param colors the color array to be updated
  35730. * @param meshNor the shape normals array
  35731. * @param normals the normals array to be updated
  35732. * @param idx the particle index
  35733. * @param idxInShape the particle index in its shape
  35734. * @param options the addShape() method passed options
  35735. * @model the particle model
  35736. * @hidden
  35737. */
  35738. private _meshBuilder;
  35739. /**
  35740. * Returns a shape Vector3 array from positions float array
  35741. * @param positions float array
  35742. * @returns a vector3 array
  35743. * @hidden
  35744. */
  35745. private _posToShape;
  35746. /**
  35747. * Returns a shapeUV array from a float uvs (array deep copy)
  35748. * @param uvs as a float array
  35749. * @returns a shapeUV array
  35750. * @hidden
  35751. */
  35752. private _uvsToShapeUV;
  35753. /**
  35754. * Adds a new particle object in the particles array
  35755. * @param idx particle index in particles array
  35756. * @param id particle id
  35757. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35758. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35759. * @param model particle ModelShape object
  35760. * @param shapeId model shape identifier
  35761. * @param idxInShape index of the particle in the current model
  35762. * @param bInfo model bounding info object
  35763. * @param storage target storage array, if any
  35764. * @hidden
  35765. */
  35766. private _addParticle;
  35767. /**
  35768. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35769. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35770. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35771. * @param nb (positive integer) the number of particles to be created from this model
  35772. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35773. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35774. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35775. * @returns the number of shapes in the system
  35776. */
  35777. addShape(mesh: Mesh, nb: number, options?: {
  35778. positionFunction?: any;
  35779. vertexFunction?: any;
  35780. storage?: [];
  35781. }): number;
  35782. /**
  35783. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35784. * @hidden
  35785. */
  35786. private _rebuildParticle;
  35787. /**
  35788. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35789. * @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.
  35790. * @returns the SPS.
  35791. */
  35792. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35793. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35794. * Returns an array with the removed particles.
  35795. * 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.
  35796. * The SPS can't be empty so at least one particle needs to remain in place.
  35797. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35798. * @param start index of the first particle to remove
  35799. * @param end index of the last particle to remove (included)
  35800. * @returns an array populated with the removed particles
  35801. */
  35802. removeParticles(start: number, end: number): SolidParticle[];
  35803. /**
  35804. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35805. * @param solidParticleArray an array populated with Solid Particles objects
  35806. * @returns the SPS
  35807. */
  35808. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35809. /**
  35810. * Creates a new particle and modifies the SPS mesh geometry :
  35811. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35812. * - calls _addParticle() to populate the particle array
  35813. * factorized code from addShape() and insertParticlesFromArray()
  35814. * @param idx particle index in the particles array
  35815. * @param i particle index in its shape
  35816. * @param modelShape particle ModelShape object
  35817. * @param shape shape vertex array
  35818. * @param meshInd shape indices array
  35819. * @param meshUV shape uv array
  35820. * @param meshCol shape color array
  35821. * @param meshNor shape normals array
  35822. * @param bbInfo shape bounding info
  35823. * @param storage target particle storage
  35824. * @options addShape() passed options
  35825. * @hidden
  35826. */
  35827. private _insertNewParticle;
  35828. /**
  35829. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35830. * This method calls `updateParticle()` for each particle of the SPS.
  35831. * For an animated SPS, it is usually called within the render loop.
  35832. * 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.
  35833. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35834. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35835. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35836. * @returns the SPS.
  35837. */
  35838. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35839. /**
  35840. * Disposes the SPS.
  35841. */
  35842. dispose(): void;
  35843. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35844. * idx is the particle index in the SPS
  35845. * faceId is the picked face index counted within this particle.
  35846. * Returns null if the pickInfo can't identify a picked particle.
  35847. * @param pickingInfo (PickingInfo object)
  35848. * @returns {idx: number, faceId: number} or null
  35849. */
  35850. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35851. idx: number;
  35852. faceId: number;
  35853. }>;
  35854. /**
  35855. * Returns a SolidParticle object from its identifier : particle.id
  35856. * @param id (integer) the particle Id
  35857. * @returns the searched particle or null if not found in the SPS.
  35858. */
  35859. getParticleById(id: number): Nullable<SolidParticle>;
  35860. /**
  35861. * Returns a new array populated with the particles having the passed shapeId.
  35862. * @param shapeId (integer) the shape identifier
  35863. * @returns a new solid particle array
  35864. */
  35865. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35866. /**
  35867. * Populates the passed array "ref" with the particles having the passed shapeId.
  35868. * @param shapeId the shape identifier
  35869. * @returns the SPS
  35870. * @param ref
  35871. */
  35872. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35873. /**
  35874. * Computes the required SubMeshes according the materials assigned to the particles.
  35875. * @returns the solid particle system.
  35876. * Does nothing if called before the SPS mesh is built.
  35877. */
  35878. computeSubMeshes(): SolidParticleSystem;
  35879. /**
  35880. * Sorts the solid particles by material when MultiMaterial is enabled.
  35881. * Updates the indices32 array.
  35882. * Updates the indicesByMaterial array.
  35883. * Updates the mesh indices array.
  35884. * @returns the SPS
  35885. * @hidden
  35886. */
  35887. private _sortParticlesByMaterial;
  35888. /**
  35889. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35890. * @hidden
  35891. */
  35892. private _setMaterialIndexesById;
  35893. /**
  35894. * Returns an array with unique values of Materials from the passed array
  35895. * @param array the material array to be checked and filtered
  35896. * @hidden
  35897. */
  35898. private _filterUniqueMaterialId;
  35899. /**
  35900. * Sets a new Standard Material as _defaultMaterial if not already set.
  35901. * @hidden
  35902. */
  35903. private _setDefaultMaterial;
  35904. /**
  35905. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35906. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35907. * @returns the SPS.
  35908. */
  35909. refreshVisibleSize(): SolidParticleSystem;
  35910. /**
  35911. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35912. * @param size the size (float) of the visibility box
  35913. * note : this doesn't lock the SPS mesh bounding box.
  35914. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35915. */
  35916. setVisibilityBox(size: number): void;
  35917. /**
  35918. * Gets whether the SPS as always visible or not
  35919. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35920. */
  35921. get isAlwaysVisible(): boolean;
  35922. /**
  35923. * Sets the SPS as always visible or not
  35924. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35925. */
  35926. set isAlwaysVisible(val: boolean);
  35927. /**
  35928. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35929. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35930. */
  35931. set isVisibilityBoxLocked(val: boolean);
  35932. /**
  35933. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35934. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35935. */
  35936. get isVisibilityBoxLocked(): boolean;
  35937. /**
  35938. * Tells to `setParticles()` to compute the particle rotations or not.
  35939. * Default value : true. The SPS is faster when it's set to false.
  35940. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35941. */
  35942. set computeParticleRotation(val: boolean);
  35943. /**
  35944. * Tells to `setParticles()` to compute the particle colors or not.
  35945. * Default value : true. The SPS is faster when it's set to false.
  35946. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35947. */
  35948. set computeParticleColor(val: boolean);
  35949. set computeParticleTexture(val: boolean);
  35950. /**
  35951. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35952. * Default value : false. The SPS is faster when it's set to false.
  35953. * Note : the particle custom vertex positions aren't stored values.
  35954. */
  35955. set computeParticleVertex(val: boolean);
  35956. /**
  35957. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35958. */
  35959. set computeBoundingBox(val: boolean);
  35960. /**
  35961. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35962. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35963. * Default : `true`
  35964. */
  35965. set depthSortParticles(val: boolean);
  35966. /**
  35967. * Gets if `setParticles()` computes the particle rotations or not.
  35968. * Default value : true. The SPS is faster when it's set to false.
  35969. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35970. */
  35971. get computeParticleRotation(): boolean;
  35972. /**
  35973. * Gets if `setParticles()` computes the particle colors or not.
  35974. * Default value : true. The SPS is faster when it's set to false.
  35975. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35976. */
  35977. get computeParticleColor(): boolean;
  35978. /**
  35979. * Gets if `setParticles()` computes the particle textures or not.
  35980. * Default value : true. The SPS is faster when it's set to false.
  35981. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35982. */
  35983. get computeParticleTexture(): boolean;
  35984. /**
  35985. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35986. * Default value : false. The SPS is faster when it's set to false.
  35987. * Note : the particle custom vertex positions aren't stored values.
  35988. */
  35989. get computeParticleVertex(): boolean;
  35990. /**
  35991. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35992. */
  35993. get computeBoundingBox(): boolean;
  35994. /**
  35995. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35996. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35997. * Default : `true`
  35998. */
  35999. get depthSortParticles(): boolean;
  36000. /**
  36001. * Gets if the SPS is created as expandable at construction time.
  36002. * Default : `false`
  36003. */
  36004. get expandable(): boolean;
  36005. /**
  36006. * Gets if the SPS supports the Multi Materials
  36007. */
  36008. get multimaterialEnabled(): boolean;
  36009. /**
  36010. * Gets if the SPS uses the model materials for its own multimaterial.
  36011. */
  36012. get useModelMaterial(): boolean;
  36013. /**
  36014. * The SPS used material array.
  36015. */
  36016. get materials(): Material[];
  36017. /**
  36018. * Sets the SPS MultiMaterial from the passed materials.
  36019. * Note : the passed array is internally copied and not used then by reference.
  36020. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36021. */
  36022. setMultiMaterial(materials: Material[]): void;
  36023. /**
  36024. * The SPS computed multimaterial object
  36025. */
  36026. get multimaterial(): MultiMaterial;
  36027. set multimaterial(mm: MultiMaterial);
  36028. /**
  36029. * If the subMeshes must be updated on the next call to setParticles()
  36030. */
  36031. get autoUpdateSubMeshes(): boolean;
  36032. set autoUpdateSubMeshes(val: boolean);
  36033. /**
  36034. * This function does nothing. It may be overwritten to set all the particle first values.
  36035. * The SPS doesn't call this function, you may have to call it by your own.
  36036. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36037. */
  36038. initParticles(): void;
  36039. /**
  36040. * This function does nothing. It may be overwritten to recycle a particle.
  36041. * The SPS doesn't call this function, you may have to call it by your own.
  36042. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36043. * @param particle The particle to recycle
  36044. * @returns the recycled particle
  36045. */
  36046. recycleParticle(particle: SolidParticle): SolidParticle;
  36047. /**
  36048. * Updates a particle : this function should be overwritten by the user.
  36049. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36050. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36051. * @example : just set a particle position or velocity and recycle conditions
  36052. * @param particle The particle to update
  36053. * @returns the updated particle
  36054. */
  36055. updateParticle(particle: SolidParticle): SolidParticle;
  36056. /**
  36057. * Updates a vertex of a particle : it can be overwritten by the user.
  36058. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36059. * @param particle the current particle
  36060. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36061. * @param pt the index of the current vertex in the particle shape
  36062. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36063. * @example : just set a vertex particle position or color
  36064. * @returns the sps
  36065. */
  36066. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36067. /**
  36068. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36069. * This does nothing and may be overwritten by the user.
  36070. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36071. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36072. * @param update the boolean update value actually passed to setParticles()
  36073. */
  36074. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36075. /**
  36076. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36077. * This will be passed three parameters.
  36078. * This does nothing and may be overwritten by the user.
  36079. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36080. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36081. * @param update the boolean update value actually passed to setParticles()
  36082. */
  36083. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36084. }
  36085. }
  36086. declare module "babylonjs/Particles/solidParticle" {
  36087. import { Nullable } from "babylonjs/types";
  36088. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36089. import { Color4 } from "babylonjs/Maths/math.color";
  36090. import { Mesh } from "babylonjs/Meshes/mesh";
  36091. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36092. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36093. import { Plane } from "babylonjs/Maths/math.plane";
  36094. import { Material } from "babylonjs/Materials/material";
  36095. /**
  36096. * Represents one particle of a solid particle system.
  36097. */
  36098. export class SolidParticle {
  36099. /**
  36100. * particle global index
  36101. */
  36102. idx: number;
  36103. /**
  36104. * particle identifier
  36105. */
  36106. id: number;
  36107. /**
  36108. * The color of the particle
  36109. */
  36110. color: Nullable<Color4>;
  36111. /**
  36112. * The world space position of the particle.
  36113. */
  36114. position: Vector3;
  36115. /**
  36116. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36117. */
  36118. rotation: Vector3;
  36119. /**
  36120. * The world space rotation quaternion of the particle.
  36121. */
  36122. rotationQuaternion: Nullable<Quaternion>;
  36123. /**
  36124. * The scaling of the particle.
  36125. */
  36126. scaling: Vector3;
  36127. /**
  36128. * The uvs of the particle.
  36129. */
  36130. uvs: Vector4;
  36131. /**
  36132. * The current speed of the particle.
  36133. */
  36134. velocity: Vector3;
  36135. /**
  36136. * The pivot point in the particle local space.
  36137. */
  36138. pivot: Vector3;
  36139. /**
  36140. * Must the particle be translated from its pivot point in its local space ?
  36141. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36142. * Default : false
  36143. */
  36144. translateFromPivot: boolean;
  36145. /**
  36146. * Is the particle active or not ?
  36147. */
  36148. alive: boolean;
  36149. /**
  36150. * Is the particle visible or not ?
  36151. */
  36152. isVisible: boolean;
  36153. /**
  36154. * Index of this particle in the global "positions" array (Internal use)
  36155. * @hidden
  36156. */
  36157. _pos: number;
  36158. /**
  36159. * @hidden Index of this particle in the global "indices" array (Internal use)
  36160. */
  36161. _ind: number;
  36162. /**
  36163. * @hidden ModelShape of this particle (Internal use)
  36164. */
  36165. _model: ModelShape;
  36166. /**
  36167. * ModelShape id of this particle
  36168. */
  36169. shapeId: number;
  36170. /**
  36171. * Index of the particle in its shape id
  36172. */
  36173. idxInShape: number;
  36174. /**
  36175. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36176. */
  36177. _modelBoundingInfo: BoundingInfo;
  36178. /**
  36179. * @hidden Particle BoundingInfo object (Internal use)
  36180. */
  36181. _boundingInfo: BoundingInfo;
  36182. /**
  36183. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36184. */
  36185. _sps: SolidParticleSystem;
  36186. /**
  36187. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36188. */
  36189. _stillInvisible: boolean;
  36190. /**
  36191. * @hidden Last computed particle rotation matrix
  36192. */
  36193. _rotationMatrix: number[];
  36194. /**
  36195. * Parent particle Id, if any.
  36196. * Default null.
  36197. */
  36198. parentId: Nullable<number>;
  36199. /**
  36200. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36201. */
  36202. materialIndex: Nullable<number>;
  36203. /**
  36204. * Custom object or properties.
  36205. */
  36206. props: Nullable<any>;
  36207. /**
  36208. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36209. * The possible values are :
  36210. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36211. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36212. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36213. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36214. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36215. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36216. * */
  36217. cullingStrategy: number;
  36218. /**
  36219. * @hidden Internal global position in the SPS.
  36220. */
  36221. _globalPosition: Vector3;
  36222. /**
  36223. * Creates a Solid Particle object.
  36224. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36225. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36226. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36227. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36228. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36229. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36230. * @param shapeId (integer) is the model shape identifier in the SPS.
  36231. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36232. * @param sps defines the sps it is associated to
  36233. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36234. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36235. */
  36236. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36237. /**
  36238. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36239. * @param target the particle target
  36240. * @returns the current particle
  36241. */
  36242. copyToRef(target: SolidParticle): SolidParticle;
  36243. /**
  36244. * Legacy support, changed scale to scaling
  36245. */
  36246. get scale(): Vector3;
  36247. /**
  36248. * Legacy support, changed scale to scaling
  36249. */
  36250. set scale(scale: Vector3);
  36251. /**
  36252. * Legacy support, changed quaternion to rotationQuaternion
  36253. */
  36254. get quaternion(): Nullable<Quaternion>;
  36255. /**
  36256. * Legacy support, changed quaternion to rotationQuaternion
  36257. */
  36258. set quaternion(q: Nullable<Quaternion>);
  36259. /**
  36260. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36261. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36262. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36263. * @returns true if it intersects
  36264. */
  36265. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36266. /**
  36267. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36268. * A particle is in the frustum if its bounding box intersects the frustum
  36269. * @param frustumPlanes defines the frustum to test
  36270. * @returns true if the particle is in the frustum planes
  36271. */
  36272. isInFrustum(frustumPlanes: Plane[]): boolean;
  36273. /**
  36274. * get the rotation matrix of the particle
  36275. * @hidden
  36276. */
  36277. getRotationMatrix(m: Matrix): void;
  36278. }
  36279. /**
  36280. * Represents the shape of the model used by one particle of a solid particle system.
  36281. * SPS internal tool, don't use it manually.
  36282. */
  36283. export class ModelShape {
  36284. /**
  36285. * The shape id
  36286. * @hidden
  36287. */
  36288. shapeID: number;
  36289. /**
  36290. * flat array of model positions (internal use)
  36291. * @hidden
  36292. */
  36293. _shape: Vector3[];
  36294. /**
  36295. * flat array of model UVs (internal use)
  36296. * @hidden
  36297. */
  36298. _shapeUV: number[];
  36299. /**
  36300. * color array of the model
  36301. * @hidden
  36302. */
  36303. _shapeColors: number[];
  36304. /**
  36305. * indices array of the model
  36306. * @hidden
  36307. */
  36308. _indices: number[];
  36309. /**
  36310. * normals array of the model
  36311. * @hidden
  36312. */
  36313. _normals: number[];
  36314. /**
  36315. * length of the shape in the model indices array (internal use)
  36316. * @hidden
  36317. */
  36318. _indicesLength: number;
  36319. /**
  36320. * Custom position function (internal use)
  36321. * @hidden
  36322. */
  36323. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36324. /**
  36325. * Custom vertex function (internal use)
  36326. * @hidden
  36327. */
  36328. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36329. /**
  36330. * Model material (internal use)
  36331. * @hidden
  36332. */
  36333. _material: Nullable<Material>;
  36334. /**
  36335. * 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.
  36336. * SPS internal tool, don't use it manually.
  36337. * @hidden
  36338. */
  36339. 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>);
  36340. }
  36341. /**
  36342. * Represents a Depth Sorted Particle in the solid particle system.
  36343. * @hidden
  36344. */
  36345. export class DepthSortedParticle {
  36346. /**
  36347. * Particle index
  36348. */
  36349. idx: number;
  36350. /**
  36351. * Index of the particle in the "indices" array
  36352. */
  36353. ind: number;
  36354. /**
  36355. * Length of the particle shape in the "indices" array
  36356. */
  36357. indicesLength: number;
  36358. /**
  36359. * Squared distance from the particle to the camera
  36360. */
  36361. sqDistance: number;
  36362. /**
  36363. * Material index when used with MultiMaterials
  36364. */
  36365. materialIndex: number;
  36366. /**
  36367. * Creates a new sorted particle
  36368. * @param materialIndex
  36369. */
  36370. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36371. }
  36372. /**
  36373. * Represents a solid particle vertex
  36374. */
  36375. export class SolidParticleVertex {
  36376. /**
  36377. * Vertex position
  36378. */
  36379. position: Vector3;
  36380. /**
  36381. * Vertex color
  36382. */
  36383. color: Color4;
  36384. /**
  36385. * Vertex UV
  36386. */
  36387. uv: Vector2;
  36388. /**
  36389. * Creates a new solid particle vertex
  36390. */
  36391. constructor();
  36392. /** Vertex x coordinate */
  36393. get x(): number;
  36394. set x(val: number);
  36395. /** Vertex y coordinate */
  36396. get y(): number;
  36397. set y(val: number);
  36398. /** Vertex z coordinate */
  36399. get z(): number;
  36400. set z(val: number);
  36401. }
  36402. }
  36403. declare module "babylonjs/Collisions/meshCollisionData" {
  36404. import { Collider } from "babylonjs/Collisions/collider";
  36405. import { Vector3 } from "babylonjs/Maths/math.vector";
  36406. import { Nullable } from "babylonjs/types";
  36407. import { Observer } from "babylonjs/Misc/observable";
  36408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36409. /**
  36410. * @hidden
  36411. */
  36412. export class _MeshCollisionData {
  36413. _checkCollisions: boolean;
  36414. _collisionMask: number;
  36415. _collisionGroup: number;
  36416. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36417. _collider: Nullable<Collider>;
  36418. _oldPositionForCollisions: Vector3;
  36419. _diffPositionForCollisions: Vector3;
  36420. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36421. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36422. _collisionResponse: boolean;
  36423. }
  36424. }
  36425. declare module "babylonjs/Meshes/abstractMesh" {
  36426. import { Observable } from "babylonjs/Misc/observable";
  36427. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36428. import { Camera } from "babylonjs/Cameras/camera";
  36429. import { Scene, IDisposable } from "babylonjs/scene";
  36430. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36431. import { Node } from "babylonjs/node";
  36432. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36433. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36434. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36435. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36436. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36437. import { Material } from "babylonjs/Materials/material";
  36438. import { Light } from "babylonjs/Lights/light";
  36439. import { Skeleton } from "babylonjs/Bones/skeleton";
  36440. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36441. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36442. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36443. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36444. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36445. import { Plane } from "babylonjs/Maths/math.plane";
  36446. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36447. import { Ray } from "babylonjs/Culling/ray";
  36448. import { Collider } from "babylonjs/Collisions/collider";
  36449. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36450. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36451. /** @hidden */
  36452. class _FacetDataStorage {
  36453. facetPositions: Vector3[];
  36454. facetNormals: Vector3[];
  36455. facetPartitioning: number[][];
  36456. facetNb: number;
  36457. partitioningSubdivisions: number;
  36458. partitioningBBoxRatio: number;
  36459. facetDataEnabled: boolean;
  36460. facetParameters: any;
  36461. bbSize: Vector3;
  36462. subDiv: {
  36463. max: number;
  36464. X: number;
  36465. Y: number;
  36466. Z: number;
  36467. };
  36468. facetDepthSort: boolean;
  36469. facetDepthSortEnabled: boolean;
  36470. depthSortedIndices: IndicesArray;
  36471. depthSortedFacets: {
  36472. ind: number;
  36473. sqDistance: number;
  36474. }[];
  36475. facetDepthSortFunction: (f1: {
  36476. ind: number;
  36477. sqDistance: number;
  36478. }, f2: {
  36479. ind: number;
  36480. sqDistance: number;
  36481. }) => number;
  36482. facetDepthSortFrom: Vector3;
  36483. facetDepthSortOrigin: Vector3;
  36484. invertedMatrix: Matrix;
  36485. }
  36486. /**
  36487. * @hidden
  36488. **/
  36489. class _InternalAbstractMeshDataInfo {
  36490. _hasVertexAlpha: boolean;
  36491. _useVertexColors: boolean;
  36492. _numBoneInfluencers: number;
  36493. _applyFog: boolean;
  36494. _receiveShadows: boolean;
  36495. _facetData: _FacetDataStorage;
  36496. _visibility: number;
  36497. _skeleton: Nullable<Skeleton>;
  36498. _layerMask: number;
  36499. _computeBonesUsingShaders: boolean;
  36500. _isActive: boolean;
  36501. _onlyForInstances: boolean;
  36502. _isActiveIntermediate: boolean;
  36503. _onlyForInstancesIntermediate: boolean;
  36504. _actAsRegularMesh: boolean;
  36505. _currentLOD: Nullable<AbstractMesh>;
  36506. }
  36507. /**
  36508. * Class used to store all common mesh properties
  36509. */
  36510. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36511. /** No occlusion */
  36512. static OCCLUSION_TYPE_NONE: number;
  36513. /** Occlusion set to optimisitic */
  36514. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36515. /** Occlusion set to strict */
  36516. static OCCLUSION_TYPE_STRICT: number;
  36517. /** Use an accurante occlusion algorithm */
  36518. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36519. /** Use a conservative occlusion algorithm */
  36520. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36521. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36522. * Test order :
  36523. * Is the bounding sphere outside the frustum ?
  36524. * If not, are the bounding box vertices outside the frustum ?
  36525. * It not, then the cullable object is in the frustum.
  36526. */
  36527. static readonly CULLINGSTRATEGY_STANDARD: number;
  36528. /** Culling strategy : Bounding Sphere Only.
  36529. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36530. * It's also less accurate than the standard because some not visible objects can still be selected.
  36531. * Test : is the bounding sphere outside the frustum ?
  36532. * If not, then the cullable object is in the frustum.
  36533. */
  36534. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36535. /** Culling strategy : Optimistic Inclusion.
  36536. * This in an inclusion test first, then the standard exclusion test.
  36537. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36538. * 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.
  36539. * Anyway, it's as accurate as the standard strategy.
  36540. * Test :
  36541. * Is the cullable object bounding sphere center in the frustum ?
  36542. * If not, apply the default culling strategy.
  36543. */
  36544. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36545. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36546. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36547. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36548. * 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.
  36549. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36550. * Test :
  36551. * Is the cullable object bounding sphere center in the frustum ?
  36552. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36553. */
  36554. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36555. /**
  36556. * No billboard
  36557. */
  36558. static get BILLBOARDMODE_NONE(): number;
  36559. /** Billboard on X axis */
  36560. static get BILLBOARDMODE_X(): number;
  36561. /** Billboard on Y axis */
  36562. static get BILLBOARDMODE_Y(): number;
  36563. /** Billboard on Z axis */
  36564. static get BILLBOARDMODE_Z(): number;
  36565. /** Billboard on all axes */
  36566. static get BILLBOARDMODE_ALL(): number;
  36567. /** Billboard on using position instead of orientation */
  36568. static get BILLBOARDMODE_USE_POSITION(): number;
  36569. /** @hidden */
  36570. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36571. /**
  36572. * The culling strategy to use to check whether the mesh must be rendered or not.
  36573. * This value can be changed at any time and will be used on the next render mesh selection.
  36574. * The possible values are :
  36575. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36576. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36577. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36578. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36579. * Please read each static variable documentation to get details about the culling process.
  36580. * */
  36581. cullingStrategy: number;
  36582. /**
  36583. * Gets the number of facets in the mesh
  36584. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36585. */
  36586. get facetNb(): number;
  36587. /**
  36588. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36589. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36590. */
  36591. get partitioningSubdivisions(): number;
  36592. set partitioningSubdivisions(nb: number);
  36593. /**
  36594. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36595. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36596. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36597. */
  36598. get partitioningBBoxRatio(): number;
  36599. set partitioningBBoxRatio(ratio: number);
  36600. /**
  36601. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36602. * Works only for updatable meshes.
  36603. * Doesn't work with multi-materials
  36604. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36605. */
  36606. get mustDepthSortFacets(): boolean;
  36607. set mustDepthSortFacets(sort: boolean);
  36608. /**
  36609. * The location (Vector3) where the facet depth sort must be computed from.
  36610. * By default, the active camera position.
  36611. * Used only when facet depth sort is enabled
  36612. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36613. */
  36614. get facetDepthSortFrom(): Vector3;
  36615. set facetDepthSortFrom(location: Vector3);
  36616. /**
  36617. * gets a boolean indicating if facetData is enabled
  36618. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36619. */
  36620. get isFacetDataEnabled(): boolean;
  36621. /** @hidden */
  36622. _updateNonUniformScalingState(value: boolean): boolean;
  36623. /**
  36624. * An event triggered when this mesh collides with another one
  36625. */
  36626. onCollideObservable: Observable<AbstractMesh>;
  36627. /** Set a function to call when this mesh collides with another one */
  36628. set onCollide(callback: () => void);
  36629. /**
  36630. * An event triggered when the collision's position changes
  36631. */
  36632. onCollisionPositionChangeObservable: Observable<Vector3>;
  36633. /** Set a function to call when the collision's position changes */
  36634. set onCollisionPositionChange(callback: () => void);
  36635. /**
  36636. * An event triggered when material is changed
  36637. */
  36638. onMaterialChangedObservable: Observable<AbstractMesh>;
  36639. /**
  36640. * Gets or sets the orientation for POV movement & rotation
  36641. */
  36642. definedFacingForward: boolean;
  36643. /** @hidden */
  36644. _occlusionQuery: Nullable<WebGLQuery>;
  36645. /** @hidden */
  36646. _renderingGroup: Nullable<RenderingGroup>;
  36647. /**
  36648. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36649. */
  36650. get visibility(): number;
  36651. /**
  36652. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36653. */
  36654. set visibility(value: number);
  36655. /** Gets or sets the alpha index used to sort transparent meshes
  36656. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36657. */
  36658. alphaIndex: number;
  36659. /**
  36660. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36661. */
  36662. isVisible: boolean;
  36663. /**
  36664. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36665. */
  36666. isPickable: boolean;
  36667. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36668. showSubMeshesBoundingBox: boolean;
  36669. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36670. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36671. */
  36672. isBlocker: boolean;
  36673. /**
  36674. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36675. */
  36676. enablePointerMoveEvents: boolean;
  36677. private _renderingGroupId;
  36678. /**
  36679. * Specifies the rendering group id for this mesh (0 by default)
  36680. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36681. */
  36682. get renderingGroupId(): number;
  36683. set renderingGroupId(value: number);
  36684. private _material;
  36685. /** Gets or sets current material */
  36686. get material(): Nullable<Material>;
  36687. set material(value: Nullable<Material>);
  36688. /**
  36689. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36690. * @see https://doc.babylonjs.com/babylon101/shadows
  36691. */
  36692. get receiveShadows(): boolean;
  36693. set receiveShadows(value: boolean);
  36694. /** Defines color to use when rendering outline */
  36695. outlineColor: Color3;
  36696. /** Define width to use when rendering outline */
  36697. outlineWidth: number;
  36698. /** Defines color to use when rendering overlay */
  36699. overlayColor: Color3;
  36700. /** Defines alpha to use when rendering overlay */
  36701. overlayAlpha: number;
  36702. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36703. get hasVertexAlpha(): boolean;
  36704. set hasVertexAlpha(value: boolean);
  36705. /** 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) */
  36706. get useVertexColors(): boolean;
  36707. set useVertexColors(value: boolean);
  36708. /**
  36709. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36710. */
  36711. get computeBonesUsingShaders(): boolean;
  36712. set computeBonesUsingShaders(value: boolean);
  36713. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36714. get numBoneInfluencers(): number;
  36715. set numBoneInfluencers(value: number);
  36716. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36717. get applyFog(): boolean;
  36718. set applyFog(value: boolean);
  36719. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36720. useOctreeForRenderingSelection: boolean;
  36721. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36722. useOctreeForPicking: boolean;
  36723. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36724. useOctreeForCollisions: boolean;
  36725. /**
  36726. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36727. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36728. */
  36729. get layerMask(): number;
  36730. set layerMask(value: number);
  36731. /**
  36732. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36733. */
  36734. alwaysSelectAsActiveMesh: boolean;
  36735. /**
  36736. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36737. */
  36738. doNotSyncBoundingInfo: boolean;
  36739. /**
  36740. * Gets or sets the current action manager
  36741. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36742. */
  36743. actionManager: Nullable<AbstractActionManager>;
  36744. private _meshCollisionData;
  36745. /**
  36746. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36747. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36748. */
  36749. ellipsoid: Vector3;
  36750. /**
  36751. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36752. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36753. */
  36754. ellipsoidOffset: Vector3;
  36755. /**
  36756. * Gets or sets a collision mask used to mask collisions (default is -1).
  36757. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36758. */
  36759. get collisionMask(): number;
  36760. set collisionMask(mask: number);
  36761. /**
  36762. * Gets or sets a collision response flag (default is true).
  36763. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36764. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36765. * to respond to the collision.
  36766. */
  36767. get collisionResponse(): boolean;
  36768. set collisionResponse(response: boolean);
  36769. /**
  36770. * Gets or sets the current collision group mask (-1 by default).
  36771. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36772. */
  36773. get collisionGroup(): number;
  36774. set collisionGroup(mask: number);
  36775. /**
  36776. * Gets or sets current surrounding meshes (null by default).
  36777. *
  36778. * By default collision detection is tested against every mesh in the scene.
  36779. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36780. * meshes will be tested for the collision.
  36781. *
  36782. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36783. */
  36784. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36785. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36786. /**
  36787. * Defines edge width used when edgesRenderer is enabled
  36788. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36789. */
  36790. edgesWidth: number;
  36791. /**
  36792. * Defines edge color used when edgesRenderer is enabled
  36793. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36794. */
  36795. edgesColor: Color4;
  36796. /** @hidden */
  36797. _edgesRenderer: Nullable<IEdgesRenderer>;
  36798. /** @hidden */
  36799. _masterMesh: Nullable<AbstractMesh>;
  36800. /** @hidden */
  36801. _boundingInfo: Nullable<BoundingInfo>;
  36802. /** @hidden */
  36803. _renderId: number;
  36804. /**
  36805. * Gets or sets the list of subMeshes
  36806. * @see https://doc.babylonjs.com/how_to/multi_materials
  36807. */
  36808. subMeshes: SubMesh[];
  36809. /** @hidden */
  36810. _intersectionsInProgress: AbstractMesh[];
  36811. /** @hidden */
  36812. _unIndexed: boolean;
  36813. /** @hidden */
  36814. _lightSources: Light[];
  36815. /** Gets the list of lights affecting that mesh */
  36816. get lightSources(): Light[];
  36817. /** @hidden */
  36818. get _positions(): Nullable<Vector3[]>;
  36819. /** @hidden */
  36820. _waitingData: {
  36821. lods: Nullable<any>;
  36822. actions: Nullable<any>;
  36823. freezeWorldMatrix: Nullable<boolean>;
  36824. };
  36825. /** @hidden */
  36826. _bonesTransformMatrices: Nullable<Float32Array>;
  36827. /** @hidden */
  36828. _transformMatrixTexture: Nullable<RawTexture>;
  36829. /**
  36830. * Gets or sets a skeleton to apply skining transformations
  36831. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36832. */
  36833. set skeleton(value: Nullable<Skeleton>);
  36834. get skeleton(): Nullable<Skeleton>;
  36835. /**
  36836. * An event triggered when the mesh is rebuilt.
  36837. */
  36838. onRebuildObservable: Observable<AbstractMesh>;
  36839. /**
  36840. * Creates a new AbstractMesh
  36841. * @param name defines the name of the mesh
  36842. * @param scene defines the hosting scene
  36843. */
  36844. constructor(name: string, scene?: Nullable<Scene>);
  36845. /**
  36846. * Returns the string "AbstractMesh"
  36847. * @returns "AbstractMesh"
  36848. */
  36849. getClassName(): string;
  36850. /**
  36851. * Gets a string representation of the current mesh
  36852. * @param fullDetails defines a boolean indicating if full details must be included
  36853. * @returns a string representation of the current mesh
  36854. */
  36855. toString(fullDetails?: boolean): string;
  36856. /**
  36857. * @hidden
  36858. */
  36859. protected _getEffectiveParent(): Nullable<Node>;
  36860. /** @hidden */
  36861. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36862. /** @hidden */
  36863. _rebuild(): void;
  36864. /** @hidden */
  36865. _resyncLightSources(): void;
  36866. /** @hidden */
  36867. _resyncLightSource(light: Light): void;
  36868. /** @hidden */
  36869. _unBindEffect(): void;
  36870. /** @hidden */
  36871. _removeLightSource(light: Light, dispose: boolean): void;
  36872. private _markSubMeshesAsDirty;
  36873. /** @hidden */
  36874. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36875. /** @hidden */
  36876. _markSubMeshesAsAttributesDirty(): void;
  36877. /** @hidden */
  36878. _markSubMeshesAsMiscDirty(): void;
  36879. /**
  36880. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36881. */
  36882. get scaling(): Vector3;
  36883. set scaling(newScaling: Vector3);
  36884. /**
  36885. * Returns true if the mesh is blocked. Implemented by child classes
  36886. */
  36887. get isBlocked(): boolean;
  36888. /**
  36889. * Returns the mesh itself by default. Implemented by child classes
  36890. * @param camera defines the camera to use to pick the right LOD level
  36891. * @returns the currentAbstractMesh
  36892. */
  36893. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36894. /**
  36895. * Returns 0 by default. Implemented by child classes
  36896. * @returns an integer
  36897. */
  36898. getTotalVertices(): number;
  36899. /**
  36900. * Returns a positive integer : the total number of indices in this mesh geometry.
  36901. * @returns the numner of indices or zero if the mesh has no geometry.
  36902. */
  36903. getTotalIndices(): number;
  36904. /**
  36905. * Returns null by default. Implemented by child classes
  36906. * @returns null
  36907. */
  36908. getIndices(): Nullable<IndicesArray>;
  36909. /**
  36910. * Returns the array of the requested vertex data kind. Implemented by child classes
  36911. * @param kind defines the vertex data kind to use
  36912. * @returns null
  36913. */
  36914. getVerticesData(kind: string): Nullable<FloatArray>;
  36915. /**
  36916. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36917. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36918. * Note that a new underlying VertexBuffer object is created each call.
  36919. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36920. * @param kind defines vertex data kind:
  36921. * * VertexBuffer.PositionKind
  36922. * * VertexBuffer.UVKind
  36923. * * VertexBuffer.UV2Kind
  36924. * * VertexBuffer.UV3Kind
  36925. * * VertexBuffer.UV4Kind
  36926. * * VertexBuffer.UV5Kind
  36927. * * VertexBuffer.UV6Kind
  36928. * * VertexBuffer.ColorKind
  36929. * * VertexBuffer.MatricesIndicesKind
  36930. * * VertexBuffer.MatricesIndicesExtraKind
  36931. * * VertexBuffer.MatricesWeightsKind
  36932. * * VertexBuffer.MatricesWeightsExtraKind
  36933. * @param data defines the data source
  36934. * @param updatable defines if the data must be flagged as updatable (or static)
  36935. * @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
  36936. * @returns the current mesh
  36937. */
  36938. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36939. /**
  36940. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36941. * If the mesh has no geometry, it is simply returned as it is.
  36942. * @param kind defines vertex data kind:
  36943. * * VertexBuffer.PositionKind
  36944. * * VertexBuffer.UVKind
  36945. * * VertexBuffer.UV2Kind
  36946. * * VertexBuffer.UV3Kind
  36947. * * VertexBuffer.UV4Kind
  36948. * * VertexBuffer.UV5Kind
  36949. * * VertexBuffer.UV6Kind
  36950. * * VertexBuffer.ColorKind
  36951. * * VertexBuffer.MatricesIndicesKind
  36952. * * VertexBuffer.MatricesIndicesExtraKind
  36953. * * VertexBuffer.MatricesWeightsKind
  36954. * * VertexBuffer.MatricesWeightsExtraKind
  36955. * @param data defines the data source
  36956. * @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
  36957. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36958. * @returns the current mesh
  36959. */
  36960. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36961. /**
  36962. * Sets the mesh indices,
  36963. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36964. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36965. * @param totalVertices Defines the total number of vertices
  36966. * @returns the current mesh
  36967. */
  36968. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36969. /**
  36970. * Gets a boolean indicating if specific vertex data is present
  36971. * @param kind defines the vertex data kind to use
  36972. * @returns true is data kind is present
  36973. */
  36974. isVerticesDataPresent(kind: string): boolean;
  36975. /**
  36976. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36977. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36978. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36979. * @returns a BoundingInfo
  36980. */
  36981. getBoundingInfo(): BoundingInfo;
  36982. /**
  36983. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36984. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36985. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36986. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36987. * @returns the current mesh
  36988. */
  36989. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36990. /**
  36991. * Overwrite the current bounding info
  36992. * @param boundingInfo defines the new bounding info
  36993. * @returns the current mesh
  36994. */
  36995. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36996. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36997. get useBones(): boolean;
  36998. /** @hidden */
  36999. _preActivate(): void;
  37000. /** @hidden */
  37001. _preActivateForIntermediateRendering(renderId: number): void;
  37002. /** @hidden */
  37003. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37004. /** @hidden */
  37005. _postActivate(): void;
  37006. /** @hidden */
  37007. _freeze(): void;
  37008. /** @hidden */
  37009. _unFreeze(): void;
  37010. /**
  37011. * Gets the current world matrix
  37012. * @returns a Matrix
  37013. */
  37014. getWorldMatrix(): Matrix;
  37015. /** @hidden */
  37016. _getWorldMatrixDeterminant(): number;
  37017. /**
  37018. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37019. */
  37020. get isAnInstance(): boolean;
  37021. /**
  37022. * Gets a boolean indicating if this mesh has instances
  37023. */
  37024. get hasInstances(): boolean;
  37025. /**
  37026. * Gets a boolean indicating if this mesh has thin instances
  37027. */
  37028. get hasThinInstances(): boolean;
  37029. /**
  37030. * Perform relative position change from the point of view of behind the front of the mesh.
  37031. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37032. * Supports definition of mesh facing forward or backward
  37033. * @param amountRight defines the distance on the right axis
  37034. * @param amountUp defines the distance on the up axis
  37035. * @param amountForward defines the distance on the forward axis
  37036. * @returns the current mesh
  37037. */
  37038. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37039. /**
  37040. * Calculate relative position change from the point of view of behind the front of the mesh.
  37041. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37042. * Supports definition of mesh facing forward or backward
  37043. * @param amountRight defines the distance on the right axis
  37044. * @param amountUp defines the distance on the up axis
  37045. * @param amountForward defines the distance on the forward axis
  37046. * @returns the new displacement vector
  37047. */
  37048. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37049. /**
  37050. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37051. * Supports definition of mesh facing forward or backward
  37052. * @param flipBack defines the flip
  37053. * @param twirlClockwise defines the twirl
  37054. * @param tiltRight defines the tilt
  37055. * @returns the current mesh
  37056. */
  37057. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37058. /**
  37059. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37060. * Supports definition of mesh facing forward or backward.
  37061. * @param flipBack defines the flip
  37062. * @param twirlClockwise defines the twirl
  37063. * @param tiltRight defines the tilt
  37064. * @returns the new rotation vector
  37065. */
  37066. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37067. /**
  37068. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37069. * This means the mesh underlying bounding box and sphere are recomputed.
  37070. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37071. * @returns the current mesh
  37072. */
  37073. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37074. /** @hidden */
  37075. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37076. /** @hidden */
  37077. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37078. /** @hidden */
  37079. _updateBoundingInfo(): AbstractMesh;
  37080. /** @hidden */
  37081. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37082. /** @hidden */
  37083. protected _afterComputeWorldMatrix(): void;
  37084. /** @hidden */
  37085. get _effectiveMesh(): AbstractMesh;
  37086. /**
  37087. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37088. * A mesh is in the frustum if its bounding box intersects the frustum
  37089. * @param frustumPlanes defines the frustum to test
  37090. * @returns true if the mesh is in the frustum planes
  37091. */
  37092. isInFrustum(frustumPlanes: Plane[]): boolean;
  37093. /**
  37094. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37095. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37096. * @param frustumPlanes defines the frustum to test
  37097. * @returns true if the mesh is completely in the frustum planes
  37098. */
  37099. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37100. /**
  37101. * True if the mesh intersects another mesh or a SolidParticle object
  37102. * @param mesh defines a target mesh or SolidParticle to test
  37103. * @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)
  37104. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37105. * @returns true if there is an intersection
  37106. */
  37107. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37108. /**
  37109. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37110. * @param point defines the point to test
  37111. * @returns true if there is an intersection
  37112. */
  37113. intersectsPoint(point: Vector3): boolean;
  37114. /**
  37115. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37116. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37117. */
  37118. get checkCollisions(): boolean;
  37119. set checkCollisions(collisionEnabled: boolean);
  37120. /**
  37121. * Gets Collider object used to compute collisions (not physics)
  37122. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37123. */
  37124. get collider(): Nullable<Collider>;
  37125. /**
  37126. * Move the mesh using collision engine
  37127. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37128. * @param displacement defines the requested displacement vector
  37129. * @returns the current mesh
  37130. */
  37131. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37132. private _onCollisionPositionChange;
  37133. /** @hidden */
  37134. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37135. /** @hidden */
  37136. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37137. /** @hidden */
  37138. _checkCollision(collider: Collider): AbstractMesh;
  37139. /** @hidden */
  37140. _generatePointsArray(): boolean;
  37141. /**
  37142. * Checks if the passed Ray intersects with the mesh
  37143. * @param ray defines the ray to use
  37144. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37145. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37146. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37147. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37148. * @returns the picking info
  37149. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37150. */
  37151. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  37152. /**
  37153. * Clones the current mesh
  37154. * @param name defines the mesh name
  37155. * @param newParent defines the new mesh parent
  37156. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37157. * @returns the new mesh
  37158. */
  37159. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37160. /**
  37161. * Disposes all the submeshes of the current meshnp
  37162. * @returns the current mesh
  37163. */
  37164. releaseSubMeshes(): AbstractMesh;
  37165. /**
  37166. * Releases resources associated with this abstract mesh.
  37167. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37168. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37169. */
  37170. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37171. /**
  37172. * Adds the passed mesh as a child to the current mesh
  37173. * @param mesh defines the child mesh
  37174. * @returns the current mesh
  37175. */
  37176. addChild(mesh: AbstractMesh): AbstractMesh;
  37177. /**
  37178. * Removes the passed mesh from the current mesh children list
  37179. * @param mesh defines the child mesh
  37180. * @returns the current mesh
  37181. */
  37182. removeChild(mesh: AbstractMesh): AbstractMesh;
  37183. /** @hidden */
  37184. private _initFacetData;
  37185. /**
  37186. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37187. * This method can be called within the render loop.
  37188. * 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
  37189. * @returns the current mesh
  37190. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37191. */
  37192. updateFacetData(): AbstractMesh;
  37193. /**
  37194. * Returns the facetLocalNormals array.
  37195. * The normals are expressed in the mesh local spac
  37196. * @returns an array of Vector3
  37197. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37198. */
  37199. getFacetLocalNormals(): Vector3[];
  37200. /**
  37201. * Returns the facetLocalPositions array.
  37202. * The facet positions are expressed in the mesh local space
  37203. * @returns an array of Vector3
  37204. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37205. */
  37206. getFacetLocalPositions(): Vector3[];
  37207. /**
  37208. * Returns the facetLocalPartioning array
  37209. * @returns an array of array of numbers
  37210. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37211. */
  37212. getFacetLocalPartitioning(): number[][];
  37213. /**
  37214. * Returns the i-th facet position in the world system.
  37215. * This method allocates a new Vector3 per call
  37216. * @param i defines the facet index
  37217. * @returns a new Vector3
  37218. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37219. */
  37220. getFacetPosition(i: number): Vector3;
  37221. /**
  37222. * Sets the reference Vector3 with the i-th facet position in the world system
  37223. * @param i defines the facet index
  37224. * @param ref defines the target vector
  37225. * @returns the current mesh
  37226. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37227. */
  37228. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37229. /**
  37230. * Returns the i-th facet normal in the world system.
  37231. * This method allocates a new Vector3 per call
  37232. * @param i defines the facet index
  37233. * @returns a new Vector3
  37234. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37235. */
  37236. getFacetNormal(i: number): Vector3;
  37237. /**
  37238. * Sets the reference Vector3 with the i-th facet normal in the world system
  37239. * @param i defines the facet index
  37240. * @param ref defines the target vector
  37241. * @returns the current mesh
  37242. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37243. */
  37244. getFacetNormalToRef(i: number, ref: Vector3): this;
  37245. /**
  37246. * 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)
  37247. * @param x defines x coordinate
  37248. * @param y defines y coordinate
  37249. * @param z defines z coordinate
  37250. * @returns the array of facet indexes
  37251. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37252. */
  37253. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37254. /**
  37255. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37256. * @param projected sets as the (x,y,z) world projection on the facet
  37257. * @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
  37258. * @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
  37259. * @param x defines x coordinate
  37260. * @param y defines y coordinate
  37261. * @param z defines z coordinate
  37262. * @returns the face index if found (or null instead)
  37263. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37264. */
  37265. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37266. /**
  37267. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37268. * @param projected sets as the (x,y,z) local projection on the facet
  37269. * @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
  37270. * @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
  37271. * @param x defines x coordinate
  37272. * @param y defines y coordinate
  37273. * @param z defines z coordinate
  37274. * @returns the face index if found (or null instead)
  37275. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37276. */
  37277. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37278. /**
  37279. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37280. * @returns the parameters
  37281. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37282. */
  37283. getFacetDataParameters(): any;
  37284. /**
  37285. * Disables the feature FacetData and frees the related memory
  37286. * @returns the current mesh
  37287. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37288. */
  37289. disableFacetData(): AbstractMesh;
  37290. /**
  37291. * Updates the AbstractMesh indices array
  37292. * @param indices defines the data source
  37293. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37294. * @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)
  37295. * @returns the current mesh
  37296. */
  37297. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37298. /**
  37299. * Creates new normals data for the mesh
  37300. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37301. * @returns the current mesh
  37302. */
  37303. createNormals(updatable: boolean): AbstractMesh;
  37304. /**
  37305. * Align the mesh with a normal
  37306. * @param normal defines the normal to use
  37307. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37308. * @returns the current mesh
  37309. */
  37310. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37311. /** @hidden */
  37312. _checkOcclusionQuery(): boolean;
  37313. /**
  37314. * Disables the mesh edge rendering mode
  37315. * @returns the currentAbstractMesh
  37316. */
  37317. disableEdgesRendering(): AbstractMesh;
  37318. /**
  37319. * Enables the edge rendering mode on the mesh.
  37320. * This mode makes the mesh edges visible
  37321. * @param epsilon defines the maximal distance between two angles to detect a face
  37322. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37323. * @returns the currentAbstractMesh
  37324. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37325. */
  37326. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37327. /**
  37328. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37329. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37330. */
  37331. getConnectedParticleSystems(): IParticleSystem[];
  37332. }
  37333. }
  37334. declare module "babylonjs/Actions/actionEvent" {
  37335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37336. import { Nullable } from "babylonjs/types";
  37337. import { Sprite } from "babylonjs/Sprites/sprite";
  37338. import { Scene } from "babylonjs/scene";
  37339. import { Vector2 } from "babylonjs/Maths/math.vector";
  37340. /**
  37341. * Interface used to define ActionEvent
  37342. */
  37343. export interface IActionEvent {
  37344. /** The mesh or sprite that triggered the action */
  37345. source: any;
  37346. /** The X mouse cursor position at the time of the event */
  37347. pointerX: number;
  37348. /** The Y mouse cursor position at the time of the event */
  37349. pointerY: number;
  37350. /** The mesh that is currently pointed at (can be null) */
  37351. meshUnderPointer: Nullable<AbstractMesh>;
  37352. /** the original (browser) event that triggered the ActionEvent */
  37353. sourceEvent?: any;
  37354. /** additional data for the event */
  37355. additionalData?: any;
  37356. }
  37357. /**
  37358. * ActionEvent is the event being sent when an action is triggered.
  37359. */
  37360. export class ActionEvent implements IActionEvent {
  37361. /** The mesh or sprite that triggered the action */
  37362. source: any;
  37363. /** The X mouse cursor position at the time of the event */
  37364. pointerX: number;
  37365. /** The Y mouse cursor position at the time of the event */
  37366. pointerY: number;
  37367. /** The mesh that is currently pointed at (can be null) */
  37368. meshUnderPointer: Nullable<AbstractMesh>;
  37369. /** the original (browser) event that triggered the ActionEvent */
  37370. sourceEvent?: any;
  37371. /** additional data for the event */
  37372. additionalData?: any;
  37373. /**
  37374. * Creates a new ActionEvent
  37375. * @param source The mesh or sprite that triggered the action
  37376. * @param pointerX The X mouse cursor position at the time of the event
  37377. * @param pointerY The Y mouse cursor position at the time of the event
  37378. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37379. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37380. * @param additionalData additional data for the event
  37381. */
  37382. constructor(
  37383. /** The mesh or sprite that triggered the action */
  37384. source: any,
  37385. /** The X mouse cursor position at the time of the event */
  37386. pointerX: number,
  37387. /** The Y mouse cursor position at the time of the event */
  37388. pointerY: number,
  37389. /** The mesh that is currently pointed at (can be null) */
  37390. meshUnderPointer: Nullable<AbstractMesh>,
  37391. /** the original (browser) event that triggered the ActionEvent */
  37392. sourceEvent?: any,
  37393. /** additional data for the event */
  37394. additionalData?: any);
  37395. /**
  37396. * Helper function to auto-create an ActionEvent from a source mesh.
  37397. * @param source The source mesh that triggered the event
  37398. * @param evt The original (browser) event
  37399. * @param additionalData additional data for the event
  37400. * @returns the new ActionEvent
  37401. */
  37402. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37403. /**
  37404. * Helper function to auto-create an ActionEvent from a source sprite
  37405. * @param source The source sprite that triggered the event
  37406. * @param scene Scene associated with the sprite
  37407. * @param evt The original (browser) event
  37408. * @param additionalData additional data for the event
  37409. * @returns the new ActionEvent
  37410. */
  37411. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37412. /**
  37413. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37414. * @param scene the scene where the event occurred
  37415. * @param evt The original (browser) event
  37416. * @returns the new ActionEvent
  37417. */
  37418. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37419. /**
  37420. * Helper function to auto-create an ActionEvent from a primitive
  37421. * @param prim defines the target primitive
  37422. * @param pointerPos defines the pointer position
  37423. * @param evt The original (browser) event
  37424. * @param additionalData additional data for the event
  37425. * @returns the new ActionEvent
  37426. */
  37427. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37428. }
  37429. }
  37430. declare module "babylonjs/Actions/abstractActionManager" {
  37431. import { IDisposable } from "babylonjs/scene";
  37432. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37433. import { IAction } from "babylonjs/Actions/action";
  37434. import { Nullable } from "babylonjs/types";
  37435. /**
  37436. * Abstract class used to decouple action Manager from scene and meshes.
  37437. * Do not instantiate.
  37438. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37439. */
  37440. export abstract class AbstractActionManager implements IDisposable {
  37441. /** Gets the list of active triggers */
  37442. static Triggers: {
  37443. [key: string]: number;
  37444. };
  37445. /** Gets the cursor to use when hovering items */
  37446. hoverCursor: string;
  37447. /** Gets the list of actions */
  37448. actions: IAction[];
  37449. /**
  37450. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37451. */
  37452. isRecursive: boolean;
  37453. /**
  37454. * Releases all associated resources
  37455. */
  37456. abstract dispose(): void;
  37457. /**
  37458. * Does this action manager has pointer triggers
  37459. */
  37460. abstract get hasPointerTriggers(): boolean;
  37461. /**
  37462. * Does this action manager has pick triggers
  37463. */
  37464. abstract get hasPickTriggers(): boolean;
  37465. /**
  37466. * Process a specific trigger
  37467. * @param trigger defines the trigger to process
  37468. * @param evt defines the event details to be processed
  37469. */
  37470. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37471. /**
  37472. * Does this action manager handles actions of any of the given triggers
  37473. * @param triggers defines the triggers to be tested
  37474. * @return a boolean indicating whether one (or more) of the triggers is handled
  37475. */
  37476. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37477. /**
  37478. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37479. * speed.
  37480. * @param triggerA defines the trigger to be tested
  37481. * @param triggerB defines the trigger to be tested
  37482. * @return a boolean indicating whether one (or more) of the triggers is handled
  37483. */
  37484. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37485. /**
  37486. * Does this action manager handles actions of a given trigger
  37487. * @param trigger defines the trigger to be tested
  37488. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37489. * @return whether the trigger is handled
  37490. */
  37491. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37492. /**
  37493. * Serialize this manager to a JSON object
  37494. * @param name defines the property name to store this manager
  37495. * @returns a JSON representation of this manager
  37496. */
  37497. abstract serialize(name: string): any;
  37498. /**
  37499. * Registers an action to this action manager
  37500. * @param action defines the action to be registered
  37501. * @return the action amended (prepared) after registration
  37502. */
  37503. abstract registerAction(action: IAction): Nullable<IAction>;
  37504. /**
  37505. * Unregisters an action to this action manager
  37506. * @param action defines the action to be unregistered
  37507. * @return a boolean indicating whether the action has been unregistered
  37508. */
  37509. abstract unregisterAction(action: IAction): Boolean;
  37510. /**
  37511. * Does exist one action manager with at least one trigger
  37512. **/
  37513. static get HasTriggers(): boolean;
  37514. /**
  37515. * Does exist one action manager with at least one pick trigger
  37516. **/
  37517. static get HasPickTriggers(): boolean;
  37518. /**
  37519. * Does exist one action manager that handles actions of a given trigger
  37520. * @param trigger defines the trigger to be tested
  37521. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37522. **/
  37523. static HasSpecificTrigger(trigger: number): boolean;
  37524. }
  37525. }
  37526. declare module "babylonjs/node" {
  37527. import { Scene } from "babylonjs/scene";
  37528. import { Nullable } from "babylonjs/types";
  37529. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37530. import { Engine } from "babylonjs/Engines/engine";
  37531. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37532. import { Observable } from "babylonjs/Misc/observable";
  37533. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37534. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37535. import { Animatable } from "babylonjs/Animations/animatable";
  37536. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37537. import { Animation } from "babylonjs/Animations/animation";
  37538. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37540. /**
  37541. * Defines how a node can be built from a string name.
  37542. */
  37543. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37544. /**
  37545. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37546. */
  37547. export class Node implements IBehaviorAware<Node> {
  37548. /** @hidden */
  37549. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37550. private static _NodeConstructors;
  37551. /**
  37552. * Add a new node constructor
  37553. * @param type defines the type name of the node to construct
  37554. * @param constructorFunc defines the constructor function
  37555. */
  37556. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37557. /**
  37558. * Returns a node constructor based on type name
  37559. * @param type defines the type name
  37560. * @param name defines the new node name
  37561. * @param scene defines the hosting scene
  37562. * @param options defines optional options to transmit to constructors
  37563. * @returns the new constructor or null
  37564. */
  37565. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37566. /**
  37567. * Gets or sets the name of the node
  37568. */
  37569. name: string;
  37570. /**
  37571. * Gets or sets the id of the node
  37572. */
  37573. id: string;
  37574. /**
  37575. * Gets or sets the unique id of the node
  37576. */
  37577. uniqueId: number;
  37578. /**
  37579. * Gets or sets a string used to store user defined state for the node
  37580. */
  37581. state: string;
  37582. /**
  37583. * Gets or sets an object used to store user defined information for the node
  37584. */
  37585. metadata: any;
  37586. /**
  37587. * For internal use only. Please do not use.
  37588. */
  37589. reservedDataStore: any;
  37590. /**
  37591. * List of inspectable custom properties (used by the Inspector)
  37592. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37593. */
  37594. inspectableCustomProperties: IInspectable[];
  37595. private _doNotSerialize;
  37596. /**
  37597. * Gets or sets a boolean used to define if the node must be serialized
  37598. */
  37599. get doNotSerialize(): boolean;
  37600. set doNotSerialize(value: boolean);
  37601. /** @hidden */
  37602. _isDisposed: boolean;
  37603. /**
  37604. * Gets a list of Animations associated with the node
  37605. */
  37606. animations: import("babylonjs/Animations/animation").Animation[];
  37607. protected _ranges: {
  37608. [name: string]: Nullable<AnimationRange>;
  37609. };
  37610. /**
  37611. * Callback raised when the node is ready to be used
  37612. */
  37613. onReady: Nullable<(node: Node) => void>;
  37614. private _isEnabled;
  37615. private _isParentEnabled;
  37616. private _isReady;
  37617. /** @hidden */
  37618. _currentRenderId: number;
  37619. private _parentUpdateId;
  37620. /** @hidden */
  37621. _childUpdateId: number;
  37622. /** @hidden */
  37623. _waitingParentId: Nullable<string>;
  37624. /** @hidden */
  37625. _scene: Scene;
  37626. /** @hidden */
  37627. _cache: any;
  37628. private _parentNode;
  37629. private _children;
  37630. /** @hidden */
  37631. _worldMatrix: Matrix;
  37632. /** @hidden */
  37633. _worldMatrixDeterminant: number;
  37634. /** @hidden */
  37635. _worldMatrixDeterminantIsDirty: boolean;
  37636. /** @hidden */
  37637. private _sceneRootNodesIndex;
  37638. /**
  37639. * Gets a boolean indicating if the node has been disposed
  37640. * @returns true if the node was disposed
  37641. */
  37642. isDisposed(): boolean;
  37643. /**
  37644. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37645. * @see https://doc.babylonjs.com/how_to/parenting
  37646. */
  37647. set parent(parent: Nullable<Node>);
  37648. get parent(): Nullable<Node>;
  37649. /** @hidden */
  37650. _addToSceneRootNodes(): void;
  37651. /** @hidden */
  37652. _removeFromSceneRootNodes(): void;
  37653. private _animationPropertiesOverride;
  37654. /**
  37655. * Gets or sets the animation properties override
  37656. */
  37657. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37658. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37659. /**
  37660. * Gets a string identifying the name of the class
  37661. * @returns "Node" string
  37662. */
  37663. getClassName(): string;
  37664. /** @hidden */
  37665. readonly _isNode: boolean;
  37666. /**
  37667. * An event triggered when the mesh is disposed
  37668. */
  37669. onDisposeObservable: Observable<Node>;
  37670. private _onDisposeObserver;
  37671. /**
  37672. * Sets a callback that will be raised when the node will be disposed
  37673. */
  37674. set onDispose(callback: () => void);
  37675. /**
  37676. * Creates a new Node
  37677. * @param name the name and id to be given to this node
  37678. * @param scene the scene this node will be added to
  37679. */
  37680. constructor(name: string, scene?: Nullable<Scene>);
  37681. /**
  37682. * Gets the scene of the node
  37683. * @returns a scene
  37684. */
  37685. getScene(): Scene;
  37686. /**
  37687. * Gets the engine of the node
  37688. * @returns a Engine
  37689. */
  37690. getEngine(): Engine;
  37691. private _behaviors;
  37692. /**
  37693. * Attach a behavior to the node
  37694. * @see https://doc.babylonjs.com/features/behaviour
  37695. * @param behavior defines the behavior to attach
  37696. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37697. * @returns the current Node
  37698. */
  37699. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37700. /**
  37701. * Remove an attached behavior
  37702. * @see https://doc.babylonjs.com/features/behaviour
  37703. * @param behavior defines the behavior to attach
  37704. * @returns the current Node
  37705. */
  37706. removeBehavior(behavior: Behavior<Node>): Node;
  37707. /**
  37708. * Gets the list of attached behaviors
  37709. * @see https://doc.babylonjs.com/features/behaviour
  37710. */
  37711. get behaviors(): Behavior<Node>[];
  37712. /**
  37713. * Gets an attached behavior by name
  37714. * @param name defines the name of the behavior to look for
  37715. * @see https://doc.babylonjs.com/features/behaviour
  37716. * @returns null if behavior was not found else the requested behavior
  37717. */
  37718. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37719. /**
  37720. * Returns the latest update of the World matrix
  37721. * @returns a Matrix
  37722. */
  37723. getWorldMatrix(): Matrix;
  37724. /** @hidden */
  37725. _getWorldMatrixDeterminant(): number;
  37726. /**
  37727. * Returns directly the latest state of the mesh World matrix.
  37728. * A Matrix is returned.
  37729. */
  37730. get worldMatrixFromCache(): Matrix;
  37731. /** @hidden */
  37732. _initCache(): void;
  37733. /** @hidden */
  37734. updateCache(force?: boolean): void;
  37735. /** @hidden */
  37736. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37737. /** @hidden */
  37738. _updateCache(ignoreParentClass?: boolean): void;
  37739. /** @hidden */
  37740. _isSynchronized(): boolean;
  37741. /** @hidden */
  37742. _markSyncedWithParent(): void;
  37743. /** @hidden */
  37744. isSynchronizedWithParent(): boolean;
  37745. /** @hidden */
  37746. isSynchronized(): boolean;
  37747. /**
  37748. * Is this node ready to be used/rendered
  37749. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37750. * @return true if the node is ready
  37751. */
  37752. isReady(completeCheck?: boolean): boolean;
  37753. /**
  37754. * Is this node enabled?
  37755. * 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
  37756. * @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
  37757. * @return whether this node (and its parent) is enabled
  37758. */
  37759. isEnabled(checkAncestors?: boolean): boolean;
  37760. /** @hidden */
  37761. protected _syncParentEnabledState(): void;
  37762. /**
  37763. * Set the enabled state of this node
  37764. * @param value defines the new enabled state
  37765. */
  37766. setEnabled(value: boolean): void;
  37767. /**
  37768. * Is this node a descendant of the given node?
  37769. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37770. * @param ancestor defines the parent node to inspect
  37771. * @returns a boolean indicating if this node is a descendant of the given node
  37772. */
  37773. isDescendantOf(ancestor: Node): boolean;
  37774. /** @hidden */
  37775. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37776. /**
  37777. * Will return all nodes that have this node as ascendant
  37778. * @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
  37779. * @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
  37780. * @return all children nodes of all types
  37781. */
  37782. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37783. /**
  37784. * Get all child-meshes of this node
  37785. * @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)
  37786. * @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
  37787. * @returns an array of AbstractMesh
  37788. */
  37789. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37790. /**
  37791. * Get all direct children of this node
  37792. * @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
  37793. * @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)
  37794. * @returns an array of Node
  37795. */
  37796. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37797. /** @hidden */
  37798. _setReady(state: boolean): void;
  37799. /**
  37800. * Get an animation by name
  37801. * @param name defines the name of the animation to look for
  37802. * @returns null if not found else the requested animation
  37803. */
  37804. getAnimationByName(name: string): Nullable<Animation>;
  37805. /**
  37806. * Creates an animation range for this node
  37807. * @param name defines the name of the range
  37808. * @param from defines the starting key
  37809. * @param to defines the end key
  37810. */
  37811. createAnimationRange(name: string, from: number, to: number): void;
  37812. /**
  37813. * Delete a specific animation range
  37814. * @param name defines the name of the range to delete
  37815. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37816. */
  37817. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37818. /**
  37819. * Get an animation range by name
  37820. * @param name defines the name of the animation range to look for
  37821. * @returns null if not found else the requested animation range
  37822. */
  37823. getAnimationRange(name: string): Nullable<AnimationRange>;
  37824. /**
  37825. * Gets the list of all animation ranges defined on this node
  37826. * @returns an array
  37827. */
  37828. getAnimationRanges(): Nullable<AnimationRange>[];
  37829. /**
  37830. * Will start the animation sequence
  37831. * @param name defines the range frames for animation sequence
  37832. * @param loop defines if the animation should loop (false by default)
  37833. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37834. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37835. * @returns the object created for this animation. If range does not exist, it will return null
  37836. */
  37837. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37838. /**
  37839. * Serialize animation ranges into a JSON compatible object
  37840. * @returns serialization object
  37841. */
  37842. serializeAnimationRanges(): any;
  37843. /**
  37844. * Computes the world matrix of the node
  37845. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37846. * @returns the world matrix
  37847. */
  37848. computeWorldMatrix(force?: boolean): Matrix;
  37849. /**
  37850. * Releases resources associated with this node.
  37851. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37852. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37853. */
  37854. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37855. /**
  37856. * Parse animation range data from a serialization object and store them into a given node
  37857. * @param node defines where to store the animation ranges
  37858. * @param parsedNode defines the serialization object to read data from
  37859. * @param scene defines the hosting scene
  37860. */
  37861. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37862. /**
  37863. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37864. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37865. * @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
  37866. * @returns the new bounding vectors
  37867. */
  37868. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37869. min: Vector3;
  37870. max: Vector3;
  37871. };
  37872. }
  37873. }
  37874. declare module "babylonjs/Animations/animation" {
  37875. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37876. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37877. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37878. import { Nullable } from "babylonjs/types";
  37879. import { Scene } from "babylonjs/scene";
  37880. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37881. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37882. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37883. import { Node } from "babylonjs/node";
  37884. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37885. import { Size } from "babylonjs/Maths/math.size";
  37886. import { Animatable } from "babylonjs/Animations/animatable";
  37887. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37888. /**
  37889. * @hidden
  37890. */
  37891. export class _IAnimationState {
  37892. key: number;
  37893. repeatCount: number;
  37894. workValue?: any;
  37895. loopMode?: number;
  37896. offsetValue?: any;
  37897. highLimitValue?: any;
  37898. }
  37899. /**
  37900. * Class used to store any kind of animation
  37901. */
  37902. export class Animation {
  37903. /**Name of the animation */
  37904. name: string;
  37905. /**Property to animate */
  37906. targetProperty: string;
  37907. /**The frames per second of the animation */
  37908. framePerSecond: number;
  37909. /**The data type of the animation */
  37910. dataType: number;
  37911. /**The loop mode of the animation */
  37912. loopMode?: number | undefined;
  37913. /**Specifies if blending should be enabled */
  37914. enableBlending?: boolean | undefined;
  37915. /**
  37916. * Use matrix interpolation instead of using direct key value when animating matrices
  37917. */
  37918. static AllowMatricesInterpolation: boolean;
  37919. /**
  37920. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37921. */
  37922. static AllowMatrixDecomposeForInterpolation: boolean;
  37923. /** Define the Url to load snippets */
  37924. static SnippetUrl: string;
  37925. /** Snippet ID if the animation was created from the snippet server */
  37926. snippetId: string;
  37927. /**
  37928. * Stores the key frames of the animation
  37929. */
  37930. private _keys;
  37931. /**
  37932. * Stores the easing function of the animation
  37933. */
  37934. private _easingFunction;
  37935. /**
  37936. * @hidden Internal use only
  37937. */
  37938. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37939. /**
  37940. * The set of event that will be linked to this animation
  37941. */
  37942. private _events;
  37943. /**
  37944. * Stores an array of target property paths
  37945. */
  37946. targetPropertyPath: string[];
  37947. /**
  37948. * Stores the blending speed of the animation
  37949. */
  37950. blendingSpeed: number;
  37951. /**
  37952. * Stores the animation ranges for the animation
  37953. */
  37954. private _ranges;
  37955. /**
  37956. * @hidden Internal use
  37957. */
  37958. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37959. /**
  37960. * Sets up an animation
  37961. * @param property The property to animate
  37962. * @param animationType The animation type to apply
  37963. * @param framePerSecond The frames per second of the animation
  37964. * @param easingFunction The easing function used in the animation
  37965. * @returns The created animation
  37966. */
  37967. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37968. /**
  37969. * Create and start an animation on a node
  37970. * @param name defines the name of the global animation that will be run on all nodes
  37971. * @param node defines the root node where the animation will take place
  37972. * @param targetProperty defines property to animate
  37973. * @param framePerSecond defines the number of frame per second yo use
  37974. * @param totalFrame defines the number of frames in total
  37975. * @param from defines the initial value
  37976. * @param to defines the final value
  37977. * @param loopMode defines which loop mode you want to use (off by default)
  37978. * @param easingFunction defines the easing function to use (linear by default)
  37979. * @param onAnimationEnd defines the callback to call when animation end
  37980. * @returns the animatable created for this animation
  37981. */
  37982. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37983. /**
  37984. * Create and start an animation on a node and its descendants
  37985. * @param name defines the name of the global animation that will be run on all nodes
  37986. * @param node defines the root node where the animation will take place
  37987. * @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
  37988. * @param targetProperty defines property to animate
  37989. * @param framePerSecond defines the number of frame per second to use
  37990. * @param totalFrame defines the number of frames in total
  37991. * @param from defines the initial value
  37992. * @param to defines the final value
  37993. * @param loopMode defines which loop mode you want to use (off by default)
  37994. * @param easingFunction defines the easing function to use (linear by default)
  37995. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37996. * @returns the list of animatables created for all nodes
  37997. * @example https://www.babylonjs-playground.com/#MH0VLI
  37998. */
  37999. 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[]>;
  38000. /**
  38001. * Creates a new animation, merges it with the existing animations and starts it
  38002. * @param name Name of the animation
  38003. * @param node Node which contains the scene that begins the animations
  38004. * @param targetProperty Specifies which property to animate
  38005. * @param framePerSecond The frames per second of the animation
  38006. * @param totalFrame The total number of frames
  38007. * @param from The frame at the beginning of the animation
  38008. * @param to The frame at the end of the animation
  38009. * @param loopMode Specifies the loop mode of the animation
  38010. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38011. * @param onAnimationEnd Callback to run once the animation is complete
  38012. * @returns Nullable animation
  38013. */
  38014. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38015. /**
  38016. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38017. * @param sourceAnimation defines the Animation containing keyframes to convert
  38018. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38019. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38020. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38021. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38022. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38023. */
  38024. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38025. /**
  38026. * Transition property of an host to the target Value
  38027. * @param property The property to transition
  38028. * @param targetValue The target Value of the property
  38029. * @param host The object where the property to animate belongs
  38030. * @param scene Scene used to run the animation
  38031. * @param frameRate Framerate (in frame/s) to use
  38032. * @param transition The transition type we want to use
  38033. * @param duration The duration of the animation, in milliseconds
  38034. * @param onAnimationEnd Callback trigger at the end of the animation
  38035. * @returns Nullable animation
  38036. */
  38037. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38038. /**
  38039. * Return the array of runtime animations currently using this animation
  38040. */
  38041. get runtimeAnimations(): RuntimeAnimation[];
  38042. /**
  38043. * Specifies if any of the runtime animations are currently running
  38044. */
  38045. get hasRunningRuntimeAnimations(): boolean;
  38046. /**
  38047. * Initializes the animation
  38048. * @param name Name of the animation
  38049. * @param targetProperty Property to animate
  38050. * @param framePerSecond The frames per second of the animation
  38051. * @param dataType The data type of the animation
  38052. * @param loopMode The loop mode of the animation
  38053. * @param enableBlending Specifies if blending should be enabled
  38054. */
  38055. constructor(
  38056. /**Name of the animation */
  38057. name: string,
  38058. /**Property to animate */
  38059. targetProperty: string,
  38060. /**The frames per second of the animation */
  38061. framePerSecond: number,
  38062. /**The data type of the animation */
  38063. dataType: number,
  38064. /**The loop mode of the animation */
  38065. loopMode?: number | undefined,
  38066. /**Specifies if blending should be enabled */
  38067. enableBlending?: boolean | undefined);
  38068. /**
  38069. * Converts the animation to a string
  38070. * @param fullDetails support for multiple levels of logging within scene loading
  38071. * @returns String form of the animation
  38072. */
  38073. toString(fullDetails?: boolean): string;
  38074. /**
  38075. * Add an event to this animation
  38076. * @param event Event to add
  38077. */
  38078. addEvent(event: AnimationEvent): void;
  38079. /**
  38080. * Remove all events found at the given frame
  38081. * @param frame The frame to remove events from
  38082. */
  38083. removeEvents(frame: number): void;
  38084. /**
  38085. * Retrieves all the events from the animation
  38086. * @returns Events from the animation
  38087. */
  38088. getEvents(): AnimationEvent[];
  38089. /**
  38090. * Creates an animation range
  38091. * @param name Name of the animation range
  38092. * @param from Starting frame of the animation range
  38093. * @param to Ending frame of the animation
  38094. */
  38095. createRange(name: string, from: number, to: number): void;
  38096. /**
  38097. * Deletes an animation range by name
  38098. * @param name Name of the animation range to delete
  38099. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38100. */
  38101. deleteRange(name: string, deleteFrames?: boolean): void;
  38102. /**
  38103. * Gets the animation range by name, or null if not defined
  38104. * @param name Name of the animation range
  38105. * @returns Nullable animation range
  38106. */
  38107. getRange(name: string): Nullable<AnimationRange>;
  38108. /**
  38109. * Gets the key frames from the animation
  38110. * @returns The key frames of the animation
  38111. */
  38112. getKeys(): Array<IAnimationKey>;
  38113. /**
  38114. * Gets the highest frame rate of the animation
  38115. * @returns Highest frame rate of the animation
  38116. */
  38117. getHighestFrame(): number;
  38118. /**
  38119. * Gets the easing function of the animation
  38120. * @returns Easing function of the animation
  38121. */
  38122. getEasingFunction(): IEasingFunction;
  38123. /**
  38124. * Sets the easing function of the animation
  38125. * @param easingFunction A custom mathematical formula for animation
  38126. */
  38127. setEasingFunction(easingFunction: EasingFunction): void;
  38128. /**
  38129. * Interpolates a scalar linearly
  38130. * @param startValue Start value of the animation curve
  38131. * @param endValue End value of the animation curve
  38132. * @param gradient Scalar amount to interpolate
  38133. * @returns Interpolated scalar value
  38134. */
  38135. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38136. /**
  38137. * Interpolates a scalar cubically
  38138. * @param startValue Start value of the animation curve
  38139. * @param outTangent End tangent of the animation
  38140. * @param endValue End value of the animation curve
  38141. * @param inTangent Start tangent of the animation curve
  38142. * @param gradient Scalar amount to interpolate
  38143. * @returns Interpolated scalar value
  38144. */
  38145. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38146. /**
  38147. * Interpolates a quaternion using a spherical linear interpolation
  38148. * @param startValue Start value of the animation curve
  38149. * @param endValue End value of the animation curve
  38150. * @param gradient Scalar amount to interpolate
  38151. * @returns Interpolated quaternion value
  38152. */
  38153. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38154. /**
  38155. * Interpolates a quaternion cubically
  38156. * @param startValue Start value of the animation curve
  38157. * @param outTangent End tangent of the animation curve
  38158. * @param endValue End value of the animation curve
  38159. * @param inTangent Start tangent of the animation curve
  38160. * @param gradient Scalar amount to interpolate
  38161. * @returns Interpolated quaternion value
  38162. */
  38163. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38164. /**
  38165. * Interpolates a Vector3 linearl
  38166. * @param startValue Start value of the animation curve
  38167. * @param endValue End value of the animation curve
  38168. * @param gradient Scalar amount to interpolate
  38169. * @returns Interpolated scalar value
  38170. */
  38171. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38172. /**
  38173. * Interpolates a Vector3 cubically
  38174. * @param startValue Start value of the animation curve
  38175. * @param outTangent End tangent of the animation
  38176. * @param endValue End value of the animation curve
  38177. * @param inTangent Start tangent of the animation curve
  38178. * @param gradient Scalar amount to interpolate
  38179. * @returns InterpolatedVector3 value
  38180. */
  38181. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38182. /**
  38183. * Interpolates a Vector2 linearly
  38184. * @param startValue Start value of the animation curve
  38185. * @param endValue End value of the animation curve
  38186. * @param gradient Scalar amount to interpolate
  38187. * @returns Interpolated Vector2 value
  38188. */
  38189. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38190. /**
  38191. * Interpolates a Vector2 cubically
  38192. * @param startValue Start value of the animation curve
  38193. * @param outTangent End tangent of the animation
  38194. * @param endValue End value of the animation curve
  38195. * @param inTangent Start tangent of the animation curve
  38196. * @param gradient Scalar amount to interpolate
  38197. * @returns Interpolated Vector2 value
  38198. */
  38199. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38200. /**
  38201. * Interpolates a size linearly
  38202. * @param startValue Start value of the animation curve
  38203. * @param endValue End value of the animation curve
  38204. * @param gradient Scalar amount to interpolate
  38205. * @returns Interpolated Size value
  38206. */
  38207. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38208. /**
  38209. * Interpolates a Color3 linearly
  38210. * @param startValue Start value of the animation curve
  38211. * @param endValue End value of the animation curve
  38212. * @param gradient Scalar amount to interpolate
  38213. * @returns Interpolated Color3 value
  38214. */
  38215. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38216. /**
  38217. * Interpolates a Color4 linearly
  38218. * @param startValue Start value of the animation curve
  38219. * @param endValue End value of the animation curve
  38220. * @param gradient Scalar amount to interpolate
  38221. * @returns Interpolated Color3 value
  38222. */
  38223. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38224. /**
  38225. * @hidden Internal use only
  38226. */
  38227. _getKeyValue(value: any): any;
  38228. /**
  38229. * @hidden Internal use only
  38230. */
  38231. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38232. /**
  38233. * Defines the function to use to interpolate matrices
  38234. * @param startValue defines the start matrix
  38235. * @param endValue defines the end matrix
  38236. * @param gradient defines the gradient between both matrices
  38237. * @param result defines an optional target matrix where to store the interpolation
  38238. * @returns the interpolated matrix
  38239. */
  38240. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38241. /**
  38242. * Makes a copy of the animation
  38243. * @returns Cloned animation
  38244. */
  38245. clone(): Animation;
  38246. /**
  38247. * Sets the key frames of the animation
  38248. * @param values The animation key frames to set
  38249. */
  38250. setKeys(values: Array<IAnimationKey>): void;
  38251. /**
  38252. * Serializes the animation to an object
  38253. * @returns Serialized object
  38254. */
  38255. serialize(): any;
  38256. /**
  38257. * Float animation type
  38258. */
  38259. static readonly ANIMATIONTYPE_FLOAT: number;
  38260. /**
  38261. * Vector3 animation type
  38262. */
  38263. static readonly ANIMATIONTYPE_VECTOR3: number;
  38264. /**
  38265. * Quaternion animation type
  38266. */
  38267. static readonly ANIMATIONTYPE_QUATERNION: number;
  38268. /**
  38269. * Matrix animation type
  38270. */
  38271. static readonly ANIMATIONTYPE_MATRIX: number;
  38272. /**
  38273. * Color3 animation type
  38274. */
  38275. static readonly ANIMATIONTYPE_COLOR3: number;
  38276. /**
  38277. * Color3 animation type
  38278. */
  38279. static readonly ANIMATIONTYPE_COLOR4: number;
  38280. /**
  38281. * Vector2 animation type
  38282. */
  38283. static readonly ANIMATIONTYPE_VECTOR2: number;
  38284. /**
  38285. * Size animation type
  38286. */
  38287. static readonly ANIMATIONTYPE_SIZE: number;
  38288. /**
  38289. * Relative Loop Mode
  38290. */
  38291. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38292. /**
  38293. * Cycle Loop Mode
  38294. */
  38295. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38296. /**
  38297. * Constant Loop Mode
  38298. */
  38299. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38300. /** @hidden */
  38301. static _UniversalLerp(left: any, right: any, amount: number): any;
  38302. /**
  38303. * Parses an animation object and creates an animation
  38304. * @param parsedAnimation Parsed animation object
  38305. * @returns Animation object
  38306. */
  38307. static Parse(parsedAnimation: any): Animation;
  38308. /**
  38309. * Appends the serialized animations from the source animations
  38310. * @param source Source containing the animations
  38311. * @param destination Target to store the animations
  38312. */
  38313. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38314. /**
  38315. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38316. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38317. * @param url defines the url to load from
  38318. * @returns a promise that will resolve to the new animation or an array of animations
  38319. */
  38320. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38321. /**
  38322. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38323. * @param snippetId defines the snippet to load
  38324. * @returns a promise that will resolve to the new animation or a new array of animations
  38325. */
  38326. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38327. }
  38328. }
  38329. declare module "babylonjs/Animations/animatable.interface" {
  38330. import { Nullable } from "babylonjs/types";
  38331. import { Animation } from "babylonjs/Animations/animation";
  38332. /**
  38333. * Interface containing an array of animations
  38334. */
  38335. export interface IAnimatable {
  38336. /**
  38337. * Array of animations
  38338. */
  38339. animations: Nullable<Array<Animation>>;
  38340. }
  38341. }
  38342. declare module "babylonjs/Misc/decorators" {
  38343. import { Nullable } from "babylonjs/types";
  38344. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38345. import { Scene } from "babylonjs/scene";
  38346. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38347. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38348. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38350. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38351. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38352. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38353. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38354. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38355. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38356. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38357. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38358. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38359. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38360. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38361. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38362. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38363. /**
  38364. * Decorator used to define property that can be serialized as reference to a camera
  38365. * @param sourceName defines the name of the property to decorate
  38366. */
  38367. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38368. /**
  38369. * Class used to help serialization objects
  38370. */
  38371. export class SerializationHelper {
  38372. /** @hidden */
  38373. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38374. /** @hidden */
  38375. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38376. /** @hidden */
  38377. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38378. /** @hidden */
  38379. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38380. /**
  38381. * Appends the serialized animations from the source animations
  38382. * @param source Source containing the animations
  38383. * @param destination Target to store the animations
  38384. */
  38385. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38386. /**
  38387. * Static function used to serialized a specific entity
  38388. * @param entity defines the entity to serialize
  38389. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38390. * @returns a JSON compatible object representing the serialization of the entity
  38391. */
  38392. static Serialize<T>(entity: T, serializationObject?: any): any;
  38393. /**
  38394. * Creates a new entity from a serialization data object
  38395. * @param creationFunction defines a function used to instanciated the new entity
  38396. * @param source defines the source serialization data
  38397. * @param scene defines the hosting scene
  38398. * @param rootUrl defines the root url for resources
  38399. * @returns a new entity
  38400. */
  38401. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38402. /**
  38403. * Clones an object
  38404. * @param creationFunction defines the function used to instanciate the new object
  38405. * @param source defines the source object
  38406. * @returns the cloned object
  38407. */
  38408. static Clone<T>(creationFunction: () => T, source: T): T;
  38409. /**
  38410. * Instanciates a new object based on a source one (some data will be shared between both object)
  38411. * @param creationFunction defines the function used to instanciate the new object
  38412. * @param source defines the source object
  38413. * @returns the new object
  38414. */
  38415. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38416. }
  38417. }
  38418. declare module "babylonjs/Materials/Textures/baseTexture" {
  38419. import { Observable } from "babylonjs/Misc/observable";
  38420. import { Nullable } from "babylonjs/types";
  38421. import { Scene } from "babylonjs/scene";
  38422. import { Matrix } from "babylonjs/Maths/math.vector";
  38423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38424. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38425. import { ISize } from "babylonjs/Maths/math.size";
  38426. import "babylonjs/Misc/fileTools";
  38427. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38428. /**
  38429. * Base class of all the textures in babylon.
  38430. * It groups all the common properties the materials, post process, lights... might need
  38431. * in order to make a correct use of the texture.
  38432. */
  38433. export class BaseTexture implements IAnimatable {
  38434. /**
  38435. * Default anisotropic filtering level for the application.
  38436. * It is set to 4 as a good tradeoff between perf and quality.
  38437. */
  38438. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38439. /**
  38440. * Gets or sets the unique id of the texture
  38441. */
  38442. uniqueId: number;
  38443. /**
  38444. * Define the name of the texture.
  38445. */
  38446. name: string;
  38447. /**
  38448. * Gets or sets an object used to store user defined information.
  38449. */
  38450. metadata: any;
  38451. /**
  38452. * For internal use only. Please do not use.
  38453. */
  38454. reservedDataStore: any;
  38455. private _hasAlpha;
  38456. /**
  38457. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38458. */
  38459. set hasAlpha(value: boolean);
  38460. get hasAlpha(): boolean;
  38461. /**
  38462. * Defines if the alpha value should be determined via the rgb values.
  38463. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38464. */
  38465. getAlphaFromRGB: boolean;
  38466. /**
  38467. * Intensity or strength of the texture.
  38468. * It is commonly used by materials to fine tune the intensity of the texture
  38469. */
  38470. level: number;
  38471. /**
  38472. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38473. * This is part of the texture as textures usually maps to one uv set.
  38474. */
  38475. coordinatesIndex: number;
  38476. protected _coordinatesMode: number;
  38477. /**
  38478. * How a texture is mapped.
  38479. *
  38480. * | Value | Type | Description |
  38481. * | ----- | ----------------------------------- | ----------- |
  38482. * | 0 | EXPLICIT_MODE | |
  38483. * | 1 | SPHERICAL_MODE | |
  38484. * | 2 | PLANAR_MODE | |
  38485. * | 3 | CUBIC_MODE | |
  38486. * | 4 | PROJECTION_MODE | |
  38487. * | 5 | SKYBOX_MODE | |
  38488. * | 6 | INVCUBIC_MODE | |
  38489. * | 7 | EQUIRECTANGULAR_MODE | |
  38490. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38491. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38492. */
  38493. set coordinatesMode(value: number);
  38494. get coordinatesMode(): number;
  38495. private _wrapU;
  38496. /**
  38497. * | Value | Type | Description |
  38498. * | ----- | ------------------ | ----------- |
  38499. * | 0 | CLAMP_ADDRESSMODE | |
  38500. * | 1 | WRAP_ADDRESSMODE | |
  38501. * | 2 | MIRROR_ADDRESSMODE | |
  38502. */
  38503. get wrapU(): number;
  38504. set wrapU(value: number);
  38505. private _wrapV;
  38506. /**
  38507. * | Value | Type | Description |
  38508. * | ----- | ------------------ | ----------- |
  38509. * | 0 | CLAMP_ADDRESSMODE | |
  38510. * | 1 | WRAP_ADDRESSMODE | |
  38511. * | 2 | MIRROR_ADDRESSMODE | |
  38512. */
  38513. get wrapV(): number;
  38514. set wrapV(value: number);
  38515. /**
  38516. * | Value | Type | Description |
  38517. * | ----- | ------------------ | ----------- |
  38518. * | 0 | CLAMP_ADDRESSMODE | |
  38519. * | 1 | WRAP_ADDRESSMODE | |
  38520. * | 2 | MIRROR_ADDRESSMODE | |
  38521. */
  38522. wrapR: number;
  38523. /**
  38524. * With compliant hardware and browser (supporting anisotropic filtering)
  38525. * this defines the level of anisotropic filtering in the texture.
  38526. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38527. */
  38528. anisotropicFilteringLevel: number;
  38529. /**
  38530. * Define if the texture is a cube texture or if false a 2d texture.
  38531. */
  38532. get isCube(): boolean;
  38533. set isCube(value: boolean);
  38534. /**
  38535. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38536. */
  38537. get is3D(): boolean;
  38538. set is3D(value: boolean);
  38539. /**
  38540. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38541. */
  38542. get is2DArray(): boolean;
  38543. set is2DArray(value: boolean);
  38544. private _gammaSpace;
  38545. /**
  38546. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38547. * HDR texture are usually stored in linear space.
  38548. * This only impacts the PBR and Background materials
  38549. */
  38550. get gammaSpace(): boolean;
  38551. set gammaSpace(gamma: boolean);
  38552. /**
  38553. * Gets or sets whether or not the texture contains RGBD data.
  38554. */
  38555. get isRGBD(): boolean;
  38556. set isRGBD(value: boolean);
  38557. /**
  38558. * Is Z inverted in the texture (useful in a cube texture).
  38559. */
  38560. invertZ: boolean;
  38561. /**
  38562. * Are mip maps generated for this texture or not.
  38563. */
  38564. get noMipmap(): boolean;
  38565. /**
  38566. * @hidden
  38567. */
  38568. lodLevelInAlpha: boolean;
  38569. /**
  38570. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38571. */
  38572. get lodGenerationOffset(): number;
  38573. set lodGenerationOffset(value: number);
  38574. /**
  38575. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38576. */
  38577. get lodGenerationScale(): number;
  38578. set lodGenerationScale(value: number);
  38579. /**
  38580. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38581. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38582. * average roughness values.
  38583. */
  38584. get linearSpecularLOD(): boolean;
  38585. set linearSpecularLOD(value: boolean);
  38586. /**
  38587. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38588. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38589. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38590. */
  38591. get irradianceTexture(): Nullable<BaseTexture>;
  38592. set irradianceTexture(value: Nullable<BaseTexture>);
  38593. /**
  38594. * Define if the texture is a render target.
  38595. */
  38596. isRenderTarget: boolean;
  38597. /**
  38598. * Define the unique id of the texture in the scene.
  38599. */
  38600. get uid(): string;
  38601. /** @hidden */
  38602. _prefiltered: boolean;
  38603. /**
  38604. * Return a string representation of the texture.
  38605. * @returns the texture as a string
  38606. */
  38607. toString(): string;
  38608. /**
  38609. * Get the class name of the texture.
  38610. * @returns "BaseTexture"
  38611. */
  38612. getClassName(): string;
  38613. /**
  38614. * Define the list of animation attached to the texture.
  38615. */
  38616. animations: import("babylonjs/Animations/animation").Animation[];
  38617. /**
  38618. * An event triggered when the texture is disposed.
  38619. */
  38620. onDisposeObservable: Observable<BaseTexture>;
  38621. private _onDisposeObserver;
  38622. /**
  38623. * Callback triggered when the texture has been disposed.
  38624. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38625. */
  38626. set onDispose(callback: () => void);
  38627. /**
  38628. * Define the current state of the loading sequence when in delayed load mode.
  38629. */
  38630. delayLoadState: number;
  38631. protected _scene: Nullable<Scene>;
  38632. protected _engine: Nullable<ThinEngine>;
  38633. /** @hidden */
  38634. _texture: Nullable<InternalTexture>;
  38635. private _uid;
  38636. /**
  38637. * Define if the texture is preventinga material to render or not.
  38638. * If not and the texture is not ready, the engine will use a default black texture instead.
  38639. */
  38640. get isBlocking(): boolean;
  38641. /**
  38642. * Instantiates a new BaseTexture.
  38643. * Base class of all the textures in babylon.
  38644. * It groups all the common properties the materials, post process, lights... might need
  38645. * in order to make a correct use of the texture.
  38646. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38647. */
  38648. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38649. /**
  38650. * Get the scene the texture belongs to.
  38651. * @returns the scene or null if undefined
  38652. */
  38653. getScene(): Nullable<Scene>;
  38654. /** @hidden */
  38655. protected _getEngine(): Nullable<ThinEngine>;
  38656. /**
  38657. * Checks if the texture has the same transform matrix than another texture
  38658. * @param texture texture to check against
  38659. * @returns true if the transforms are the same, else false
  38660. */
  38661. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  38662. /**
  38663. * Get the texture transform matrix used to offset tile the texture for istance.
  38664. * @returns the transformation matrix
  38665. */
  38666. getTextureMatrix(): Matrix;
  38667. /**
  38668. * Get the texture reflection matrix used to rotate/transform the reflection.
  38669. * @returns the reflection matrix
  38670. */
  38671. getReflectionTextureMatrix(): Matrix;
  38672. /**
  38673. * Get the underlying lower level texture from Babylon.
  38674. * @returns the insternal texture
  38675. */
  38676. getInternalTexture(): Nullable<InternalTexture>;
  38677. /**
  38678. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38679. * @returns true if ready or not blocking
  38680. */
  38681. isReadyOrNotBlocking(): boolean;
  38682. /**
  38683. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38684. * @returns true if fully ready
  38685. */
  38686. isReady(): boolean;
  38687. private _cachedSize;
  38688. /**
  38689. * Get the size of the texture.
  38690. * @returns the texture size.
  38691. */
  38692. getSize(): ISize;
  38693. /**
  38694. * Get the base size of the texture.
  38695. * It can be different from the size if the texture has been resized for POT for instance
  38696. * @returns the base size
  38697. */
  38698. getBaseSize(): ISize;
  38699. /**
  38700. * Update the sampling mode of the texture.
  38701. * Default is Trilinear mode.
  38702. *
  38703. * | Value | Type | Description |
  38704. * | ----- | ------------------ | ----------- |
  38705. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38706. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38707. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38708. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38709. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38710. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38711. * | 7 | NEAREST_LINEAR | |
  38712. * | 8 | NEAREST_NEAREST | |
  38713. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38714. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38715. * | 11 | LINEAR_LINEAR | |
  38716. * | 12 | LINEAR_NEAREST | |
  38717. *
  38718. * > _mag_: magnification filter (close to the viewer)
  38719. * > _min_: minification filter (far from the viewer)
  38720. * > _mip_: filter used between mip map levels
  38721. *@param samplingMode Define the new sampling mode of the texture
  38722. */
  38723. updateSamplingMode(samplingMode: number): void;
  38724. /**
  38725. * Scales the texture if is `canRescale()`
  38726. * @param ratio the resize factor we want to use to rescale
  38727. */
  38728. scale(ratio: number): void;
  38729. /**
  38730. * Get if the texture can rescale.
  38731. */
  38732. get canRescale(): boolean;
  38733. /** @hidden */
  38734. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  38735. /** @hidden */
  38736. _rebuild(): void;
  38737. /**
  38738. * Triggers the load sequence in delayed load mode.
  38739. */
  38740. delayLoad(): void;
  38741. /**
  38742. * Clones the texture.
  38743. * @returns the cloned texture
  38744. */
  38745. clone(): Nullable<BaseTexture>;
  38746. /**
  38747. * Get the texture underlying type (INT, FLOAT...)
  38748. */
  38749. get textureType(): number;
  38750. /**
  38751. * Get the texture underlying format (RGB, RGBA...)
  38752. */
  38753. get textureFormat(): number;
  38754. /**
  38755. * Indicates that textures need to be re-calculated for all materials
  38756. */
  38757. protected _markAllSubMeshesAsTexturesDirty(): void;
  38758. /**
  38759. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  38760. * This will returns an RGBA array buffer containing either in values (0-255) or
  38761. * float values (0-1) depending of the underlying buffer type.
  38762. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  38763. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  38764. * @param buffer defines a user defined buffer to fill with data (can be null)
  38765. * @returns The Array buffer containing the pixels data.
  38766. */
  38767. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  38768. /**
  38769. * Release and destroy the underlying lower level texture aka internalTexture.
  38770. */
  38771. releaseInternalTexture(): void;
  38772. /** @hidden */
  38773. get _lodTextureHigh(): Nullable<BaseTexture>;
  38774. /** @hidden */
  38775. get _lodTextureMid(): Nullable<BaseTexture>;
  38776. /** @hidden */
  38777. get _lodTextureLow(): Nullable<BaseTexture>;
  38778. /**
  38779. * Dispose the texture and release its associated resources.
  38780. */
  38781. dispose(): void;
  38782. /**
  38783. * Serialize the texture into a JSON representation that can be parsed later on.
  38784. * @returns the JSON representation of the texture
  38785. */
  38786. serialize(): any;
  38787. /**
  38788. * Helper function to be called back once a list of texture contains only ready textures.
  38789. * @param textures Define the list of textures to wait for
  38790. * @param callback Define the callback triggered once the entire list will be ready
  38791. */
  38792. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  38793. private static _isScene;
  38794. }
  38795. }
  38796. declare module "babylonjs/Materials/effect" {
  38797. import { Observable } from "babylonjs/Misc/observable";
  38798. import { Nullable } from "babylonjs/types";
  38799. import { IDisposable } from "babylonjs/scene";
  38800. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38801. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38802. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  38803. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38804. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  38805. import { Engine } from "babylonjs/Engines/engine";
  38806. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38807. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38808. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38809. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38810. /**
  38811. * Options to be used when creating an effect.
  38812. */
  38813. export interface IEffectCreationOptions {
  38814. /**
  38815. * Atrributes that will be used in the shader.
  38816. */
  38817. attributes: string[];
  38818. /**
  38819. * Uniform varible names that will be set in the shader.
  38820. */
  38821. uniformsNames: string[];
  38822. /**
  38823. * Uniform buffer variable names that will be set in the shader.
  38824. */
  38825. uniformBuffersNames: string[];
  38826. /**
  38827. * Sampler texture variable names that will be set in the shader.
  38828. */
  38829. samplers: string[];
  38830. /**
  38831. * Define statements that will be set in the shader.
  38832. */
  38833. defines: any;
  38834. /**
  38835. * Possible fallbacks for this effect to improve performance when needed.
  38836. */
  38837. fallbacks: Nullable<IEffectFallbacks>;
  38838. /**
  38839. * Callback that will be called when the shader is compiled.
  38840. */
  38841. onCompiled: Nullable<(effect: Effect) => void>;
  38842. /**
  38843. * Callback that will be called if an error occurs during shader compilation.
  38844. */
  38845. onError: Nullable<(effect: Effect, errors: string) => void>;
  38846. /**
  38847. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38848. */
  38849. indexParameters?: any;
  38850. /**
  38851. * Max number of lights that can be used in the shader.
  38852. */
  38853. maxSimultaneousLights?: number;
  38854. /**
  38855. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38856. */
  38857. transformFeedbackVaryings?: Nullable<string[]>;
  38858. /**
  38859. * 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
  38860. */
  38861. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38862. /**
  38863. * Is this effect rendering to several color attachments ?
  38864. */
  38865. multiTarget?: boolean;
  38866. }
  38867. /**
  38868. * Effect containing vertex and fragment shader that can be executed on an object.
  38869. */
  38870. export class Effect implements IDisposable {
  38871. /**
  38872. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38873. */
  38874. static ShadersRepository: string;
  38875. /**
  38876. * Enable logging of the shader code when a compilation error occurs
  38877. */
  38878. static LogShaderCodeOnCompilationError: boolean;
  38879. /**
  38880. * Name of the effect.
  38881. */
  38882. name: any;
  38883. /**
  38884. * String container all the define statements that should be set on the shader.
  38885. */
  38886. defines: string;
  38887. /**
  38888. * Callback that will be called when the shader is compiled.
  38889. */
  38890. onCompiled: Nullable<(effect: Effect) => void>;
  38891. /**
  38892. * Callback that will be called if an error occurs during shader compilation.
  38893. */
  38894. onError: Nullable<(effect: Effect, errors: string) => void>;
  38895. /**
  38896. * Callback that will be called when effect is bound.
  38897. */
  38898. onBind: Nullable<(effect: Effect) => void>;
  38899. /**
  38900. * Unique ID of the effect.
  38901. */
  38902. uniqueId: number;
  38903. /**
  38904. * Observable that will be called when the shader is compiled.
  38905. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38906. */
  38907. onCompileObservable: Observable<Effect>;
  38908. /**
  38909. * Observable that will be called if an error occurs during shader compilation.
  38910. */
  38911. onErrorObservable: Observable<Effect>;
  38912. /** @hidden */
  38913. _onBindObservable: Nullable<Observable<Effect>>;
  38914. /**
  38915. * @hidden
  38916. * Specifies if the effect was previously ready
  38917. */
  38918. _wasPreviouslyReady: boolean;
  38919. /**
  38920. * Observable that will be called when effect is bound.
  38921. */
  38922. get onBindObservable(): Observable<Effect>;
  38923. /** @hidden */
  38924. _bonesComputationForcedToCPU: boolean;
  38925. /** @hidden */
  38926. _multiTarget: boolean;
  38927. private static _uniqueIdSeed;
  38928. private _engine;
  38929. private _uniformBuffersNames;
  38930. private _uniformBuffersNamesList;
  38931. private _uniformsNames;
  38932. private _samplerList;
  38933. private _samplers;
  38934. private _isReady;
  38935. private _compilationError;
  38936. private _allFallbacksProcessed;
  38937. private _attributesNames;
  38938. private _attributes;
  38939. private _attributeLocationByName;
  38940. private _uniforms;
  38941. /**
  38942. * Key for the effect.
  38943. * @hidden
  38944. */
  38945. _key: string;
  38946. private _indexParameters;
  38947. private _fallbacks;
  38948. private _vertexSourceCode;
  38949. private _fragmentSourceCode;
  38950. private _vertexSourceCodeOverride;
  38951. private _fragmentSourceCodeOverride;
  38952. private _transformFeedbackVaryings;
  38953. /**
  38954. * Compiled shader to webGL program.
  38955. * @hidden
  38956. */
  38957. _pipelineContext: Nullable<IPipelineContext>;
  38958. private _valueCache;
  38959. private static _baseCache;
  38960. /**
  38961. * Instantiates an effect.
  38962. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38963. * @param baseName Name of the effect.
  38964. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38965. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38966. * @param samplers List of sampler variables that will be passed to the shader.
  38967. * @param engine Engine to be used to render the effect
  38968. * @param defines Define statements to be added to the shader.
  38969. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38970. * @param onCompiled Callback that will be called when the shader is compiled.
  38971. * @param onError Callback that will be called if an error occurs during shader compilation.
  38972. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38973. */
  38974. 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);
  38975. private _useFinalCode;
  38976. /**
  38977. * Unique key for this effect
  38978. */
  38979. get key(): string;
  38980. /**
  38981. * If the effect has been compiled and prepared.
  38982. * @returns if the effect is compiled and prepared.
  38983. */
  38984. isReady(): boolean;
  38985. private _isReadyInternal;
  38986. /**
  38987. * The engine the effect was initialized with.
  38988. * @returns the engine.
  38989. */
  38990. getEngine(): Engine;
  38991. /**
  38992. * The pipeline context for this effect
  38993. * @returns the associated pipeline context
  38994. */
  38995. getPipelineContext(): Nullable<IPipelineContext>;
  38996. /**
  38997. * The set of names of attribute variables for the shader.
  38998. * @returns An array of attribute names.
  38999. */
  39000. getAttributesNames(): string[];
  39001. /**
  39002. * Returns the attribute at the given index.
  39003. * @param index The index of the attribute.
  39004. * @returns The location of the attribute.
  39005. */
  39006. getAttributeLocation(index: number): number;
  39007. /**
  39008. * Returns the attribute based on the name of the variable.
  39009. * @param name of the attribute to look up.
  39010. * @returns the attribute location.
  39011. */
  39012. getAttributeLocationByName(name: string): number;
  39013. /**
  39014. * The number of attributes.
  39015. * @returns the numnber of attributes.
  39016. */
  39017. getAttributesCount(): number;
  39018. /**
  39019. * Gets the index of a uniform variable.
  39020. * @param uniformName of the uniform to look up.
  39021. * @returns the index.
  39022. */
  39023. getUniformIndex(uniformName: string): number;
  39024. /**
  39025. * Returns the attribute based on the name of the variable.
  39026. * @param uniformName of the uniform to look up.
  39027. * @returns the location of the uniform.
  39028. */
  39029. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39030. /**
  39031. * Returns an array of sampler variable names
  39032. * @returns The array of sampler variable names.
  39033. */
  39034. getSamplers(): string[];
  39035. /**
  39036. * Returns an array of uniform variable names
  39037. * @returns The array of uniform variable names.
  39038. */
  39039. getUniformNames(): string[];
  39040. /**
  39041. * Returns an array of uniform buffer variable names
  39042. * @returns The array of uniform buffer variable names.
  39043. */
  39044. getUniformBuffersNames(): string[];
  39045. /**
  39046. * Returns the index parameters used to create the effect
  39047. * @returns The index parameters object
  39048. */
  39049. getIndexParameters(): any;
  39050. /**
  39051. * The error from the last compilation.
  39052. * @returns the error string.
  39053. */
  39054. getCompilationError(): string;
  39055. /**
  39056. * Gets a boolean indicating that all fallbacks were used during compilation
  39057. * @returns true if all fallbacks were used
  39058. */
  39059. allFallbacksProcessed(): boolean;
  39060. /**
  39061. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39062. * @param func The callback to be used.
  39063. */
  39064. executeWhenCompiled(func: (effect: Effect) => void): void;
  39065. private _checkIsReady;
  39066. private _loadShader;
  39067. /**
  39068. * Gets the vertex shader source code of this effect
  39069. */
  39070. get vertexSourceCode(): string;
  39071. /**
  39072. * Gets the fragment shader source code of this effect
  39073. */
  39074. get fragmentSourceCode(): string;
  39075. /**
  39076. * Recompiles the webGL program
  39077. * @param vertexSourceCode The source code for the vertex shader.
  39078. * @param fragmentSourceCode The source code for the fragment shader.
  39079. * @param onCompiled Callback called when completed.
  39080. * @param onError Callback called on error.
  39081. * @hidden
  39082. */
  39083. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39084. /**
  39085. * Prepares the effect
  39086. * @hidden
  39087. */
  39088. _prepareEffect(): void;
  39089. private _getShaderCodeAndErrorLine;
  39090. private _processCompilationErrors;
  39091. /**
  39092. * Checks if the effect is supported. (Must be called after compilation)
  39093. */
  39094. get isSupported(): boolean;
  39095. /**
  39096. * Binds a texture to the engine to be used as output of the shader.
  39097. * @param channel Name of the output variable.
  39098. * @param texture Texture to bind.
  39099. * @hidden
  39100. */
  39101. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39102. /**
  39103. * Sets a texture on the engine to be used in the shader.
  39104. * @param channel Name of the sampler variable.
  39105. * @param texture Texture to set.
  39106. */
  39107. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39108. /**
  39109. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39110. * @param channel Name of the sampler variable.
  39111. * @param texture Texture to set.
  39112. */
  39113. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39114. /**
  39115. * Sets an array of textures on the engine to be used in the shader.
  39116. * @param channel Name of the variable.
  39117. * @param textures Textures to set.
  39118. */
  39119. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39120. /**
  39121. * 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)
  39122. * @param channel Name of the sampler variable.
  39123. * @param postProcess Post process to get the input texture from.
  39124. */
  39125. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39126. /**
  39127. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39128. * 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)
  39129. * @param channel Name of the sampler variable.
  39130. * @param postProcess Post process to get the output texture from.
  39131. */
  39132. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39133. /** @hidden */
  39134. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39135. /** @hidden */
  39136. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39137. /** @hidden */
  39138. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39139. /** @hidden */
  39140. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39141. /**
  39142. * Binds a buffer to a uniform.
  39143. * @param buffer Buffer to bind.
  39144. * @param name Name of the uniform variable to bind to.
  39145. */
  39146. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39147. /**
  39148. * Binds block to a uniform.
  39149. * @param blockName Name of the block to bind.
  39150. * @param index Index to bind.
  39151. */
  39152. bindUniformBlock(blockName: string, index: number): void;
  39153. /**
  39154. * Sets an interger value on a uniform variable.
  39155. * @param uniformName Name of the variable.
  39156. * @param value Value to be set.
  39157. * @returns this effect.
  39158. */
  39159. setInt(uniformName: string, value: number): Effect;
  39160. /**
  39161. * Sets an int array on a uniform variable.
  39162. * @param uniformName Name of the variable.
  39163. * @param array array to be set.
  39164. * @returns this effect.
  39165. */
  39166. setIntArray(uniformName: string, array: Int32Array): Effect;
  39167. /**
  39168. * 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)
  39169. * @param uniformName Name of the variable.
  39170. * @param array array to be set.
  39171. * @returns this effect.
  39172. */
  39173. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39174. /**
  39175. * 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)
  39176. * @param uniformName Name of the variable.
  39177. * @param array array to be set.
  39178. * @returns this effect.
  39179. */
  39180. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39181. /**
  39182. * 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)
  39183. * @param uniformName Name of the variable.
  39184. * @param array array to be set.
  39185. * @returns this effect.
  39186. */
  39187. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39188. /**
  39189. * Sets an float array on a uniform variable.
  39190. * @param uniformName Name of the variable.
  39191. * @param array array to be set.
  39192. * @returns this effect.
  39193. */
  39194. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39195. /**
  39196. * 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)
  39197. * @param uniformName Name of the variable.
  39198. * @param array array to be set.
  39199. * @returns this effect.
  39200. */
  39201. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39202. /**
  39203. * 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)
  39204. * @param uniformName Name of the variable.
  39205. * @param array array to be set.
  39206. * @returns this effect.
  39207. */
  39208. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39209. /**
  39210. * 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)
  39211. * @param uniformName Name of the variable.
  39212. * @param array array to be set.
  39213. * @returns this effect.
  39214. */
  39215. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39216. /**
  39217. * Sets an array on a uniform variable.
  39218. * @param uniformName Name of the variable.
  39219. * @param array array to be set.
  39220. * @returns this effect.
  39221. */
  39222. setArray(uniformName: string, array: number[]): Effect;
  39223. /**
  39224. * 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)
  39225. * @param uniformName Name of the variable.
  39226. * @param array array to be set.
  39227. * @returns this effect.
  39228. */
  39229. setArray2(uniformName: string, array: number[]): Effect;
  39230. /**
  39231. * 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)
  39232. * @param uniformName Name of the variable.
  39233. * @param array array to be set.
  39234. * @returns this effect.
  39235. */
  39236. setArray3(uniformName: string, array: number[]): Effect;
  39237. /**
  39238. * 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)
  39239. * @param uniformName Name of the variable.
  39240. * @param array array to be set.
  39241. * @returns this effect.
  39242. */
  39243. setArray4(uniformName: string, array: number[]): Effect;
  39244. /**
  39245. * Sets matrices on a uniform variable.
  39246. * @param uniformName Name of the variable.
  39247. * @param matrices matrices to be set.
  39248. * @returns this effect.
  39249. */
  39250. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39251. /**
  39252. * Sets matrix on a uniform variable.
  39253. * @param uniformName Name of the variable.
  39254. * @param matrix matrix to be set.
  39255. * @returns this effect.
  39256. */
  39257. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39258. /**
  39259. * 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)
  39260. * @param uniformName Name of the variable.
  39261. * @param matrix matrix to be set.
  39262. * @returns this effect.
  39263. */
  39264. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39265. /**
  39266. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39267. * @param uniformName Name of the variable.
  39268. * @param matrix matrix to be set.
  39269. * @returns this effect.
  39270. */
  39271. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39272. /**
  39273. * Sets a float on a uniform variable.
  39274. * @param uniformName Name of the variable.
  39275. * @param value value to be set.
  39276. * @returns this effect.
  39277. */
  39278. setFloat(uniformName: string, value: number): Effect;
  39279. /**
  39280. * Sets a boolean on a uniform variable.
  39281. * @param uniformName Name of the variable.
  39282. * @param bool value to be set.
  39283. * @returns this effect.
  39284. */
  39285. setBool(uniformName: string, bool: boolean): Effect;
  39286. /**
  39287. * Sets a Vector2 on a uniform variable.
  39288. * @param uniformName Name of the variable.
  39289. * @param vector2 vector2 to be set.
  39290. * @returns this effect.
  39291. */
  39292. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39293. /**
  39294. * Sets a float2 on a uniform variable.
  39295. * @param uniformName Name of the variable.
  39296. * @param x First float in float2.
  39297. * @param y Second float in float2.
  39298. * @returns this effect.
  39299. */
  39300. setFloat2(uniformName: string, x: number, y: number): Effect;
  39301. /**
  39302. * Sets a Vector3 on a uniform variable.
  39303. * @param uniformName Name of the variable.
  39304. * @param vector3 Value to be set.
  39305. * @returns this effect.
  39306. */
  39307. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39308. /**
  39309. * Sets a float3 on a uniform variable.
  39310. * @param uniformName Name of the variable.
  39311. * @param x First float in float3.
  39312. * @param y Second float in float3.
  39313. * @param z Third float in float3.
  39314. * @returns this effect.
  39315. */
  39316. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39317. /**
  39318. * Sets a Vector4 on a uniform variable.
  39319. * @param uniformName Name of the variable.
  39320. * @param vector4 Value to be set.
  39321. * @returns this effect.
  39322. */
  39323. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39324. /**
  39325. * Sets a float4 on a uniform variable.
  39326. * @param uniformName Name of the variable.
  39327. * @param x First float in float4.
  39328. * @param y Second float in float4.
  39329. * @param z Third float in float4.
  39330. * @param w Fourth float in float4.
  39331. * @returns this effect.
  39332. */
  39333. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39334. /**
  39335. * Sets a Color3 on a uniform variable.
  39336. * @param uniformName Name of the variable.
  39337. * @param color3 Value to be set.
  39338. * @returns this effect.
  39339. */
  39340. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39341. /**
  39342. * Sets a Color4 on a uniform variable.
  39343. * @param uniformName Name of the variable.
  39344. * @param color3 Value to be set.
  39345. * @param alpha Alpha value to be set.
  39346. * @returns this effect.
  39347. */
  39348. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39349. /**
  39350. * Sets a Color4 on a uniform variable
  39351. * @param uniformName defines the name of the variable
  39352. * @param color4 defines the value to be set
  39353. * @returns this effect.
  39354. */
  39355. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39356. /** Release all associated resources */
  39357. dispose(): void;
  39358. /**
  39359. * This function will add a new shader to the shader store
  39360. * @param name the name of the shader
  39361. * @param pixelShader optional pixel shader content
  39362. * @param vertexShader optional vertex shader content
  39363. */
  39364. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39365. /**
  39366. * Store of each shader (The can be looked up using effect.key)
  39367. */
  39368. static ShadersStore: {
  39369. [key: string]: string;
  39370. };
  39371. /**
  39372. * Store of each included file for a shader (The can be looked up using effect.key)
  39373. */
  39374. static IncludesShadersStore: {
  39375. [key: string]: string;
  39376. };
  39377. /**
  39378. * Resets the cache of effects.
  39379. */
  39380. static ResetCache(): void;
  39381. }
  39382. }
  39383. declare module "babylonjs/Engines/engineCapabilities" {
  39384. /**
  39385. * Interface used to describe the capabilities of the engine relatively to the current browser
  39386. */
  39387. export interface EngineCapabilities {
  39388. /** Maximum textures units per fragment shader */
  39389. maxTexturesImageUnits: number;
  39390. /** Maximum texture units per vertex shader */
  39391. maxVertexTextureImageUnits: number;
  39392. /** Maximum textures units in the entire pipeline */
  39393. maxCombinedTexturesImageUnits: number;
  39394. /** Maximum texture size */
  39395. maxTextureSize: number;
  39396. /** Maximum texture samples */
  39397. maxSamples?: number;
  39398. /** Maximum cube texture size */
  39399. maxCubemapTextureSize: number;
  39400. /** Maximum render texture size */
  39401. maxRenderTextureSize: number;
  39402. /** Maximum number of vertex attributes */
  39403. maxVertexAttribs: number;
  39404. /** Maximum number of varyings */
  39405. maxVaryingVectors: number;
  39406. /** Maximum number of uniforms per vertex shader */
  39407. maxVertexUniformVectors: number;
  39408. /** Maximum number of uniforms per fragment shader */
  39409. maxFragmentUniformVectors: number;
  39410. /** Defines if standard derivates (dx/dy) are supported */
  39411. standardDerivatives: boolean;
  39412. /** Defines if s3tc texture compression is supported */
  39413. s3tc?: WEBGL_compressed_texture_s3tc;
  39414. /** Defines if pvrtc texture compression is supported */
  39415. pvrtc: any;
  39416. /** Defines if etc1 texture compression is supported */
  39417. etc1: any;
  39418. /** Defines if etc2 texture compression is supported */
  39419. etc2: any;
  39420. /** Defines if astc texture compression is supported */
  39421. astc: any;
  39422. /** Defines if bptc texture compression is supported */
  39423. bptc: any;
  39424. /** Defines if float textures are supported */
  39425. textureFloat: boolean;
  39426. /** Defines if vertex array objects are supported */
  39427. vertexArrayObject: boolean;
  39428. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39429. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39430. /** Gets the maximum level of anisotropy supported */
  39431. maxAnisotropy: number;
  39432. /** Defines if instancing is supported */
  39433. instancedArrays: boolean;
  39434. /** Defines if 32 bits indices are supported */
  39435. uintIndices: boolean;
  39436. /** Defines if high precision shaders are supported */
  39437. highPrecisionShaderSupported: boolean;
  39438. /** Defines if depth reading in the fragment shader is supported */
  39439. fragmentDepthSupported: boolean;
  39440. /** Defines if float texture linear filtering is supported*/
  39441. textureFloatLinearFiltering: boolean;
  39442. /** Defines if rendering to float textures is supported */
  39443. textureFloatRender: boolean;
  39444. /** Defines if half float textures are supported*/
  39445. textureHalfFloat: boolean;
  39446. /** Defines if half float texture linear filtering is supported*/
  39447. textureHalfFloatLinearFiltering: boolean;
  39448. /** Defines if rendering to half float textures is supported */
  39449. textureHalfFloatRender: boolean;
  39450. /** Defines if textureLOD shader command is supported */
  39451. textureLOD: boolean;
  39452. /** Defines if draw buffers extension is supported */
  39453. drawBuffersExtension: boolean;
  39454. /** Defines if depth textures are supported */
  39455. depthTextureExtension: boolean;
  39456. /** Defines if float color buffer are supported */
  39457. colorBufferFloat: boolean;
  39458. /** Gets disjoint timer query extension (null if not supported) */
  39459. timerQuery?: EXT_disjoint_timer_query;
  39460. /** Defines if timestamp can be used with timer query */
  39461. canUseTimestampForTimerQuery: boolean;
  39462. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39463. multiview?: any;
  39464. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39465. oculusMultiview?: any;
  39466. /** Function used to let the system compiles shaders in background */
  39467. parallelShaderCompile?: {
  39468. COMPLETION_STATUS_KHR: number;
  39469. };
  39470. /** Max number of texture samples for MSAA */
  39471. maxMSAASamples: number;
  39472. /** Defines if the blend min max extension is supported */
  39473. blendMinMax: boolean;
  39474. }
  39475. }
  39476. declare module "babylonjs/States/depthCullingState" {
  39477. import { Nullable } from "babylonjs/types";
  39478. /**
  39479. * @hidden
  39480. **/
  39481. export class DepthCullingState {
  39482. private _isDepthTestDirty;
  39483. private _isDepthMaskDirty;
  39484. private _isDepthFuncDirty;
  39485. private _isCullFaceDirty;
  39486. private _isCullDirty;
  39487. private _isZOffsetDirty;
  39488. private _isFrontFaceDirty;
  39489. private _depthTest;
  39490. private _depthMask;
  39491. private _depthFunc;
  39492. private _cull;
  39493. private _cullFace;
  39494. private _zOffset;
  39495. private _frontFace;
  39496. /**
  39497. * Initializes the state.
  39498. */
  39499. constructor();
  39500. get isDirty(): boolean;
  39501. get zOffset(): number;
  39502. set zOffset(value: number);
  39503. get cullFace(): Nullable<number>;
  39504. set cullFace(value: Nullable<number>);
  39505. get cull(): Nullable<boolean>;
  39506. set cull(value: Nullable<boolean>);
  39507. get depthFunc(): Nullable<number>;
  39508. set depthFunc(value: Nullable<number>);
  39509. get depthMask(): boolean;
  39510. set depthMask(value: boolean);
  39511. get depthTest(): boolean;
  39512. set depthTest(value: boolean);
  39513. get frontFace(): Nullable<number>;
  39514. set frontFace(value: Nullable<number>);
  39515. reset(): void;
  39516. apply(gl: WebGLRenderingContext): void;
  39517. }
  39518. }
  39519. declare module "babylonjs/States/stencilState" {
  39520. /**
  39521. * @hidden
  39522. **/
  39523. export class StencilState {
  39524. /** 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 */
  39525. static readonly ALWAYS: number;
  39526. /** Passed to stencilOperation to specify that stencil value must be kept */
  39527. static readonly KEEP: number;
  39528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39529. static readonly REPLACE: number;
  39530. private _isStencilTestDirty;
  39531. private _isStencilMaskDirty;
  39532. private _isStencilFuncDirty;
  39533. private _isStencilOpDirty;
  39534. private _stencilTest;
  39535. private _stencilMask;
  39536. private _stencilFunc;
  39537. private _stencilFuncRef;
  39538. private _stencilFuncMask;
  39539. private _stencilOpStencilFail;
  39540. private _stencilOpDepthFail;
  39541. private _stencilOpStencilDepthPass;
  39542. get isDirty(): boolean;
  39543. get stencilFunc(): number;
  39544. set stencilFunc(value: number);
  39545. get stencilFuncRef(): number;
  39546. set stencilFuncRef(value: number);
  39547. get stencilFuncMask(): number;
  39548. set stencilFuncMask(value: number);
  39549. get stencilOpStencilFail(): number;
  39550. set stencilOpStencilFail(value: number);
  39551. get stencilOpDepthFail(): number;
  39552. set stencilOpDepthFail(value: number);
  39553. get stencilOpStencilDepthPass(): number;
  39554. set stencilOpStencilDepthPass(value: number);
  39555. get stencilMask(): number;
  39556. set stencilMask(value: number);
  39557. get stencilTest(): boolean;
  39558. set stencilTest(value: boolean);
  39559. constructor();
  39560. reset(): void;
  39561. apply(gl: WebGLRenderingContext): void;
  39562. }
  39563. }
  39564. declare module "babylonjs/States/alphaCullingState" {
  39565. /**
  39566. * @hidden
  39567. **/
  39568. export class AlphaState {
  39569. private _isAlphaBlendDirty;
  39570. private _isBlendFunctionParametersDirty;
  39571. private _isBlendEquationParametersDirty;
  39572. private _isBlendConstantsDirty;
  39573. private _alphaBlend;
  39574. private _blendFunctionParameters;
  39575. private _blendEquationParameters;
  39576. private _blendConstants;
  39577. /**
  39578. * Initializes the state.
  39579. */
  39580. constructor();
  39581. get isDirty(): boolean;
  39582. get alphaBlend(): boolean;
  39583. set alphaBlend(value: boolean);
  39584. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39585. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39586. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39587. reset(): void;
  39588. apply(gl: WebGLRenderingContext): void;
  39589. }
  39590. }
  39591. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39592. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39593. /** @hidden */
  39594. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39595. attributeProcessor(attribute: string): string;
  39596. varyingProcessor(varying: string, isFragment: boolean): string;
  39597. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39598. }
  39599. }
  39600. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39601. /**
  39602. * Interface for attribute information associated with buffer instanciation
  39603. */
  39604. export interface InstancingAttributeInfo {
  39605. /**
  39606. * Name of the GLSL attribute
  39607. * if attribute index is not specified, this is used to retrieve the index from the effect
  39608. */
  39609. attributeName: string;
  39610. /**
  39611. * Index/offset of the attribute in the vertex shader
  39612. * if not specified, this will be computes from the name.
  39613. */
  39614. index?: number;
  39615. /**
  39616. * size of the attribute, 1, 2, 3 or 4
  39617. */
  39618. attributeSize: number;
  39619. /**
  39620. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39621. */
  39622. offset: number;
  39623. /**
  39624. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39625. * default to 1
  39626. */
  39627. divisor?: number;
  39628. /**
  39629. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39630. * default is FLOAT
  39631. */
  39632. attributeType?: number;
  39633. /**
  39634. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39635. */
  39636. normalized?: boolean;
  39637. }
  39638. }
  39639. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39640. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39641. import { Nullable } from "babylonjs/types";
  39642. module "babylonjs/Engines/thinEngine" {
  39643. interface ThinEngine {
  39644. /**
  39645. * Update a video texture
  39646. * @param texture defines the texture to update
  39647. * @param video defines the video element to use
  39648. * @param invertY defines if data must be stored with Y axis inverted
  39649. */
  39650. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39651. }
  39652. }
  39653. }
  39654. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39655. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39656. import { Nullable } from "babylonjs/types";
  39657. module "babylonjs/Engines/thinEngine" {
  39658. interface ThinEngine {
  39659. /**
  39660. * Creates a dynamic texture
  39661. * @param width defines the width of the texture
  39662. * @param height defines the height of the texture
  39663. * @param generateMipMaps defines if the engine should generate the mip levels
  39664. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39665. * @returns the dynamic texture inside an InternalTexture
  39666. */
  39667. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39668. /**
  39669. * Update the content of a dynamic texture
  39670. * @param texture defines the texture to update
  39671. * @param canvas defines the canvas containing the source
  39672. * @param invertY defines if data must be stored with Y axis inverted
  39673. * @param premulAlpha defines if alpha is stored as premultiplied
  39674. * @param format defines the format of the data
  39675. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39676. */
  39677. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39678. }
  39679. }
  39680. }
  39681. declare module "babylonjs/Materials/Textures/videoTexture" {
  39682. import { Observable } from "babylonjs/Misc/observable";
  39683. import { Nullable } from "babylonjs/types";
  39684. import { Scene } from "babylonjs/scene";
  39685. import { Texture } from "babylonjs/Materials/Textures/texture";
  39686. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39687. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39688. /**
  39689. * Settings for finer control over video usage
  39690. */
  39691. export interface VideoTextureSettings {
  39692. /**
  39693. * Applies `autoplay` to video, if specified
  39694. */
  39695. autoPlay?: boolean;
  39696. /**
  39697. * Applies `muted` to video, if specified
  39698. */
  39699. muted?: boolean;
  39700. /**
  39701. * Applies `loop` to video, if specified
  39702. */
  39703. loop?: boolean;
  39704. /**
  39705. * Automatically updates internal texture from video at every frame in the render loop
  39706. */
  39707. autoUpdateTexture: boolean;
  39708. /**
  39709. * Image src displayed during the video loading or until the user interacts with the video.
  39710. */
  39711. poster?: string;
  39712. }
  39713. /**
  39714. * If you want to display a video in your scene, this is the special texture for that.
  39715. * This special texture works similar to other textures, with the exception of a few parameters.
  39716. * @see https://doc.babylonjs.com/how_to/video_texture
  39717. */
  39718. export class VideoTexture extends Texture {
  39719. /**
  39720. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39721. */
  39722. readonly autoUpdateTexture: boolean;
  39723. /**
  39724. * The video instance used by the texture internally
  39725. */
  39726. readonly video: HTMLVideoElement;
  39727. private _onUserActionRequestedObservable;
  39728. /**
  39729. * Event triggerd when a dom action is required by the user to play the video.
  39730. * This happens due to recent changes in browser policies preventing video to auto start.
  39731. */
  39732. get onUserActionRequestedObservable(): Observable<Texture>;
  39733. private _generateMipMaps;
  39734. private _stillImageCaptured;
  39735. private _displayingPosterTexture;
  39736. private _settings;
  39737. private _createInternalTextureOnEvent;
  39738. private _frameId;
  39739. private _currentSrc;
  39740. /**
  39741. * Creates a video texture.
  39742. * If you want to display a video in your scene, this is the special texture for that.
  39743. * This special texture works similar to other textures, with the exception of a few parameters.
  39744. * @see https://doc.babylonjs.com/how_to/video_texture
  39745. * @param name optional name, will detect from video source, if not defined
  39746. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39747. * @param scene is obviously the current scene.
  39748. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39749. * @param invertY is false by default but can be used to invert video on Y axis
  39750. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39751. * @param settings allows finer control over video usage
  39752. */
  39753. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39754. private _getName;
  39755. private _getVideo;
  39756. private _createInternalTexture;
  39757. private reset;
  39758. /**
  39759. * @hidden Internal method to initiate `update`.
  39760. */
  39761. _rebuild(): void;
  39762. /**
  39763. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39764. */
  39765. update(): void;
  39766. /**
  39767. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39768. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39769. */
  39770. updateTexture(isVisible: boolean): void;
  39771. protected _updateInternalTexture: () => void;
  39772. /**
  39773. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39774. * @param url New url.
  39775. */
  39776. updateURL(url: string): void;
  39777. /**
  39778. * Clones the texture.
  39779. * @returns the cloned texture
  39780. */
  39781. clone(): VideoTexture;
  39782. /**
  39783. * Dispose the texture and release its associated resources.
  39784. */
  39785. dispose(): void;
  39786. /**
  39787. * Creates a video texture straight from a stream.
  39788. * @param scene Define the scene the texture should be created in
  39789. * @param stream Define the stream the texture should be created from
  39790. * @returns The created video texture as a promise
  39791. */
  39792. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39793. /**
  39794. * Creates a video texture straight from your WebCam video feed.
  39795. * @param scene Define the scene the texture should be created in
  39796. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39797. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39798. * @returns The created video texture as a promise
  39799. */
  39800. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39801. minWidth: number;
  39802. maxWidth: number;
  39803. minHeight: number;
  39804. maxHeight: number;
  39805. deviceId: string;
  39806. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39807. /**
  39808. * Creates a video texture straight from your WebCam video feed.
  39809. * @param scene Define the scene the texture should be created in
  39810. * @param onReady Define a callback to triggered once the texture will be ready
  39811. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39812. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39813. */
  39814. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39815. minWidth: number;
  39816. maxWidth: number;
  39817. minHeight: number;
  39818. maxHeight: number;
  39819. deviceId: string;
  39820. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39821. }
  39822. }
  39823. declare module "babylonjs/Engines/thinEngine" {
  39824. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  39825. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  39826. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39827. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39828. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  39829. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  39830. import { Observable } from "babylonjs/Misc/observable";
  39831. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  39832. import { StencilState } from "babylonjs/States/stencilState";
  39833. import { AlphaState } from "babylonjs/States/alphaCullingState";
  39834. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39835. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  39836. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39837. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39838. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39839. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  39840. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  39841. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  39842. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39843. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39844. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39845. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  39846. import { WebRequest } from "babylonjs/Misc/webRequest";
  39847. import { LoadFileError } from "babylonjs/Misc/fileTools";
  39848. /**
  39849. * Defines the interface used by objects working like Scene
  39850. * @hidden
  39851. */
  39852. export interface ISceneLike {
  39853. _addPendingData(data: any): void;
  39854. _removePendingData(data: any): void;
  39855. offlineProvider: IOfflineProvider;
  39856. }
  39857. /**
  39858. * Information about the current host
  39859. */
  39860. export interface HostInformation {
  39861. /**
  39862. * Defines if the current host is a mobile
  39863. */
  39864. isMobile: boolean;
  39865. }
  39866. /** Interface defining initialization parameters for Engine class */
  39867. export interface EngineOptions extends WebGLContextAttributes {
  39868. /**
  39869. * Defines if the engine should no exceed a specified device ratio
  39870. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39871. */
  39872. limitDeviceRatio?: number;
  39873. /**
  39874. * Defines if webvr should be enabled automatically
  39875. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39876. */
  39877. autoEnableWebVR?: boolean;
  39878. /**
  39879. * Defines if webgl2 should be turned off even if supported
  39880. * @see https://doc.babylonjs.com/features/webgl2
  39881. */
  39882. disableWebGL2Support?: boolean;
  39883. /**
  39884. * Defines if webaudio should be initialized as well
  39885. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39886. */
  39887. audioEngine?: boolean;
  39888. /**
  39889. * Defines if animations should run using a deterministic lock step
  39890. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39891. */
  39892. deterministicLockstep?: boolean;
  39893. /** Defines the maximum steps to use with deterministic lock step mode */
  39894. lockstepMaxSteps?: number;
  39895. /** Defines the seconds between each deterministic lock step */
  39896. timeStep?: number;
  39897. /**
  39898. * Defines that engine should ignore context lost events
  39899. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39900. */
  39901. doNotHandleContextLost?: boolean;
  39902. /**
  39903. * Defines that engine should ignore modifying touch action attribute and style
  39904. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39905. */
  39906. doNotHandleTouchAction?: boolean;
  39907. /**
  39908. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39909. */
  39910. useHighPrecisionFloats?: boolean;
  39911. /**
  39912. * Make the canvas XR Compatible for XR sessions
  39913. */
  39914. xrCompatible?: boolean;
  39915. /**
  39916. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39917. */
  39918. useHighPrecisionMatrix?: boolean;
  39919. /**
  39920. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39921. */
  39922. failIfMajorPerformanceCaveat?: boolean;
  39923. }
  39924. /**
  39925. * The base engine class (root of all engines)
  39926. */
  39927. export class ThinEngine {
  39928. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39929. static ExceptionList: ({
  39930. key: string;
  39931. capture: string;
  39932. captureConstraint: number;
  39933. targets: string[];
  39934. } | {
  39935. key: string;
  39936. capture: null;
  39937. captureConstraint: null;
  39938. targets: string[];
  39939. })[];
  39940. /** @hidden */
  39941. static _TextureLoaders: IInternalTextureLoader[];
  39942. /**
  39943. * Returns the current npm package of the sdk
  39944. */
  39945. static get NpmPackage(): string;
  39946. /**
  39947. * Returns the current version of the framework
  39948. */
  39949. static get Version(): string;
  39950. /**
  39951. * Returns a string describing the current engine
  39952. */
  39953. get description(): string;
  39954. /**
  39955. * Gets or sets the epsilon value used by collision engine
  39956. */
  39957. static CollisionsEpsilon: number;
  39958. /**
  39959. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39960. */
  39961. static get ShadersRepository(): string;
  39962. static set ShadersRepository(value: string);
  39963. /** @hidden */
  39964. _shaderProcessor: IShaderProcessor;
  39965. /**
  39966. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39967. */
  39968. forcePOTTextures: boolean;
  39969. /**
  39970. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39971. */
  39972. isFullscreen: boolean;
  39973. /**
  39974. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39975. */
  39976. cullBackFaces: boolean;
  39977. /**
  39978. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39979. */
  39980. renderEvenInBackground: boolean;
  39981. /**
  39982. * Gets or sets a boolean indicating that cache can be kept between frames
  39983. */
  39984. preventCacheWipeBetweenFrames: boolean;
  39985. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39986. validateShaderPrograms: boolean;
  39987. /**
  39988. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39989. * This can provide greater z depth for distant objects.
  39990. */
  39991. useReverseDepthBuffer: boolean;
  39992. /**
  39993. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39994. */
  39995. disableUniformBuffers: boolean;
  39996. /** @hidden */
  39997. _uniformBuffers: UniformBuffer[];
  39998. /**
  39999. * Gets a boolean indicating that the engine supports uniform buffers
  40000. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40001. */
  40002. get supportsUniformBuffers(): boolean;
  40003. /** @hidden */
  40004. _gl: WebGLRenderingContext;
  40005. /** @hidden */
  40006. _webGLVersion: number;
  40007. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40008. protected _windowIsBackground: boolean;
  40009. protected _creationOptions: EngineOptions;
  40010. protected _highPrecisionShadersAllowed: boolean;
  40011. /** @hidden */
  40012. get _shouldUseHighPrecisionShader(): boolean;
  40013. /**
  40014. * Gets a boolean indicating that only power of 2 textures are supported
  40015. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40016. */
  40017. get needPOTTextures(): boolean;
  40018. /** @hidden */
  40019. _badOS: boolean;
  40020. /** @hidden */
  40021. _badDesktopOS: boolean;
  40022. private _hardwareScalingLevel;
  40023. /** @hidden */
  40024. _caps: EngineCapabilities;
  40025. private _isStencilEnable;
  40026. private _glVersion;
  40027. private _glRenderer;
  40028. private _glVendor;
  40029. /** @hidden */
  40030. _videoTextureSupported: boolean;
  40031. protected _renderingQueueLaunched: boolean;
  40032. protected _activeRenderLoops: (() => void)[];
  40033. /**
  40034. * Observable signaled when a context lost event is raised
  40035. */
  40036. onContextLostObservable: Observable<ThinEngine>;
  40037. /**
  40038. * Observable signaled when a context restored event is raised
  40039. */
  40040. onContextRestoredObservable: Observable<ThinEngine>;
  40041. private _onContextLost;
  40042. private _onContextRestored;
  40043. protected _contextWasLost: boolean;
  40044. /** @hidden */
  40045. _doNotHandleContextLost: boolean;
  40046. /**
  40047. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40048. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40049. */
  40050. get doNotHandleContextLost(): boolean;
  40051. set doNotHandleContextLost(value: boolean);
  40052. /**
  40053. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40054. */
  40055. disableVertexArrayObjects: boolean;
  40056. /** @hidden */
  40057. protected _colorWrite: boolean;
  40058. /** @hidden */
  40059. protected _colorWriteChanged: boolean;
  40060. /** @hidden */
  40061. protected _depthCullingState: DepthCullingState;
  40062. /** @hidden */
  40063. protected _stencilState: StencilState;
  40064. /** @hidden */
  40065. _alphaState: AlphaState;
  40066. /** @hidden */
  40067. _alphaMode: number;
  40068. /** @hidden */
  40069. _alphaEquation: number;
  40070. /** @hidden */
  40071. _internalTexturesCache: InternalTexture[];
  40072. /** @hidden */
  40073. protected _activeChannel: number;
  40074. private _currentTextureChannel;
  40075. /** @hidden */
  40076. protected _boundTexturesCache: {
  40077. [key: string]: Nullable<InternalTexture>;
  40078. };
  40079. /** @hidden */
  40080. protected _currentEffect: Nullable<Effect>;
  40081. /** @hidden */
  40082. protected _currentProgram: Nullable<WebGLProgram>;
  40083. private _compiledEffects;
  40084. private _vertexAttribArraysEnabled;
  40085. /** @hidden */
  40086. protected _cachedViewport: Nullable<IViewportLike>;
  40087. private _cachedVertexArrayObject;
  40088. /** @hidden */
  40089. protected _cachedVertexBuffers: any;
  40090. /** @hidden */
  40091. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40092. /** @hidden */
  40093. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40094. /** @hidden */
  40095. _currentRenderTarget: Nullable<InternalTexture>;
  40096. private _uintIndicesCurrentlySet;
  40097. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40098. /** @hidden */
  40099. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40100. /** @hidden */
  40101. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40102. private _currentBufferPointers;
  40103. private _currentInstanceLocations;
  40104. private _currentInstanceBuffers;
  40105. private _textureUnits;
  40106. /** @hidden */
  40107. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40108. /** @hidden */
  40109. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40110. /** @hidden */
  40111. _boundRenderFunction: any;
  40112. private _vaoRecordInProgress;
  40113. private _mustWipeVertexAttributes;
  40114. private _emptyTexture;
  40115. private _emptyCubeTexture;
  40116. private _emptyTexture3D;
  40117. private _emptyTexture2DArray;
  40118. /** @hidden */
  40119. _frameHandler: number;
  40120. private _nextFreeTextureSlots;
  40121. private _maxSimultaneousTextures;
  40122. private _activeRequests;
  40123. /** @hidden */
  40124. _transformTextureUrl: Nullable<(url: string) => string>;
  40125. /**
  40126. * Gets information about the current host
  40127. */
  40128. hostInformation: HostInformation;
  40129. protected get _supportsHardwareTextureRescaling(): boolean;
  40130. private _framebufferDimensionsObject;
  40131. /**
  40132. * sets the object from which width and height will be taken from when getting render width and height
  40133. * Will fallback to the gl object
  40134. * @param dimensions the framebuffer width and height that will be used.
  40135. */
  40136. set framebufferDimensionsObject(dimensions: Nullable<{
  40137. framebufferWidth: number;
  40138. framebufferHeight: number;
  40139. }>);
  40140. /**
  40141. * Gets the current viewport
  40142. */
  40143. get currentViewport(): Nullable<IViewportLike>;
  40144. /**
  40145. * Gets the default empty texture
  40146. */
  40147. get emptyTexture(): InternalTexture;
  40148. /**
  40149. * Gets the default empty 3D texture
  40150. */
  40151. get emptyTexture3D(): InternalTexture;
  40152. /**
  40153. * Gets the default empty 2D array texture
  40154. */
  40155. get emptyTexture2DArray(): InternalTexture;
  40156. /**
  40157. * Gets the default empty cube texture
  40158. */
  40159. get emptyCubeTexture(): InternalTexture;
  40160. /**
  40161. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40162. */
  40163. readonly premultipliedAlpha: boolean;
  40164. /**
  40165. * Observable event triggered before each texture is initialized
  40166. */
  40167. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40168. /**
  40169. * Creates a new engine
  40170. * @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
  40171. * @param antialias defines enable antialiasing (default: false)
  40172. * @param options defines further options to be sent to the getContext() function
  40173. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40174. */
  40175. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40176. private _rebuildInternalTextures;
  40177. private _rebuildEffects;
  40178. /**
  40179. * Gets a boolean indicating if all created effects are ready
  40180. * @returns true if all effects are ready
  40181. */
  40182. areAllEffectsReady(): boolean;
  40183. protected _rebuildBuffers(): void;
  40184. protected _initGLContext(): void;
  40185. /**
  40186. * Gets version of the current webGL context
  40187. */
  40188. get webGLVersion(): number;
  40189. /**
  40190. * Gets a string identifying the name of the class
  40191. * @returns "Engine" string
  40192. */
  40193. getClassName(): string;
  40194. /**
  40195. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40196. */
  40197. get isStencilEnable(): boolean;
  40198. /** @hidden */
  40199. _prepareWorkingCanvas(): void;
  40200. /**
  40201. * Reset the texture cache to empty state
  40202. */
  40203. resetTextureCache(): void;
  40204. /**
  40205. * Gets an object containing information about the current webGL context
  40206. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40207. */
  40208. getGlInfo(): {
  40209. vendor: string;
  40210. renderer: string;
  40211. version: string;
  40212. };
  40213. /**
  40214. * Defines the hardware scaling level.
  40215. * By default the hardware scaling level is computed from the window device ratio.
  40216. * 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.
  40217. * @param level defines the level to use
  40218. */
  40219. setHardwareScalingLevel(level: number): void;
  40220. /**
  40221. * Gets the current hardware scaling level.
  40222. * By default the hardware scaling level is computed from the window device ratio.
  40223. * 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.
  40224. * @returns a number indicating the current hardware scaling level
  40225. */
  40226. getHardwareScalingLevel(): number;
  40227. /**
  40228. * Gets the list of loaded textures
  40229. * @returns an array containing all loaded textures
  40230. */
  40231. getLoadedTexturesCache(): InternalTexture[];
  40232. /**
  40233. * Gets the object containing all engine capabilities
  40234. * @returns the EngineCapabilities object
  40235. */
  40236. getCaps(): EngineCapabilities;
  40237. /**
  40238. * stop executing a render loop function and remove it from the execution array
  40239. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40240. */
  40241. stopRenderLoop(renderFunction?: () => void): void;
  40242. /** @hidden */
  40243. _renderLoop(): void;
  40244. /**
  40245. * Gets the HTML canvas attached with the current webGL context
  40246. * @returns a HTML canvas
  40247. */
  40248. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40249. /**
  40250. * Gets host window
  40251. * @returns the host window object
  40252. */
  40253. getHostWindow(): Nullable<Window>;
  40254. /**
  40255. * Gets the current render width
  40256. * @param useScreen defines if screen size must be used (or the current render target if any)
  40257. * @returns a number defining the current render width
  40258. */
  40259. getRenderWidth(useScreen?: boolean): number;
  40260. /**
  40261. * Gets the current render height
  40262. * @param useScreen defines if screen size must be used (or the current render target if any)
  40263. * @returns a number defining the current render height
  40264. */
  40265. getRenderHeight(useScreen?: boolean): number;
  40266. /**
  40267. * Can be used to override the current requestAnimationFrame requester.
  40268. * @hidden
  40269. */
  40270. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40271. /**
  40272. * Register and execute a render loop. The engine can have more than one render function
  40273. * @param renderFunction defines the function to continuously execute
  40274. */
  40275. runRenderLoop(renderFunction: () => void): void;
  40276. /**
  40277. * Clear the current render buffer or the current render target (if any is set up)
  40278. * @param color defines the color to use
  40279. * @param backBuffer defines if the back buffer must be cleared
  40280. * @param depth defines if the depth buffer must be cleared
  40281. * @param stencil defines if the stencil buffer must be cleared
  40282. */
  40283. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40284. private _viewportCached;
  40285. /** @hidden */
  40286. _viewport(x: number, y: number, width: number, height: number): void;
  40287. /**
  40288. * Set the WebGL's viewport
  40289. * @param viewport defines the viewport element to be used
  40290. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40291. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40292. */
  40293. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40294. /**
  40295. * Begin a new frame
  40296. */
  40297. beginFrame(): void;
  40298. /**
  40299. * Enf the current frame
  40300. */
  40301. endFrame(): void;
  40302. /**
  40303. * Resize the view according to the canvas' size
  40304. */
  40305. resize(): void;
  40306. /**
  40307. * Force a specific size of the canvas
  40308. * @param width defines the new canvas' width
  40309. * @param height defines the new canvas' height
  40310. * @returns true if the size was changed
  40311. */
  40312. setSize(width: number, height: number): boolean;
  40313. /**
  40314. * Binds the frame buffer to the specified texture.
  40315. * @param texture The texture to render to or null for the default canvas
  40316. * @param faceIndex The face of the texture to render to in case of cube texture
  40317. * @param requiredWidth The width of the target to render to
  40318. * @param requiredHeight The height of the target to render to
  40319. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40320. * @param lodLevel defines the lod level to bind to the frame buffer
  40321. * @param layer defines the 2d array index to bind to frame buffer to
  40322. */
  40323. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40324. /** @hidden */
  40325. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40326. /**
  40327. * Unbind the current render target texture from the webGL context
  40328. * @param texture defines the render target texture to unbind
  40329. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40330. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40331. */
  40332. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40333. /**
  40334. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40335. */
  40336. flushFramebuffer(): void;
  40337. /**
  40338. * Unbind the current render target and bind the default framebuffer
  40339. */
  40340. restoreDefaultFramebuffer(): void;
  40341. /** @hidden */
  40342. protected _resetVertexBufferBinding(): void;
  40343. /**
  40344. * Creates a vertex buffer
  40345. * @param data the data for the vertex buffer
  40346. * @returns the new WebGL static buffer
  40347. */
  40348. createVertexBuffer(data: DataArray): DataBuffer;
  40349. private _createVertexBuffer;
  40350. /**
  40351. * Creates a dynamic vertex buffer
  40352. * @param data the data for the dynamic vertex buffer
  40353. * @returns the new WebGL dynamic buffer
  40354. */
  40355. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40356. protected _resetIndexBufferBinding(): void;
  40357. /**
  40358. * Creates a new index buffer
  40359. * @param indices defines the content of the index buffer
  40360. * @param updatable defines if the index buffer must be updatable
  40361. * @returns a new webGL buffer
  40362. */
  40363. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40364. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40365. /**
  40366. * Bind a webGL buffer to the webGL context
  40367. * @param buffer defines the buffer to bind
  40368. */
  40369. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40370. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40371. private bindBuffer;
  40372. /**
  40373. * update the bound buffer with the given data
  40374. * @param data defines the data to update
  40375. */
  40376. updateArrayBuffer(data: Float32Array): void;
  40377. private _vertexAttribPointer;
  40378. /** @hidden */
  40379. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40380. private _bindVertexBuffersAttributes;
  40381. /**
  40382. * Records a vertex array object
  40383. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40384. * @param vertexBuffers defines the list of vertex buffers to store
  40385. * @param indexBuffer defines the index buffer to store
  40386. * @param effect defines the effect to store
  40387. * @returns the new vertex array object
  40388. */
  40389. recordVertexArrayObject(vertexBuffers: {
  40390. [key: string]: VertexBuffer;
  40391. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40392. /**
  40393. * Bind a specific vertex array object
  40394. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40395. * @param vertexArrayObject defines the vertex array object to bind
  40396. * @param indexBuffer defines the index buffer to bind
  40397. */
  40398. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40399. /**
  40400. * Bind webGl buffers directly to the webGL context
  40401. * @param vertexBuffer defines the vertex buffer to bind
  40402. * @param indexBuffer defines the index buffer to bind
  40403. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40404. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40405. * @param effect defines the effect associated with the vertex buffer
  40406. */
  40407. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40408. private _unbindVertexArrayObject;
  40409. /**
  40410. * Bind a list of vertex buffers to the webGL context
  40411. * @param vertexBuffers defines the list of vertex buffers to bind
  40412. * @param indexBuffer defines the index buffer to bind
  40413. * @param effect defines the effect associated with the vertex buffers
  40414. */
  40415. bindBuffers(vertexBuffers: {
  40416. [key: string]: Nullable<VertexBuffer>;
  40417. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40418. /**
  40419. * Unbind all instance attributes
  40420. */
  40421. unbindInstanceAttributes(): void;
  40422. /**
  40423. * Release and free the memory of a vertex array object
  40424. * @param vao defines the vertex array object to delete
  40425. */
  40426. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40427. /** @hidden */
  40428. _releaseBuffer(buffer: DataBuffer): boolean;
  40429. protected _deleteBuffer(buffer: DataBuffer): void;
  40430. /**
  40431. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40432. * @param instancesBuffer defines the webGL buffer to update and bind
  40433. * @param data defines the data to store in the buffer
  40434. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40435. */
  40436. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40437. /**
  40438. * Bind the content of a webGL buffer used with instantiation
  40439. * @param instancesBuffer defines the webGL buffer to bind
  40440. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40441. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40442. */
  40443. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40444. /**
  40445. * Disable the instance attribute corresponding to the name in parameter
  40446. * @param name defines the name of the attribute to disable
  40447. */
  40448. disableInstanceAttributeByName(name: string): void;
  40449. /**
  40450. * Disable the instance attribute corresponding to the location in parameter
  40451. * @param attributeLocation defines the attribute location of the attribute to disable
  40452. */
  40453. disableInstanceAttribute(attributeLocation: number): void;
  40454. /**
  40455. * Disable the attribute corresponding to the location in parameter
  40456. * @param attributeLocation defines the attribute location of the attribute to disable
  40457. */
  40458. disableAttributeByIndex(attributeLocation: number): void;
  40459. /**
  40460. * Send a draw order
  40461. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40462. * @param indexStart defines the starting index
  40463. * @param indexCount defines the number of index to draw
  40464. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40465. */
  40466. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40467. /**
  40468. * Draw a list of points
  40469. * @param verticesStart defines the index of first vertex to draw
  40470. * @param verticesCount defines the count of vertices to draw
  40471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40472. */
  40473. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40474. /**
  40475. * Draw a list of unindexed primitives
  40476. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40477. * @param verticesStart defines the index of first vertex to draw
  40478. * @param verticesCount defines the count of vertices to draw
  40479. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40480. */
  40481. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40482. /**
  40483. * Draw a list of indexed primitives
  40484. * @param fillMode defines the primitive to use
  40485. * @param indexStart defines the starting index
  40486. * @param indexCount defines the number of index to draw
  40487. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40488. */
  40489. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40490. /**
  40491. * Draw a list of unindexed primitives
  40492. * @param fillMode defines the primitive to use
  40493. * @param verticesStart defines the index of first vertex to draw
  40494. * @param verticesCount defines the count of vertices to draw
  40495. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40496. */
  40497. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40498. private _drawMode;
  40499. /** @hidden */
  40500. protected _reportDrawCall(): void;
  40501. /** @hidden */
  40502. _releaseEffect(effect: Effect): void;
  40503. /** @hidden */
  40504. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40505. /**
  40506. * Create a new effect (used to store vertex/fragment shaders)
  40507. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40508. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40509. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40510. * @param samplers defines an array of string used to represent textures
  40511. * @param defines defines the string containing the defines to use to compile the shaders
  40512. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40513. * @param onCompiled defines a function to call when the effect creation is successful
  40514. * @param onError defines a function to call when the effect creation has failed
  40515. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40516. * @returns the new Effect
  40517. */
  40518. 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;
  40519. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40520. private _compileShader;
  40521. private _compileRawShader;
  40522. /** @hidden */
  40523. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40524. /**
  40525. * Directly creates a webGL program
  40526. * @param pipelineContext defines the pipeline context to attach to
  40527. * @param vertexCode defines the vertex shader code to use
  40528. * @param fragmentCode defines the fragment shader code to use
  40529. * @param context defines the webGL context to use (if not set, the current one will be used)
  40530. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40531. * @returns the new webGL program
  40532. */
  40533. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40534. /**
  40535. * Creates a webGL program
  40536. * @param pipelineContext defines the pipeline context to attach to
  40537. * @param vertexCode defines the vertex shader code to use
  40538. * @param fragmentCode defines the fragment shader code to use
  40539. * @param defines defines the string containing the defines to use to compile the shaders
  40540. * @param context defines the webGL context to use (if not set, the current one will be used)
  40541. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40542. * @returns the new webGL program
  40543. */
  40544. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40545. /**
  40546. * Creates a new pipeline context
  40547. * @returns the new pipeline
  40548. */
  40549. createPipelineContext(): IPipelineContext;
  40550. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40551. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40552. /** @hidden */
  40553. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40554. /** @hidden */
  40555. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40556. /** @hidden */
  40557. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40558. /**
  40559. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40560. * @param pipelineContext defines the pipeline context to use
  40561. * @param uniformsNames defines the list of uniform names
  40562. * @returns an array of webGL uniform locations
  40563. */
  40564. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40565. /**
  40566. * Gets the lsit of active attributes for a given webGL program
  40567. * @param pipelineContext defines the pipeline context to use
  40568. * @param attributesNames defines the list of attribute names to get
  40569. * @returns an array of indices indicating the offset of each attribute
  40570. */
  40571. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40572. /**
  40573. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40574. * @param effect defines the effect to activate
  40575. */
  40576. enableEffect(effect: Nullable<Effect>): void;
  40577. /**
  40578. * Set the value of an uniform to a number (int)
  40579. * @param uniform defines the webGL uniform location where to store the value
  40580. * @param value defines the int number to store
  40581. * @returns true if the value was set
  40582. */
  40583. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40584. /**
  40585. * Set the value of an uniform to an array of int32
  40586. * @param uniform defines the webGL uniform location where to store the value
  40587. * @param array defines the array of int32 to store
  40588. * @returns true if the value was set
  40589. */
  40590. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40591. /**
  40592. * Set the value of an uniform to an array of int32 (stored as vec2)
  40593. * @param uniform defines the webGL uniform location where to store the value
  40594. * @param array defines the array of int32 to store
  40595. * @returns true if the value was set
  40596. */
  40597. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40598. /**
  40599. * Set the value of an uniform to an array of int32 (stored as vec3)
  40600. * @param uniform defines the webGL uniform location where to store the value
  40601. * @param array defines the array of int32 to store
  40602. * @returns true if the value was set
  40603. */
  40604. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40605. /**
  40606. * Set the value of an uniform to an array of int32 (stored as vec4)
  40607. * @param uniform defines the webGL uniform location where to store the value
  40608. * @param array defines the array of int32 to store
  40609. * @returns true if the value was set
  40610. */
  40611. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40612. /**
  40613. * Set the value of an uniform to an array of number
  40614. * @param uniform defines the webGL uniform location where to store the value
  40615. * @param array defines the array of number to store
  40616. * @returns true if the value was set
  40617. */
  40618. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40619. /**
  40620. * Set the value of an uniform to an array of number (stored as vec2)
  40621. * @param uniform defines the webGL uniform location where to store the value
  40622. * @param array defines the array of number to store
  40623. * @returns true if the value was set
  40624. */
  40625. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40626. /**
  40627. * Set the value of an uniform to an array of number (stored as vec3)
  40628. * @param uniform defines the webGL uniform location where to store the value
  40629. * @param array defines the array of number to store
  40630. * @returns true if the value was set
  40631. */
  40632. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40633. /**
  40634. * Set the value of an uniform to an array of number (stored as vec4)
  40635. * @param uniform defines the webGL uniform location where to store the value
  40636. * @param array defines the array of number to store
  40637. * @returns true if the value was set
  40638. */
  40639. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40640. /**
  40641. * Set the value of an uniform to an array of float32 (stored as matrices)
  40642. * @param uniform defines the webGL uniform location where to store the value
  40643. * @param matrices defines the array of float32 to store
  40644. * @returns true if the value was set
  40645. */
  40646. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40647. /**
  40648. * Set the value of an uniform to a matrix (3x3)
  40649. * @param uniform defines the webGL uniform location where to store the value
  40650. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40651. * @returns true if the value was set
  40652. */
  40653. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40654. /**
  40655. * Set the value of an uniform to a matrix (2x2)
  40656. * @param uniform defines the webGL uniform location where to store the value
  40657. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40658. * @returns true if the value was set
  40659. */
  40660. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40661. /**
  40662. * Set the value of an uniform to a number (float)
  40663. * @param uniform defines the webGL uniform location where to store the value
  40664. * @param value defines the float number to store
  40665. * @returns true if the value was transfered
  40666. */
  40667. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40668. /**
  40669. * Set the value of an uniform to a vec2
  40670. * @param uniform defines the webGL uniform location where to store the value
  40671. * @param x defines the 1st component of the value
  40672. * @param y defines the 2nd component of the value
  40673. * @returns true if the value was set
  40674. */
  40675. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40676. /**
  40677. * Set the value of an uniform to a vec3
  40678. * @param uniform defines the webGL uniform location where to store the value
  40679. * @param x defines the 1st component of the value
  40680. * @param y defines the 2nd component of the value
  40681. * @param z defines the 3rd component of the value
  40682. * @returns true if the value was set
  40683. */
  40684. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40685. /**
  40686. * Set the value of an uniform to a vec4
  40687. * @param uniform defines the webGL uniform location where to store the value
  40688. * @param x defines the 1st component of the value
  40689. * @param y defines the 2nd component of the value
  40690. * @param z defines the 3rd component of the value
  40691. * @param w defines the 4th component of the value
  40692. * @returns true if the value was set
  40693. */
  40694. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40695. /**
  40696. * Apply all cached states (depth, culling, stencil and alpha)
  40697. */
  40698. applyStates(): void;
  40699. /**
  40700. * Enable or disable color writing
  40701. * @param enable defines the state to set
  40702. */
  40703. setColorWrite(enable: boolean): void;
  40704. /**
  40705. * Gets a boolean indicating if color writing is enabled
  40706. * @returns the current color writing state
  40707. */
  40708. getColorWrite(): boolean;
  40709. /**
  40710. * Gets the depth culling state manager
  40711. */
  40712. get depthCullingState(): DepthCullingState;
  40713. /**
  40714. * Gets the alpha state manager
  40715. */
  40716. get alphaState(): AlphaState;
  40717. /**
  40718. * Gets the stencil state manager
  40719. */
  40720. get stencilState(): StencilState;
  40721. /**
  40722. * Clears the list of texture accessible through engine.
  40723. * This can help preventing texture load conflict due to name collision.
  40724. */
  40725. clearInternalTexturesCache(): void;
  40726. /**
  40727. * Force the entire cache to be cleared
  40728. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40729. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40730. */
  40731. wipeCaches(bruteForce?: boolean): void;
  40732. /** @hidden */
  40733. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40734. min: number;
  40735. mag: number;
  40736. };
  40737. /** @hidden */
  40738. _createTexture(): WebGLTexture;
  40739. /**
  40740. * Usually called from Texture.ts.
  40741. * Passed information to create a WebGLTexture
  40742. * @param url defines a value which contains one of the following:
  40743. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40744. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40745. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40746. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40747. * @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)
  40748. * @param scene needed for loading to the correct scene
  40749. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40750. * @param onLoad optional callback to be called upon successful completion
  40751. * @param onError optional callback to be called upon failure
  40752. * @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
  40753. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40754. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40755. * @param forcedExtension defines the extension to use to pick the right loader
  40756. * @param mimeType defines an optional mime type
  40757. * @param loaderOptions options to be passed to the loader
  40758. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40759. */
  40760. 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, loaderOptions?: any): InternalTexture;
  40761. /**
  40762. * Loads an image as an HTMLImageElement.
  40763. * @param input url string, ArrayBuffer, or Blob to load
  40764. * @param onLoad callback called when the image successfully loads
  40765. * @param onError callback called when the image fails to load
  40766. * @param offlineProvider offline provider for caching
  40767. * @param mimeType optional mime type
  40768. * @returns the HTMLImageElement of the loaded image
  40769. * @hidden
  40770. */
  40771. 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>;
  40772. /**
  40773. * @hidden
  40774. */
  40775. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40776. private _unpackFlipYCached;
  40777. /**
  40778. * In case you are sharing the context with other applications, it might
  40779. * be interested to not cache the unpack flip y state to ensure a consistent
  40780. * value would be set.
  40781. */
  40782. enableUnpackFlipYCached: boolean;
  40783. /** @hidden */
  40784. _unpackFlipY(value: boolean): void;
  40785. /** @hidden */
  40786. _getUnpackAlignement(): number;
  40787. private _getTextureTarget;
  40788. /**
  40789. * Update the sampling mode of a given texture
  40790. * @param samplingMode defines the required sampling mode
  40791. * @param texture defines the texture to update
  40792. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40793. */
  40794. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40795. /**
  40796. * Update the sampling mode of a given texture
  40797. * @param texture defines the texture to update
  40798. * @param wrapU defines the texture wrap mode of the u coordinates
  40799. * @param wrapV defines the texture wrap mode of the v coordinates
  40800. * @param wrapR defines the texture wrap mode of the r coordinates
  40801. */
  40802. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40803. /** @hidden */
  40804. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40805. width: number;
  40806. height: number;
  40807. layers?: number;
  40808. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  40809. /** @hidden */
  40810. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40811. /** @hidden */
  40812. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40813. /**
  40814. * Update a portion of an internal texture
  40815. * @param texture defines the texture to update
  40816. * @param imageData defines the data to store into the texture
  40817. * @param xOffset defines the x coordinates of the update rectangle
  40818. * @param yOffset defines the y coordinates of the update rectangle
  40819. * @param width defines the width of the update rectangle
  40820. * @param height defines the height of the update rectangle
  40821. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40822. * @param lod defines the lod level to update (0 by default)
  40823. */
  40824. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40825. /** @hidden */
  40826. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40827. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40828. private _prepareWebGLTexture;
  40829. /** @hidden */
  40830. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40831. private _getDepthStencilBuffer;
  40832. /** @hidden */
  40833. _releaseFramebufferObjects(texture: InternalTexture): void;
  40834. /** @hidden */
  40835. _releaseTexture(texture: InternalTexture): void;
  40836. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40837. protected _setProgram(program: WebGLProgram): void;
  40838. protected _boundUniforms: {
  40839. [key: number]: WebGLUniformLocation;
  40840. };
  40841. /**
  40842. * Binds an effect to the webGL context
  40843. * @param effect defines the effect to bind
  40844. */
  40845. bindSamplers(effect: Effect): void;
  40846. private _activateCurrentTexture;
  40847. /** @hidden */
  40848. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40849. /** @hidden */
  40850. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  40851. /**
  40852. * Unbind all textures from the webGL context
  40853. */
  40854. unbindAllTextures(): void;
  40855. /**
  40856. * Sets a texture to the according uniform.
  40857. * @param channel The texture channel
  40858. * @param uniform The uniform to set
  40859. * @param texture The texture to apply
  40860. */
  40861. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  40862. private _bindSamplerUniformToChannel;
  40863. private _getTextureWrapMode;
  40864. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40865. /**
  40866. * Sets an array of texture to the webGL context
  40867. * @param channel defines the channel where the texture array must be set
  40868. * @param uniform defines the associated uniform location
  40869. * @param textures defines the array of textures to bind
  40870. */
  40871. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  40872. /** @hidden */
  40873. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40874. private _setTextureParameterFloat;
  40875. private _setTextureParameterInteger;
  40876. /**
  40877. * Unbind all vertex attributes from the webGL context
  40878. */
  40879. unbindAllAttributes(): void;
  40880. /**
  40881. * 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
  40882. */
  40883. releaseEffects(): void;
  40884. /**
  40885. * Dispose and release all associated resources
  40886. */
  40887. dispose(): void;
  40888. /**
  40889. * Attach a new callback raised when context lost event is fired
  40890. * @param callback defines the callback to call
  40891. */
  40892. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40893. /**
  40894. * Attach a new callback raised when context restored event is fired
  40895. * @param callback defines the callback to call
  40896. */
  40897. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40898. /**
  40899. * Get the current error code of the webGL context
  40900. * @returns the error code
  40901. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40902. */
  40903. getError(): number;
  40904. private _canRenderToFloatFramebuffer;
  40905. private _canRenderToHalfFloatFramebuffer;
  40906. private _canRenderToFramebuffer;
  40907. /** @hidden */
  40908. _getWebGLTextureType(type: number): number;
  40909. /** @hidden */
  40910. _getInternalFormat(format: number): number;
  40911. /** @hidden */
  40912. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40913. /** @hidden */
  40914. _getRGBAMultiSampleBufferFormat(type: number): number;
  40915. /** @hidden */
  40916. _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;
  40917. /**
  40918. * Loads a file from a url
  40919. * @param url url to load
  40920. * @param onSuccess callback called when the file successfully loads
  40921. * @param onProgress callback called while file is loading (if the server supports this mode)
  40922. * @param offlineProvider defines the offline provider for caching
  40923. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40924. * @param onError callback called when the file fails to load
  40925. * @returns a file request object
  40926. * @hidden
  40927. */
  40928. 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;
  40929. /**
  40930. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40931. * @param x defines the x coordinate of the rectangle where pixels must be read
  40932. * @param y defines the y coordinate of the rectangle where pixels must be read
  40933. * @param width defines the width of the rectangle where pixels must be read
  40934. * @param height defines the height of the rectangle where pixels must be read
  40935. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40936. * @returns a Uint8Array containing RGBA colors
  40937. */
  40938. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40939. private static _IsSupported;
  40940. private static _HasMajorPerformanceCaveat;
  40941. /**
  40942. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40943. */
  40944. static get IsSupported(): boolean;
  40945. /**
  40946. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40947. * @returns true if the engine can be created
  40948. * @ignorenaming
  40949. */
  40950. static isSupported(): boolean;
  40951. /**
  40952. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  40953. */
  40954. static get HasMajorPerformanceCaveat(): boolean;
  40955. /**
  40956. * Find the next highest power of two.
  40957. * @param x Number to start search from.
  40958. * @return Next highest power of two.
  40959. */
  40960. static CeilingPOT(x: number): number;
  40961. /**
  40962. * Find the next lowest power of two.
  40963. * @param x Number to start search from.
  40964. * @return Next lowest power of two.
  40965. */
  40966. static FloorPOT(x: number): number;
  40967. /**
  40968. * Find the nearest power of two.
  40969. * @param x Number to start search from.
  40970. * @return Next nearest power of two.
  40971. */
  40972. static NearestPOT(x: number): number;
  40973. /**
  40974. * Get the closest exponent of two
  40975. * @param value defines the value to approximate
  40976. * @param max defines the maximum value to return
  40977. * @param mode defines how to define the closest value
  40978. * @returns closest exponent of two of the given value
  40979. */
  40980. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40981. /**
  40982. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40983. * @param func - the function to be called
  40984. * @param requester - the object that will request the next frame. Falls back to window.
  40985. * @returns frame number
  40986. */
  40987. static QueueNewFrame(func: () => void, requester?: any): number;
  40988. /**
  40989. * Gets host document
  40990. * @returns the host document object
  40991. */
  40992. getHostDocument(): Nullable<Document>;
  40993. }
  40994. }
  40995. declare module "babylonjs/Materials/Textures/internalTexture" {
  40996. import { Observable } from "babylonjs/Misc/observable";
  40997. import { Nullable, int } from "babylonjs/types";
  40998. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41000. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41001. /**
  41002. * Defines the source of the internal texture
  41003. */
  41004. export enum InternalTextureSource {
  41005. /**
  41006. * The source of the texture data is unknown
  41007. */
  41008. Unknown = 0,
  41009. /**
  41010. * Texture data comes from an URL
  41011. */
  41012. Url = 1,
  41013. /**
  41014. * Texture data is only used for temporary storage
  41015. */
  41016. Temp = 2,
  41017. /**
  41018. * Texture data comes from raw data (ArrayBuffer)
  41019. */
  41020. Raw = 3,
  41021. /**
  41022. * Texture content is dynamic (video or dynamic texture)
  41023. */
  41024. Dynamic = 4,
  41025. /**
  41026. * Texture content is generated by rendering to it
  41027. */
  41028. RenderTarget = 5,
  41029. /**
  41030. * Texture content is part of a multi render target process
  41031. */
  41032. MultiRenderTarget = 6,
  41033. /**
  41034. * Texture data comes from a cube data file
  41035. */
  41036. Cube = 7,
  41037. /**
  41038. * Texture data comes from a raw cube data
  41039. */
  41040. CubeRaw = 8,
  41041. /**
  41042. * Texture data come from a prefiltered cube data file
  41043. */
  41044. CubePrefiltered = 9,
  41045. /**
  41046. * Texture content is raw 3D data
  41047. */
  41048. Raw3D = 10,
  41049. /**
  41050. * Texture content is raw 2D array data
  41051. */
  41052. Raw2DArray = 11,
  41053. /**
  41054. * Texture content is a depth texture
  41055. */
  41056. Depth = 12,
  41057. /**
  41058. * Texture data comes from a raw cube data encoded with RGBD
  41059. */
  41060. CubeRawRGBD = 13
  41061. }
  41062. /**
  41063. * Class used to store data associated with WebGL texture data for the engine
  41064. * This class should not be used directly
  41065. */
  41066. export class InternalTexture {
  41067. /** @hidden */
  41068. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41069. /**
  41070. * Defines if the texture is ready
  41071. */
  41072. isReady: boolean;
  41073. /**
  41074. * Defines if the texture is a cube texture
  41075. */
  41076. isCube: boolean;
  41077. /**
  41078. * Defines if the texture contains 3D data
  41079. */
  41080. is3D: boolean;
  41081. /**
  41082. * Defines if the texture contains 2D array data
  41083. */
  41084. is2DArray: boolean;
  41085. /**
  41086. * Defines if the texture contains multiview data
  41087. */
  41088. isMultiview: boolean;
  41089. /**
  41090. * Gets the URL used to load this texture
  41091. */
  41092. url: string;
  41093. /**
  41094. * Gets the sampling mode of the texture
  41095. */
  41096. samplingMode: number;
  41097. /**
  41098. * Gets a boolean indicating if the texture needs mipmaps generation
  41099. */
  41100. generateMipMaps: boolean;
  41101. /**
  41102. * Gets the number of samples used by the texture (WebGL2+ only)
  41103. */
  41104. samples: number;
  41105. /**
  41106. * Gets the type of the texture (int, float...)
  41107. */
  41108. type: number;
  41109. /**
  41110. * Gets the format of the texture (RGB, RGBA...)
  41111. */
  41112. format: number;
  41113. /**
  41114. * Observable called when the texture is loaded
  41115. */
  41116. onLoadedObservable: Observable<InternalTexture>;
  41117. /**
  41118. * Gets the width of the texture
  41119. */
  41120. width: number;
  41121. /**
  41122. * Gets the height of the texture
  41123. */
  41124. height: number;
  41125. /**
  41126. * Gets the depth of the texture
  41127. */
  41128. depth: number;
  41129. /**
  41130. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41131. */
  41132. baseWidth: number;
  41133. /**
  41134. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41135. */
  41136. baseHeight: number;
  41137. /**
  41138. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41139. */
  41140. baseDepth: number;
  41141. /**
  41142. * Gets a boolean indicating if the texture is inverted on Y axis
  41143. */
  41144. invertY: boolean;
  41145. /** @hidden */
  41146. _invertVScale: boolean;
  41147. /** @hidden */
  41148. _associatedChannel: number;
  41149. /** @hidden */
  41150. _source: InternalTextureSource;
  41151. /** @hidden */
  41152. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41153. /** @hidden */
  41154. _bufferView: Nullable<ArrayBufferView>;
  41155. /** @hidden */
  41156. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41157. /** @hidden */
  41158. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41159. /** @hidden */
  41160. _size: number;
  41161. /** @hidden */
  41162. _extension: string;
  41163. /** @hidden */
  41164. _files: Nullable<string[]>;
  41165. /** @hidden */
  41166. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41167. /** @hidden */
  41168. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41169. /** @hidden */
  41170. _framebuffer: Nullable<WebGLFramebuffer>;
  41171. /** @hidden */
  41172. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41173. /** @hidden */
  41174. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41175. /** @hidden */
  41176. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41177. /** @hidden */
  41178. _attachments: Nullable<number[]>;
  41179. /** @hidden */
  41180. _textureArray: Nullable<InternalTexture[]>;
  41181. /** @hidden */
  41182. _cachedCoordinatesMode: Nullable<number>;
  41183. /** @hidden */
  41184. _cachedWrapU: Nullable<number>;
  41185. /** @hidden */
  41186. _cachedWrapV: Nullable<number>;
  41187. /** @hidden */
  41188. _cachedWrapR: Nullable<number>;
  41189. /** @hidden */
  41190. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41191. /** @hidden */
  41192. _isDisabled: boolean;
  41193. /** @hidden */
  41194. _compression: Nullable<string>;
  41195. /** @hidden */
  41196. _generateStencilBuffer: boolean;
  41197. /** @hidden */
  41198. _generateDepthBuffer: boolean;
  41199. /** @hidden */
  41200. _comparisonFunction: number;
  41201. /** @hidden */
  41202. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41203. /** @hidden */
  41204. _lodGenerationScale: number;
  41205. /** @hidden */
  41206. _lodGenerationOffset: number;
  41207. /** @hidden */
  41208. _depthStencilTexture: Nullable<InternalTexture>;
  41209. /** @hidden */
  41210. _colorTextureArray: Nullable<WebGLTexture>;
  41211. /** @hidden */
  41212. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41213. /** @hidden */
  41214. _lodTextureHigh: Nullable<BaseTexture>;
  41215. /** @hidden */
  41216. _lodTextureMid: Nullable<BaseTexture>;
  41217. /** @hidden */
  41218. _lodTextureLow: Nullable<BaseTexture>;
  41219. /** @hidden */
  41220. _isRGBD: boolean;
  41221. /** @hidden */
  41222. _linearSpecularLOD: boolean;
  41223. /** @hidden */
  41224. _irradianceTexture: Nullable<BaseTexture>;
  41225. /** @hidden */
  41226. _webGLTexture: Nullable<WebGLTexture>;
  41227. /** @hidden */
  41228. _references: number;
  41229. /** @hidden */
  41230. _gammaSpace: Nullable<boolean>;
  41231. private _engine;
  41232. /**
  41233. * Gets the Engine the texture belongs to.
  41234. * @returns The babylon engine
  41235. */
  41236. getEngine(): ThinEngine;
  41237. /**
  41238. * Gets the data source type of the texture
  41239. */
  41240. get source(): InternalTextureSource;
  41241. /**
  41242. * Creates a new InternalTexture
  41243. * @param engine defines the engine to use
  41244. * @param source defines the type of data that will be used
  41245. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41246. */
  41247. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41248. /**
  41249. * Increments the number of references (ie. the number of Texture that point to it)
  41250. */
  41251. incrementReferences(): void;
  41252. /**
  41253. * Change the size of the texture (not the size of the content)
  41254. * @param width defines the new width
  41255. * @param height defines the new height
  41256. * @param depth defines the new depth (1 by default)
  41257. */
  41258. updateSize(width: int, height: int, depth?: int): void;
  41259. /** @hidden */
  41260. _rebuild(): void;
  41261. /** @hidden */
  41262. _swapAndDie(target: InternalTexture): void;
  41263. /**
  41264. * Dispose the current allocated resources
  41265. */
  41266. dispose(): void;
  41267. }
  41268. }
  41269. declare module "babylonjs/Audio/analyser" {
  41270. import { Scene } from "babylonjs/scene";
  41271. /**
  41272. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41273. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41274. */
  41275. export class Analyser {
  41276. /**
  41277. * Gets or sets the smoothing
  41278. * @ignorenaming
  41279. */
  41280. SMOOTHING: number;
  41281. /**
  41282. * Gets or sets the FFT table size
  41283. * @ignorenaming
  41284. */
  41285. FFT_SIZE: number;
  41286. /**
  41287. * Gets or sets the bar graph amplitude
  41288. * @ignorenaming
  41289. */
  41290. BARGRAPHAMPLITUDE: number;
  41291. /**
  41292. * Gets or sets the position of the debug canvas
  41293. * @ignorenaming
  41294. */
  41295. DEBUGCANVASPOS: {
  41296. x: number;
  41297. y: number;
  41298. };
  41299. /**
  41300. * Gets or sets the debug canvas size
  41301. * @ignorenaming
  41302. */
  41303. DEBUGCANVASSIZE: {
  41304. width: number;
  41305. height: number;
  41306. };
  41307. private _byteFreqs;
  41308. private _byteTime;
  41309. private _floatFreqs;
  41310. private _webAudioAnalyser;
  41311. private _debugCanvas;
  41312. private _debugCanvasContext;
  41313. private _scene;
  41314. private _registerFunc;
  41315. private _audioEngine;
  41316. /**
  41317. * Creates a new analyser
  41318. * @param scene defines hosting scene
  41319. */
  41320. constructor(scene: Scene);
  41321. /**
  41322. * Get the number of data values you will have to play with for the visualization
  41323. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41324. * @returns a number
  41325. */
  41326. getFrequencyBinCount(): number;
  41327. /**
  41328. * Gets the current frequency data as a byte array
  41329. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41330. * @returns a Uint8Array
  41331. */
  41332. getByteFrequencyData(): Uint8Array;
  41333. /**
  41334. * Gets the current waveform as a byte array
  41335. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41336. * @returns a Uint8Array
  41337. */
  41338. getByteTimeDomainData(): Uint8Array;
  41339. /**
  41340. * Gets the current frequency data as a float array
  41341. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41342. * @returns a Float32Array
  41343. */
  41344. getFloatFrequencyData(): Float32Array;
  41345. /**
  41346. * Renders the debug canvas
  41347. */
  41348. drawDebugCanvas(): void;
  41349. /**
  41350. * Stops rendering the debug canvas and removes it
  41351. */
  41352. stopDebugCanvas(): void;
  41353. /**
  41354. * Connects two audio nodes
  41355. * @param inputAudioNode defines first node to connect
  41356. * @param outputAudioNode defines second node to connect
  41357. */
  41358. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41359. /**
  41360. * Releases all associated resources
  41361. */
  41362. dispose(): void;
  41363. }
  41364. }
  41365. declare module "babylonjs/Audio/audioEngine" {
  41366. import { IDisposable } from "babylonjs/scene";
  41367. import { Analyser } from "babylonjs/Audio/analyser";
  41368. import { Nullable } from "babylonjs/types";
  41369. import { Observable } from "babylonjs/Misc/observable";
  41370. /**
  41371. * This represents an audio engine and it is responsible
  41372. * to play, synchronize and analyse sounds throughout the application.
  41373. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41374. */
  41375. export interface IAudioEngine extends IDisposable {
  41376. /**
  41377. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41378. */
  41379. readonly canUseWebAudio: boolean;
  41380. /**
  41381. * Gets the current AudioContext if available.
  41382. */
  41383. readonly audioContext: Nullable<AudioContext>;
  41384. /**
  41385. * The master gain node defines the global audio volume of your audio engine.
  41386. */
  41387. readonly masterGain: GainNode;
  41388. /**
  41389. * Gets whether or not mp3 are supported by your browser.
  41390. */
  41391. readonly isMP3supported: boolean;
  41392. /**
  41393. * Gets whether or not ogg are supported by your browser.
  41394. */
  41395. readonly isOGGsupported: boolean;
  41396. /**
  41397. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41398. * @ignoreNaming
  41399. */
  41400. WarnedWebAudioUnsupported: boolean;
  41401. /**
  41402. * Defines if the audio engine relies on a custom unlocked button.
  41403. * In this case, the embedded button will not be displayed.
  41404. */
  41405. useCustomUnlockedButton: boolean;
  41406. /**
  41407. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41408. */
  41409. readonly unlocked: boolean;
  41410. /**
  41411. * Event raised when audio has been unlocked on the browser.
  41412. */
  41413. onAudioUnlockedObservable: Observable<AudioEngine>;
  41414. /**
  41415. * Event raised when audio has been locked on the browser.
  41416. */
  41417. onAudioLockedObservable: Observable<AudioEngine>;
  41418. /**
  41419. * Flags the audio engine in Locked state.
  41420. * This happens due to new browser policies preventing audio to autoplay.
  41421. */
  41422. lock(): void;
  41423. /**
  41424. * Unlocks the audio engine once a user action has been done on the dom.
  41425. * This is helpful to resume play once browser policies have been satisfied.
  41426. */
  41427. unlock(): void;
  41428. /**
  41429. * Gets the global volume sets on the master gain.
  41430. * @returns the global volume if set or -1 otherwise
  41431. */
  41432. getGlobalVolume(): number;
  41433. /**
  41434. * Sets the global volume of your experience (sets on the master gain).
  41435. * @param newVolume Defines the new global volume of the application
  41436. */
  41437. setGlobalVolume(newVolume: number): void;
  41438. /**
  41439. * Connect the audio engine to an audio analyser allowing some amazing
  41440. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41441. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41442. * @param analyser The analyser to connect to the engine
  41443. */
  41444. connectToAnalyser(analyser: Analyser): void;
  41445. }
  41446. /**
  41447. * This represents the default audio engine used in babylon.
  41448. * It is responsible to play, synchronize and analyse sounds throughout the application.
  41449. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41450. */
  41451. export class AudioEngine implements IAudioEngine {
  41452. private _audioContext;
  41453. private _audioContextInitialized;
  41454. private _muteButton;
  41455. private _hostElement;
  41456. /**
  41457. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41458. */
  41459. canUseWebAudio: boolean;
  41460. /**
  41461. * The master gain node defines the global audio volume of your audio engine.
  41462. */
  41463. masterGain: GainNode;
  41464. /**
  41465. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41466. * @ignoreNaming
  41467. */
  41468. WarnedWebAudioUnsupported: boolean;
  41469. /**
  41470. * Gets whether or not mp3 are supported by your browser.
  41471. */
  41472. isMP3supported: boolean;
  41473. /**
  41474. * Gets whether or not ogg are supported by your browser.
  41475. */
  41476. isOGGsupported: boolean;
  41477. /**
  41478. * Gets whether audio has been unlocked on the device.
  41479. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  41480. * a user interaction has happened.
  41481. */
  41482. unlocked: boolean;
  41483. /**
  41484. * Defines if the audio engine relies on a custom unlocked button.
  41485. * In this case, the embedded button will not be displayed.
  41486. */
  41487. useCustomUnlockedButton: boolean;
  41488. /**
  41489. * Event raised when audio has been unlocked on the browser.
  41490. */
  41491. onAudioUnlockedObservable: Observable<AudioEngine>;
  41492. /**
  41493. * Event raised when audio has been locked on the browser.
  41494. */
  41495. onAudioLockedObservable: Observable<AudioEngine>;
  41496. /**
  41497. * Gets the current AudioContext if available.
  41498. */
  41499. get audioContext(): Nullable<AudioContext>;
  41500. private _connectedAnalyser;
  41501. /**
  41502. * Instantiates a new audio engine.
  41503. *
  41504. * There should be only one per page as some browsers restrict the number
  41505. * of audio contexts you can create.
  41506. * @param hostElement defines the host element where to display the mute icon if necessary
  41507. */
  41508. constructor(hostElement?: Nullable<HTMLElement>);
  41509. /**
  41510. * Flags the audio engine in Locked state.
  41511. * This happens due to new browser policies preventing audio to autoplay.
  41512. */
  41513. lock(): void;
  41514. /**
  41515. * Unlocks the audio engine once a user action has been done on the dom.
  41516. * This is helpful to resume play once browser policies have been satisfied.
  41517. */
  41518. unlock(): void;
  41519. private _resumeAudioContext;
  41520. private _initializeAudioContext;
  41521. private _tryToRun;
  41522. private _triggerRunningState;
  41523. private _triggerSuspendedState;
  41524. private _displayMuteButton;
  41525. private _moveButtonToTopLeft;
  41526. private _onResize;
  41527. private _hideMuteButton;
  41528. /**
  41529. * Destroy and release the resources associated with the audio ccontext.
  41530. */
  41531. dispose(): void;
  41532. /**
  41533. * Gets the global volume sets on the master gain.
  41534. * @returns the global volume if set or -1 otherwise
  41535. */
  41536. getGlobalVolume(): number;
  41537. /**
  41538. * Sets the global volume of your experience (sets on the master gain).
  41539. * @param newVolume Defines the new global volume of the application
  41540. */
  41541. setGlobalVolume(newVolume: number): void;
  41542. /**
  41543. * Connect the audio engine to an audio analyser allowing some amazing
  41544. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41545. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41546. * @param analyser The analyser to connect to the engine
  41547. */
  41548. connectToAnalyser(analyser: Analyser): void;
  41549. }
  41550. }
  41551. declare module "babylonjs/Loading/loadingScreen" {
  41552. /**
  41553. * Interface used to present a loading screen while loading a scene
  41554. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41555. */
  41556. export interface ILoadingScreen {
  41557. /**
  41558. * Function called to display the loading screen
  41559. */
  41560. displayLoadingUI: () => void;
  41561. /**
  41562. * Function called to hide the loading screen
  41563. */
  41564. hideLoadingUI: () => void;
  41565. /**
  41566. * Gets or sets the color to use for the background
  41567. */
  41568. loadingUIBackgroundColor: string;
  41569. /**
  41570. * Gets or sets the text to display while loading
  41571. */
  41572. loadingUIText: string;
  41573. }
  41574. /**
  41575. * Class used for the default loading screen
  41576. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41577. */
  41578. export class DefaultLoadingScreen implements ILoadingScreen {
  41579. private _renderingCanvas;
  41580. private _loadingText;
  41581. private _loadingDivBackgroundColor;
  41582. private _loadingDiv;
  41583. private _loadingTextDiv;
  41584. /** Gets or sets the logo url to use for the default loading screen */
  41585. static DefaultLogoUrl: string;
  41586. /** Gets or sets the spinner url to use for the default loading screen */
  41587. static DefaultSpinnerUrl: string;
  41588. /**
  41589. * Creates a new default loading screen
  41590. * @param _renderingCanvas defines the canvas used to render the scene
  41591. * @param _loadingText defines the default text to display
  41592. * @param _loadingDivBackgroundColor defines the default background color
  41593. */
  41594. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41595. /**
  41596. * Function called to display the loading screen
  41597. */
  41598. displayLoadingUI(): void;
  41599. /**
  41600. * Function called to hide the loading screen
  41601. */
  41602. hideLoadingUI(): void;
  41603. /**
  41604. * Gets or sets the text to display while loading
  41605. */
  41606. set loadingUIText(text: string);
  41607. get loadingUIText(): string;
  41608. /**
  41609. * Gets or sets the color to use for the background
  41610. */
  41611. get loadingUIBackgroundColor(): string;
  41612. set loadingUIBackgroundColor(color: string);
  41613. private _resizeLoadingUI;
  41614. }
  41615. }
  41616. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41617. /**
  41618. * Interface for any object that can request an animation frame
  41619. */
  41620. export interface ICustomAnimationFrameRequester {
  41621. /**
  41622. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41623. */
  41624. renderFunction?: Function;
  41625. /**
  41626. * Called to request the next frame to render to
  41627. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41628. */
  41629. requestAnimationFrame: Function;
  41630. /**
  41631. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41632. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41633. */
  41634. requestID?: number;
  41635. }
  41636. }
  41637. declare module "babylonjs/Misc/performanceMonitor" {
  41638. /**
  41639. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41640. */
  41641. export class PerformanceMonitor {
  41642. private _enabled;
  41643. private _rollingFrameTime;
  41644. private _lastFrameTimeMs;
  41645. /**
  41646. * constructor
  41647. * @param frameSampleSize The number of samples required to saturate the sliding window
  41648. */
  41649. constructor(frameSampleSize?: number);
  41650. /**
  41651. * Samples current frame
  41652. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41653. */
  41654. sampleFrame(timeMs?: number): void;
  41655. /**
  41656. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41657. */
  41658. get averageFrameTime(): number;
  41659. /**
  41660. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41661. */
  41662. get averageFrameTimeVariance(): number;
  41663. /**
  41664. * Returns the frame time of the most recent frame
  41665. */
  41666. get instantaneousFrameTime(): number;
  41667. /**
  41668. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41669. */
  41670. get averageFPS(): number;
  41671. /**
  41672. * Returns the average framerate in frames per second using the most recent frame time
  41673. */
  41674. get instantaneousFPS(): number;
  41675. /**
  41676. * Returns true if enough samples have been taken to completely fill the sliding window
  41677. */
  41678. get isSaturated(): boolean;
  41679. /**
  41680. * Enables contributions to the sliding window sample set
  41681. */
  41682. enable(): void;
  41683. /**
  41684. * Disables contributions to the sliding window sample set
  41685. * Samples will not be interpolated over the disabled period
  41686. */
  41687. disable(): void;
  41688. /**
  41689. * Returns true if sampling is enabled
  41690. */
  41691. get isEnabled(): boolean;
  41692. /**
  41693. * Resets performance monitor
  41694. */
  41695. reset(): void;
  41696. }
  41697. /**
  41698. * RollingAverage
  41699. *
  41700. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41701. */
  41702. export class RollingAverage {
  41703. /**
  41704. * Current average
  41705. */
  41706. average: number;
  41707. /**
  41708. * Current variance
  41709. */
  41710. variance: number;
  41711. protected _samples: Array<number>;
  41712. protected _sampleCount: number;
  41713. protected _pos: number;
  41714. protected _m2: number;
  41715. /**
  41716. * constructor
  41717. * @param length The number of samples required to saturate the sliding window
  41718. */
  41719. constructor(length: number);
  41720. /**
  41721. * Adds a sample to the sample set
  41722. * @param v The sample value
  41723. */
  41724. add(v: number): void;
  41725. /**
  41726. * Returns previously added values or null if outside of history or outside the sliding window domain
  41727. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41728. * @return Value previously recorded with add() or null if outside of range
  41729. */
  41730. history(i: number): number;
  41731. /**
  41732. * Returns true if enough samples have been taken to completely fill the sliding window
  41733. * @return true if sample-set saturated
  41734. */
  41735. isSaturated(): boolean;
  41736. /**
  41737. * Resets the rolling average (equivalent to 0 samples taken so far)
  41738. */
  41739. reset(): void;
  41740. /**
  41741. * Wraps a value around the sample range boundaries
  41742. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41743. * @return Wrapped position in sample range
  41744. */
  41745. protected _wrapPosition(i: number): number;
  41746. }
  41747. }
  41748. declare module "babylonjs/Misc/perfCounter" {
  41749. /**
  41750. * This class is used to track a performance counter which is number based.
  41751. * The user has access to many properties which give statistics of different nature.
  41752. *
  41753. * The implementer can track two kinds of Performance Counter: time and count.
  41754. * 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.
  41755. * 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.
  41756. */
  41757. export class PerfCounter {
  41758. /**
  41759. * Gets or sets a global boolean to turn on and off all the counters
  41760. */
  41761. static Enabled: boolean;
  41762. /**
  41763. * Returns the smallest value ever
  41764. */
  41765. get min(): number;
  41766. /**
  41767. * Returns the biggest value ever
  41768. */
  41769. get max(): number;
  41770. /**
  41771. * Returns the average value since the performance counter is running
  41772. */
  41773. get average(): number;
  41774. /**
  41775. * Returns the average value of the last second the counter was monitored
  41776. */
  41777. get lastSecAverage(): number;
  41778. /**
  41779. * Returns the current value
  41780. */
  41781. get current(): number;
  41782. /**
  41783. * Gets the accumulated total
  41784. */
  41785. get total(): number;
  41786. /**
  41787. * Gets the total value count
  41788. */
  41789. get count(): number;
  41790. /**
  41791. * Creates a new counter
  41792. */
  41793. constructor();
  41794. /**
  41795. * Call this method to start monitoring a new frame.
  41796. * 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.
  41797. */
  41798. fetchNewFrame(): void;
  41799. /**
  41800. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41801. * @param newCount the count value to add to the monitored count
  41802. * @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.
  41803. */
  41804. addCount(newCount: number, fetchResult: boolean): void;
  41805. /**
  41806. * Start monitoring this performance counter
  41807. */
  41808. beginMonitoring(): void;
  41809. /**
  41810. * Compute the time lapsed since the previous beginMonitoring() call.
  41811. * @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
  41812. */
  41813. endMonitoring(newFrame?: boolean): void;
  41814. private _fetchResult;
  41815. private _startMonitoringTime;
  41816. private _min;
  41817. private _max;
  41818. private _average;
  41819. private _current;
  41820. private _totalValueCount;
  41821. private _totalAccumulated;
  41822. private _lastSecAverage;
  41823. private _lastSecAccumulated;
  41824. private _lastSecTime;
  41825. private _lastSecValueCount;
  41826. }
  41827. }
  41828. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  41829. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41830. import { Nullable } from "babylonjs/types";
  41831. module "babylonjs/Engines/thinEngine" {
  41832. interface ThinEngine {
  41833. /** @hidden */
  41834. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  41835. }
  41836. }
  41837. }
  41838. declare module "babylonjs/Engines/engine" {
  41839. import { Observable } from "babylonjs/Misc/observable";
  41840. import { Nullable } from "babylonjs/types";
  41841. import { Scene } from "babylonjs/scene";
  41842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41843. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  41844. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41845. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  41846. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41847. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41848. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  41849. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  41850. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41851. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41852. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  41853. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41854. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  41855. import "babylonjs/Engines/Extensions/engine.alpha";
  41856. import "babylonjs/Engines/Extensions/engine.readTexture";
  41857. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  41858. import { Material } from "babylonjs/Materials/material";
  41859. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41860. /**
  41861. * Defines the interface used by display changed events
  41862. */
  41863. export interface IDisplayChangedEventArgs {
  41864. /** Gets the vrDisplay object (if any) */
  41865. vrDisplay: Nullable<any>;
  41866. /** Gets a boolean indicating if webVR is supported */
  41867. vrSupported: boolean;
  41868. }
  41869. /**
  41870. * Defines the interface used by objects containing a viewport (like a camera)
  41871. */
  41872. interface IViewportOwnerLike {
  41873. /**
  41874. * Gets or sets the viewport
  41875. */
  41876. viewport: IViewportLike;
  41877. }
  41878. /**
  41879. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41880. */
  41881. export class Engine extends ThinEngine {
  41882. /** Defines that alpha blending is disabled */
  41883. static readonly ALPHA_DISABLE: number;
  41884. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41885. static readonly ALPHA_ADD: number;
  41886. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41887. static readonly ALPHA_COMBINE: number;
  41888. /** Defines that alpha blending to DEST - SRC * DEST */
  41889. static readonly ALPHA_SUBTRACT: number;
  41890. /** Defines that alpha blending to SRC * DEST */
  41891. static readonly ALPHA_MULTIPLY: number;
  41892. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41893. static readonly ALPHA_MAXIMIZED: number;
  41894. /** Defines that alpha blending to SRC + DEST */
  41895. static readonly ALPHA_ONEONE: number;
  41896. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41897. static readonly ALPHA_PREMULTIPLIED: number;
  41898. /**
  41899. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41900. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41901. */
  41902. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41903. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41904. static readonly ALPHA_INTERPOLATE: number;
  41905. /**
  41906. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41907. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41908. */
  41909. static readonly ALPHA_SCREENMODE: number;
  41910. /** Defines that the ressource is not delayed*/
  41911. static readonly DELAYLOADSTATE_NONE: number;
  41912. /** Defines that the ressource was successfully delay loaded */
  41913. static readonly DELAYLOADSTATE_LOADED: number;
  41914. /** Defines that the ressource is currently delay loading */
  41915. static readonly DELAYLOADSTATE_LOADING: number;
  41916. /** Defines that the ressource is delayed and has not started loading */
  41917. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41918. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41919. static readonly NEVER: number;
  41920. /** 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 */
  41921. static readonly ALWAYS: number;
  41922. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41923. static readonly LESS: number;
  41924. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41925. static readonly EQUAL: number;
  41926. /** 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 */
  41927. static readonly LEQUAL: number;
  41928. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41929. static readonly GREATER: number;
  41930. /** 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 */
  41931. static readonly GEQUAL: number;
  41932. /** 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 */
  41933. static readonly NOTEQUAL: number;
  41934. /** Passed to stencilOperation to specify that stencil value must be kept */
  41935. static readonly KEEP: number;
  41936. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41937. static readonly REPLACE: number;
  41938. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41939. static readonly INCR: number;
  41940. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41941. static readonly DECR: number;
  41942. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41943. static readonly INVERT: number;
  41944. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41945. static readonly INCR_WRAP: number;
  41946. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41947. static readonly DECR_WRAP: number;
  41948. /** Texture is not repeating outside of 0..1 UVs */
  41949. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41950. /** Texture is repeating outside of 0..1 UVs */
  41951. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41952. /** Texture is repeating and mirrored */
  41953. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41954. /** ALPHA */
  41955. static readonly TEXTUREFORMAT_ALPHA: number;
  41956. /** LUMINANCE */
  41957. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41958. /** LUMINANCE_ALPHA */
  41959. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41960. /** RGB */
  41961. static readonly TEXTUREFORMAT_RGB: number;
  41962. /** RGBA */
  41963. static readonly TEXTUREFORMAT_RGBA: number;
  41964. /** RED */
  41965. static readonly TEXTUREFORMAT_RED: number;
  41966. /** RED (2nd reference) */
  41967. static readonly TEXTUREFORMAT_R: number;
  41968. /** RG */
  41969. static readonly TEXTUREFORMAT_RG: number;
  41970. /** RED_INTEGER */
  41971. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41972. /** RED_INTEGER (2nd reference) */
  41973. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41974. /** RG_INTEGER */
  41975. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41976. /** RGB_INTEGER */
  41977. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41978. /** RGBA_INTEGER */
  41979. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41980. /** UNSIGNED_BYTE */
  41981. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41982. /** UNSIGNED_BYTE (2nd reference) */
  41983. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41984. /** FLOAT */
  41985. static readonly TEXTURETYPE_FLOAT: number;
  41986. /** HALF_FLOAT */
  41987. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41988. /** BYTE */
  41989. static readonly TEXTURETYPE_BYTE: number;
  41990. /** SHORT */
  41991. static readonly TEXTURETYPE_SHORT: number;
  41992. /** UNSIGNED_SHORT */
  41993. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41994. /** INT */
  41995. static readonly TEXTURETYPE_INT: number;
  41996. /** UNSIGNED_INT */
  41997. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41998. /** UNSIGNED_SHORT_4_4_4_4 */
  41999. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42000. /** UNSIGNED_SHORT_5_5_5_1 */
  42001. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42002. /** UNSIGNED_SHORT_5_6_5 */
  42003. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42004. /** UNSIGNED_INT_2_10_10_10_REV */
  42005. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42006. /** UNSIGNED_INT_24_8 */
  42007. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42008. /** UNSIGNED_INT_10F_11F_11F_REV */
  42009. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42010. /** UNSIGNED_INT_5_9_9_9_REV */
  42011. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42012. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42013. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42014. /** nearest is mag = nearest and min = nearest and mip = linear */
  42015. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42016. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42017. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42018. /** Trilinear is mag = linear and min = linear and mip = linear */
  42019. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42020. /** nearest is mag = nearest and min = nearest and mip = linear */
  42021. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42022. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42023. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42024. /** Trilinear is mag = linear and min = linear and mip = linear */
  42025. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42026. /** mag = nearest and min = nearest and mip = nearest */
  42027. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42028. /** mag = nearest and min = linear and mip = nearest */
  42029. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42030. /** mag = nearest and min = linear and mip = linear */
  42031. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42032. /** mag = nearest and min = linear and mip = none */
  42033. static readonly TEXTURE_NEAREST_LINEAR: number;
  42034. /** mag = nearest and min = nearest and mip = none */
  42035. static readonly TEXTURE_NEAREST_NEAREST: number;
  42036. /** mag = linear and min = nearest and mip = nearest */
  42037. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42038. /** mag = linear and min = nearest and mip = linear */
  42039. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42040. /** mag = linear and min = linear and mip = none */
  42041. static readonly TEXTURE_LINEAR_LINEAR: number;
  42042. /** mag = linear and min = nearest and mip = none */
  42043. static readonly TEXTURE_LINEAR_NEAREST: number;
  42044. /** Explicit coordinates mode */
  42045. static readonly TEXTURE_EXPLICIT_MODE: number;
  42046. /** Spherical coordinates mode */
  42047. static readonly TEXTURE_SPHERICAL_MODE: number;
  42048. /** Planar coordinates mode */
  42049. static readonly TEXTURE_PLANAR_MODE: number;
  42050. /** Cubic coordinates mode */
  42051. static readonly TEXTURE_CUBIC_MODE: number;
  42052. /** Projection coordinates mode */
  42053. static readonly TEXTURE_PROJECTION_MODE: number;
  42054. /** Skybox coordinates mode */
  42055. static readonly TEXTURE_SKYBOX_MODE: number;
  42056. /** Inverse Cubic coordinates mode */
  42057. static readonly TEXTURE_INVCUBIC_MODE: number;
  42058. /** Equirectangular coordinates mode */
  42059. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42060. /** Equirectangular Fixed coordinates mode */
  42061. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42062. /** Equirectangular Fixed Mirrored coordinates mode */
  42063. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42064. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42065. static readonly SCALEMODE_FLOOR: number;
  42066. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42067. static readonly SCALEMODE_NEAREST: number;
  42068. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42069. static readonly SCALEMODE_CEILING: number;
  42070. /**
  42071. * Returns the current npm package of the sdk
  42072. */
  42073. static get NpmPackage(): string;
  42074. /**
  42075. * Returns the current version of the framework
  42076. */
  42077. static get Version(): string;
  42078. /** Gets the list of created engines */
  42079. static get Instances(): Engine[];
  42080. /**
  42081. * Gets the latest created engine
  42082. */
  42083. static get LastCreatedEngine(): Nullable<Engine>;
  42084. /**
  42085. * Gets the latest created scene
  42086. */
  42087. static get LastCreatedScene(): Nullable<Scene>;
  42088. /**
  42089. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42090. * @param flag defines which part of the materials must be marked as dirty
  42091. * @param predicate defines a predicate used to filter which materials should be affected
  42092. */
  42093. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42094. /**
  42095. * Method called to create the default loading screen.
  42096. * This can be overriden in your own app.
  42097. * @param canvas The rendering canvas element
  42098. * @returns The loading screen
  42099. */
  42100. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42101. /**
  42102. * Method called to create the default rescale post process on each engine.
  42103. */
  42104. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42105. /**
  42106. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42107. **/
  42108. enableOfflineSupport: boolean;
  42109. /**
  42110. * 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)
  42111. **/
  42112. disableManifestCheck: boolean;
  42113. /**
  42114. * Gets the list of created scenes
  42115. */
  42116. scenes: Scene[];
  42117. /**
  42118. * Event raised when a new scene is created
  42119. */
  42120. onNewSceneAddedObservable: Observable<Scene>;
  42121. /**
  42122. * Gets the list of created postprocesses
  42123. */
  42124. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42125. /**
  42126. * Gets a boolean indicating if the pointer is currently locked
  42127. */
  42128. isPointerLock: boolean;
  42129. /**
  42130. * Observable event triggered each time the rendering canvas is resized
  42131. */
  42132. onResizeObservable: Observable<Engine>;
  42133. /**
  42134. * Observable event triggered each time the canvas loses focus
  42135. */
  42136. onCanvasBlurObservable: Observable<Engine>;
  42137. /**
  42138. * Observable event triggered each time the canvas gains focus
  42139. */
  42140. onCanvasFocusObservable: Observable<Engine>;
  42141. /**
  42142. * Observable event triggered each time the canvas receives pointerout event
  42143. */
  42144. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42145. /**
  42146. * Observable raised when the engine begins a new frame
  42147. */
  42148. onBeginFrameObservable: Observable<Engine>;
  42149. /**
  42150. * If set, will be used to request the next animation frame for the render loop
  42151. */
  42152. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42153. /**
  42154. * Observable raised when the engine ends the current frame
  42155. */
  42156. onEndFrameObservable: Observable<Engine>;
  42157. /**
  42158. * Observable raised when the engine is about to compile a shader
  42159. */
  42160. onBeforeShaderCompilationObservable: Observable<Engine>;
  42161. /**
  42162. * Observable raised when the engine has jsut compiled a shader
  42163. */
  42164. onAfterShaderCompilationObservable: Observable<Engine>;
  42165. /**
  42166. * Gets the audio engine
  42167. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42168. * @ignorenaming
  42169. */
  42170. static audioEngine: IAudioEngine;
  42171. /**
  42172. * Default AudioEngine factory responsible of creating the Audio Engine.
  42173. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42174. */
  42175. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42176. /**
  42177. * Default offline support factory responsible of creating a tool used to store data locally.
  42178. * By default, this will create a Database object if the workload has been embedded.
  42179. */
  42180. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42181. private _loadingScreen;
  42182. private _pointerLockRequested;
  42183. private _rescalePostProcess;
  42184. private _deterministicLockstep;
  42185. private _lockstepMaxSteps;
  42186. private _timeStep;
  42187. protected get _supportsHardwareTextureRescaling(): boolean;
  42188. private _fps;
  42189. private _deltaTime;
  42190. /** @hidden */
  42191. _drawCalls: PerfCounter;
  42192. /** 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 */
  42193. canvasTabIndex: number;
  42194. /**
  42195. * Turn this value on if you want to pause FPS computation when in background
  42196. */
  42197. disablePerformanceMonitorInBackground: boolean;
  42198. private _performanceMonitor;
  42199. /**
  42200. * Gets the performance monitor attached to this engine
  42201. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42202. */
  42203. get performanceMonitor(): PerformanceMonitor;
  42204. private _onFocus;
  42205. private _onBlur;
  42206. private _onCanvasPointerOut;
  42207. private _onCanvasBlur;
  42208. private _onCanvasFocus;
  42209. private _onFullscreenChange;
  42210. private _onPointerLockChange;
  42211. /**
  42212. * Gets the HTML element used to attach event listeners
  42213. * @returns a HTML element
  42214. */
  42215. getInputElement(): Nullable<HTMLElement>;
  42216. /**
  42217. * Creates a new engine
  42218. * @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
  42219. * @param antialias defines enable antialiasing (default: false)
  42220. * @param options defines further options to be sent to the getContext() function
  42221. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42222. */
  42223. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42224. /**
  42225. * Gets current aspect ratio
  42226. * @param viewportOwner defines the camera to use to get the aspect ratio
  42227. * @param useScreen defines if screen size must be used (or the current render target if any)
  42228. * @returns a number defining the aspect ratio
  42229. */
  42230. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42231. /**
  42232. * Gets current screen aspect ratio
  42233. * @returns a number defining the aspect ratio
  42234. */
  42235. getScreenAspectRatio(): number;
  42236. /**
  42237. * Gets the client rect of the HTML canvas attached with the current webGL context
  42238. * @returns a client rectanglee
  42239. */
  42240. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42241. /**
  42242. * Gets the client rect of the HTML element used for events
  42243. * @returns a client rectanglee
  42244. */
  42245. getInputElementClientRect(): Nullable<ClientRect>;
  42246. /**
  42247. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42248. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42249. * @returns true if engine is in deterministic lock step mode
  42250. */
  42251. isDeterministicLockStep(): boolean;
  42252. /**
  42253. * Gets the max steps when engine is running in deterministic lock step
  42254. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42255. * @returns the max steps
  42256. */
  42257. getLockstepMaxSteps(): number;
  42258. /**
  42259. * Returns the time in ms between steps when using deterministic lock step.
  42260. * @returns time step in (ms)
  42261. */
  42262. getTimeStep(): number;
  42263. /**
  42264. * Force the mipmap generation for the given render target texture
  42265. * @param texture defines the render target texture to use
  42266. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42267. */
  42268. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42269. /** States */
  42270. /**
  42271. * Set various states to the webGL context
  42272. * @param culling defines backface culling state
  42273. * @param zOffset defines the value to apply to zOffset (0 by default)
  42274. * @param force defines if states must be applied even if cache is up to date
  42275. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42276. */
  42277. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42278. /**
  42279. * Set the z offset to apply to current rendering
  42280. * @param value defines the offset to apply
  42281. */
  42282. setZOffset(value: number): void;
  42283. /**
  42284. * Gets the current value of the zOffset
  42285. * @returns the current zOffset state
  42286. */
  42287. getZOffset(): number;
  42288. /**
  42289. * Enable or disable depth buffering
  42290. * @param enable defines the state to set
  42291. */
  42292. setDepthBuffer(enable: boolean): void;
  42293. /**
  42294. * Gets a boolean indicating if depth writing is enabled
  42295. * @returns the current depth writing state
  42296. */
  42297. getDepthWrite(): boolean;
  42298. /**
  42299. * Enable or disable depth writing
  42300. * @param enable defines the state to set
  42301. */
  42302. setDepthWrite(enable: boolean): void;
  42303. /**
  42304. * Gets a boolean indicating if stencil buffer is enabled
  42305. * @returns the current stencil buffer state
  42306. */
  42307. getStencilBuffer(): boolean;
  42308. /**
  42309. * Enable or disable the stencil buffer
  42310. * @param enable defines if the stencil buffer must be enabled or disabled
  42311. */
  42312. setStencilBuffer(enable: boolean): void;
  42313. /**
  42314. * Gets the current stencil mask
  42315. * @returns a number defining the new stencil mask to use
  42316. */
  42317. getStencilMask(): number;
  42318. /**
  42319. * Sets the current stencil mask
  42320. * @param mask defines the new stencil mask to use
  42321. */
  42322. setStencilMask(mask: number): void;
  42323. /**
  42324. * Gets the current stencil function
  42325. * @returns a number defining the stencil function to use
  42326. */
  42327. getStencilFunction(): number;
  42328. /**
  42329. * Gets the current stencil reference value
  42330. * @returns a number defining the stencil reference value to use
  42331. */
  42332. getStencilFunctionReference(): number;
  42333. /**
  42334. * Gets the current stencil mask
  42335. * @returns a number defining the stencil mask to use
  42336. */
  42337. getStencilFunctionMask(): number;
  42338. /**
  42339. * Sets the current stencil function
  42340. * @param stencilFunc defines the new stencil function to use
  42341. */
  42342. setStencilFunction(stencilFunc: number): void;
  42343. /**
  42344. * Sets the current stencil reference
  42345. * @param reference defines the new stencil reference to use
  42346. */
  42347. setStencilFunctionReference(reference: number): void;
  42348. /**
  42349. * Sets the current stencil mask
  42350. * @param mask defines the new stencil mask to use
  42351. */
  42352. setStencilFunctionMask(mask: number): void;
  42353. /**
  42354. * Gets the current stencil operation when stencil fails
  42355. * @returns a number defining stencil operation to use when stencil fails
  42356. */
  42357. getStencilOperationFail(): number;
  42358. /**
  42359. * Gets the current stencil operation when depth fails
  42360. * @returns a number defining stencil operation to use when depth fails
  42361. */
  42362. getStencilOperationDepthFail(): number;
  42363. /**
  42364. * Gets the current stencil operation when stencil passes
  42365. * @returns a number defining stencil operation to use when stencil passes
  42366. */
  42367. getStencilOperationPass(): number;
  42368. /**
  42369. * Sets the stencil operation to use when stencil fails
  42370. * @param operation defines the stencil operation to use when stencil fails
  42371. */
  42372. setStencilOperationFail(operation: number): void;
  42373. /**
  42374. * Sets the stencil operation to use when depth fails
  42375. * @param operation defines the stencil operation to use when depth fails
  42376. */
  42377. setStencilOperationDepthFail(operation: number): void;
  42378. /**
  42379. * Sets the stencil operation to use when stencil passes
  42380. * @param operation defines the stencil operation to use when stencil passes
  42381. */
  42382. setStencilOperationPass(operation: number): void;
  42383. /**
  42384. * Sets a boolean indicating if the dithering state is enabled or disabled
  42385. * @param value defines the dithering state
  42386. */
  42387. setDitheringState(value: boolean): void;
  42388. /**
  42389. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42390. * @param value defines the rasterizer state
  42391. */
  42392. setRasterizerState(value: boolean): void;
  42393. /**
  42394. * Gets the current depth function
  42395. * @returns a number defining the depth function
  42396. */
  42397. getDepthFunction(): Nullable<number>;
  42398. /**
  42399. * Sets the current depth function
  42400. * @param depthFunc defines the function to use
  42401. */
  42402. setDepthFunction(depthFunc: number): void;
  42403. /**
  42404. * Sets the current depth function to GREATER
  42405. */
  42406. setDepthFunctionToGreater(): void;
  42407. /**
  42408. * Sets the current depth function to GEQUAL
  42409. */
  42410. setDepthFunctionToGreaterOrEqual(): void;
  42411. /**
  42412. * Sets the current depth function to LESS
  42413. */
  42414. setDepthFunctionToLess(): void;
  42415. /**
  42416. * Sets the current depth function to LEQUAL
  42417. */
  42418. setDepthFunctionToLessOrEqual(): void;
  42419. private _cachedStencilBuffer;
  42420. private _cachedStencilFunction;
  42421. private _cachedStencilMask;
  42422. private _cachedStencilOperationPass;
  42423. private _cachedStencilOperationFail;
  42424. private _cachedStencilOperationDepthFail;
  42425. private _cachedStencilReference;
  42426. /**
  42427. * Caches the the state of the stencil buffer
  42428. */
  42429. cacheStencilState(): void;
  42430. /**
  42431. * Restores the state of the stencil buffer
  42432. */
  42433. restoreStencilState(): void;
  42434. /**
  42435. * Directly set the WebGL Viewport
  42436. * @param x defines the x coordinate of the viewport (in screen space)
  42437. * @param y defines the y coordinate of the viewport (in screen space)
  42438. * @param width defines the width of the viewport (in screen space)
  42439. * @param height defines the height of the viewport (in screen space)
  42440. * @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
  42441. */
  42442. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42443. /**
  42444. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42445. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42446. * @param y defines the y-coordinate of the corner of the clear rectangle
  42447. * @param width defines the width of the clear rectangle
  42448. * @param height defines the height of the clear rectangle
  42449. * @param clearColor defines the clear color
  42450. */
  42451. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42452. /**
  42453. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42454. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42455. * @param y defines the y-coordinate of the corner of the clear rectangle
  42456. * @param width defines the width of the clear rectangle
  42457. * @param height defines the height of the clear rectangle
  42458. */
  42459. enableScissor(x: number, y: number, width: number, height: number): void;
  42460. /**
  42461. * Disable previously set scissor test rectangle
  42462. */
  42463. disableScissor(): void;
  42464. protected _reportDrawCall(): void;
  42465. /**
  42466. * Initializes a webVR display and starts listening to display change events
  42467. * The onVRDisplayChangedObservable will be notified upon these changes
  42468. * @returns The onVRDisplayChangedObservable
  42469. */
  42470. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42471. /** @hidden */
  42472. _prepareVRComponent(): void;
  42473. /** @hidden */
  42474. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42475. /** @hidden */
  42476. _submitVRFrame(): void;
  42477. /**
  42478. * Call this function to leave webVR mode
  42479. * Will do nothing if webVR is not supported or if there is no webVR device
  42480. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42481. */
  42482. disableVR(): void;
  42483. /**
  42484. * Gets a boolean indicating that the system is in VR mode and is presenting
  42485. * @returns true if VR mode is engaged
  42486. */
  42487. isVRPresenting(): boolean;
  42488. /** @hidden */
  42489. _requestVRFrame(): void;
  42490. /** @hidden */
  42491. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42492. /**
  42493. * Gets the source code of the vertex shader associated with a specific webGL program
  42494. * @param program defines the program to use
  42495. * @returns a string containing the source code of the vertex shader associated with the program
  42496. */
  42497. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42498. /**
  42499. * Gets the source code of the fragment shader associated with a specific webGL program
  42500. * @param program defines the program to use
  42501. * @returns a string containing the source code of the fragment shader associated with the program
  42502. */
  42503. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42504. /**
  42505. * Sets a depth stencil texture from a render target to the according uniform.
  42506. * @param channel The texture channel
  42507. * @param uniform The uniform to set
  42508. * @param texture The render target texture containing the depth stencil texture to apply
  42509. */
  42510. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42511. /**
  42512. * Sets a texture to the webGL context from a postprocess
  42513. * @param channel defines the channel to use
  42514. * @param postProcess defines the source postprocess
  42515. */
  42516. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42517. /**
  42518. * Binds the output of the passed in post process to the texture channel specified
  42519. * @param channel The channel the texture should be bound to
  42520. * @param postProcess The post process which's output should be bound
  42521. */
  42522. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42523. protected _rebuildBuffers(): void;
  42524. /** @hidden */
  42525. _renderFrame(): void;
  42526. _renderLoop(): void;
  42527. /** @hidden */
  42528. _renderViews(): boolean;
  42529. /**
  42530. * Toggle full screen mode
  42531. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42532. */
  42533. switchFullscreen(requestPointerLock: boolean): void;
  42534. /**
  42535. * Enters full screen mode
  42536. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42537. */
  42538. enterFullscreen(requestPointerLock: boolean): void;
  42539. /**
  42540. * Exits full screen mode
  42541. */
  42542. exitFullscreen(): void;
  42543. /**
  42544. * Enters Pointerlock mode
  42545. */
  42546. enterPointerlock(): void;
  42547. /**
  42548. * Exits Pointerlock mode
  42549. */
  42550. exitPointerlock(): void;
  42551. /**
  42552. * Begin a new frame
  42553. */
  42554. beginFrame(): void;
  42555. /**
  42556. * Enf the current frame
  42557. */
  42558. endFrame(): void;
  42559. resize(): void;
  42560. /**
  42561. * Force a specific size of the canvas
  42562. * @param width defines the new canvas' width
  42563. * @param height defines the new canvas' height
  42564. * @returns true if the size was changed
  42565. */
  42566. setSize(width: number, height: number): boolean;
  42567. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42568. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42569. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42570. _releaseTexture(texture: InternalTexture): void;
  42571. /**
  42572. * @hidden
  42573. * Rescales a texture
  42574. * @param source input texutre
  42575. * @param destination destination texture
  42576. * @param scene scene to use to render the resize
  42577. * @param internalFormat format to use when resizing
  42578. * @param onComplete callback to be called when resize has completed
  42579. */
  42580. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42581. /**
  42582. * Gets the current framerate
  42583. * @returns a number representing the framerate
  42584. */
  42585. getFps(): number;
  42586. /**
  42587. * Gets the time spent between current and previous frame
  42588. * @returns a number representing the delta time in ms
  42589. */
  42590. getDeltaTime(): number;
  42591. private _measureFps;
  42592. /** @hidden */
  42593. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42594. /**
  42595. * Updates the sample count of a render target texture
  42596. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42597. * @param texture defines the texture to update
  42598. * @param samples defines the sample count to set
  42599. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42600. */
  42601. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42602. /**
  42603. * Updates a depth texture Comparison Mode and Function.
  42604. * If the comparison Function is equal to 0, the mode will be set to none.
  42605. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42606. * @param texture The texture to set the comparison function for
  42607. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42608. */
  42609. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42610. /**
  42611. * Creates a webGL buffer to use with instanciation
  42612. * @param capacity defines the size of the buffer
  42613. * @returns the webGL buffer
  42614. */
  42615. createInstancesBuffer(capacity: number): DataBuffer;
  42616. /**
  42617. * Delete a webGL buffer used with instanciation
  42618. * @param buffer defines the webGL buffer to delete
  42619. */
  42620. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42621. private _clientWaitAsync;
  42622. /** @hidden */
  42623. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42624. dispose(): void;
  42625. private _disableTouchAction;
  42626. /**
  42627. * Display the loading screen
  42628. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42629. */
  42630. displayLoadingUI(): void;
  42631. /**
  42632. * Hide the loading screen
  42633. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42634. */
  42635. hideLoadingUI(): void;
  42636. /**
  42637. * Gets the current loading screen object
  42638. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42639. */
  42640. get loadingScreen(): ILoadingScreen;
  42641. /**
  42642. * Sets the current loading screen object
  42643. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42644. */
  42645. set loadingScreen(loadingScreen: ILoadingScreen);
  42646. /**
  42647. * Sets the current loading screen text
  42648. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42649. */
  42650. set loadingUIText(text: string);
  42651. /**
  42652. * Sets the current loading screen background color
  42653. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42654. */
  42655. set loadingUIBackgroundColor(color: string);
  42656. /** Pointerlock and fullscreen */
  42657. /**
  42658. * Ask the browser to promote the current element to pointerlock mode
  42659. * @param element defines the DOM element to promote
  42660. */
  42661. static _RequestPointerlock(element: HTMLElement): void;
  42662. /**
  42663. * Asks the browser to exit pointerlock mode
  42664. */
  42665. static _ExitPointerlock(): void;
  42666. /**
  42667. * Ask the browser to promote the current element to fullscreen rendering mode
  42668. * @param element defines the DOM element to promote
  42669. */
  42670. static _RequestFullscreen(element: HTMLElement): void;
  42671. /**
  42672. * Asks the browser to exit fullscreen mode
  42673. */
  42674. static _ExitFullscreen(): void;
  42675. }
  42676. }
  42677. declare module "babylonjs/Engines/engineStore" {
  42678. import { Nullable } from "babylonjs/types";
  42679. import { Engine } from "babylonjs/Engines/engine";
  42680. import { Scene } from "babylonjs/scene";
  42681. /**
  42682. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42683. * during the life time of the application.
  42684. */
  42685. export class EngineStore {
  42686. /** Gets the list of created engines */
  42687. static Instances: import("babylonjs/Engines/engine").Engine[];
  42688. /** @hidden */
  42689. static _LastCreatedScene: Nullable<Scene>;
  42690. /**
  42691. * Gets the latest created engine
  42692. */
  42693. static get LastCreatedEngine(): Nullable<Engine>;
  42694. /**
  42695. * Gets the latest created scene
  42696. */
  42697. static get LastCreatedScene(): Nullable<Scene>;
  42698. /**
  42699. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42700. * @ignorenaming
  42701. */
  42702. static UseFallbackTexture: boolean;
  42703. /**
  42704. * Texture content used if a texture cannot loaded
  42705. * @ignorenaming
  42706. */
  42707. static FallbackTexture: string;
  42708. }
  42709. }
  42710. declare module "babylonjs/Misc/promise" {
  42711. /**
  42712. * Helper class that provides a small promise polyfill
  42713. */
  42714. export class PromisePolyfill {
  42715. /**
  42716. * Static function used to check if the polyfill is required
  42717. * If this is the case then the function will inject the polyfill to window.Promise
  42718. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42719. */
  42720. static Apply(force?: boolean): void;
  42721. }
  42722. }
  42723. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  42724. /**
  42725. * Interface for screenshot methods with describe argument called `size` as object with options
  42726. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42727. */
  42728. export interface IScreenshotSize {
  42729. /**
  42730. * number in pixels for canvas height
  42731. */
  42732. height?: number;
  42733. /**
  42734. * multiplier allowing render at a higher or lower resolution
  42735. * If value is defined then height and width will be ignored and taken from camera
  42736. */
  42737. precision?: number;
  42738. /**
  42739. * number in pixels for canvas width
  42740. */
  42741. width?: number;
  42742. }
  42743. }
  42744. declare module "babylonjs/Misc/tools" {
  42745. import { Nullable, float } from "babylonjs/types";
  42746. import { DomManagement } from "babylonjs/Misc/domManagement";
  42747. import { WebRequest } from "babylonjs/Misc/webRequest";
  42748. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  42749. import { ReadFileError } from "babylonjs/Misc/fileTools";
  42750. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42751. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  42752. import { Camera } from "babylonjs/Cameras/camera";
  42753. import { Engine } from "babylonjs/Engines/engine";
  42754. interface IColor4Like {
  42755. r: float;
  42756. g: float;
  42757. b: float;
  42758. a: float;
  42759. }
  42760. /**
  42761. * Class containing a set of static utilities functions
  42762. */
  42763. export class Tools {
  42764. /**
  42765. * Gets or sets the base URL to use to load assets
  42766. */
  42767. static get BaseUrl(): string;
  42768. static set BaseUrl(value: string);
  42769. /**
  42770. * Enable/Disable Custom HTTP Request Headers globally.
  42771. * default = false
  42772. * @see CustomRequestHeaders
  42773. */
  42774. static UseCustomRequestHeaders: boolean;
  42775. /**
  42776. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42777. * i.e. when loading files, where the server/service expects an Authorization header
  42778. */
  42779. static CustomRequestHeaders: {
  42780. [key: string]: string;
  42781. };
  42782. /**
  42783. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42784. */
  42785. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42786. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42787. /**
  42788. * Default behaviour for cors in the application.
  42789. * It can be a string if the expected behavior is identical in the entire app.
  42790. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42791. */
  42792. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42793. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42794. /**
  42795. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42796. * @ignorenaming
  42797. */
  42798. static get UseFallbackTexture(): boolean;
  42799. static set UseFallbackTexture(value: boolean);
  42800. /**
  42801. * Use this object to register external classes like custom textures or material
  42802. * to allow the laoders to instantiate them
  42803. */
  42804. static get RegisteredExternalClasses(): {
  42805. [key: string]: Object;
  42806. };
  42807. static set RegisteredExternalClasses(classes: {
  42808. [key: string]: Object;
  42809. });
  42810. /**
  42811. * Texture content used if a texture cannot loaded
  42812. * @ignorenaming
  42813. */
  42814. static get fallbackTexture(): string;
  42815. static set fallbackTexture(value: string);
  42816. /**
  42817. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42818. * @param u defines the coordinate on X axis
  42819. * @param v defines the coordinate on Y axis
  42820. * @param width defines the width of the source data
  42821. * @param height defines the height of the source data
  42822. * @param pixels defines the source byte array
  42823. * @param color defines the output color
  42824. */
  42825. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42826. /**
  42827. * Interpolates between a and b via alpha
  42828. * @param a The lower value (returned when alpha = 0)
  42829. * @param b The upper value (returned when alpha = 1)
  42830. * @param alpha The interpolation-factor
  42831. * @return The mixed value
  42832. */
  42833. static Mix(a: number, b: number, alpha: number): number;
  42834. /**
  42835. * Tries to instantiate a new object from a given class name
  42836. * @param className defines the class name to instantiate
  42837. * @returns the new object or null if the system was not able to do the instantiation
  42838. */
  42839. static Instantiate(className: string): any;
  42840. /**
  42841. * Provides a slice function that will work even on IE
  42842. * @param data defines the array to slice
  42843. * @param start defines the start of the data (optional)
  42844. * @param end defines the end of the data (optional)
  42845. * @returns the new sliced array
  42846. */
  42847. static Slice<T>(data: T, start?: number, end?: number): T;
  42848. /**
  42849. * Polyfill for setImmediate
  42850. * @param action defines the action to execute after the current execution block
  42851. */
  42852. static SetImmediate(action: () => void): void;
  42853. /**
  42854. * Function indicating if a number is an exponent of 2
  42855. * @param value defines the value to test
  42856. * @returns true if the value is an exponent of 2
  42857. */
  42858. static IsExponentOfTwo(value: number): boolean;
  42859. private static _tmpFloatArray;
  42860. /**
  42861. * Returns the nearest 32-bit single precision float representation of a Number
  42862. * @param value A Number. If the parameter is of a different type, it will get converted
  42863. * to a number or to NaN if it cannot be converted
  42864. * @returns number
  42865. */
  42866. static FloatRound(value: number): number;
  42867. /**
  42868. * Extracts the filename from a path
  42869. * @param path defines the path to use
  42870. * @returns the filename
  42871. */
  42872. static GetFilename(path: string): string;
  42873. /**
  42874. * Extracts the "folder" part of a path (everything before the filename).
  42875. * @param uri The URI to extract the info from
  42876. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42877. * @returns The "folder" part of the path
  42878. */
  42879. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42880. /**
  42881. * Extracts text content from a DOM element hierarchy
  42882. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42883. */
  42884. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42885. /**
  42886. * Convert an angle in radians to degrees
  42887. * @param angle defines the angle to convert
  42888. * @returns the angle in degrees
  42889. */
  42890. static ToDegrees(angle: number): number;
  42891. /**
  42892. * Convert an angle in degrees to radians
  42893. * @param angle defines the angle to convert
  42894. * @returns the angle in radians
  42895. */
  42896. static ToRadians(angle: number): number;
  42897. /**
  42898. * Returns an array if obj is not an array
  42899. * @param obj defines the object to evaluate as an array
  42900. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42901. * @returns either obj directly if obj is an array or a new array containing obj
  42902. */
  42903. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42904. /**
  42905. * Gets the pointer prefix to use
  42906. * @param engine defines the engine we are finding the prefix for
  42907. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42908. */
  42909. static GetPointerPrefix(engine: Engine): string;
  42910. /**
  42911. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42912. * @param url define the url we are trying
  42913. * @param element define the dom element where to configure the cors policy
  42914. */
  42915. static SetCorsBehavior(url: string | string[], element: {
  42916. crossOrigin: string | null;
  42917. }): void;
  42918. /**
  42919. * Removes unwanted characters from an url
  42920. * @param url defines the url to clean
  42921. * @returns the cleaned url
  42922. */
  42923. static CleanUrl(url: string): string;
  42924. /**
  42925. * Gets or sets a function used to pre-process url before using them to load assets
  42926. */
  42927. static get PreprocessUrl(): (url: string) => string;
  42928. static set PreprocessUrl(processor: (url: string) => string);
  42929. /**
  42930. * Loads an image as an HTMLImageElement.
  42931. * @param input url string, ArrayBuffer, or Blob to load
  42932. * @param onLoad callback called when the image successfully loads
  42933. * @param onError callback called when the image fails to load
  42934. * @param offlineProvider offline provider for caching
  42935. * @param mimeType optional mime type
  42936. * @returns the HTMLImageElement of the loaded image
  42937. */
  42938. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42939. /**
  42940. * Loads a file from a url
  42941. * @param url url string, ArrayBuffer, or Blob to load
  42942. * @param onSuccess callback called when the file successfully loads
  42943. * @param onProgress callback called while file is loading (if the server supports this mode)
  42944. * @param offlineProvider defines the offline provider for caching
  42945. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42946. * @param onError callback called when the file fails to load
  42947. * @returns a file request object
  42948. */
  42949. 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;
  42950. /**
  42951. * Loads a file from a url
  42952. * @param url the file url to load
  42953. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42954. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42955. */
  42956. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42957. /**
  42958. * Load a script (identified by an url). When the url returns, the
  42959. * content of this file is added into a new script element, attached to the DOM (body element)
  42960. * @param scriptUrl defines the url of the script to laod
  42961. * @param onSuccess defines the callback called when the script is loaded
  42962. * @param onError defines the callback to call if an error occurs
  42963. * @param scriptId defines the id of the script element
  42964. */
  42965. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42966. /**
  42967. * Load an asynchronous script (identified by an url). When the url returns, the
  42968. * content of this file is added into a new script element, attached to the DOM (body element)
  42969. * @param scriptUrl defines the url of the script to laod
  42970. * @param scriptId defines the id of the script element
  42971. * @returns a promise request object
  42972. */
  42973. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42974. /**
  42975. * Loads a file from a blob
  42976. * @param fileToLoad defines the blob to use
  42977. * @param callback defines the callback to call when data is loaded
  42978. * @param progressCallback defines the callback to call during loading process
  42979. * @returns a file request object
  42980. */
  42981. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42982. /**
  42983. * Reads a file from a File object
  42984. * @param file defines the file to load
  42985. * @param onSuccess defines the callback to call when data is loaded
  42986. * @param onProgress defines the callback to call during loading process
  42987. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42988. * @param onError defines the callback to call when an error occurs
  42989. * @returns a file request object
  42990. */
  42991. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42992. /**
  42993. * Creates a data url from a given string content
  42994. * @param content defines the content to convert
  42995. * @returns the new data url link
  42996. */
  42997. static FileAsURL(content: string): string;
  42998. /**
  42999. * Format the given number to a specific decimal format
  43000. * @param value defines the number to format
  43001. * @param decimals defines the number of decimals to use
  43002. * @returns the formatted string
  43003. */
  43004. static Format(value: number, decimals?: number): string;
  43005. /**
  43006. * Tries to copy an object by duplicating every property
  43007. * @param source defines the source object
  43008. * @param destination defines the target object
  43009. * @param doNotCopyList defines a list of properties to avoid
  43010. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43011. */
  43012. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43013. /**
  43014. * Gets a boolean indicating if the given object has no own property
  43015. * @param obj defines the object to test
  43016. * @returns true if object has no own property
  43017. */
  43018. static IsEmpty(obj: any): boolean;
  43019. /**
  43020. * Function used to register events at window level
  43021. * @param windowElement defines the Window object to use
  43022. * @param events defines the events to register
  43023. */
  43024. static RegisterTopRootEvents(windowElement: Window, events: {
  43025. name: string;
  43026. handler: Nullable<(e: FocusEvent) => any>;
  43027. }[]): void;
  43028. /**
  43029. * Function used to unregister events from window level
  43030. * @param windowElement defines the Window object to use
  43031. * @param events defines the events to unregister
  43032. */
  43033. static UnregisterTopRootEvents(windowElement: Window, events: {
  43034. name: string;
  43035. handler: Nullable<(e: FocusEvent) => any>;
  43036. }[]): void;
  43037. /**
  43038. * @ignore
  43039. */
  43040. static _ScreenshotCanvas: HTMLCanvasElement;
  43041. /**
  43042. * Dumps the current bound framebuffer
  43043. * @param width defines the rendering width
  43044. * @param height defines the rendering height
  43045. * @param engine defines the hosting engine
  43046. * @param successCallback defines the callback triggered once the data are available
  43047. * @param mimeType defines the mime type of the result
  43048. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43049. */
  43050. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43051. /**
  43052. * Converts the canvas data to blob.
  43053. * This acts as a polyfill for browsers not supporting the to blob function.
  43054. * @param canvas Defines the canvas to extract the data from
  43055. * @param successCallback Defines the callback triggered once the data are available
  43056. * @param mimeType Defines the mime type of the result
  43057. */
  43058. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43059. /**
  43060. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43061. * @param successCallback defines the callback triggered once the data are available
  43062. * @param mimeType defines the mime type of the result
  43063. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43064. */
  43065. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43066. /**
  43067. * Downloads a blob in the browser
  43068. * @param blob defines the blob to download
  43069. * @param fileName defines the name of the downloaded file
  43070. */
  43071. static Download(blob: Blob, fileName: string): void;
  43072. /**
  43073. * Captures a screenshot of the current rendering
  43074. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43075. * @param engine defines the rendering engine
  43076. * @param camera defines the source camera
  43077. * @param size This parameter can be set to a single number or to an object with the
  43078. * following (optional) properties: precision, width, height. If a single number is passed,
  43079. * it will be used for both width and height. If an object is passed, the screenshot size
  43080. * will be derived from the parameters. The precision property is a multiplier allowing
  43081. * rendering at a higher or lower resolution
  43082. * @param successCallback defines the callback receives a single parameter which contains the
  43083. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43084. * src parameter of an <img> to display it
  43085. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43086. * Check your browser for supported MIME types
  43087. */
  43088. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43089. /**
  43090. * Captures a screenshot of the current rendering
  43091. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43092. * @param engine defines the rendering engine
  43093. * @param camera defines the source camera
  43094. * @param size This parameter can be set to a single number or to an object with the
  43095. * following (optional) properties: precision, width, height. If a single number is passed,
  43096. * it will be used for both width and height. If an object is passed, the screenshot size
  43097. * will be derived from the parameters. The precision property is a multiplier allowing
  43098. * rendering at a higher or lower resolution
  43099. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43100. * Check your browser for supported MIME types
  43101. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43102. * to the src parameter of an <img> to display it
  43103. */
  43104. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43105. /**
  43106. * Generates an image screenshot from the specified camera.
  43107. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43108. * @param engine The engine to use for rendering
  43109. * @param camera The camera to use for rendering
  43110. * @param size This parameter can be set to a single number or to an object with the
  43111. * following (optional) properties: precision, width, height. If a single number is passed,
  43112. * it will be used for both width and height. If an object is passed, the screenshot size
  43113. * will be derived from the parameters. The precision property is a multiplier allowing
  43114. * rendering at a higher or lower resolution
  43115. * @param successCallback The callback receives a single parameter which contains the
  43116. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43117. * src parameter of an <img> to display it
  43118. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43119. * Check your browser for supported MIME types
  43120. * @param samples Texture samples (default: 1)
  43121. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43122. * @param fileName A name for for the downloaded file.
  43123. */
  43124. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43125. /**
  43126. * Generates an image screenshot from the specified camera.
  43127. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43128. * @param engine The engine to use for rendering
  43129. * @param camera The camera to use for rendering
  43130. * @param size This parameter can be set to a single number or to an object with the
  43131. * following (optional) properties: precision, width, height. If a single number is passed,
  43132. * it will be used for both width and height. If an object is passed, the screenshot size
  43133. * will be derived from the parameters. The precision property is a multiplier allowing
  43134. * rendering at a higher or lower resolution
  43135. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43136. * Check your browser for supported MIME types
  43137. * @param samples Texture samples (default: 1)
  43138. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43139. * @param fileName A name for for the downloaded file.
  43140. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43141. * to the src parameter of an <img> to display it
  43142. */
  43143. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43144. /**
  43145. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43146. * Be aware Math.random() could cause collisions, but:
  43147. * "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"
  43148. * @returns a pseudo random id
  43149. */
  43150. static RandomId(): string;
  43151. /**
  43152. * Test if the given uri is a base64 string
  43153. * @param uri The uri to test
  43154. * @return True if the uri is a base64 string or false otherwise
  43155. */
  43156. static IsBase64(uri: string): boolean;
  43157. /**
  43158. * Decode the given base64 uri.
  43159. * @param uri The uri to decode
  43160. * @return The decoded base64 data.
  43161. */
  43162. static DecodeBase64(uri: string): ArrayBuffer;
  43163. /**
  43164. * Gets the absolute url.
  43165. * @param url the input url
  43166. * @return the absolute url
  43167. */
  43168. static GetAbsoluteUrl(url: string): string;
  43169. /**
  43170. * No log
  43171. */
  43172. static readonly NoneLogLevel: number;
  43173. /**
  43174. * Only message logs
  43175. */
  43176. static readonly MessageLogLevel: number;
  43177. /**
  43178. * Only warning logs
  43179. */
  43180. static readonly WarningLogLevel: number;
  43181. /**
  43182. * Only error logs
  43183. */
  43184. static readonly ErrorLogLevel: number;
  43185. /**
  43186. * All logs
  43187. */
  43188. static readonly AllLogLevel: number;
  43189. /**
  43190. * Gets a value indicating the number of loading errors
  43191. * @ignorenaming
  43192. */
  43193. static get errorsCount(): number;
  43194. /**
  43195. * Callback called when a new log is added
  43196. */
  43197. static OnNewCacheEntry: (entry: string) => void;
  43198. /**
  43199. * Log a message to the console
  43200. * @param message defines the message to log
  43201. */
  43202. static Log(message: string): void;
  43203. /**
  43204. * Write a warning message to the console
  43205. * @param message defines the message to log
  43206. */
  43207. static Warn(message: string): void;
  43208. /**
  43209. * Write an error message to the console
  43210. * @param message defines the message to log
  43211. */
  43212. static Error(message: string): void;
  43213. /**
  43214. * Gets current log cache (list of logs)
  43215. */
  43216. static get LogCache(): string;
  43217. /**
  43218. * Clears the log cache
  43219. */
  43220. static ClearLogCache(): void;
  43221. /**
  43222. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43223. */
  43224. static set LogLevels(level: number);
  43225. /**
  43226. * Checks if the window object exists
  43227. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43228. */
  43229. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43230. /**
  43231. * No performance log
  43232. */
  43233. static readonly PerformanceNoneLogLevel: number;
  43234. /**
  43235. * Use user marks to log performance
  43236. */
  43237. static readonly PerformanceUserMarkLogLevel: number;
  43238. /**
  43239. * Log performance to the console
  43240. */
  43241. static readonly PerformanceConsoleLogLevel: number;
  43242. private static _performance;
  43243. /**
  43244. * Sets the current performance log level
  43245. */
  43246. static set PerformanceLogLevel(level: number);
  43247. private static _StartPerformanceCounterDisabled;
  43248. private static _EndPerformanceCounterDisabled;
  43249. private static _StartUserMark;
  43250. private static _EndUserMark;
  43251. private static _StartPerformanceConsole;
  43252. private static _EndPerformanceConsole;
  43253. /**
  43254. * Starts a performance counter
  43255. */
  43256. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43257. /**
  43258. * Ends a specific performance coutner
  43259. */
  43260. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43261. /**
  43262. * Gets either window.performance.now() if supported or Date.now() else
  43263. */
  43264. static get Now(): number;
  43265. /**
  43266. * This method will return the name of the class used to create the instance of the given object.
  43267. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43268. * @param object the object to get the class name from
  43269. * @param isType defines if the object is actually a type
  43270. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43271. */
  43272. static GetClassName(object: any, isType?: boolean): string;
  43273. /**
  43274. * Gets the first element of an array satisfying a given predicate
  43275. * @param array defines the array to browse
  43276. * @param predicate defines the predicate to use
  43277. * @returns null if not found or the element
  43278. */
  43279. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43280. /**
  43281. * This method will return the name of the full name of the class, including its owning module (if any).
  43282. * 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).
  43283. * @param object the object to get the class name from
  43284. * @param isType defines if the object is actually a type
  43285. * @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.
  43286. * @ignorenaming
  43287. */
  43288. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43289. /**
  43290. * Returns a promise that resolves after the given amount of time.
  43291. * @param delay Number of milliseconds to delay
  43292. * @returns Promise that resolves after the given amount of time
  43293. */
  43294. static DelayAsync(delay: number): Promise<void>;
  43295. /**
  43296. * Utility function to detect if the current user agent is Safari
  43297. * @returns whether or not the current user agent is safari
  43298. */
  43299. static IsSafari(): boolean;
  43300. }
  43301. /**
  43302. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43303. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43304. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43305. * @param name The name of the class, case should be preserved
  43306. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43307. */
  43308. export function className(name: string, module?: string): (target: Object) => void;
  43309. /**
  43310. * An implementation of a loop for asynchronous functions.
  43311. */
  43312. export class AsyncLoop {
  43313. /**
  43314. * Defines the number of iterations for the loop
  43315. */
  43316. iterations: number;
  43317. /**
  43318. * Defines the current index of the loop.
  43319. */
  43320. index: number;
  43321. private _done;
  43322. private _fn;
  43323. private _successCallback;
  43324. /**
  43325. * Constructor.
  43326. * @param iterations the number of iterations.
  43327. * @param func the function to run each iteration
  43328. * @param successCallback the callback that will be called upon succesful execution
  43329. * @param offset starting offset.
  43330. */
  43331. constructor(
  43332. /**
  43333. * Defines the number of iterations for the loop
  43334. */
  43335. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43336. /**
  43337. * Execute the next iteration. Must be called after the last iteration was finished.
  43338. */
  43339. executeNext(): void;
  43340. /**
  43341. * Break the loop and run the success callback.
  43342. */
  43343. breakLoop(): void;
  43344. /**
  43345. * Create and run an async loop.
  43346. * @param iterations the number of iterations.
  43347. * @param fn the function to run each iteration
  43348. * @param successCallback the callback that will be called upon succesful execution
  43349. * @param offset starting offset.
  43350. * @returns the created async loop object
  43351. */
  43352. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43353. /**
  43354. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43355. * @param iterations total number of iterations
  43356. * @param syncedIterations number of synchronous iterations in each async iteration.
  43357. * @param fn the function to call each iteration.
  43358. * @param callback a success call back that will be called when iterating stops.
  43359. * @param breakFunction a break condition (optional)
  43360. * @param timeout timeout settings for the setTimeout function. default - 0.
  43361. * @returns the created async loop object
  43362. */
  43363. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43364. }
  43365. }
  43366. declare module "babylonjs/Misc/stringDictionary" {
  43367. import { Nullable } from "babylonjs/types";
  43368. /**
  43369. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43370. * The underlying implementation relies on an associative array to ensure the best performances.
  43371. * The value can be anything including 'null' but except 'undefined'
  43372. */
  43373. export class StringDictionary<T> {
  43374. /**
  43375. * This will clear this dictionary and copy the content from the 'source' one.
  43376. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43377. * @param source the dictionary to take the content from and copy to this dictionary
  43378. */
  43379. copyFrom(source: StringDictionary<T>): void;
  43380. /**
  43381. * Get a value based from its key
  43382. * @param key the given key to get the matching value from
  43383. * @return the value if found, otherwise undefined is returned
  43384. */
  43385. get(key: string): T | undefined;
  43386. /**
  43387. * Get a value from its key or add it if it doesn't exist.
  43388. * This method will ensure you that a given key/data will be present in the dictionary.
  43389. * @param key the given key to get the matching value from
  43390. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43391. * The factory will only be invoked if there's no data for the given key.
  43392. * @return the value corresponding to the key.
  43393. */
  43394. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43395. /**
  43396. * Get a value from its key if present in the dictionary otherwise add it
  43397. * @param key the key to get the value from
  43398. * @param val if there's no such key/value pair in the dictionary add it with this value
  43399. * @return the value corresponding to the key
  43400. */
  43401. getOrAdd(key: string, val: T): T;
  43402. /**
  43403. * Check if there's a given key in the dictionary
  43404. * @param key the key to check for
  43405. * @return true if the key is present, false otherwise
  43406. */
  43407. contains(key: string): boolean;
  43408. /**
  43409. * Add a new key and its corresponding value
  43410. * @param key the key to add
  43411. * @param value the value corresponding to the key
  43412. * @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
  43413. */
  43414. add(key: string, value: T): boolean;
  43415. /**
  43416. * Update a specific value associated to a key
  43417. * @param key defines the key to use
  43418. * @param value defines the value to store
  43419. * @returns true if the value was updated (or false if the key was not found)
  43420. */
  43421. set(key: string, value: T): boolean;
  43422. /**
  43423. * Get the element of the given key and remove it from the dictionary
  43424. * @param key defines the key to search
  43425. * @returns the value associated with the key or null if not found
  43426. */
  43427. getAndRemove(key: string): Nullable<T>;
  43428. /**
  43429. * Remove a key/value from the dictionary.
  43430. * @param key the key to remove
  43431. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43432. */
  43433. remove(key: string): boolean;
  43434. /**
  43435. * Clear the whole content of the dictionary
  43436. */
  43437. clear(): void;
  43438. /**
  43439. * Gets the current count
  43440. */
  43441. get count(): number;
  43442. /**
  43443. * Execute a callback on each key/val of the dictionary.
  43444. * Note that you can remove any element in this dictionary in the callback implementation
  43445. * @param callback the callback to execute on a given key/value pair
  43446. */
  43447. forEach(callback: (key: string, val: T) => void): void;
  43448. /**
  43449. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43450. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43451. * Note that you can remove any element in this dictionary in the callback implementation
  43452. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43453. * @returns the first item
  43454. */
  43455. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43456. private _count;
  43457. private _data;
  43458. }
  43459. }
  43460. declare module "babylonjs/Collisions/collisionCoordinator" {
  43461. import { Nullable } from "babylonjs/types";
  43462. import { Scene } from "babylonjs/scene";
  43463. import { Vector3 } from "babylonjs/Maths/math.vector";
  43464. import { Collider } from "babylonjs/Collisions/collider";
  43465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43466. /** @hidden */
  43467. export interface ICollisionCoordinator {
  43468. createCollider(): Collider;
  43469. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43470. init(scene: Scene): void;
  43471. }
  43472. /** @hidden */
  43473. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43474. private _scene;
  43475. private _scaledPosition;
  43476. private _scaledVelocity;
  43477. private _finalPosition;
  43478. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43479. createCollider(): Collider;
  43480. init(scene: Scene): void;
  43481. private _collideWithWorld;
  43482. }
  43483. }
  43484. declare module "babylonjs/Inputs/scene.inputManager" {
  43485. import { Nullable } from "babylonjs/types";
  43486. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43487. import { Vector2 } from "babylonjs/Maths/math.vector";
  43488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43489. import { Scene } from "babylonjs/scene";
  43490. /**
  43491. * Class used to manage all inputs for the scene.
  43492. */
  43493. export class InputManager {
  43494. /** The distance in pixel that you have to move to prevent some events */
  43495. static DragMovementThreshold: number;
  43496. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43497. static LongPressDelay: number;
  43498. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43499. static DoubleClickDelay: number;
  43500. /** If you need to check double click without raising a single click at first click, enable this flag */
  43501. static ExclusiveDoubleClickMode: boolean;
  43502. /** 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. */
  43503. private _alreadyAttached;
  43504. private _alreadyAttachedTo;
  43505. private _wheelEventName;
  43506. private _onPointerMove;
  43507. private _onPointerDown;
  43508. private _onPointerUp;
  43509. private _initClickEvent;
  43510. private _initActionManager;
  43511. private _delayedSimpleClick;
  43512. private _delayedSimpleClickTimeout;
  43513. private _previousDelayedSimpleClickTimeout;
  43514. private _meshPickProceed;
  43515. private _previousButtonPressed;
  43516. private _currentPickResult;
  43517. private _previousPickResult;
  43518. private _totalPointersPressed;
  43519. private _doubleClickOccured;
  43520. private _pointerOverMesh;
  43521. private _pickedDownMesh;
  43522. private _pickedUpMesh;
  43523. private _pointerX;
  43524. private _pointerY;
  43525. private _unTranslatedPointerX;
  43526. private _unTranslatedPointerY;
  43527. private _startingPointerPosition;
  43528. private _previousStartingPointerPosition;
  43529. private _startingPointerTime;
  43530. private _previousStartingPointerTime;
  43531. private _pointerCaptures;
  43532. private _meshUnderPointerId;
  43533. private _onKeyDown;
  43534. private _onKeyUp;
  43535. private _keyboardIsAttached;
  43536. private _onCanvasFocusObserver;
  43537. private _onCanvasBlurObserver;
  43538. private _scene;
  43539. /**
  43540. * Creates a new InputManager
  43541. * @param scene defines the hosting scene
  43542. */
  43543. constructor(scene: Scene);
  43544. /**
  43545. * Gets the mesh that is currently under the pointer
  43546. */
  43547. get meshUnderPointer(): Nullable<AbstractMesh>;
  43548. /**
  43549. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43550. * @param pointerId the pointer id to use
  43551. * @returns The mesh under this pointer id or null if not found
  43552. */
  43553. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43554. /**
  43555. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43556. */
  43557. get unTranslatedPointer(): Vector2;
  43558. /**
  43559. * Gets or sets the current on-screen X position of the pointer
  43560. */
  43561. get pointerX(): number;
  43562. set pointerX(value: number);
  43563. /**
  43564. * Gets or sets the current on-screen Y position of the pointer
  43565. */
  43566. get pointerY(): number;
  43567. set pointerY(value: number);
  43568. private _updatePointerPosition;
  43569. private _processPointerMove;
  43570. private _setRayOnPointerInfo;
  43571. private _checkPrePointerObservable;
  43572. /**
  43573. * Use this method to simulate a pointer move on a mesh
  43574. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43575. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43576. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43577. */
  43578. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43579. /**
  43580. * Use this method to simulate a pointer down on a mesh
  43581. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43582. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43583. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43584. */
  43585. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43586. private _processPointerDown;
  43587. /** @hidden */
  43588. _isPointerSwiping(): boolean;
  43589. /**
  43590. * Use this method to simulate a pointer up on a mesh
  43591. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43592. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43593. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43594. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43595. */
  43596. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43597. private _processPointerUp;
  43598. /**
  43599. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43600. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43601. * @returns true if the pointer was captured
  43602. */
  43603. isPointerCaptured(pointerId?: number): boolean;
  43604. /**
  43605. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43606. * @param attachUp defines if you want to attach events to pointerup
  43607. * @param attachDown defines if you want to attach events to pointerdown
  43608. * @param attachMove defines if you want to attach events to pointermove
  43609. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43610. */
  43611. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43612. /**
  43613. * Detaches all event handlers
  43614. */
  43615. detachControl(): void;
  43616. /**
  43617. * Force the value of meshUnderPointer
  43618. * @param mesh defines the mesh to use
  43619. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43620. */
  43621. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43622. /**
  43623. * Gets the mesh under the pointer
  43624. * @returns a Mesh or null if no mesh is under the pointer
  43625. */
  43626. getPointerOverMesh(): Nullable<AbstractMesh>;
  43627. }
  43628. }
  43629. declare module "babylonjs/Animations/animationGroup" {
  43630. import { Animatable } from "babylonjs/Animations/animatable";
  43631. import { Animation } from "babylonjs/Animations/animation";
  43632. import { Scene, IDisposable } from "babylonjs/scene";
  43633. import { Observable } from "babylonjs/Misc/observable";
  43634. import { Nullable } from "babylonjs/types";
  43635. import "babylonjs/Animations/animatable";
  43636. /**
  43637. * This class defines the direct association between an animation and a target
  43638. */
  43639. export class TargetedAnimation {
  43640. /**
  43641. * Animation to perform
  43642. */
  43643. animation: Animation;
  43644. /**
  43645. * Target to animate
  43646. */
  43647. target: any;
  43648. /**
  43649. * Returns the string "TargetedAnimation"
  43650. * @returns "TargetedAnimation"
  43651. */
  43652. getClassName(): string;
  43653. /**
  43654. * Serialize the object
  43655. * @returns the JSON object representing the current entity
  43656. */
  43657. serialize(): any;
  43658. }
  43659. /**
  43660. * Use this class to create coordinated animations on multiple targets
  43661. */
  43662. export class AnimationGroup implements IDisposable {
  43663. /** The name of the animation group */
  43664. name: string;
  43665. private _scene;
  43666. private _targetedAnimations;
  43667. private _animatables;
  43668. private _from;
  43669. private _to;
  43670. private _isStarted;
  43671. private _isPaused;
  43672. private _speedRatio;
  43673. private _loopAnimation;
  43674. private _isAdditive;
  43675. /**
  43676. * Gets or sets the unique id of the node
  43677. */
  43678. uniqueId: number;
  43679. /**
  43680. * This observable will notify when one animation have ended
  43681. */
  43682. onAnimationEndObservable: Observable<TargetedAnimation>;
  43683. /**
  43684. * Observer raised when one animation loops
  43685. */
  43686. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43687. /**
  43688. * Observer raised when all animations have looped
  43689. */
  43690. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43691. /**
  43692. * This observable will notify when all animations have ended.
  43693. */
  43694. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43695. /**
  43696. * This observable will notify when all animations have paused.
  43697. */
  43698. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43699. /**
  43700. * This observable will notify when all animations are playing.
  43701. */
  43702. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43703. /**
  43704. * Gets the first frame
  43705. */
  43706. get from(): number;
  43707. /**
  43708. * Gets the last frame
  43709. */
  43710. get to(): number;
  43711. /**
  43712. * Define if the animations are started
  43713. */
  43714. get isStarted(): boolean;
  43715. /**
  43716. * Gets a value indicating that the current group is playing
  43717. */
  43718. get isPlaying(): boolean;
  43719. /**
  43720. * Gets or sets the speed ratio to use for all animations
  43721. */
  43722. get speedRatio(): number;
  43723. /**
  43724. * Gets or sets the speed ratio to use for all animations
  43725. */
  43726. set speedRatio(value: number);
  43727. /**
  43728. * Gets or sets if all animations should loop or not
  43729. */
  43730. get loopAnimation(): boolean;
  43731. set loopAnimation(value: boolean);
  43732. /**
  43733. * Gets or sets if all animations should be evaluated additively
  43734. */
  43735. get isAdditive(): boolean;
  43736. set isAdditive(value: boolean);
  43737. /**
  43738. * Gets the targeted animations for this animation group
  43739. */
  43740. get targetedAnimations(): Array<TargetedAnimation>;
  43741. /**
  43742. * returning the list of animatables controlled by this animation group.
  43743. */
  43744. get animatables(): Array<Animatable>;
  43745. /**
  43746. * Gets the list of target animations
  43747. */
  43748. get children(): TargetedAnimation[];
  43749. /**
  43750. * Instantiates a new Animation Group.
  43751. * This helps managing several animations at once.
  43752. * @see https://doc.babylonjs.com/how_to/group
  43753. * @param name Defines the name of the group
  43754. * @param scene Defines the scene the group belongs to
  43755. */
  43756. constructor(
  43757. /** The name of the animation group */
  43758. name: string, scene?: Nullable<Scene>);
  43759. /**
  43760. * Add an animation (with its target) in the group
  43761. * @param animation defines the animation we want to add
  43762. * @param target defines the target of the animation
  43763. * @returns the TargetedAnimation object
  43764. */
  43765. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43766. /**
  43767. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43768. * It can add constant keys at begin or end
  43769. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43770. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43771. * @returns the animation group
  43772. */
  43773. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43774. private _animationLoopCount;
  43775. private _animationLoopFlags;
  43776. private _processLoop;
  43777. /**
  43778. * Start all animations on given targets
  43779. * @param loop defines if animations must loop
  43780. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43781. * @param from defines the from key (optional)
  43782. * @param to defines the to key (optional)
  43783. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43784. * @returns the current animation group
  43785. */
  43786. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43787. /**
  43788. * Pause all animations
  43789. * @returns the animation group
  43790. */
  43791. pause(): AnimationGroup;
  43792. /**
  43793. * Play all animations to initial state
  43794. * This function will start() the animations if they were not started or will restart() them if they were paused
  43795. * @param loop defines if animations must loop
  43796. * @returns the animation group
  43797. */
  43798. play(loop?: boolean): AnimationGroup;
  43799. /**
  43800. * Reset all animations to initial state
  43801. * @returns the animation group
  43802. */
  43803. reset(): AnimationGroup;
  43804. /**
  43805. * Restart animations from key 0
  43806. * @returns the animation group
  43807. */
  43808. restart(): AnimationGroup;
  43809. /**
  43810. * Stop all animations
  43811. * @returns the animation group
  43812. */
  43813. stop(): AnimationGroup;
  43814. /**
  43815. * Set animation weight for all animatables
  43816. * @param weight defines the weight to use
  43817. * @return the animationGroup
  43818. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43819. */
  43820. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43821. /**
  43822. * Synchronize and normalize all animatables with a source animatable
  43823. * @param root defines the root animatable to synchronize with
  43824. * @return the animationGroup
  43825. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43826. */
  43827. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43828. /**
  43829. * Goes to a specific frame in this animation group
  43830. * @param frame the frame number to go to
  43831. * @return the animationGroup
  43832. */
  43833. goToFrame(frame: number): AnimationGroup;
  43834. /**
  43835. * Dispose all associated resources
  43836. */
  43837. dispose(): void;
  43838. private _checkAnimationGroupEnded;
  43839. /**
  43840. * Clone the current animation group and returns a copy
  43841. * @param newName defines the name of the new group
  43842. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43843. * @returns the new aniamtion group
  43844. */
  43845. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43846. /**
  43847. * Serializes the animationGroup to an object
  43848. * @returns Serialized object
  43849. */
  43850. serialize(): any;
  43851. /**
  43852. * Returns a new AnimationGroup object parsed from the source provided.
  43853. * @param parsedAnimationGroup defines the source
  43854. * @param scene defines the scene that will receive the animationGroup
  43855. * @returns a new AnimationGroup
  43856. */
  43857. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43858. /**
  43859. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43860. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43861. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43862. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43863. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43864. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43865. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43866. */
  43867. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43868. /**
  43869. * Returns the string "AnimationGroup"
  43870. * @returns "AnimationGroup"
  43871. */
  43872. getClassName(): string;
  43873. /**
  43874. * Creates a detailled string about the object
  43875. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43876. * @returns a string representing the object
  43877. */
  43878. toString(fullDetails?: boolean): string;
  43879. }
  43880. }
  43881. declare module "babylonjs/scene" {
  43882. import { Nullable } from "babylonjs/types";
  43883. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  43884. import { Observable } from "babylonjs/Misc/observable";
  43885. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43886. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  43887. import { Geometry } from "babylonjs/Meshes/geometry";
  43888. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43889. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43891. import { Mesh } from "babylonjs/Meshes/mesh";
  43892. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43893. import { Bone } from "babylonjs/Bones/bone";
  43894. import { Skeleton } from "babylonjs/Bones/skeleton";
  43895. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  43896. import { Camera } from "babylonjs/Cameras/camera";
  43897. import { AbstractScene } from "babylonjs/abstractScene";
  43898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43899. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43900. import { Material } from "babylonjs/Materials/material";
  43901. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43902. import { Effect } from "babylonjs/Materials/effect";
  43903. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  43904. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  43905. import { Light } from "babylonjs/Lights/light";
  43906. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43907. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  43908. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  43909. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  43910. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  43911. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43912. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  43913. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  43914. import { Engine } from "babylonjs/Engines/engine";
  43915. import { Node } from "babylonjs/node";
  43916. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  43917. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  43918. import { WebRequest } from "babylonjs/Misc/webRequest";
  43919. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  43920. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43921. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43922. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  43923. import { Plane } from "babylonjs/Maths/math.plane";
  43924. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  43925. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  43926. import { Ray } from "babylonjs/Culling/ray";
  43927. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  43928. import { Animation } from "babylonjs/Animations/animation";
  43929. import { Animatable } from "babylonjs/Animations/animatable";
  43930. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43931. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  43932. import { Collider } from "babylonjs/Collisions/collider";
  43933. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43934. /**
  43935. * Define an interface for all classes that will hold resources
  43936. */
  43937. export interface IDisposable {
  43938. /**
  43939. * Releases all held resources
  43940. */
  43941. dispose(): void;
  43942. }
  43943. /** Interface defining initialization parameters for Scene class */
  43944. export interface SceneOptions {
  43945. /**
  43946. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  43947. * It will improve performance when the number of geometries becomes important.
  43948. */
  43949. useGeometryUniqueIdsMap?: boolean;
  43950. /**
  43951. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  43952. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43953. */
  43954. useMaterialMeshMap?: boolean;
  43955. /**
  43956. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  43957. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43958. */
  43959. useClonedMeshMap?: boolean;
  43960. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  43961. virtual?: boolean;
  43962. }
  43963. /**
  43964. * Represents a scene to be rendered by the engine.
  43965. * @see https://doc.babylonjs.com/features/scene
  43966. */
  43967. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  43968. /** The fog is deactivated */
  43969. static readonly FOGMODE_NONE: number;
  43970. /** The fog density is following an exponential function */
  43971. static readonly FOGMODE_EXP: number;
  43972. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  43973. static readonly FOGMODE_EXP2: number;
  43974. /** The fog density is following a linear function. */
  43975. static readonly FOGMODE_LINEAR: number;
  43976. /**
  43977. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  43978. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43979. */
  43980. static MinDeltaTime: number;
  43981. /**
  43982. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  43983. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43984. */
  43985. static MaxDeltaTime: number;
  43986. /**
  43987. * Factory used to create the default material.
  43988. * @param name The name of the material to create
  43989. * @param scene The scene to create the material for
  43990. * @returns The default material
  43991. */
  43992. static DefaultMaterialFactory(scene: Scene): Material;
  43993. /**
  43994. * Factory used to create the a collision coordinator.
  43995. * @returns The collision coordinator
  43996. */
  43997. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  43998. /** @hidden */
  43999. _inputManager: InputManager;
  44000. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44001. cameraToUseForPointers: Nullable<Camera>;
  44002. /** @hidden */
  44003. readonly _isScene: boolean;
  44004. /** @hidden */
  44005. _blockEntityCollection: boolean;
  44006. /**
  44007. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44008. */
  44009. autoClear: boolean;
  44010. /**
  44011. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44012. */
  44013. autoClearDepthAndStencil: boolean;
  44014. /**
  44015. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44016. */
  44017. clearColor: Color4;
  44018. /**
  44019. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44020. */
  44021. ambientColor: Color3;
  44022. /**
  44023. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44024. * It should only be one of the following (if not the default embedded one):
  44025. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44026. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44027. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44028. * The material properties need to be setup according to the type of texture in use.
  44029. */
  44030. environmentBRDFTexture: BaseTexture;
  44031. /**
  44032. * Texture used in all pbr material as the reflection texture.
  44033. * As in the majority of the scene they are the same (exception for multi room and so on),
  44034. * this is easier to reference from here than from all the materials.
  44035. */
  44036. get environmentTexture(): Nullable<BaseTexture>;
  44037. /**
  44038. * Texture used in all pbr material as the reflection texture.
  44039. * As in the majority of the scene they are the same (exception for multi room and so on),
  44040. * this is easier to set here than in all the materials.
  44041. */
  44042. set environmentTexture(value: Nullable<BaseTexture>);
  44043. /** @hidden */
  44044. protected _environmentIntensity: number;
  44045. /**
  44046. * Intensity of the environment in all pbr material.
  44047. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44048. * As in the majority of the scene they are the same (exception for multi room and so on),
  44049. * this is easier to reference from here than from all the materials.
  44050. */
  44051. get environmentIntensity(): number;
  44052. /**
  44053. * Intensity of the environment in all pbr material.
  44054. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44055. * As in the majority of the scene they are the same (exception for multi room and so on),
  44056. * this is easier to set here than in all the materials.
  44057. */
  44058. set environmentIntensity(value: number);
  44059. /** @hidden */
  44060. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44061. /**
  44062. * Default image processing configuration used either in the rendering
  44063. * Forward main pass or through the imageProcessingPostProcess if present.
  44064. * As in the majority of the scene they are the same (exception for multi camera),
  44065. * this is easier to reference from here than from all the materials and post process.
  44066. *
  44067. * No setter as we it is a shared configuration, you can set the values instead.
  44068. */
  44069. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44070. private _forceWireframe;
  44071. /**
  44072. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44073. */
  44074. set forceWireframe(value: boolean);
  44075. get forceWireframe(): boolean;
  44076. private _skipFrustumClipping;
  44077. /**
  44078. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44079. */
  44080. set skipFrustumClipping(value: boolean);
  44081. get skipFrustumClipping(): boolean;
  44082. private _forcePointsCloud;
  44083. /**
  44084. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44085. */
  44086. set forcePointsCloud(value: boolean);
  44087. get forcePointsCloud(): boolean;
  44088. /**
  44089. * Gets or sets the active clipplane 1
  44090. */
  44091. clipPlane: Nullable<Plane>;
  44092. /**
  44093. * Gets or sets the active clipplane 2
  44094. */
  44095. clipPlane2: Nullable<Plane>;
  44096. /**
  44097. * Gets or sets the active clipplane 3
  44098. */
  44099. clipPlane3: Nullable<Plane>;
  44100. /**
  44101. * Gets or sets the active clipplane 4
  44102. */
  44103. clipPlane4: Nullable<Plane>;
  44104. /**
  44105. * Gets or sets the active clipplane 5
  44106. */
  44107. clipPlane5: Nullable<Plane>;
  44108. /**
  44109. * Gets or sets the active clipplane 6
  44110. */
  44111. clipPlane6: Nullable<Plane>;
  44112. /**
  44113. * Gets or sets a boolean indicating if animations are enabled
  44114. */
  44115. animationsEnabled: boolean;
  44116. private _animationPropertiesOverride;
  44117. /**
  44118. * Gets or sets the animation properties override
  44119. */
  44120. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44121. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44122. /**
  44123. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44124. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44125. */
  44126. useConstantAnimationDeltaTime: boolean;
  44127. /**
  44128. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44129. * Please note that it requires to run a ray cast through the scene on every frame
  44130. */
  44131. constantlyUpdateMeshUnderPointer: boolean;
  44132. /**
  44133. * Defines the HTML cursor to use when hovering over interactive elements
  44134. */
  44135. hoverCursor: string;
  44136. /**
  44137. * Defines the HTML default cursor to use (empty by default)
  44138. */
  44139. defaultCursor: string;
  44140. /**
  44141. * Defines whether cursors are handled by the scene.
  44142. */
  44143. doNotHandleCursors: boolean;
  44144. /**
  44145. * This is used to call preventDefault() on pointer down
  44146. * in order to block unwanted artifacts like system double clicks
  44147. */
  44148. preventDefaultOnPointerDown: boolean;
  44149. /**
  44150. * This is used to call preventDefault() on pointer up
  44151. * in order to block unwanted artifacts like system double clicks
  44152. */
  44153. preventDefaultOnPointerUp: boolean;
  44154. /**
  44155. * Gets or sets user defined metadata
  44156. */
  44157. metadata: any;
  44158. /**
  44159. * For internal use only. Please do not use.
  44160. */
  44161. reservedDataStore: any;
  44162. /**
  44163. * Gets the name of the plugin used to load this scene (null by default)
  44164. */
  44165. loadingPluginName: string;
  44166. /**
  44167. * Use this array to add regular expressions used to disable offline support for specific urls
  44168. */
  44169. disableOfflineSupportExceptionRules: RegExp[];
  44170. /**
  44171. * An event triggered when the scene is disposed.
  44172. */
  44173. onDisposeObservable: Observable<Scene>;
  44174. private _onDisposeObserver;
  44175. /** Sets a function to be executed when this scene is disposed. */
  44176. set onDispose(callback: () => void);
  44177. /**
  44178. * An event triggered before rendering the scene (right after animations and physics)
  44179. */
  44180. onBeforeRenderObservable: Observable<Scene>;
  44181. private _onBeforeRenderObserver;
  44182. /** Sets a function to be executed before rendering this scene */
  44183. set beforeRender(callback: Nullable<() => void>);
  44184. /**
  44185. * An event triggered after rendering the scene
  44186. */
  44187. onAfterRenderObservable: Observable<Scene>;
  44188. /**
  44189. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44190. */
  44191. onAfterRenderCameraObservable: Observable<Camera>;
  44192. private _onAfterRenderObserver;
  44193. /** Sets a function to be executed after rendering this scene */
  44194. set afterRender(callback: Nullable<() => void>);
  44195. /**
  44196. * An event triggered before animating the scene
  44197. */
  44198. onBeforeAnimationsObservable: Observable<Scene>;
  44199. /**
  44200. * An event triggered after animations processing
  44201. */
  44202. onAfterAnimationsObservable: Observable<Scene>;
  44203. /**
  44204. * An event triggered before draw calls are ready to be sent
  44205. */
  44206. onBeforeDrawPhaseObservable: Observable<Scene>;
  44207. /**
  44208. * An event triggered after draw calls have been sent
  44209. */
  44210. onAfterDrawPhaseObservable: Observable<Scene>;
  44211. /**
  44212. * An event triggered when the scene is ready
  44213. */
  44214. onReadyObservable: Observable<Scene>;
  44215. /**
  44216. * An event triggered before rendering a camera
  44217. */
  44218. onBeforeCameraRenderObservable: Observable<Camera>;
  44219. private _onBeforeCameraRenderObserver;
  44220. /** Sets a function to be executed before rendering a camera*/
  44221. set beforeCameraRender(callback: () => void);
  44222. /**
  44223. * An event triggered after rendering a camera
  44224. */
  44225. onAfterCameraRenderObservable: Observable<Camera>;
  44226. private _onAfterCameraRenderObserver;
  44227. /** Sets a function to be executed after rendering a camera*/
  44228. set afterCameraRender(callback: () => void);
  44229. /**
  44230. * An event triggered when active meshes evaluation is about to start
  44231. */
  44232. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44233. /**
  44234. * An event triggered when active meshes evaluation is done
  44235. */
  44236. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44237. /**
  44238. * An event triggered when particles rendering is about to start
  44239. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44240. */
  44241. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44242. /**
  44243. * An event triggered when particles rendering is done
  44244. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44245. */
  44246. onAfterParticlesRenderingObservable: Observable<Scene>;
  44247. /**
  44248. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44249. */
  44250. onDataLoadedObservable: Observable<Scene>;
  44251. /**
  44252. * An event triggered when a camera is created
  44253. */
  44254. onNewCameraAddedObservable: Observable<Camera>;
  44255. /**
  44256. * An event triggered when a camera is removed
  44257. */
  44258. onCameraRemovedObservable: Observable<Camera>;
  44259. /**
  44260. * An event triggered when a light is created
  44261. */
  44262. onNewLightAddedObservable: Observable<Light>;
  44263. /**
  44264. * An event triggered when a light is removed
  44265. */
  44266. onLightRemovedObservable: Observable<Light>;
  44267. /**
  44268. * An event triggered when a geometry is created
  44269. */
  44270. onNewGeometryAddedObservable: Observable<Geometry>;
  44271. /**
  44272. * An event triggered when a geometry is removed
  44273. */
  44274. onGeometryRemovedObservable: Observable<Geometry>;
  44275. /**
  44276. * An event triggered when a transform node is created
  44277. */
  44278. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44279. /**
  44280. * An event triggered when a transform node is removed
  44281. */
  44282. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44283. /**
  44284. * An event triggered when a mesh is created
  44285. */
  44286. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44287. /**
  44288. * An event triggered when a mesh is removed
  44289. */
  44290. onMeshRemovedObservable: Observable<AbstractMesh>;
  44291. /**
  44292. * An event triggered when a skeleton is created
  44293. */
  44294. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44295. /**
  44296. * An event triggered when a skeleton is removed
  44297. */
  44298. onSkeletonRemovedObservable: Observable<Skeleton>;
  44299. /**
  44300. * An event triggered when a material is created
  44301. */
  44302. onNewMaterialAddedObservable: Observable<Material>;
  44303. /**
  44304. * An event triggered when a material is removed
  44305. */
  44306. onMaterialRemovedObservable: Observable<Material>;
  44307. /**
  44308. * An event triggered when a texture is created
  44309. */
  44310. onNewTextureAddedObservable: Observable<BaseTexture>;
  44311. /**
  44312. * An event triggered when a texture is removed
  44313. */
  44314. onTextureRemovedObservable: Observable<BaseTexture>;
  44315. /**
  44316. * An event triggered when render targets are about to be rendered
  44317. * Can happen multiple times per frame.
  44318. */
  44319. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44320. /**
  44321. * An event triggered when render targets were rendered.
  44322. * Can happen multiple times per frame.
  44323. */
  44324. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44325. /**
  44326. * An event triggered before calculating deterministic simulation step
  44327. */
  44328. onBeforeStepObservable: Observable<Scene>;
  44329. /**
  44330. * An event triggered after calculating deterministic simulation step
  44331. */
  44332. onAfterStepObservable: Observable<Scene>;
  44333. /**
  44334. * An event triggered when the activeCamera property is updated
  44335. */
  44336. onActiveCameraChanged: Observable<Scene>;
  44337. /**
  44338. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44339. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44340. * 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)
  44341. */
  44342. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44343. /**
  44344. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44345. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44346. * 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)
  44347. */
  44348. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44349. /**
  44350. * This Observable will when a mesh has been imported into the scene.
  44351. */
  44352. onMeshImportedObservable: Observable<AbstractMesh>;
  44353. /**
  44354. * This Observable will when an animation file has been imported into the scene.
  44355. */
  44356. onAnimationFileImportedObservable: Observable<Scene>;
  44357. /**
  44358. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44359. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44360. */
  44361. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44362. /** @hidden */
  44363. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44364. /**
  44365. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44366. */
  44367. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44368. /**
  44369. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44370. */
  44371. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44372. /**
  44373. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44374. */
  44375. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44376. /** Callback called when a pointer move is detected */
  44377. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44378. /** Callback called when a pointer down is detected */
  44379. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44380. /** Callback called when a pointer up is detected */
  44381. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44382. /** Callback called when a pointer pick is detected */
  44383. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44384. /**
  44385. * 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).
  44386. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44387. */
  44388. onPrePointerObservable: Observable<PointerInfoPre>;
  44389. /**
  44390. * Observable event triggered each time an input event is received from the rendering canvas
  44391. */
  44392. onPointerObservable: Observable<PointerInfo>;
  44393. /**
  44394. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44395. */
  44396. get unTranslatedPointer(): Vector2;
  44397. /**
  44398. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44399. */
  44400. static get DragMovementThreshold(): number;
  44401. static set DragMovementThreshold(value: number);
  44402. /**
  44403. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44404. */
  44405. static get LongPressDelay(): number;
  44406. static set LongPressDelay(value: number);
  44407. /**
  44408. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44409. */
  44410. static get DoubleClickDelay(): number;
  44411. static set DoubleClickDelay(value: number);
  44412. /** If you need to check double click without raising a single click at first click, enable this flag */
  44413. static get ExclusiveDoubleClickMode(): boolean;
  44414. static set ExclusiveDoubleClickMode(value: boolean);
  44415. /** @hidden */
  44416. _mirroredCameraPosition: Nullable<Vector3>;
  44417. /**
  44418. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44419. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44420. */
  44421. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44422. /**
  44423. * Observable event triggered each time an keyboard event is received from the hosting window
  44424. */
  44425. onKeyboardObservable: Observable<KeyboardInfo>;
  44426. private _useRightHandedSystem;
  44427. /**
  44428. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44429. */
  44430. set useRightHandedSystem(value: boolean);
  44431. get useRightHandedSystem(): boolean;
  44432. private _timeAccumulator;
  44433. private _currentStepId;
  44434. private _currentInternalStep;
  44435. /**
  44436. * Sets the step Id used by deterministic lock step
  44437. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44438. * @param newStepId defines the step Id
  44439. */
  44440. setStepId(newStepId: number): void;
  44441. /**
  44442. * Gets the step Id used by deterministic lock step
  44443. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44444. * @returns the step Id
  44445. */
  44446. getStepId(): number;
  44447. /**
  44448. * Gets the internal step used by deterministic lock step
  44449. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44450. * @returns the internal step
  44451. */
  44452. getInternalStep(): number;
  44453. private _fogEnabled;
  44454. /**
  44455. * Gets or sets a boolean indicating if fog is enabled on this scene
  44456. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44457. * (Default is true)
  44458. */
  44459. set fogEnabled(value: boolean);
  44460. get fogEnabled(): boolean;
  44461. private _fogMode;
  44462. /**
  44463. * Gets or sets the fog mode to use
  44464. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44465. * | mode | value |
  44466. * | --- | --- |
  44467. * | FOGMODE_NONE | 0 |
  44468. * | FOGMODE_EXP | 1 |
  44469. * | FOGMODE_EXP2 | 2 |
  44470. * | FOGMODE_LINEAR | 3 |
  44471. */
  44472. set fogMode(value: number);
  44473. get fogMode(): number;
  44474. /**
  44475. * Gets or sets the fog color to use
  44476. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44477. * (Default is Color3(0.2, 0.2, 0.3))
  44478. */
  44479. fogColor: Color3;
  44480. /**
  44481. * Gets or sets the fog density to use
  44482. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44483. * (Default is 0.1)
  44484. */
  44485. fogDensity: number;
  44486. /**
  44487. * Gets or sets the fog start distance to use
  44488. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44489. * (Default is 0)
  44490. */
  44491. fogStart: number;
  44492. /**
  44493. * Gets or sets the fog end distance to use
  44494. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44495. * (Default is 1000)
  44496. */
  44497. fogEnd: number;
  44498. /**
  44499. * Flag indicating that the frame buffer binding is handled by another component
  44500. */
  44501. prePass: boolean;
  44502. private _shadowsEnabled;
  44503. /**
  44504. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44505. */
  44506. set shadowsEnabled(value: boolean);
  44507. get shadowsEnabled(): boolean;
  44508. private _lightsEnabled;
  44509. /**
  44510. * Gets or sets a boolean indicating if lights are enabled on this scene
  44511. */
  44512. set lightsEnabled(value: boolean);
  44513. get lightsEnabled(): boolean;
  44514. /** All of the active cameras added to this scene. */
  44515. activeCameras: Camera[];
  44516. /** @hidden */
  44517. _activeCamera: Nullable<Camera>;
  44518. /** Gets or sets the current active camera */
  44519. get activeCamera(): Nullable<Camera>;
  44520. set activeCamera(value: Nullable<Camera>);
  44521. private _defaultMaterial;
  44522. /** The default material used on meshes when no material is affected */
  44523. get defaultMaterial(): Material;
  44524. /** The default material used on meshes when no material is affected */
  44525. set defaultMaterial(value: Material);
  44526. private _texturesEnabled;
  44527. /**
  44528. * Gets or sets a boolean indicating if textures are enabled on this scene
  44529. */
  44530. set texturesEnabled(value: boolean);
  44531. get texturesEnabled(): boolean;
  44532. /**
  44533. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44534. */
  44535. physicsEnabled: boolean;
  44536. /**
  44537. * Gets or sets a boolean indicating if particles are enabled on this scene
  44538. */
  44539. particlesEnabled: boolean;
  44540. /**
  44541. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44542. */
  44543. spritesEnabled: boolean;
  44544. private _skeletonsEnabled;
  44545. /**
  44546. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44547. */
  44548. set skeletonsEnabled(value: boolean);
  44549. get skeletonsEnabled(): boolean;
  44550. /**
  44551. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44552. */
  44553. lensFlaresEnabled: boolean;
  44554. /**
  44555. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44556. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44557. */
  44558. collisionsEnabled: boolean;
  44559. private _collisionCoordinator;
  44560. /** @hidden */
  44561. get collisionCoordinator(): ICollisionCoordinator;
  44562. /**
  44563. * Defines the gravity applied to this scene (used only for collisions)
  44564. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44565. */
  44566. gravity: Vector3;
  44567. /**
  44568. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44569. */
  44570. postProcessesEnabled: boolean;
  44571. /**
  44572. * Gets the current postprocess manager
  44573. */
  44574. postProcessManager: PostProcessManager;
  44575. /**
  44576. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44577. */
  44578. renderTargetsEnabled: boolean;
  44579. /**
  44580. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44581. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44582. */
  44583. dumpNextRenderTargets: boolean;
  44584. /**
  44585. * The list of user defined render targets added to the scene
  44586. */
  44587. customRenderTargets: RenderTargetTexture[];
  44588. /**
  44589. * Defines if texture loading must be delayed
  44590. * If true, textures will only be loaded when they need to be rendered
  44591. */
  44592. useDelayedTextureLoading: boolean;
  44593. /**
  44594. * Gets the list of meshes imported to the scene through SceneLoader
  44595. */
  44596. importedMeshesFiles: String[];
  44597. /**
  44598. * Gets or sets a boolean indicating if probes are enabled on this scene
  44599. */
  44600. probesEnabled: boolean;
  44601. /**
  44602. * Gets or sets the current offline provider to use to store scene data
  44603. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44604. */
  44605. offlineProvider: IOfflineProvider;
  44606. /**
  44607. * Gets or sets the action manager associated with the scene
  44608. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44609. */
  44610. actionManager: AbstractActionManager;
  44611. private _meshesForIntersections;
  44612. /**
  44613. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44614. */
  44615. proceduralTexturesEnabled: boolean;
  44616. private _engine;
  44617. private _totalVertices;
  44618. /** @hidden */
  44619. _activeIndices: PerfCounter;
  44620. /** @hidden */
  44621. _activeParticles: PerfCounter;
  44622. /** @hidden */
  44623. _activeBones: PerfCounter;
  44624. private _animationRatio;
  44625. /** @hidden */
  44626. _animationTimeLast: number;
  44627. /** @hidden */
  44628. _animationTime: number;
  44629. /**
  44630. * Gets or sets a general scale for animation speed
  44631. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44632. */
  44633. animationTimeScale: number;
  44634. /** @hidden */
  44635. _cachedMaterial: Nullable<Material>;
  44636. /** @hidden */
  44637. _cachedEffect: Nullable<Effect>;
  44638. /** @hidden */
  44639. _cachedVisibility: Nullable<number>;
  44640. private _renderId;
  44641. private _frameId;
  44642. private _executeWhenReadyTimeoutId;
  44643. private _intermediateRendering;
  44644. private _viewUpdateFlag;
  44645. private _projectionUpdateFlag;
  44646. /** @hidden */
  44647. _toBeDisposed: Nullable<IDisposable>[];
  44648. private _activeRequests;
  44649. /** @hidden */
  44650. _pendingData: any[];
  44651. private _isDisposed;
  44652. /**
  44653. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44654. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44655. */
  44656. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44657. private _activeMeshes;
  44658. private _processedMaterials;
  44659. private _renderTargets;
  44660. /** @hidden */
  44661. _activeParticleSystems: SmartArray<IParticleSystem>;
  44662. private _activeSkeletons;
  44663. private _softwareSkinnedMeshes;
  44664. private _renderingManager;
  44665. /** @hidden */
  44666. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44667. private _transformMatrix;
  44668. private _sceneUbo;
  44669. /** @hidden */
  44670. _viewMatrix: Matrix;
  44671. private _projectionMatrix;
  44672. /** @hidden */
  44673. _forcedViewPosition: Nullable<Vector3>;
  44674. /** @hidden */
  44675. _frustumPlanes: Plane[];
  44676. /**
  44677. * Gets the list of frustum planes (built from the active camera)
  44678. */
  44679. get frustumPlanes(): Plane[];
  44680. /**
  44681. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44682. * This is useful if there are more lights that the maximum simulteanous authorized
  44683. */
  44684. requireLightSorting: boolean;
  44685. /** @hidden */
  44686. readonly useMaterialMeshMap: boolean;
  44687. /** @hidden */
  44688. readonly useClonedMeshMap: boolean;
  44689. private _externalData;
  44690. private _uid;
  44691. /**
  44692. * @hidden
  44693. * Backing store of defined scene components.
  44694. */
  44695. _components: ISceneComponent[];
  44696. /**
  44697. * @hidden
  44698. * Backing store of defined scene components.
  44699. */
  44700. _serializableComponents: ISceneSerializableComponent[];
  44701. /**
  44702. * List of components to register on the next registration step.
  44703. */
  44704. private _transientComponents;
  44705. /**
  44706. * Registers the transient components if needed.
  44707. */
  44708. private _registerTransientComponents;
  44709. /**
  44710. * @hidden
  44711. * Add a component to the scene.
  44712. * Note that the ccomponent could be registered on th next frame if this is called after
  44713. * the register component stage.
  44714. * @param component Defines the component to add to the scene
  44715. */
  44716. _addComponent(component: ISceneComponent): void;
  44717. /**
  44718. * @hidden
  44719. * Gets a component from the scene.
  44720. * @param name defines the name of the component to retrieve
  44721. * @returns the component or null if not present
  44722. */
  44723. _getComponent(name: string): Nullable<ISceneComponent>;
  44724. /**
  44725. * @hidden
  44726. * Defines the actions happening before camera updates.
  44727. */
  44728. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  44729. /**
  44730. * @hidden
  44731. * Defines the actions happening before clear the canvas.
  44732. */
  44733. _beforeClearStage: Stage<SimpleStageAction>;
  44734. /**
  44735. * @hidden
  44736. * Defines the actions when collecting render targets for the frame.
  44737. */
  44738. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44739. /**
  44740. * @hidden
  44741. * Defines the actions happening for one camera in the frame.
  44742. */
  44743. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44744. /**
  44745. * @hidden
  44746. * Defines the actions happening during the per mesh ready checks.
  44747. */
  44748. _isReadyForMeshStage: Stage<MeshStageAction>;
  44749. /**
  44750. * @hidden
  44751. * Defines the actions happening before evaluate active mesh checks.
  44752. */
  44753. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  44754. /**
  44755. * @hidden
  44756. * Defines the actions happening during the evaluate sub mesh checks.
  44757. */
  44758. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  44759. /**
  44760. * @hidden
  44761. * Defines the actions happening during the active mesh stage.
  44762. */
  44763. _activeMeshStage: Stage<ActiveMeshStageAction>;
  44764. /**
  44765. * @hidden
  44766. * Defines the actions happening during the per camera render target step.
  44767. */
  44768. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  44769. /**
  44770. * @hidden
  44771. * Defines the actions happening just before the active camera is drawing.
  44772. */
  44773. _beforeCameraDrawStage: Stage<CameraStageAction>;
  44774. /**
  44775. * @hidden
  44776. * Defines the actions happening just before a render target is drawing.
  44777. */
  44778. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44779. /**
  44780. * @hidden
  44781. * Defines the actions happening just before a rendering group is drawing.
  44782. */
  44783. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44784. /**
  44785. * @hidden
  44786. * Defines the actions happening just before a mesh is drawing.
  44787. */
  44788. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44789. /**
  44790. * @hidden
  44791. * Defines the actions happening just after a mesh has been drawn.
  44792. */
  44793. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44794. /**
  44795. * @hidden
  44796. * Defines the actions happening just after a rendering group has been drawn.
  44797. */
  44798. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44799. /**
  44800. * @hidden
  44801. * Defines the actions happening just after the active camera has been drawn.
  44802. */
  44803. _afterCameraDrawStage: Stage<CameraStageAction>;
  44804. /**
  44805. * @hidden
  44806. * Defines the actions happening just after a render target has been drawn.
  44807. */
  44808. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44809. /**
  44810. * @hidden
  44811. * Defines the actions happening just after rendering all cameras and computing intersections.
  44812. */
  44813. _afterRenderStage: Stage<SimpleStageAction>;
  44814. /**
  44815. * @hidden
  44816. * Defines the actions happening when a pointer move event happens.
  44817. */
  44818. _pointerMoveStage: Stage<PointerMoveStageAction>;
  44819. /**
  44820. * @hidden
  44821. * Defines the actions happening when a pointer down event happens.
  44822. */
  44823. _pointerDownStage: Stage<PointerUpDownStageAction>;
  44824. /**
  44825. * @hidden
  44826. * Defines the actions happening when a pointer up event happens.
  44827. */
  44828. _pointerUpStage: Stage<PointerUpDownStageAction>;
  44829. /**
  44830. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  44831. */
  44832. private geometriesByUniqueId;
  44833. /**
  44834. * Creates a new Scene
  44835. * @param engine defines the engine to use to render this scene
  44836. * @param options defines the scene options
  44837. */
  44838. constructor(engine: Engine, options?: SceneOptions);
  44839. /**
  44840. * Gets a string identifying the name of the class
  44841. * @returns "Scene" string
  44842. */
  44843. getClassName(): string;
  44844. private _defaultMeshCandidates;
  44845. /**
  44846. * @hidden
  44847. */
  44848. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44849. private _defaultSubMeshCandidates;
  44850. /**
  44851. * @hidden
  44852. */
  44853. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44854. /**
  44855. * Sets the default candidate providers for the scene.
  44856. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  44857. * and getCollidingSubMeshCandidates to their default function
  44858. */
  44859. setDefaultCandidateProviders(): void;
  44860. /**
  44861. * Gets the mesh that is currently under the pointer
  44862. */
  44863. get meshUnderPointer(): Nullable<AbstractMesh>;
  44864. /**
  44865. * Gets or sets the current on-screen X position of the pointer
  44866. */
  44867. get pointerX(): number;
  44868. set pointerX(value: number);
  44869. /**
  44870. * Gets or sets the current on-screen Y position of the pointer
  44871. */
  44872. get pointerY(): number;
  44873. set pointerY(value: number);
  44874. /**
  44875. * Gets the cached material (ie. the latest rendered one)
  44876. * @returns the cached material
  44877. */
  44878. getCachedMaterial(): Nullable<Material>;
  44879. /**
  44880. * Gets the cached effect (ie. the latest rendered one)
  44881. * @returns the cached effect
  44882. */
  44883. getCachedEffect(): Nullable<Effect>;
  44884. /**
  44885. * Gets the cached visibility state (ie. the latest rendered one)
  44886. * @returns the cached visibility state
  44887. */
  44888. getCachedVisibility(): Nullable<number>;
  44889. /**
  44890. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  44891. * @param material defines the current material
  44892. * @param effect defines the current effect
  44893. * @param visibility defines the current visibility state
  44894. * @returns true if one parameter is not cached
  44895. */
  44896. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  44897. /**
  44898. * Gets the engine associated with the scene
  44899. * @returns an Engine
  44900. */
  44901. getEngine(): Engine;
  44902. /**
  44903. * Gets the total number of vertices rendered per frame
  44904. * @returns the total number of vertices rendered per frame
  44905. */
  44906. getTotalVertices(): number;
  44907. /**
  44908. * Gets the performance counter for total vertices
  44909. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44910. */
  44911. get totalVerticesPerfCounter(): PerfCounter;
  44912. /**
  44913. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  44914. * @returns the total number of active indices rendered per frame
  44915. */
  44916. getActiveIndices(): number;
  44917. /**
  44918. * Gets the performance counter for active indices
  44919. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44920. */
  44921. get totalActiveIndicesPerfCounter(): PerfCounter;
  44922. /**
  44923. * Gets the total number of active particles rendered per frame
  44924. * @returns the total number of active particles rendered per frame
  44925. */
  44926. getActiveParticles(): number;
  44927. /**
  44928. * Gets the performance counter for active particles
  44929. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44930. */
  44931. get activeParticlesPerfCounter(): PerfCounter;
  44932. /**
  44933. * Gets the total number of active bones rendered per frame
  44934. * @returns the total number of active bones rendered per frame
  44935. */
  44936. getActiveBones(): number;
  44937. /**
  44938. * Gets the performance counter for active bones
  44939. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44940. */
  44941. get activeBonesPerfCounter(): PerfCounter;
  44942. /**
  44943. * Gets the array of active meshes
  44944. * @returns an array of AbstractMesh
  44945. */
  44946. getActiveMeshes(): SmartArray<AbstractMesh>;
  44947. /**
  44948. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  44949. * @returns a number
  44950. */
  44951. getAnimationRatio(): number;
  44952. /**
  44953. * Gets an unique Id for the current render phase
  44954. * @returns a number
  44955. */
  44956. getRenderId(): number;
  44957. /**
  44958. * Gets an unique Id for the current frame
  44959. * @returns a number
  44960. */
  44961. getFrameId(): number;
  44962. /** Call this function if you want to manually increment the render Id*/
  44963. incrementRenderId(): void;
  44964. private _createUbo;
  44965. /**
  44966. * Use this method to simulate a pointer move on a mesh
  44967. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44968. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44969. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44970. * @returns the current scene
  44971. */
  44972. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44973. /**
  44974. * Use this method to simulate a pointer down on a mesh
  44975. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44976. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44977. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44978. * @returns the current scene
  44979. */
  44980. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44981. /**
  44982. * Use this method to simulate a pointer up on a mesh
  44983. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44984. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44985. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44986. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44987. * @returns the current scene
  44988. */
  44989. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  44990. /**
  44991. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44992. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44993. * @returns true if the pointer was captured
  44994. */
  44995. isPointerCaptured(pointerId?: number): boolean;
  44996. /**
  44997. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44998. * @param attachUp defines if you want to attach events to pointerup
  44999. * @param attachDown defines if you want to attach events to pointerdown
  45000. * @param attachMove defines if you want to attach events to pointermove
  45001. */
  45002. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45003. /** Detaches all event handlers*/
  45004. detachControl(): void;
  45005. /**
  45006. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45007. * Delay loaded resources are not taking in account
  45008. * @return true if all required resources are ready
  45009. */
  45010. isReady(): boolean;
  45011. /** Resets all cached information relative to material (including effect and visibility) */
  45012. resetCachedMaterial(): void;
  45013. /**
  45014. * Registers a function to be called before every frame render
  45015. * @param func defines the function to register
  45016. */
  45017. registerBeforeRender(func: () => void): void;
  45018. /**
  45019. * Unregisters a function called before every frame render
  45020. * @param func defines the function to unregister
  45021. */
  45022. unregisterBeforeRender(func: () => void): void;
  45023. /**
  45024. * Registers a function to be called after every frame render
  45025. * @param func defines the function to register
  45026. */
  45027. registerAfterRender(func: () => void): void;
  45028. /**
  45029. * Unregisters a function called after every frame render
  45030. * @param func defines the function to unregister
  45031. */
  45032. unregisterAfterRender(func: () => void): void;
  45033. private _executeOnceBeforeRender;
  45034. /**
  45035. * The provided function will run before render once and will be disposed afterwards.
  45036. * A timeout delay can be provided so that the function will be executed in N ms.
  45037. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45038. * @param func The function to be executed.
  45039. * @param timeout optional delay in ms
  45040. */
  45041. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45042. /** @hidden */
  45043. _addPendingData(data: any): void;
  45044. /** @hidden */
  45045. _removePendingData(data: any): void;
  45046. /**
  45047. * Returns the number of items waiting to be loaded
  45048. * @returns the number of items waiting to be loaded
  45049. */
  45050. getWaitingItemsCount(): number;
  45051. /**
  45052. * Returns a boolean indicating if the scene is still loading data
  45053. */
  45054. get isLoading(): boolean;
  45055. /**
  45056. * Registers a function to be executed when the scene is ready
  45057. * @param {Function} func - the function to be executed
  45058. */
  45059. executeWhenReady(func: () => void): void;
  45060. /**
  45061. * Returns a promise that resolves when the scene is ready
  45062. * @returns A promise that resolves when the scene is ready
  45063. */
  45064. whenReadyAsync(): Promise<void>;
  45065. /** @hidden */
  45066. _checkIsReady(): void;
  45067. /**
  45068. * Gets all animatable attached to the scene
  45069. */
  45070. get animatables(): Animatable[];
  45071. /**
  45072. * Resets the last animation time frame.
  45073. * Useful to override when animations start running when loading a scene for the first time.
  45074. */
  45075. resetLastAnimationTimeFrame(): void;
  45076. /**
  45077. * Gets the current view matrix
  45078. * @returns a Matrix
  45079. */
  45080. getViewMatrix(): Matrix;
  45081. /**
  45082. * Gets the current projection matrix
  45083. * @returns a Matrix
  45084. */
  45085. getProjectionMatrix(): Matrix;
  45086. /**
  45087. * Gets the current transform matrix
  45088. * @returns a Matrix made of View * Projection
  45089. */
  45090. getTransformMatrix(): Matrix;
  45091. /**
  45092. * Sets the current transform matrix
  45093. * @param viewL defines the View matrix to use
  45094. * @param projectionL defines the Projection matrix to use
  45095. * @param viewR defines the right View matrix to use (if provided)
  45096. * @param projectionR defines the right Projection matrix to use (if provided)
  45097. */
  45098. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45099. /**
  45100. * Gets the uniform buffer used to store scene data
  45101. * @returns a UniformBuffer
  45102. */
  45103. getSceneUniformBuffer(): UniformBuffer;
  45104. /**
  45105. * Gets an unique (relatively to the current scene) Id
  45106. * @returns an unique number for the scene
  45107. */
  45108. getUniqueId(): number;
  45109. /**
  45110. * Add a mesh to the list of scene's meshes
  45111. * @param newMesh defines the mesh to add
  45112. * @param recursive if all child meshes should also be added to the scene
  45113. */
  45114. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45115. /**
  45116. * Remove a mesh for the list of scene's meshes
  45117. * @param toRemove defines the mesh to remove
  45118. * @param recursive if all child meshes should also be removed from the scene
  45119. * @returns the index where the mesh was in the mesh list
  45120. */
  45121. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45122. /**
  45123. * Add a transform node to the list of scene's transform nodes
  45124. * @param newTransformNode defines the transform node to add
  45125. */
  45126. addTransformNode(newTransformNode: TransformNode): void;
  45127. /**
  45128. * Remove a transform node for the list of scene's transform nodes
  45129. * @param toRemove defines the transform node to remove
  45130. * @returns the index where the transform node was in the transform node list
  45131. */
  45132. removeTransformNode(toRemove: TransformNode): number;
  45133. /**
  45134. * Remove a skeleton for the list of scene's skeletons
  45135. * @param toRemove defines the skeleton to remove
  45136. * @returns the index where the skeleton was in the skeleton list
  45137. */
  45138. removeSkeleton(toRemove: Skeleton): number;
  45139. /**
  45140. * Remove a morph target for the list of scene's morph targets
  45141. * @param toRemove defines the morph target to remove
  45142. * @returns the index where the morph target was in the morph target list
  45143. */
  45144. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45145. /**
  45146. * Remove a light for the list of scene's lights
  45147. * @param toRemove defines the light to remove
  45148. * @returns the index where the light was in the light list
  45149. */
  45150. removeLight(toRemove: Light): number;
  45151. /**
  45152. * Remove a camera for the list of scene's cameras
  45153. * @param toRemove defines the camera to remove
  45154. * @returns the index where the camera was in the camera list
  45155. */
  45156. removeCamera(toRemove: Camera): number;
  45157. /**
  45158. * Remove a particle system for the list of scene's particle systems
  45159. * @param toRemove defines the particle system to remove
  45160. * @returns the index where the particle system was in the particle system list
  45161. */
  45162. removeParticleSystem(toRemove: IParticleSystem): number;
  45163. /**
  45164. * Remove a animation for the list of scene's animations
  45165. * @param toRemove defines the animation to remove
  45166. * @returns the index where the animation was in the animation list
  45167. */
  45168. removeAnimation(toRemove: Animation): number;
  45169. /**
  45170. * Will stop the animation of the given target
  45171. * @param target - the target
  45172. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45173. * @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)
  45174. */
  45175. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45176. /**
  45177. * Removes the given animation group from this scene.
  45178. * @param toRemove The animation group to remove
  45179. * @returns The index of the removed animation group
  45180. */
  45181. removeAnimationGroup(toRemove: AnimationGroup): number;
  45182. /**
  45183. * Removes the given multi-material from this scene.
  45184. * @param toRemove The multi-material to remove
  45185. * @returns The index of the removed multi-material
  45186. */
  45187. removeMultiMaterial(toRemove: MultiMaterial): number;
  45188. /**
  45189. * Removes the given material from this scene.
  45190. * @param toRemove The material to remove
  45191. * @returns The index of the removed material
  45192. */
  45193. removeMaterial(toRemove: Material): number;
  45194. /**
  45195. * Removes the given action manager from this scene.
  45196. * @param toRemove The action manager to remove
  45197. * @returns The index of the removed action manager
  45198. */
  45199. removeActionManager(toRemove: AbstractActionManager): number;
  45200. /**
  45201. * Removes the given texture from this scene.
  45202. * @param toRemove The texture to remove
  45203. * @returns The index of the removed texture
  45204. */
  45205. removeTexture(toRemove: BaseTexture): number;
  45206. /**
  45207. * Adds the given light to this scene
  45208. * @param newLight The light to add
  45209. */
  45210. addLight(newLight: Light): void;
  45211. /**
  45212. * Sorts the list list based on light priorities
  45213. */
  45214. sortLightsByPriority(): void;
  45215. /**
  45216. * Adds the given camera to this scene
  45217. * @param newCamera The camera to add
  45218. */
  45219. addCamera(newCamera: Camera): void;
  45220. /**
  45221. * Adds the given skeleton to this scene
  45222. * @param newSkeleton The skeleton to add
  45223. */
  45224. addSkeleton(newSkeleton: Skeleton): void;
  45225. /**
  45226. * Adds the given particle system to this scene
  45227. * @param newParticleSystem The particle system to add
  45228. */
  45229. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45230. /**
  45231. * Adds the given animation to this scene
  45232. * @param newAnimation The animation to add
  45233. */
  45234. addAnimation(newAnimation: Animation): void;
  45235. /**
  45236. * Adds the given animation group to this scene.
  45237. * @param newAnimationGroup The animation group to add
  45238. */
  45239. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45240. /**
  45241. * Adds the given multi-material to this scene
  45242. * @param newMultiMaterial The multi-material to add
  45243. */
  45244. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45245. /**
  45246. * Adds the given material to this scene
  45247. * @param newMaterial The material to add
  45248. */
  45249. addMaterial(newMaterial: Material): void;
  45250. /**
  45251. * Adds the given morph target to this scene
  45252. * @param newMorphTargetManager The morph target to add
  45253. */
  45254. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45255. /**
  45256. * Adds the given geometry to this scene
  45257. * @param newGeometry The geometry to add
  45258. */
  45259. addGeometry(newGeometry: Geometry): void;
  45260. /**
  45261. * Adds the given action manager to this scene
  45262. * @param newActionManager The action manager to add
  45263. */
  45264. addActionManager(newActionManager: AbstractActionManager): void;
  45265. /**
  45266. * Adds the given texture to this scene.
  45267. * @param newTexture The texture to add
  45268. */
  45269. addTexture(newTexture: BaseTexture): void;
  45270. /**
  45271. * Switch active camera
  45272. * @param newCamera defines the new active camera
  45273. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45274. */
  45275. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45276. /**
  45277. * sets the active camera of the scene using its ID
  45278. * @param id defines the camera's ID
  45279. * @return the new active camera or null if none found.
  45280. */
  45281. setActiveCameraByID(id: string): Nullable<Camera>;
  45282. /**
  45283. * sets the active camera of the scene using its name
  45284. * @param name defines the camera's name
  45285. * @returns the new active camera or null if none found.
  45286. */
  45287. setActiveCameraByName(name: string): Nullable<Camera>;
  45288. /**
  45289. * get an animation group using its name
  45290. * @param name defines the material's name
  45291. * @return the animation group or null if none found.
  45292. */
  45293. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45294. /**
  45295. * Get a material using its unique id
  45296. * @param uniqueId defines the material's unique id
  45297. * @return the material or null if none found.
  45298. */
  45299. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45300. /**
  45301. * get a material using its id
  45302. * @param id defines the material's ID
  45303. * @return the material or null if none found.
  45304. */
  45305. getMaterialByID(id: string): Nullable<Material>;
  45306. /**
  45307. * Gets a the last added material using a given id
  45308. * @param id defines the material's ID
  45309. * @return the last material with the given id or null if none found.
  45310. */
  45311. getLastMaterialByID(id: string): Nullable<Material>;
  45312. /**
  45313. * Gets a material using its name
  45314. * @param name defines the material's name
  45315. * @return the material or null if none found.
  45316. */
  45317. getMaterialByName(name: string): Nullable<Material>;
  45318. /**
  45319. * Get a texture using its unique id
  45320. * @param uniqueId defines the texture's unique id
  45321. * @return the texture or null if none found.
  45322. */
  45323. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45324. /**
  45325. * Gets a camera using its id
  45326. * @param id defines the id to look for
  45327. * @returns the camera or null if not found
  45328. */
  45329. getCameraByID(id: string): Nullable<Camera>;
  45330. /**
  45331. * Gets a camera using its unique id
  45332. * @param uniqueId defines the unique id to look for
  45333. * @returns the camera or null if not found
  45334. */
  45335. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45336. /**
  45337. * Gets a camera using its name
  45338. * @param name defines the camera's name
  45339. * @return the camera or null if none found.
  45340. */
  45341. getCameraByName(name: string): Nullable<Camera>;
  45342. /**
  45343. * Gets a bone using its id
  45344. * @param id defines the bone's id
  45345. * @return the bone or null if not found
  45346. */
  45347. getBoneByID(id: string): Nullable<Bone>;
  45348. /**
  45349. * Gets a bone using its id
  45350. * @param name defines the bone's name
  45351. * @return the bone or null if not found
  45352. */
  45353. getBoneByName(name: string): Nullable<Bone>;
  45354. /**
  45355. * Gets a light node using its name
  45356. * @param name defines the the light's name
  45357. * @return the light or null if none found.
  45358. */
  45359. getLightByName(name: string): Nullable<Light>;
  45360. /**
  45361. * Gets a light node using its id
  45362. * @param id defines the light's id
  45363. * @return the light or null if none found.
  45364. */
  45365. getLightByID(id: string): Nullable<Light>;
  45366. /**
  45367. * Gets a light node using its scene-generated unique ID
  45368. * @param uniqueId defines the light's unique id
  45369. * @return the light or null if none found.
  45370. */
  45371. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45372. /**
  45373. * Gets a particle system by id
  45374. * @param id defines the particle system id
  45375. * @return the corresponding system or null if none found
  45376. */
  45377. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45378. /**
  45379. * Gets a geometry using its ID
  45380. * @param id defines the geometry's id
  45381. * @return the geometry or null if none found.
  45382. */
  45383. getGeometryByID(id: string): Nullable<Geometry>;
  45384. private _getGeometryByUniqueID;
  45385. /**
  45386. * Add a new geometry to this scene
  45387. * @param geometry defines the geometry to be added to the scene.
  45388. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45389. * @return a boolean defining if the geometry was added or not
  45390. */
  45391. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45392. /**
  45393. * Removes an existing geometry
  45394. * @param geometry defines the geometry to be removed from the scene
  45395. * @return a boolean defining if the geometry was removed or not
  45396. */
  45397. removeGeometry(geometry: Geometry): boolean;
  45398. /**
  45399. * Gets the list of geometries attached to the scene
  45400. * @returns an array of Geometry
  45401. */
  45402. getGeometries(): Geometry[];
  45403. /**
  45404. * Gets the first added mesh found of a given ID
  45405. * @param id defines the id to search for
  45406. * @return the mesh found or null if not found at all
  45407. */
  45408. getMeshByID(id: string): Nullable<AbstractMesh>;
  45409. /**
  45410. * Gets a list of meshes using their id
  45411. * @param id defines the id to search for
  45412. * @returns a list of meshes
  45413. */
  45414. getMeshesByID(id: string): Array<AbstractMesh>;
  45415. /**
  45416. * Gets the first added transform node found of a given ID
  45417. * @param id defines the id to search for
  45418. * @return the found transform node or null if not found at all.
  45419. */
  45420. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45421. /**
  45422. * Gets a transform node with its auto-generated unique id
  45423. * @param uniqueId efines the unique id to search for
  45424. * @return the found transform node or null if not found at all.
  45425. */
  45426. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45427. /**
  45428. * Gets a list of transform nodes using their id
  45429. * @param id defines the id to search for
  45430. * @returns a list of transform nodes
  45431. */
  45432. getTransformNodesByID(id: string): Array<TransformNode>;
  45433. /**
  45434. * Gets a mesh with its auto-generated unique id
  45435. * @param uniqueId defines the unique id to search for
  45436. * @return the found mesh or null if not found at all.
  45437. */
  45438. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45439. /**
  45440. * Gets a the last added mesh using a given id
  45441. * @param id defines the id to search for
  45442. * @return the found mesh or null if not found at all.
  45443. */
  45444. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45445. /**
  45446. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45447. * @param id defines the id to search for
  45448. * @return the found node or null if not found at all
  45449. */
  45450. getLastEntryByID(id: string): Nullable<Node>;
  45451. /**
  45452. * Gets a node (Mesh, Camera, Light) using a given id
  45453. * @param id defines the id to search for
  45454. * @return the found node or null if not found at all
  45455. */
  45456. getNodeByID(id: string): Nullable<Node>;
  45457. /**
  45458. * Gets a node (Mesh, Camera, Light) using a given name
  45459. * @param name defines the name to search for
  45460. * @return the found node or null if not found at all.
  45461. */
  45462. getNodeByName(name: string): Nullable<Node>;
  45463. /**
  45464. * Gets a mesh using a given name
  45465. * @param name defines the name to search for
  45466. * @return the found mesh or null if not found at all.
  45467. */
  45468. getMeshByName(name: string): Nullable<AbstractMesh>;
  45469. /**
  45470. * Gets a transform node using a given name
  45471. * @param name defines the name to search for
  45472. * @return the found transform node or null if not found at all.
  45473. */
  45474. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45475. /**
  45476. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45477. * @param id defines the id to search for
  45478. * @return the found skeleton or null if not found at all.
  45479. */
  45480. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45481. /**
  45482. * Gets a skeleton using a given auto generated unique id
  45483. * @param uniqueId defines the unique id to search for
  45484. * @return the found skeleton or null if not found at all.
  45485. */
  45486. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45487. /**
  45488. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45489. * @param id defines the id to search for
  45490. * @return the found skeleton or null if not found at all.
  45491. */
  45492. getSkeletonById(id: string): Nullable<Skeleton>;
  45493. /**
  45494. * Gets a skeleton using a given name
  45495. * @param name defines the name to search for
  45496. * @return the found skeleton or null if not found at all.
  45497. */
  45498. getSkeletonByName(name: string): Nullable<Skeleton>;
  45499. /**
  45500. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45501. * @param id defines the id to search for
  45502. * @return the found morph target manager or null if not found at all.
  45503. */
  45504. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45505. /**
  45506. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45507. * @param id defines the id to search for
  45508. * @return the found morph target or null if not found at all.
  45509. */
  45510. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45511. /**
  45512. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45513. * @param name defines the name to search for
  45514. * @return the found morph target or null if not found at all.
  45515. */
  45516. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45517. /**
  45518. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45519. * @param name defines the name to search for
  45520. * @return the found post process or null if not found at all.
  45521. */
  45522. getPostProcessByName(name: string): Nullable<PostProcess>;
  45523. /**
  45524. * Gets a boolean indicating if the given mesh is active
  45525. * @param mesh defines the mesh to look for
  45526. * @returns true if the mesh is in the active list
  45527. */
  45528. isActiveMesh(mesh: AbstractMesh): boolean;
  45529. /**
  45530. * Return a unique id as a string which can serve as an identifier for the scene
  45531. */
  45532. get uid(): string;
  45533. /**
  45534. * Add an externaly attached data from its key.
  45535. * This method call will fail and return false, if such key already exists.
  45536. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45537. * @param key the unique key that identifies the data
  45538. * @param data the data object to associate to the key for this Engine instance
  45539. * @return true if no such key were already present and the data was added successfully, false otherwise
  45540. */
  45541. addExternalData<T>(key: string, data: T): boolean;
  45542. /**
  45543. * Get an externaly attached data from its key
  45544. * @param key the unique key that identifies the data
  45545. * @return the associated data, if present (can be null), or undefined if not present
  45546. */
  45547. getExternalData<T>(key: string): Nullable<T>;
  45548. /**
  45549. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45550. * @param key the unique key that identifies the data
  45551. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45552. * @return the associated data, can be null if the factory returned null.
  45553. */
  45554. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45555. /**
  45556. * Remove an externaly attached data from the Engine instance
  45557. * @param key the unique key that identifies the data
  45558. * @return true if the data was successfully removed, false if it doesn't exist
  45559. */
  45560. removeExternalData(key: string): boolean;
  45561. private _evaluateSubMesh;
  45562. /**
  45563. * Clear the processed materials smart array preventing retention point in material dispose.
  45564. */
  45565. freeProcessedMaterials(): void;
  45566. private _preventFreeActiveMeshesAndRenderingGroups;
  45567. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45568. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45569. * when disposing several meshes in a row or a hierarchy of meshes.
  45570. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45571. */
  45572. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45573. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45574. /**
  45575. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45576. */
  45577. freeActiveMeshes(): void;
  45578. /**
  45579. * Clear the info related to rendering groups preventing retention points during dispose.
  45580. */
  45581. freeRenderingGroups(): void;
  45582. /** @hidden */
  45583. _isInIntermediateRendering(): boolean;
  45584. /**
  45585. * Lambda returning the list of potentially active meshes.
  45586. */
  45587. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45588. /**
  45589. * Lambda returning the list of potentially active sub meshes.
  45590. */
  45591. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45592. /**
  45593. * Lambda returning the list of potentially intersecting sub meshes.
  45594. */
  45595. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45596. /**
  45597. * Lambda returning the list of potentially colliding sub meshes.
  45598. */
  45599. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45600. private _activeMeshesFrozen;
  45601. private _skipEvaluateActiveMeshesCompletely;
  45602. /**
  45603. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45604. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45605. * @param onSuccess optional success callback
  45606. * @param onError optional error callback
  45607. * @returns the current scene
  45608. */
  45609. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45610. /**
  45611. * Use this function to restart evaluating active meshes on every frame
  45612. * @returns the current scene
  45613. */
  45614. unfreezeActiveMeshes(): Scene;
  45615. private _evaluateActiveMeshes;
  45616. private _activeMesh;
  45617. /**
  45618. * Update the transform matrix to update from the current active camera
  45619. * @param force defines a boolean used to force the update even if cache is up to date
  45620. */
  45621. updateTransformMatrix(force?: boolean): void;
  45622. private _bindFrameBuffer;
  45623. /** @hidden */
  45624. _allowPostProcessClearColor: boolean;
  45625. /** @hidden */
  45626. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45627. private _processSubCameras;
  45628. private _checkIntersections;
  45629. /** @hidden */
  45630. _advancePhysicsEngineStep(step: number): void;
  45631. /**
  45632. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45633. */
  45634. getDeterministicFrameTime: () => number;
  45635. /** @hidden */
  45636. _animate(): void;
  45637. /** Execute all animations (for a frame) */
  45638. animate(): void;
  45639. /**
  45640. * Render the scene
  45641. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45642. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45643. */
  45644. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45645. /**
  45646. * Freeze all materials
  45647. * A frozen material will not be updatable but should be faster to render
  45648. */
  45649. freezeMaterials(): void;
  45650. /**
  45651. * Unfreeze all materials
  45652. * A frozen material will not be updatable but should be faster to render
  45653. */
  45654. unfreezeMaterials(): void;
  45655. /**
  45656. * Releases all held ressources
  45657. */
  45658. dispose(): void;
  45659. /**
  45660. * Gets if the scene is already disposed
  45661. */
  45662. get isDisposed(): boolean;
  45663. /**
  45664. * Call this function to reduce memory footprint of the scene.
  45665. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45666. */
  45667. clearCachedVertexData(): void;
  45668. /**
  45669. * This function will remove the local cached buffer data from texture.
  45670. * It will save memory but will prevent the texture from being rebuilt
  45671. */
  45672. cleanCachedTextureBuffer(): void;
  45673. /**
  45674. * Get the world extend vectors with an optional filter
  45675. *
  45676. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45677. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45678. */
  45679. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45680. min: Vector3;
  45681. max: Vector3;
  45682. };
  45683. /**
  45684. * Creates a ray that can be used to pick in the scene
  45685. * @param x defines the x coordinate of the origin (on-screen)
  45686. * @param y defines the y coordinate of the origin (on-screen)
  45687. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45688. * @param camera defines the camera to use for the picking
  45689. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45690. * @returns a Ray
  45691. */
  45692. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45693. /**
  45694. * Creates a ray that can be used to pick in the scene
  45695. * @param x defines the x coordinate of the origin (on-screen)
  45696. * @param y defines the y coordinate of the origin (on-screen)
  45697. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45698. * @param result defines the ray where to store the picking ray
  45699. * @param camera defines the camera to use for the picking
  45700. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45701. * @returns the current scene
  45702. */
  45703. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  45704. /**
  45705. * Creates a ray that can be used to pick in the scene
  45706. * @param x defines the x coordinate of the origin (on-screen)
  45707. * @param y defines the y coordinate of the origin (on-screen)
  45708. * @param camera defines the camera to use for the picking
  45709. * @returns a Ray
  45710. */
  45711. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  45712. /**
  45713. * Creates a ray that can be used to pick in the scene
  45714. * @param x defines the x coordinate of the origin (on-screen)
  45715. * @param y defines the y coordinate of the origin (on-screen)
  45716. * @param result defines the ray where to store the picking ray
  45717. * @param camera defines the camera to use for the picking
  45718. * @returns the current scene
  45719. */
  45720. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  45721. /** Launch a ray to try to pick a mesh in the scene
  45722. * @param x position on screen
  45723. * @param y position on screen
  45724. * @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
  45725. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45726. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45727. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45728. * @returns a PickingInfo
  45729. */
  45730. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45731. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  45732. * @param x position on screen
  45733. * @param y position on screen
  45734. * @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
  45735. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45736. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45737. * @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)
  45738. */
  45739. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  45740. /** Use the given ray to pick a mesh in the scene
  45741. * @param ray The ray to use to pick meshes
  45742. * @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
  45743. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45744. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45745. * @returns a PickingInfo
  45746. */
  45747. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45748. /**
  45749. * Launch a ray to try to pick a mesh in the scene
  45750. * @param x X position on screen
  45751. * @param y Y position on screen
  45752. * @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
  45753. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45754. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45755. * @returns an array of PickingInfo
  45756. */
  45757. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45758. /**
  45759. * Launch a ray to try to pick a mesh in the scene
  45760. * @param ray Ray to use
  45761. * @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
  45762. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45763. * @returns an array of PickingInfo
  45764. */
  45765. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45766. /**
  45767. * Force the value of meshUnderPointer
  45768. * @param mesh defines the mesh to use
  45769. * @param pointerId optional pointer id when using more than one pointer
  45770. */
  45771. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45772. /**
  45773. * Gets the mesh under the pointer
  45774. * @returns a Mesh or null if no mesh is under the pointer
  45775. */
  45776. getPointerOverMesh(): Nullable<AbstractMesh>;
  45777. /** @hidden */
  45778. _rebuildGeometries(): void;
  45779. /** @hidden */
  45780. _rebuildTextures(): void;
  45781. private _getByTags;
  45782. /**
  45783. * Get a list of meshes by tags
  45784. * @param tagsQuery defines the tags query to use
  45785. * @param forEach defines a predicate used to filter results
  45786. * @returns an array of Mesh
  45787. */
  45788. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  45789. /**
  45790. * Get a list of cameras by tags
  45791. * @param tagsQuery defines the tags query to use
  45792. * @param forEach defines a predicate used to filter results
  45793. * @returns an array of Camera
  45794. */
  45795. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  45796. /**
  45797. * Get a list of lights by tags
  45798. * @param tagsQuery defines the tags query to use
  45799. * @param forEach defines a predicate used to filter results
  45800. * @returns an array of Light
  45801. */
  45802. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  45803. /**
  45804. * Get a list of materials by tags
  45805. * @param tagsQuery defines the tags query to use
  45806. * @param forEach defines a predicate used to filter results
  45807. * @returns an array of Material
  45808. */
  45809. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  45810. /**
  45811. * Get a list of transform nodes by tags
  45812. * @param tagsQuery defines the tags query to use
  45813. * @param forEach defines a predicate used to filter results
  45814. * @returns an array of TransformNode
  45815. */
  45816. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  45817. /**
  45818. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  45819. * This allowed control for front to back rendering or reversly depending of the special needs.
  45820. *
  45821. * @param renderingGroupId The rendering group id corresponding to its index
  45822. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  45823. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  45824. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  45825. */
  45826. 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;
  45827. /**
  45828. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  45829. *
  45830. * @param renderingGroupId The rendering group id corresponding to its index
  45831. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45832. * @param depth Automatically clears depth between groups if true and autoClear is true.
  45833. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  45834. */
  45835. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  45836. /**
  45837. * Gets the current auto clear configuration for one rendering group of the rendering
  45838. * manager.
  45839. * @param index the rendering group index to get the information for
  45840. * @returns The auto clear setup for the requested rendering group
  45841. */
  45842. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  45843. private _blockMaterialDirtyMechanism;
  45844. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  45845. get blockMaterialDirtyMechanism(): boolean;
  45846. set blockMaterialDirtyMechanism(value: boolean);
  45847. /**
  45848. * Will flag all materials as dirty to trigger new shader compilation
  45849. * @param flag defines the flag used to specify which material part must be marked as dirty
  45850. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  45851. */
  45852. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  45853. /** @hidden */
  45854. _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;
  45855. /** @hidden */
  45856. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45857. /** @hidden */
  45858. _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;
  45859. /** @hidden */
  45860. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  45861. /** @hidden */
  45862. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  45863. /** @hidden */
  45864. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45865. }
  45866. }
  45867. declare module "babylonjs/assetContainer" {
  45868. import { AbstractScene } from "babylonjs/abstractScene";
  45869. import { Scene } from "babylonjs/scene";
  45870. import { Mesh } from "babylonjs/Meshes/mesh";
  45871. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45872. import { Skeleton } from "babylonjs/Bones/skeleton";
  45873. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45874. import { Animatable } from "babylonjs/Animations/animatable";
  45875. import { Nullable } from "babylonjs/types";
  45876. import { Node } from "babylonjs/node";
  45877. /**
  45878. * Set of assets to keep when moving a scene into an asset container.
  45879. */
  45880. export class KeepAssets extends AbstractScene {
  45881. }
  45882. /**
  45883. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  45884. */
  45885. export class InstantiatedEntries {
  45886. /**
  45887. * List of new root nodes (eg. nodes with no parent)
  45888. */
  45889. rootNodes: TransformNode[];
  45890. /**
  45891. * List of new skeletons
  45892. */
  45893. skeletons: Skeleton[];
  45894. /**
  45895. * List of new animation groups
  45896. */
  45897. animationGroups: AnimationGroup[];
  45898. }
  45899. /**
  45900. * Container with a set of assets that can be added or removed from a scene.
  45901. */
  45902. export class AssetContainer extends AbstractScene {
  45903. private _wasAddedToScene;
  45904. /**
  45905. * The scene the AssetContainer belongs to.
  45906. */
  45907. scene: Scene;
  45908. /**
  45909. * Instantiates an AssetContainer.
  45910. * @param scene The scene the AssetContainer belongs to.
  45911. */
  45912. constructor(scene: Scene);
  45913. /**
  45914. * Instantiate or clone all meshes and add the new ones to the scene.
  45915. * Skeletons and animation groups will all be cloned
  45916. * @param nameFunction defines an optional function used to get new names for clones
  45917. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  45918. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  45919. */
  45920. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  45921. /**
  45922. * Adds all the assets from the container to the scene.
  45923. */
  45924. addAllToScene(): void;
  45925. /**
  45926. * Removes all the assets in the container from the scene
  45927. */
  45928. removeAllFromScene(): void;
  45929. /**
  45930. * Disposes all the assets in the container
  45931. */
  45932. dispose(): void;
  45933. private _moveAssets;
  45934. /**
  45935. * Removes all the assets contained in the scene and adds them to the container.
  45936. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  45937. */
  45938. moveAllFromScene(keepAssets?: KeepAssets): void;
  45939. /**
  45940. * 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.
  45941. * @returns the root mesh
  45942. */
  45943. createRootMesh(): Mesh;
  45944. /**
  45945. * Merge animations (direct and animation groups) from this asset container into a scene
  45946. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45947. * @param animatables set of animatables to retarget to a node from the scene
  45948. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  45949. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  45950. */
  45951. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  45952. }
  45953. }
  45954. declare module "babylonjs/abstractScene" {
  45955. import { Scene } from "babylonjs/scene";
  45956. import { Nullable } from "babylonjs/types";
  45957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45958. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45959. import { Geometry } from "babylonjs/Meshes/geometry";
  45960. import { Skeleton } from "babylonjs/Bones/skeleton";
  45961. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  45962. import { AssetContainer } from "babylonjs/assetContainer";
  45963. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45964. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45966. import { Material } from "babylonjs/Materials/material";
  45967. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  45968. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  45969. import { Camera } from "babylonjs/Cameras/camera";
  45970. import { Light } from "babylonjs/Lights/light";
  45971. import { Node } from "babylonjs/node";
  45972. import { Animation } from "babylonjs/Animations/animation";
  45973. /**
  45974. * Defines how the parser contract is defined.
  45975. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  45976. */
  45977. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  45978. /**
  45979. * Defines how the individual parser contract is defined.
  45980. * These parser can parse an individual asset
  45981. */
  45982. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  45983. /**
  45984. * Base class of the scene acting as a container for the different elements composing a scene.
  45985. * This class is dynamically extended by the different components of the scene increasing
  45986. * flexibility and reducing coupling
  45987. */
  45988. export abstract class AbstractScene {
  45989. /**
  45990. * Stores the list of available parsers in the application.
  45991. */
  45992. private static _BabylonFileParsers;
  45993. /**
  45994. * Stores the list of available individual parsers in the application.
  45995. */
  45996. private static _IndividualBabylonFileParsers;
  45997. /**
  45998. * Adds a parser in the list of available ones
  45999. * @param name Defines the name of the parser
  46000. * @param parser Defines the parser to add
  46001. */
  46002. static AddParser(name: string, parser: BabylonFileParser): void;
  46003. /**
  46004. * Gets a general parser from the list of avaialble ones
  46005. * @param name Defines the name of the parser
  46006. * @returns the requested parser or null
  46007. */
  46008. static GetParser(name: string): Nullable<BabylonFileParser>;
  46009. /**
  46010. * Adds n individual parser in the list of available ones
  46011. * @param name Defines the name of the parser
  46012. * @param parser Defines the parser to add
  46013. */
  46014. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46015. /**
  46016. * Gets an individual parser from the list of avaialble ones
  46017. * @param name Defines the name of the parser
  46018. * @returns the requested parser or null
  46019. */
  46020. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46021. /**
  46022. * Parser json data and populate both a scene and its associated container object
  46023. * @param jsonData Defines the data to parse
  46024. * @param scene Defines the scene to parse the data for
  46025. * @param container Defines the container attached to the parsing sequence
  46026. * @param rootUrl Defines the root url of the data
  46027. */
  46028. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46029. /**
  46030. * Gets the list of root nodes (ie. nodes with no parent)
  46031. */
  46032. rootNodes: Node[];
  46033. /** All of the cameras added to this scene
  46034. * @see https://doc.babylonjs.com/babylon101/cameras
  46035. */
  46036. cameras: Camera[];
  46037. /**
  46038. * All of the lights added to this scene
  46039. * @see https://doc.babylonjs.com/babylon101/lights
  46040. */
  46041. lights: Light[];
  46042. /**
  46043. * All of the (abstract) meshes added to this scene
  46044. */
  46045. meshes: AbstractMesh[];
  46046. /**
  46047. * The list of skeletons added to the scene
  46048. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46049. */
  46050. skeletons: Skeleton[];
  46051. /**
  46052. * All of the particle systems added to this scene
  46053. * @see https://doc.babylonjs.com/babylon101/particles
  46054. */
  46055. particleSystems: IParticleSystem[];
  46056. /**
  46057. * Gets a list of Animations associated with the scene
  46058. */
  46059. animations: Animation[];
  46060. /**
  46061. * All of the animation groups added to this scene
  46062. * @see https://doc.babylonjs.com/how_to/group
  46063. */
  46064. animationGroups: AnimationGroup[];
  46065. /**
  46066. * All of the multi-materials added to this scene
  46067. * @see https://doc.babylonjs.com/how_to/multi_materials
  46068. */
  46069. multiMaterials: MultiMaterial[];
  46070. /**
  46071. * All of the materials added to this scene
  46072. * In the context of a Scene, it is not supposed to be modified manually.
  46073. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46074. * Note also that the order of the Material within the array is not significant and might change.
  46075. * @see https://doc.babylonjs.com/babylon101/materials
  46076. */
  46077. materials: Material[];
  46078. /**
  46079. * The list of morph target managers added to the scene
  46080. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46081. */
  46082. morphTargetManagers: MorphTargetManager[];
  46083. /**
  46084. * The list of geometries used in the scene.
  46085. */
  46086. geometries: Geometry[];
  46087. /**
  46088. * All of the tranform nodes added to this scene
  46089. * In the context of a Scene, it is not supposed to be modified manually.
  46090. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46091. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46092. * @see https://doc.babylonjs.com/how_to/transformnode
  46093. */
  46094. transformNodes: TransformNode[];
  46095. /**
  46096. * ActionManagers available on the scene.
  46097. */
  46098. actionManagers: AbstractActionManager[];
  46099. /**
  46100. * Textures to keep.
  46101. */
  46102. textures: BaseTexture[];
  46103. /** @hidden */
  46104. protected _environmentTexture: Nullable<BaseTexture>;
  46105. /**
  46106. * Texture used in all pbr material as the reflection texture.
  46107. * As in the majority of the scene they are the same (exception for multi room and so on),
  46108. * this is easier to reference from here than from all the materials.
  46109. */
  46110. get environmentTexture(): Nullable<BaseTexture>;
  46111. set environmentTexture(value: Nullable<BaseTexture>);
  46112. /**
  46113. * The list of postprocesses added to the scene
  46114. */
  46115. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46116. /**
  46117. * @returns all meshes, lights, cameras, transformNodes and bones
  46118. */
  46119. getNodes(): Array<Node>;
  46120. }
  46121. }
  46122. declare module "babylonjs/Audio/sound" {
  46123. import { Observable } from "babylonjs/Misc/observable";
  46124. import { Vector3 } from "babylonjs/Maths/math.vector";
  46125. import { Nullable } from "babylonjs/types";
  46126. import { Scene } from "babylonjs/scene";
  46127. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46128. /**
  46129. * Interface used to define options for Sound class
  46130. */
  46131. export interface ISoundOptions {
  46132. /**
  46133. * Does the sound autoplay once loaded.
  46134. */
  46135. autoplay?: boolean;
  46136. /**
  46137. * Does the sound loop after it finishes playing once.
  46138. */
  46139. loop?: boolean;
  46140. /**
  46141. * Sound's volume
  46142. */
  46143. volume?: number;
  46144. /**
  46145. * Is it a spatial sound?
  46146. */
  46147. spatialSound?: boolean;
  46148. /**
  46149. * Maximum distance to hear that sound
  46150. */
  46151. maxDistance?: number;
  46152. /**
  46153. * Uses user defined attenuation function
  46154. */
  46155. useCustomAttenuation?: boolean;
  46156. /**
  46157. * Define the roll off factor of spatial sounds.
  46158. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46159. */
  46160. rolloffFactor?: number;
  46161. /**
  46162. * Define the reference distance the sound should be heard perfectly.
  46163. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46164. */
  46165. refDistance?: number;
  46166. /**
  46167. * Define the distance attenuation model the sound will follow.
  46168. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46169. */
  46170. distanceModel?: string;
  46171. /**
  46172. * Defines the playback speed (1 by default)
  46173. */
  46174. playbackRate?: number;
  46175. /**
  46176. * Defines if the sound is from a streaming source
  46177. */
  46178. streaming?: boolean;
  46179. /**
  46180. * Defines an optional length (in seconds) inside the sound file
  46181. */
  46182. length?: number;
  46183. /**
  46184. * Defines an optional offset (in seconds) inside the sound file
  46185. */
  46186. offset?: number;
  46187. /**
  46188. * If true, URLs will not be required to state the audio file codec to use.
  46189. */
  46190. skipCodecCheck?: boolean;
  46191. }
  46192. /**
  46193. * Defines a sound that can be played in the application.
  46194. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46195. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46196. */
  46197. export class Sound {
  46198. /**
  46199. * The name of the sound in the scene.
  46200. */
  46201. name: string;
  46202. /**
  46203. * Does the sound autoplay once loaded.
  46204. */
  46205. autoplay: boolean;
  46206. /**
  46207. * Does the sound loop after it finishes playing once.
  46208. */
  46209. loop: boolean;
  46210. /**
  46211. * Does the sound use a custom attenuation curve to simulate the falloff
  46212. * happening when the source gets further away from the camera.
  46213. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46214. */
  46215. useCustomAttenuation: boolean;
  46216. /**
  46217. * The sound track id this sound belongs to.
  46218. */
  46219. soundTrackId: number;
  46220. /**
  46221. * Is this sound currently played.
  46222. */
  46223. isPlaying: boolean;
  46224. /**
  46225. * Is this sound currently paused.
  46226. */
  46227. isPaused: boolean;
  46228. /**
  46229. * Does this sound enables spatial sound.
  46230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46231. */
  46232. spatialSound: boolean;
  46233. /**
  46234. * Define the reference distance the sound should be heard perfectly.
  46235. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46236. */
  46237. refDistance: number;
  46238. /**
  46239. * Define the roll off factor of spatial sounds.
  46240. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46241. */
  46242. rolloffFactor: number;
  46243. /**
  46244. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46245. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46246. */
  46247. maxDistance: number;
  46248. /**
  46249. * Define the distance attenuation model the sound will follow.
  46250. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46251. */
  46252. distanceModel: string;
  46253. /**
  46254. * @hidden
  46255. * Back Compat
  46256. **/
  46257. onended: () => any;
  46258. /**
  46259. * Gets or sets an object used to store user defined information for the sound.
  46260. */
  46261. metadata: any;
  46262. /**
  46263. * Observable event when the current playing sound finishes.
  46264. */
  46265. onEndedObservable: Observable<Sound>;
  46266. private _panningModel;
  46267. private _playbackRate;
  46268. private _streaming;
  46269. private _startTime;
  46270. private _startOffset;
  46271. private _position;
  46272. /** @hidden */
  46273. _positionInEmitterSpace: boolean;
  46274. private _localDirection;
  46275. private _volume;
  46276. private _isReadyToPlay;
  46277. private _isDirectional;
  46278. private _readyToPlayCallback;
  46279. private _audioBuffer;
  46280. private _soundSource;
  46281. private _streamingSource;
  46282. private _soundPanner;
  46283. private _soundGain;
  46284. private _inputAudioNode;
  46285. private _outputAudioNode;
  46286. private _coneInnerAngle;
  46287. private _coneOuterAngle;
  46288. private _coneOuterGain;
  46289. private _scene;
  46290. private _connectedTransformNode;
  46291. private _customAttenuationFunction;
  46292. private _registerFunc;
  46293. private _isOutputConnected;
  46294. private _htmlAudioElement;
  46295. private _urlType;
  46296. private _length?;
  46297. private _offset?;
  46298. /** @hidden */
  46299. static _SceneComponentInitialization: (scene: Scene) => void;
  46300. /**
  46301. * Create a sound and attach it to a scene
  46302. * @param name Name of your sound
  46303. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46304. * @param scene defines the scene the sound belongs to
  46305. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46306. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46307. */
  46308. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46309. /**
  46310. * Release the sound and its associated resources
  46311. */
  46312. dispose(): void;
  46313. /**
  46314. * Gets if the sounds is ready to be played or not.
  46315. * @returns true if ready, otherwise false
  46316. */
  46317. isReady(): boolean;
  46318. private _soundLoaded;
  46319. /**
  46320. * Sets the data of the sound from an audiobuffer
  46321. * @param audioBuffer The audioBuffer containing the data
  46322. */
  46323. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46324. /**
  46325. * Updates the current sounds options such as maxdistance, loop...
  46326. * @param options A JSON object containing values named as the object properties
  46327. */
  46328. updateOptions(options: ISoundOptions): void;
  46329. private _createSpatialParameters;
  46330. private _updateSpatialParameters;
  46331. /**
  46332. * Switch the panning model to HRTF:
  46333. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46334. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46335. */
  46336. switchPanningModelToHRTF(): void;
  46337. /**
  46338. * Switch the panning model to Equal Power:
  46339. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46340. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46341. */
  46342. switchPanningModelToEqualPower(): void;
  46343. private _switchPanningModel;
  46344. /**
  46345. * Connect this sound to a sound track audio node like gain...
  46346. * @param soundTrackAudioNode the sound track audio node to connect to
  46347. */
  46348. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46349. /**
  46350. * Transform this sound into a directional source
  46351. * @param coneInnerAngle Size of the inner cone in degree
  46352. * @param coneOuterAngle Size of the outer cone in degree
  46353. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46354. */
  46355. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46356. /**
  46357. * Gets or sets the inner angle for the directional cone.
  46358. */
  46359. get directionalConeInnerAngle(): number;
  46360. /**
  46361. * Gets or sets the inner angle for the directional cone.
  46362. */
  46363. set directionalConeInnerAngle(value: number);
  46364. /**
  46365. * Gets or sets the outer angle for the directional cone.
  46366. */
  46367. get directionalConeOuterAngle(): number;
  46368. /**
  46369. * Gets or sets the outer angle for the directional cone.
  46370. */
  46371. set directionalConeOuterAngle(value: number);
  46372. /**
  46373. * Sets the position of the emitter if spatial sound is enabled
  46374. * @param newPosition Defines the new posisiton
  46375. */
  46376. setPosition(newPosition: Vector3): void;
  46377. /**
  46378. * Sets the local direction of the emitter if spatial sound is enabled
  46379. * @param newLocalDirection Defines the new local direction
  46380. */
  46381. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46382. private _updateDirection;
  46383. /** @hidden */
  46384. updateDistanceFromListener(): void;
  46385. /**
  46386. * Sets a new custom attenuation function for the sound.
  46387. * @param callback Defines the function used for the attenuation
  46388. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46389. */
  46390. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46391. /**
  46392. * Play the sound
  46393. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46394. * @param offset (optional) Start the sound at a specific time in seconds
  46395. * @param length (optional) Sound duration (in seconds)
  46396. */
  46397. play(time?: number, offset?: number, length?: number): void;
  46398. private _onended;
  46399. /**
  46400. * Stop the sound
  46401. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46402. */
  46403. stop(time?: number): void;
  46404. /**
  46405. * Put the sound in pause
  46406. */
  46407. pause(): void;
  46408. /**
  46409. * Sets a dedicated volume for this sounds
  46410. * @param newVolume Define the new volume of the sound
  46411. * @param time Define time for gradual change to new volume
  46412. */
  46413. setVolume(newVolume: number, time?: number): void;
  46414. /**
  46415. * Set the sound play back rate
  46416. * @param newPlaybackRate Define the playback rate the sound should be played at
  46417. */
  46418. setPlaybackRate(newPlaybackRate: number): void;
  46419. /**
  46420. * Gets the volume of the sound.
  46421. * @returns the volume of the sound
  46422. */
  46423. getVolume(): number;
  46424. /**
  46425. * Attach the sound to a dedicated mesh
  46426. * @param transformNode The transform node to connect the sound with
  46427. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46428. */
  46429. attachToMesh(transformNode: TransformNode): void;
  46430. /**
  46431. * Detach the sound from the previously attached mesh
  46432. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46433. */
  46434. detachFromMesh(): void;
  46435. private _onRegisterAfterWorldMatrixUpdate;
  46436. /**
  46437. * Clone the current sound in the scene.
  46438. * @returns the new sound clone
  46439. */
  46440. clone(): Nullable<Sound>;
  46441. /**
  46442. * Gets the current underlying audio buffer containing the data
  46443. * @returns the audio buffer
  46444. */
  46445. getAudioBuffer(): Nullable<AudioBuffer>;
  46446. /**
  46447. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46448. * @returns the source node
  46449. */
  46450. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46451. /**
  46452. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46453. * @returns the gain node
  46454. */
  46455. getSoundGain(): Nullable<GainNode>;
  46456. /**
  46457. * Serializes the Sound in a JSON representation
  46458. * @returns the JSON representation of the sound
  46459. */
  46460. serialize(): any;
  46461. /**
  46462. * Parse a JSON representation of a sound to innstantiate in a given scene
  46463. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46464. * @param scene Define the scene the new parsed sound should be created in
  46465. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46466. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46467. * @returns the newly parsed sound
  46468. */
  46469. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46470. }
  46471. }
  46472. declare module "babylonjs/Actions/directAudioActions" {
  46473. import { Action } from "babylonjs/Actions/action";
  46474. import { Condition } from "babylonjs/Actions/condition";
  46475. import { Sound } from "babylonjs/Audio/sound";
  46476. /**
  46477. * This defines an action helpful to play a defined sound on a triggered action.
  46478. */
  46479. export class PlaySoundAction extends Action {
  46480. private _sound;
  46481. /**
  46482. * Instantiate the action
  46483. * @param triggerOptions defines the trigger options
  46484. * @param sound defines the sound to play
  46485. * @param condition defines the trigger related conditions
  46486. */
  46487. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46488. /** @hidden */
  46489. _prepare(): void;
  46490. /**
  46491. * Execute the action and play the sound.
  46492. */
  46493. execute(): void;
  46494. /**
  46495. * Serializes the actions and its related information.
  46496. * @param parent defines the object to serialize in
  46497. * @returns the serialized object
  46498. */
  46499. serialize(parent: any): any;
  46500. }
  46501. /**
  46502. * This defines an action helpful to stop a defined sound on a triggered action.
  46503. */
  46504. export class StopSoundAction extends Action {
  46505. private _sound;
  46506. /**
  46507. * Instantiate the action
  46508. * @param triggerOptions defines the trigger options
  46509. * @param sound defines the sound to stop
  46510. * @param condition defines the trigger related conditions
  46511. */
  46512. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46513. /** @hidden */
  46514. _prepare(): void;
  46515. /**
  46516. * Execute the action and stop the sound.
  46517. */
  46518. execute(): void;
  46519. /**
  46520. * Serializes the actions and its related information.
  46521. * @param parent defines the object to serialize in
  46522. * @returns the serialized object
  46523. */
  46524. serialize(parent: any): any;
  46525. }
  46526. }
  46527. declare module "babylonjs/Actions/interpolateValueAction" {
  46528. import { Action } from "babylonjs/Actions/action";
  46529. import { Condition } from "babylonjs/Actions/condition";
  46530. import { Observable } from "babylonjs/Misc/observable";
  46531. /**
  46532. * This defines an action responsible to change the value of a property
  46533. * by interpolating between its current value and the newly set one once triggered.
  46534. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46535. */
  46536. export class InterpolateValueAction extends Action {
  46537. /**
  46538. * Defines the path of the property where the value should be interpolated
  46539. */
  46540. propertyPath: string;
  46541. /**
  46542. * Defines the target value at the end of the interpolation.
  46543. */
  46544. value: any;
  46545. /**
  46546. * Defines the time it will take for the property to interpolate to the value.
  46547. */
  46548. duration: number;
  46549. /**
  46550. * Defines if the other scene animations should be stopped when the action has been triggered
  46551. */
  46552. stopOtherAnimations?: boolean;
  46553. /**
  46554. * Defines a callback raised once the interpolation animation has been done.
  46555. */
  46556. onInterpolationDone?: () => void;
  46557. /**
  46558. * Observable triggered once the interpolation animation has been done.
  46559. */
  46560. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46561. private _target;
  46562. private _effectiveTarget;
  46563. private _property;
  46564. /**
  46565. * Instantiate the action
  46566. * @param triggerOptions defines the trigger options
  46567. * @param target defines the object containing the value to interpolate
  46568. * @param propertyPath defines the path to the property in the target object
  46569. * @param value defines the target value at the end of the interpolation
  46570. * @param duration deines the time it will take for the property to interpolate to the value.
  46571. * @param condition defines the trigger related conditions
  46572. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46573. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46574. */
  46575. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46576. /** @hidden */
  46577. _prepare(): void;
  46578. /**
  46579. * Execute the action starts the value interpolation.
  46580. */
  46581. execute(): void;
  46582. /**
  46583. * Serializes the actions and its related information.
  46584. * @param parent defines the object to serialize in
  46585. * @returns the serialized object
  46586. */
  46587. serialize(parent: any): any;
  46588. }
  46589. }
  46590. declare module "babylonjs/Actions/index" {
  46591. export * from "babylonjs/Actions/abstractActionManager";
  46592. export * from "babylonjs/Actions/action";
  46593. export * from "babylonjs/Actions/actionEvent";
  46594. export * from "babylonjs/Actions/actionManager";
  46595. export * from "babylonjs/Actions/condition";
  46596. export * from "babylonjs/Actions/directActions";
  46597. export * from "babylonjs/Actions/directAudioActions";
  46598. export * from "babylonjs/Actions/interpolateValueAction";
  46599. }
  46600. declare module "babylonjs/Animations/index" {
  46601. export * from "babylonjs/Animations/animatable";
  46602. export * from "babylonjs/Animations/animation";
  46603. export * from "babylonjs/Animations/animationGroup";
  46604. export * from "babylonjs/Animations/animationPropertiesOverride";
  46605. export * from "babylonjs/Animations/easing";
  46606. export * from "babylonjs/Animations/runtimeAnimation";
  46607. export * from "babylonjs/Animations/animationEvent";
  46608. export * from "babylonjs/Animations/animationGroup";
  46609. export * from "babylonjs/Animations/animationKey";
  46610. export * from "babylonjs/Animations/animationRange";
  46611. export * from "babylonjs/Animations/animatable.interface";
  46612. }
  46613. declare module "babylonjs/Audio/soundTrack" {
  46614. import { Sound } from "babylonjs/Audio/sound";
  46615. import { Analyser } from "babylonjs/Audio/analyser";
  46616. import { Scene } from "babylonjs/scene";
  46617. /**
  46618. * Options allowed during the creation of a sound track.
  46619. */
  46620. export interface ISoundTrackOptions {
  46621. /**
  46622. * The volume the sound track should take during creation
  46623. */
  46624. volume?: number;
  46625. /**
  46626. * Define if the sound track is the main sound track of the scene
  46627. */
  46628. mainTrack?: boolean;
  46629. }
  46630. /**
  46631. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46632. * It will be also used in a future release to apply effects on a specific track.
  46633. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46634. */
  46635. export class SoundTrack {
  46636. /**
  46637. * The unique identifier of the sound track in the scene.
  46638. */
  46639. id: number;
  46640. /**
  46641. * The list of sounds included in the sound track.
  46642. */
  46643. soundCollection: Array<Sound>;
  46644. private _outputAudioNode;
  46645. private _scene;
  46646. private _connectedAnalyser;
  46647. private _options;
  46648. private _isInitialized;
  46649. /**
  46650. * Creates a new sound track.
  46651. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46652. * @param scene Define the scene the sound track belongs to
  46653. * @param options
  46654. */
  46655. constructor(scene: Scene, options?: ISoundTrackOptions);
  46656. private _initializeSoundTrackAudioGraph;
  46657. /**
  46658. * Release the sound track and its associated resources
  46659. */
  46660. dispose(): void;
  46661. /**
  46662. * Adds a sound to this sound track
  46663. * @param sound define the cound to add
  46664. * @ignoreNaming
  46665. */
  46666. AddSound(sound: Sound): void;
  46667. /**
  46668. * Removes a sound to this sound track
  46669. * @param sound define the cound to remove
  46670. * @ignoreNaming
  46671. */
  46672. RemoveSound(sound: Sound): void;
  46673. /**
  46674. * Set a global volume for the full sound track.
  46675. * @param newVolume Define the new volume of the sound track
  46676. */
  46677. setVolume(newVolume: number): void;
  46678. /**
  46679. * Switch the panning model to HRTF:
  46680. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46681. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46682. */
  46683. switchPanningModelToHRTF(): void;
  46684. /**
  46685. * Switch the panning model to Equal Power:
  46686. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46687. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46688. */
  46689. switchPanningModelToEqualPower(): void;
  46690. /**
  46691. * Connect the sound track to an audio analyser allowing some amazing
  46692. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46693. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46694. * @param analyser The analyser to connect to the engine
  46695. */
  46696. connectToAnalyser(analyser: Analyser): void;
  46697. }
  46698. }
  46699. declare module "babylonjs/Audio/audioSceneComponent" {
  46700. import { Sound } from "babylonjs/Audio/sound";
  46701. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  46702. import { Nullable } from "babylonjs/types";
  46703. import { Vector3 } from "babylonjs/Maths/math.vector";
  46704. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46705. import { Scene } from "babylonjs/scene";
  46706. import { AbstractScene } from "babylonjs/abstractScene";
  46707. import "babylonjs/Audio/audioEngine";
  46708. module "babylonjs/abstractScene" {
  46709. interface AbstractScene {
  46710. /**
  46711. * The list of sounds used in the scene.
  46712. */
  46713. sounds: Nullable<Array<Sound>>;
  46714. }
  46715. }
  46716. module "babylonjs/scene" {
  46717. interface Scene {
  46718. /**
  46719. * @hidden
  46720. * Backing field
  46721. */
  46722. _mainSoundTrack: SoundTrack;
  46723. /**
  46724. * The main sound track played by the scene.
  46725. * It cotains your primary collection of sounds.
  46726. */
  46727. mainSoundTrack: SoundTrack;
  46728. /**
  46729. * The list of sound tracks added to the scene
  46730. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46731. */
  46732. soundTracks: Nullable<Array<SoundTrack>>;
  46733. /**
  46734. * Gets a sound using a given name
  46735. * @param name defines the name to search for
  46736. * @return the found sound or null if not found at all.
  46737. */
  46738. getSoundByName(name: string): Nullable<Sound>;
  46739. /**
  46740. * Gets or sets if audio support is enabled
  46741. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46742. */
  46743. audioEnabled: boolean;
  46744. /**
  46745. * Gets or sets if audio will be output to headphones
  46746. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46747. */
  46748. headphone: boolean;
  46749. /**
  46750. * Gets or sets custom audio listener position provider
  46751. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46752. */
  46753. audioListenerPositionProvider: Nullable<() => Vector3>;
  46754. /**
  46755. * Gets or sets a refresh rate when using 3D audio positioning
  46756. */
  46757. audioPositioningRefreshRate: number;
  46758. }
  46759. }
  46760. /**
  46761. * Defines the sound scene component responsible to manage any sounds
  46762. * in a given scene.
  46763. */
  46764. export class AudioSceneComponent implements ISceneSerializableComponent {
  46765. private static _CameraDirectionLH;
  46766. private static _CameraDirectionRH;
  46767. /**
  46768. * The component name helpfull to identify the component in the list of scene components.
  46769. */
  46770. readonly name: string;
  46771. /**
  46772. * The scene the component belongs to.
  46773. */
  46774. scene: Scene;
  46775. private _audioEnabled;
  46776. /**
  46777. * Gets whether audio is enabled or not.
  46778. * Please use related enable/disable method to switch state.
  46779. */
  46780. get audioEnabled(): boolean;
  46781. private _headphone;
  46782. /**
  46783. * Gets whether audio is outputing to headphone or not.
  46784. * Please use the according Switch methods to change output.
  46785. */
  46786. get headphone(): boolean;
  46787. /**
  46788. * Gets or sets a refresh rate when using 3D audio positioning
  46789. */
  46790. audioPositioningRefreshRate: number;
  46791. private _audioListenerPositionProvider;
  46792. /**
  46793. * Gets the current audio listener position provider
  46794. */
  46795. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  46796. /**
  46797. * Sets a custom listener position for all sounds in the scene
  46798. * By default, this is the position of the first active camera
  46799. */
  46800. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  46801. /**
  46802. * Creates a new instance of the component for the given scene
  46803. * @param scene Defines the scene to register the component in
  46804. */
  46805. constructor(scene: Scene);
  46806. /**
  46807. * Registers the component in a given scene
  46808. */
  46809. register(): void;
  46810. /**
  46811. * Rebuilds the elements related to this component in case of
  46812. * context lost for instance.
  46813. */
  46814. rebuild(): void;
  46815. /**
  46816. * Serializes the component data to the specified json object
  46817. * @param serializationObject The object to serialize to
  46818. */
  46819. serialize(serializationObject: any): void;
  46820. /**
  46821. * Adds all the elements from the container to the scene
  46822. * @param container the container holding the elements
  46823. */
  46824. addFromContainer(container: AbstractScene): void;
  46825. /**
  46826. * Removes all the elements in the container from the scene
  46827. * @param container contains the elements to remove
  46828. * @param dispose if the removed element should be disposed (default: false)
  46829. */
  46830. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46831. /**
  46832. * Disposes the component and the associated ressources.
  46833. */
  46834. dispose(): void;
  46835. /**
  46836. * Disables audio in the associated scene.
  46837. */
  46838. disableAudio(): void;
  46839. /**
  46840. * Enables audio in the associated scene.
  46841. */
  46842. enableAudio(): void;
  46843. /**
  46844. * Switch audio to headphone output.
  46845. */
  46846. switchAudioModeForHeadphones(): void;
  46847. /**
  46848. * Switch audio to normal speakers.
  46849. */
  46850. switchAudioModeForNormalSpeakers(): void;
  46851. private _cachedCameraDirection;
  46852. private _cachedCameraPosition;
  46853. private _lastCheck;
  46854. private _afterRender;
  46855. }
  46856. }
  46857. declare module "babylonjs/Audio/weightedsound" {
  46858. import { Sound } from "babylonjs/Audio/sound";
  46859. /**
  46860. * Wraps one or more Sound objects and selects one with random weight for playback.
  46861. */
  46862. export class WeightedSound {
  46863. /** When true a Sound will be selected and played when the current playing Sound completes. */
  46864. loop: boolean;
  46865. private _coneInnerAngle;
  46866. private _coneOuterAngle;
  46867. private _volume;
  46868. /** A Sound is currently playing. */
  46869. isPlaying: boolean;
  46870. /** A Sound is currently paused. */
  46871. isPaused: boolean;
  46872. private _sounds;
  46873. private _weights;
  46874. private _currentIndex?;
  46875. /**
  46876. * Creates a new WeightedSound from the list of sounds given.
  46877. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  46878. * @param sounds Array of Sounds that will be selected from.
  46879. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  46880. */
  46881. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  46882. /**
  46883. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  46884. */
  46885. get directionalConeInnerAngle(): number;
  46886. /**
  46887. * The size of cone in degress for a directional sound in which there will be no attenuation.
  46888. */
  46889. set directionalConeInnerAngle(value: number);
  46890. /**
  46891. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46892. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46893. */
  46894. get directionalConeOuterAngle(): number;
  46895. /**
  46896. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46897. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46898. */
  46899. set directionalConeOuterAngle(value: number);
  46900. /**
  46901. * Playback volume.
  46902. */
  46903. get volume(): number;
  46904. /**
  46905. * Playback volume.
  46906. */
  46907. set volume(value: number);
  46908. private _onended;
  46909. /**
  46910. * Suspend playback
  46911. */
  46912. pause(): void;
  46913. /**
  46914. * Stop playback
  46915. */
  46916. stop(): void;
  46917. /**
  46918. * Start playback.
  46919. * @param startOffset Position the clip head at a specific time in seconds.
  46920. */
  46921. play(startOffset?: number): void;
  46922. }
  46923. }
  46924. declare module "babylonjs/Audio/index" {
  46925. export * from "babylonjs/Audio/analyser";
  46926. export * from "babylonjs/Audio/audioEngine";
  46927. export * from "babylonjs/Audio/audioSceneComponent";
  46928. export * from "babylonjs/Audio/sound";
  46929. export * from "babylonjs/Audio/soundTrack";
  46930. export * from "babylonjs/Audio/weightedsound";
  46931. }
  46932. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  46933. import { Behavior } from "babylonjs/Behaviors/behavior";
  46934. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46935. import { BackEase } from "babylonjs/Animations/easing";
  46936. /**
  46937. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  46938. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46939. */
  46940. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  46941. /**
  46942. * Gets the name of the behavior.
  46943. */
  46944. get name(): string;
  46945. /**
  46946. * The easing function used by animations
  46947. */
  46948. static EasingFunction: BackEase;
  46949. /**
  46950. * The easing mode used by animations
  46951. */
  46952. static EasingMode: number;
  46953. /**
  46954. * The duration of the animation, in milliseconds
  46955. */
  46956. transitionDuration: number;
  46957. /**
  46958. * Length of the distance animated by the transition when lower radius is reached
  46959. */
  46960. lowerRadiusTransitionRange: number;
  46961. /**
  46962. * Length of the distance animated by the transition when upper radius is reached
  46963. */
  46964. upperRadiusTransitionRange: number;
  46965. private _autoTransitionRange;
  46966. /**
  46967. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46968. */
  46969. get autoTransitionRange(): boolean;
  46970. /**
  46971. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46972. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  46973. */
  46974. set autoTransitionRange(value: boolean);
  46975. private _attachedCamera;
  46976. private _onAfterCheckInputsObserver;
  46977. private _onMeshTargetChangedObserver;
  46978. /**
  46979. * Initializes the behavior.
  46980. */
  46981. init(): void;
  46982. /**
  46983. * Attaches the behavior to its arc rotate camera.
  46984. * @param camera Defines the camera to attach the behavior to
  46985. */
  46986. attach(camera: ArcRotateCamera): void;
  46987. /**
  46988. * Detaches the behavior from its current arc rotate camera.
  46989. */
  46990. detach(): void;
  46991. private _radiusIsAnimating;
  46992. private _radiusBounceTransition;
  46993. private _animatables;
  46994. private _cachedWheelPrecision;
  46995. /**
  46996. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  46997. * @param radiusLimit The limit to check against.
  46998. * @return Bool to indicate if at limit.
  46999. */
  47000. private _isRadiusAtLimit;
  47001. /**
  47002. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47003. * @param radiusDelta The delta by which to animate to. Can be negative.
  47004. */
  47005. private _applyBoundRadiusAnimation;
  47006. /**
  47007. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47008. */
  47009. protected _clearAnimationLocks(): void;
  47010. /**
  47011. * Stops and removes all animations that have been applied to the camera
  47012. */
  47013. stopAllAnimations(): void;
  47014. }
  47015. }
  47016. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47017. import { Behavior } from "babylonjs/Behaviors/behavior";
  47018. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47019. import { ExponentialEase } from "babylonjs/Animations/easing";
  47020. import { Nullable } from "babylonjs/types";
  47021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47022. import { Vector3 } from "babylonjs/Maths/math.vector";
  47023. /**
  47024. * 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.
  47025. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47026. */
  47027. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47028. /**
  47029. * Gets the name of the behavior.
  47030. */
  47031. get name(): string;
  47032. private _mode;
  47033. private _radiusScale;
  47034. private _positionScale;
  47035. private _defaultElevation;
  47036. private _elevationReturnTime;
  47037. private _elevationReturnWaitTime;
  47038. private _zoomStopsAnimation;
  47039. private _framingTime;
  47040. /**
  47041. * The easing function used by animations
  47042. */
  47043. static EasingFunction: ExponentialEase;
  47044. /**
  47045. * The easing mode used by animations
  47046. */
  47047. static EasingMode: number;
  47048. /**
  47049. * Sets the current mode used by the behavior
  47050. */
  47051. set mode(mode: number);
  47052. /**
  47053. * Gets current mode used by the behavior.
  47054. */
  47055. get mode(): number;
  47056. /**
  47057. * Sets the scale applied to the radius (1 by default)
  47058. */
  47059. set radiusScale(radius: number);
  47060. /**
  47061. * Gets the scale applied to the radius
  47062. */
  47063. get radiusScale(): number;
  47064. /**
  47065. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47066. */
  47067. set positionScale(scale: number);
  47068. /**
  47069. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47070. */
  47071. get positionScale(): number;
  47072. /**
  47073. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47074. * behaviour is triggered, in radians.
  47075. */
  47076. set defaultElevation(elevation: number);
  47077. /**
  47078. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47079. * behaviour is triggered, in radians.
  47080. */
  47081. get defaultElevation(): number;
  47082. /**
  47083. * Sets the time (in milliseconds) taken to return to the default beta position.
  47084. * Negative value indicates camera should not return to default.
  47085. */
  47086. set elevationReturnTime(speed: number);
  47087. /**
  47088. * Gets the time (in milliseconds) taken to return to the default beta position.
  47089. * Negative value indicates camera should not return to default.
  47090. */
  47091. get elevationReturnTime(): number;
  47092. /**
  47093. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47094. */
  47095. set elevationReturnWaitTime(time: number);
  47096. /**
  47097. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47098. */
  47099. get elevationReturnWaitTime(): number;
  47100. /**
  47101. * Sets the flag that indicates if user zooming should stop animation.
  47102. */
  47103. set zoomStopsAnimation(flag: boolean);
  47104. /**
  47105. * Gets the flag that indicates if user zooming should stop animation.
  47106. */
  47107. get zoomStopsAnimation(): boolean;
  47108. /**
  47109. * Sets the transition time when framing the mesh, in milliseconds
  47110. */
  47111. set framingTime(time: number);
  47112. /**
  47113. * Gets the transition time when framing the mesh, in milliseconds
  47114. */
  47115. get framingTime(): number;
  47116. /**
  47117. * Define if the behavior should automatically change the configured
  47118. * camera limits and sensibilities.
  47119. */
  47120. autoCorrectCameraLimitsAndSensibility: boolean;
  47121. private _onPrePointerObservableObserver;
  47122. private _onAfterCheckInputsObserver;
  47123. private _onMeshTargetChangedObserver;
  47124. private _attachedCamera;
  47125. private _isPointerDown;
  47126. private _lastInteractionTime;
  47127. /**
  47128. * Initializes the behavior.
  47129. */
  47130. init(): void;
  47131. /**
  47132. * Attaches the behavior to its arc rotate camera.
  47133. * @param camera Defines the camera to attach the behavior to
  47134. */
  47135. attach(camera: ArcRotateCamera): void;
  47136. /**
  47137. * Detaches the behavior from its current arc rotate camera.
  47138. */
  47139. detach(): void;
  47140. private _animatables;
  47141. private _betaIsAnimating;
  47142. private _betaTransition;
  47143. private _radiusTransition;
  47144. private _vectorTransition;
  47145. /**
  47146. * Targets the given mesh and updates zoom level accordingly.
  47147. * @param mesh The mesh to target.
  47148. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47149. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47150. */
  47151. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47152. /**
  47153. * Targets the given mesh with its children and updates zoom level accordingly.
  47154. * @param mesh The mesh to target.
  47155. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47156. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47157. */
  47158. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47159. /**
  47160. * Targets the given meshes with their children and updates zoom level accordingly.
  47161. * @param meshes The mesh to target.
  47162. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47163. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47164. */
  47165. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47166. /**
  47167. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47168. * @param minimumWorld Determines the smaller position of the bounding box extend
  47169. * @param maximumWorld Determines the bigger position of the bounding box extend
  47170. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47171. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47172. */
  47173. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47174. /**
  47175. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47176. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47177. * frustum width.
  47178. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47179. * to fully enclose the mesh in the viewing frustum.
  47180. */
  47181. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47182. /**
  47183. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47184. * is automatically returned to its default position (expected to be above ground plane).
  47185. */
  47186. private _maintainCameraAboveGround;
  47187. /**
  47188. * Returns the frustum slope based on the canvas ratio and camera FOV
  47189. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47190. */
  47191. private _getFrustumSlope;
  47192. /**
  47193. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47194. */
  47195. private _clearAnimationLocks;
  47196. /**
  47197. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47198. */
  47199. private _applyUserInteraction;
  47200. /**
  47201. * Stops and removes all animations that have been applied to the camera
  47202. */
  47203. stopAllAnimations(): void;
  47204. /**
  47205. * Gets a value indicating if the user is moving the camera
  47206. */
  47207. get isUserIsMoving(): boolean;
  47208. /**
  47209. * The camera can move all the way towards the mesh.
  47210. */
  47211. static IgnoreBoundsSizeMode: number;
  47212. /**
  47213. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47214. */
  47215. static FitFrustumSidesMode: number;
  47216. }
  47217. }
  47218. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47219. import { Nullable } from "babylonjs/types";
  47220. import { Camera } from "babylonjs/Cameras/camera";
  47221. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47222. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47223. /**
  47224. * Base class for Camera Pointer Inputs.
  47225. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47226. * for example usage.
  47227. */
  47228. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47229. /**
  47230. * Defines the camera the input is attached to.
  47231. */
  47232. abstract camera: Camera;
  47233. /**
  47234. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47235. */
  47236. protected _altKey: boolean;
  47237. protected _ctrlKey: boolean;
  47238. protected _metaKey: boolean;
  47239. protected _shiftKey: boolean;
  47240. /**
  47241. * Which mouse buttons were pressed at time of last mouse event.
  47242. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47243. */
  47244. protected _buttonsPressed: number;
  47245. /**
  47246. * Defines the buttons associated with the input to handle camera move.
  47247. */
  47248. buttons: number[];
  47249. /**
  47250. * Attach the input controls to a specific dom element to get the input from.
  47251. * @param element Defines the element the controls should be listened from
  47252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47253. */
  47254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47255. /**
  47256. * Detach the current controls from the specified dom element.
  47257. * @param element Defines the element to stop listening the inputs from
  47258. */
  47259. detachControl(element: Nullable<HTMLElement>): void;
  47260. /**
  47261. * Gets the class name of the current input.
  47262. * @returns the class name
  47263. */
  47264. getClassName(): string;
  47265. /**
  47266. * Get the friendly name associated with the input class.
  47267. * @returns the input friendly name
  47268. */
  47269. getSimpleName(): string;
  47270. /**
  47271. * Called on pointer POINTERDOUBLETAP event.
  47272. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47273. */
  47274. protected onDoubleTap(type: string): void;
  47275. /**
  47276. * Called on pointer POINTERMOVE event if only a single touch is active.
  47277. * Override this method to provide functionality.
  47278. */
  47279. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47280. /**
  47281. * Called on pointer POINTERMOVE event if multiple touches are active.
  47282. * Override this method to provide functionality.
  47283. */
  47284. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47285. /**
  47286. * Called on JS contextmenu event.
  47287. * Override this method to provide functionality.
  47288. */
  47289. protected onContextMenu(evt: PointerEvent): void;
  47290. /**
  47291. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47292. * press.
  47293. * Override this method to provide functionality.
  47294. */
  47295. protected onButtonDown(evt: PointerEvent): void;
  47296. /**
  47297. * Called each time a new POINTERUP event occurs. Ie, for each button
  47298. * release.
  47299. * Override this method to provide functionality.
  47300. */
  47301. protected onButtonUp(evt: PointerEvent): void;
  47302. /**
  47303. * Called when window becomes inactive.
  47304. * Override this method to provide functionality.
  47305. */
  47306. protected onLostFocus(): void;
  47307. private _pointerInput;
  47308. private _observer;
  47309. private _onLostFocus;
  47310. private pointA;
  47311. private pointB;
  47312. }
  47313. }
  47314. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47315. import { Nullable } from "babylonjs/types";
  47316. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47317. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47318. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47319. /**
  47320. * Manage the pointers inputs to control an arc rotate camera.
  47321. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47322. */
  47323. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47324. /**
  47325. * Defines the camera the input is attached to.
  47326. */
  47327. camera: ArcRotateCamera;
  47328. /**
  47329. * Gets the class name of the current input.
  47330. * @returns the class name
  47331. */
  47332. getClassName(): string;
  47333. /**
  47334. * Defines the buttons associated with the input to handle camera move.
  47335. */
  47336. buttons: number[];
  47337. /**
  47338. * Defines the pointer angular sensibility along the X axis or how fast is
  47339. * the camera rotating.
  47340. */
  47341. angularSensibilityX: number;
  47342. /**
  47343. * Defines the pointer angular sensibility along the Y axis or how fast is
  47344. * the camera rotating.
  47345. */
  47346. angularSensibilityY: number;
  47347. /**
  47348. * Defines the pointer pinch precision or how fast is the camera zooming.
  47349. */
  47350. pinchPrecision: number;
  47351. /**
  47352. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47353. * from 0.
  47354. * It defines the percentage of current camera.radius to use as delta when
  47355. * pinch zoom is used.
  47356. */
  47357. pinchDeltaPercentage: number;
  47358. /**
  47359. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47360. * that any object in the plane at the camera's target point will scale
  47361. * perfectly with finger motion.
  47362. * Overrides pinchDeltaPercentage and pinchPrecision.
  47363. */
  47364. useNaturalPinchZoom: boolean;
  47365. /**
  47366. * Defines the pointer panning sensibility or how fast is the camera moving.
  47367. */
  47368. panningSensibility: number;
  47369. /**
  47370. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47371. */
  47372. multiTouchPanning: boolean;
  47373. /**
  47374. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47375. * zoom (pinch) through multitouch.
  47376. */
  47377. multiTouchPanAndZoom: boolean;
  47378. /**
  47379. * Revers pinch action direction.
  47380. */
  47381. pinchInwards: boolean;
  47382. private _isPanClick;
  47383. private _twoFingerActivityCount;
  47384. private _isPinching;
  47385. /**
  47386. * Called on pointer POINTERMOVE event if only a single touch is active.
  47387. */
  47388. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47389. /**
  47390. * Called on pointer POINTERDOUBLETAP event.
  47391. */
  47392. protected onDoubleTap(type: string): void;
  47393. /**
  47394. * Called on pointer POINTERMOVE event if multiple touches are active.
  47395. */
  47396. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47397. /**
  47398. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47399. * press.
  47400. */
  47401. protected onButtonDown(evt: PointerEvent): void;
  47402. /**
  47403. * Called each time a new POINTERUP event occurs. Ie, for each button
  47404. * release.
  47405. */
  47406. protected onButtonUp(evt: PointerEvent): void;
  47407. /**
  47408. * Called when window becomes inactive.
  47409. */
  47410. protected onLostFocus(): void;
  47411. }
  47412. }
  47413. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47414. import { Nullable } from "babylonjs/types";
  47415. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47416. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47417. /**
  47418. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47419. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47420. */
  47421. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47422. /**
  47423. * Defines the camera the input is attached to.
  47424. */
  47425. camera: ArcRotateCamera;
  47426. /**
  47427. * Defines the list of key codes associated with the up action (increase alpha)
  47428. */
  47429. keysUp: number[];
  47430. /**
  47431. * Defines the list of key codes associated with the down action (decrease alpha)
  47432. */
  47433. keysDown: number[];
  47434. /**
  47435. * Defines the list of key codes associated with the left action (increase beta)
  47436. */
  47437. keysLeft: number[];
  47438. /**
  47439. * Defines the list of key codes associated with the right action (decrease beta)
  47440. */
  47441. keysRight: number[];
  47442. /**
  47443. * Defines the list of key codes associated with the reset action.
  47444. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47445. */
  47446. keysReset: number[];
  47447. /**
  47448. * Defines the panning sensibility of the inputs.
  47449. * (How fast is the camera panning)
  47450. */
  47451. panningSensibility: number;
  47452. /**
  47453. * Defines the zooming sensibility of the inputs.
  47454. * (How fast is the camera zooming)
  47455. */
  47456. zoomingSensibility: number;
  47457. /**
  47458. * Defines whether maintaining the alt key down switch the movement mode from
  47459. * orientation to zoom.
  47460. */
  47461. useAltToZoom: boolean;
  47462. /**
  47463. * Rotation speed of the camera
  47464. */
  47465. angularSpeed: number;
  47466. private _keys;
  47467. private _ctrlPressed;
  47468. private _altPressed;
  47469. private _onCanvasBlurObserver;
  47470. private _onKeyboardObserver;
  47471. private _engine;
  47472. private _scene;
  47473. /**
  47474. * Attach the input controls to a specific dom element to get the input from.
  47475. * @param element Defines the element the controls should be listened from
  47476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47477. */
  47478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47479. /**
  47480. * Detach the current controls from the specified dom element.
  47481. * @param element Defines the element to stop listening the inputs from
  47482. */
  47483. detachControl(element: Nullable<HTMLElement>): void;
  47484. /**
  47485. * Update the current camera state depending on the inputs that have been used this frame.
  47486. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47487. */
  47488. checkInputs(): void;
  47489. /**
  47490. * Gets the class name of the current intput.
  47491. * @returns the class name
  47492. */
  47493. getClassName(): string;
  47494. /**
  47495. * Get the friendly name associated with the input class.
  47496. * @returns the input friendly name
  47497. */
  47498. getSimpleName(): string;
  47499. }
  47500. }
  47501. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47502. import { Nullable } from "babylonjs/types";
  47503. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47504. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47505. /**
  47506. * Manage the mouse wheel inputs to control an arc rotate camera.
  47507. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47508. */
  47509. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47510. /**
  47511. * Defines the camera the input is attached to.
  47512. */
  47513. camera: ArcRotateCamera;
  47514. /**
  47515. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47516. */
  47517. wheelPrecision: number;
  47518. /**
  47519. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47520. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47521. */
  47522. wheelDeltaPercentage: number;
  47523. private _wheel;
  47524. private _observer;
  47525. private computeDeltaFromMouseWheelLegacyEvent;
  47526. /**
  47527. * Attach the input controls to a specific dom element to get the input from.
  47528. * @param element Defines the element the controls should be listened from
  47529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47530. */
  47531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47532. /**
  47533. * Detach the current controls from the specified dom element.
  47534. * @param element Defines the element to stop listening the inputs from
  47535. */
  47536. detachControl(element: Nullable<HTMLElement>): void;
  47537. /**
  47538. * Gets the class name of the current intput.
  47539. * @returns the class name
  47540. */
  47541. getClassName(): string;
  47542. /**
  47543. * Get the friendly name associated with the input class.
  47544. * @returns the input friendly name
  47545. */
  47546. getSimpleName(): string;
  47547. }
  47548. }
  47549. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47550. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47551. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47552. /**
  47553. * Default Inputs manager for the ArcRotateCamera.
  47554. * It groups all the default supported inputs for ease of use.
  47555. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47556. */
  47557. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47558. /**
  47559. * Instantiates a new ArcRotateCameraInputsManager.
  47560. * @param camera Defines the camera the inputs belong to
  47561. */
  47562. constructor(camera: ArcRotateCamera);
  47563. /**
  47564. * Add mouse wheel input support to the input manager.
  47565. * @returns the current input manager
  47566. */
  47567. addMouseWheel(): ArcRotateCameraInputsManager;
  47568. /**
  47569. * Add pointers input support to the input manager.
  47570. * @returns the current input manager
  47571. */
  47572. addPointers(): ArcRotateCameraInputsManager;
  47573. /**
  47574. * Add keyboard input support to the input manager.
  47575. * @returns the current input manager
  47576. */
  47577. addKeyboard(): ArcRotateCameraInputsManager;
  47578. }
  47579. }
  47580. declare module "babylonjs/Cameras/arcRotateCamera" {
  47581. import { Observable } from "babylonjs/Misc/observable";
  47582. import { Nullable } from "babylonjs/types";
  47583. import { Scene } from "babylonjs/scene";
  47584. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47586. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47587. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47588. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47589. import { Camera } from "babylonjs/Cameras/camera";
  47590. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47591. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47592. import { Collider } from "babylonjs/Collisions/collider";
  47593. /**
  47594. * This represents an orbital type of camera.
  47595. *
  47596. * 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.
  47597. * 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.
  47598. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47599. */
  47600. export class ArcRotateCamera extends TargetCamera {
  47601. /**
  47602. * Defines the rotation angle of the camera along the longitudinal axis.
  47603. */
  47604. alpha: number;
  47605. /**
  47606. * Defines the rotation angle of the camera along the latitudinal axis.
  47607. */
  47608. beta: number;
  47609. /**
  47610. * Defines the radius of the camera from it s target point.
  47611. */
  47612. radius: number;
  47613. protected _target: Vector3;
  47614. protected _targetHost: Nullable<AbstractMesh>;
  47615. /**
  47616. * Defines the target point of the camera.
  47617. * The camera looks towards it form the radius distance.
  47618. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47619. */
  47620. get target(): Vector3;
  47621. set target(value: Vector3);
  47622. /**
  47623. * Define the current local position of the camera in the scene
  47624. */
  47625. get position(): Vector3;
  47626. set position(newPosition: Vector3);
  47627. protected _upToYMatrix: Matrix;
  47628. protected _YToUpMatrix: Matrix;
  47629. /**
  47630. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47631. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47632. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47633. */
  47634. set upVector(vec: Vector3);
  47635. get upVector(): Vector3;
  47636. /**
  47637. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47638. */
  47639. setMatUp(): void;
  47640. /**
  47641. * Current inertia value on the longitudinal axis.
  47642. * The bigger this number the longer it will take for the camera to stop.
  47643. */
  47644. inertialAlphaOffset: number;
  47645. /**
  47646. * Current inertia value on the latitudinal axis.
  47647. * The bigger this number the longer it will take for the camera to stop.
  47648. */
  47649. inertialBetaOffset: number;
  47650. /**
  47651. * Current inertia value on the radius axis.
  47652. * The bigger this number the longer it will take for the camera to stop.
  47653. */
  47654. inertialRadiusOffset: number;
  47655. /**
  47656. * Minimum allowed angle on the longitudinal axis.
  47657. * This can help limiting how the Camera is able to move in the scene.
  47658. */
  47659. lowerAlphaLimit: Nullable<number>;
  47660. /**
  47661. * Maximum allowed angle on the longitudinal axis.
  47662. * This can help limiting how the Camera is able to move in the scene.
  47663. */
  47664. upperAlphaLimit: Nullable<number>;
  47665. /**
  47666. * Minimum allowed angle on the latitudinal axis.
  47667. * This can help limiting how the Camera is able to move in the scene.
  47668. */
  47669. lowerBetaLimit: number;
  47670. /**
  47671. * Maximum allowed angle on the latitudinal axis.
  47672. * This can help limiting how the Camera is able to move in the scene.
  47673. */
  47674. upperBetaLimit: number;
  47675. /**
  47676. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  47677. * This can help limiting how the Camera is able to move in the scene.
  47678. */
  47679. lowerRadiusLimit: Nullable<number>;
  47680. /**
  47681. * Maximum allowed distance of the camera to the target (The camera can not get further).
  47682. * This can help limiting how the Camera is able to move in the scene.
  47683. */
  47684. upperRadiusLimit: Nullable<number>;
  47685. /**
  47686. * Defines the current inertia value used during panning of the camera along the X axis.
  47687. */
  47688. inertialPanningX: number;
  47689. /**
  47690. * Defines the current inertia value used during panning of the camera along the Y axis.
  47691. */
  47692. inertialPanningY: number;
  47693. /**
  47694. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  47695. * Basically if your fingers moves away from more than this distance you will be considered
  47696. * in pinch mode.
  47697. */
  47698. pinchToPanMaxDistance: number;
  47699. /**
  47700. * Defines the maximum distance the camera can pan.
  47701. * This could help keeping the cammera always in your scene.
  47702. */
  47703. panningDistanceLimit: Nullable<number>;
  47704. /**
  47705. * Defines the target of the camera before paning.
  47706. */
  47707. panningOriginTarget: Vector3;
  47708. /**
  47709. * Defines the value of the inertia used during panning.
  47710. * 0 would mean stop inertia and one would mean no decelleration at all.
  47711. */
  47712. panningInertia: number;
  47713. /**
  47714. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  47715. */
  47716. get angularSensibilityX(): number;
  47717. set angularSensibilityX(value: number);
  47718. /**
  47719. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  47720. */
  47721. get angularSensibilityY(): number;
  47722. set angularSensibilityY(value: number);
  47723. /**
  47724. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  47725. */
  47726. get pinchPrecision(): number;
  47727. set pinchPrecision(value: number);
  47728. /**
  47729. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  47730. * It will be used instead of pinchDeltaPrecision if different from 0.
  47731. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47732. */
  47733. get pinchDeltaPercentage(): number;
  47734. set pinchDeltaPercentage(value: number);
  47735. /**
  47736. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  47737. * and pinch delta percentage.
  47738. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47739. * that any object in the plane at the camera's target point will scale
  47740. * perfectly with finger motion.
  47741. */
  47742. get useNaturalPinchZoom(): boolean;
  47743. set useNaturalPinchZoom(value: boolean);
  47744. /**
  47745. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  47746. */
  47747. get panningSensibility(): number;
  47748. set panningSensibility(value: number);
  47749. /**
  47750. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  47751. */
  47752. get keysUp(): number[];
  47753. set keysUp(value: number[]);
  47754. /**
  47755. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  47756. */
  47757. get keysDown(): number[];
  47758. set keysDown(value: number[]);
  47759. /**
  47760. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  47761. */
  47762. get keysLeft(): number[];
  47763. set keysLeft(value: number[]);
  47764. /**
  47765. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  47766. */
  47767. get keysRight(): number[];
  47768. set keysRight(value: number[]);
  47769. /**
  47770. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47771. */
  47772. get wheelPrecision(): number;
  47773. set wheelPrecision(value: number);
  47774. /**
  47775. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  47776. * It will be used instead of pinchDeltaPrecision if different from 0.
  47777. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47778. */
  47779. get wheelDeltaPercentage(): number;
  47780. set wheelDeltaPercentage(value: number);
  47781. /**
  47782. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  47783. */
  47784. zoomOnFactor: number;
  47785. /**
  47786. * Defines a screen offset for the camera position.
  47787. */
  47788. targetScreenOffset: Vector2;
  47789. /**
  47790. * Allows the camera to be completely reversed.
  47791. * If false the camera can not arrive upside down.
  47792. */
  47793. allowUpsideDown: boolean;
  47794. /**
  47795. * Define if double tap/click is used to restore the previously saved state of the camera.
  47796. */
  47797. useInputToRestoreState: boolean;
  47798. /** @hidden */
  47799. _viewMatrix: Matrix;
  47800. /** @hidden */
  47801. _useCtrlForPanning: boolean;
  47802. /** @hidden */
  47803. _panningMouseButton: number;
  47804. /**
  47805. * Defines the input associated to the camera.
  47806. */
  47807. inputs: ArcRotateCameraInputsManager;
  47808. /** @hidden */
  47809. _reset: () => void;
  47810. /**
  47811. * Defines the allowed panning axis.
  47812. */
  47813. panningAxis: Vector3;
  47814. protected _localDirection: Vector3;
  47815. protected _transformedDirection: Vector3;
  47816. private _bouncingBehavior;
  47817. /**
  47818. * Gets the bouncing behavior of the camera if it has been enabled.
  47819. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47820. */
  47821. get bouncingBehavior(): Nullable<BouncingBehavior>;
  47822. /**
  47823. * Defines if the bouncing behavior of the camera is enabled on the camera.
  47824. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47825. */
  47826. get useBouncingBehavior(): boolean;
  47827. set useBouncingBehavior(value: boolean);
  47828. private _framingBehavior;
  47829. /**
  47830. * Gets the framing behavior of the camera if it has been enabled.
  47831. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47832. */
  47833. get framingBehavior(): Nullable<FramingBehavior>;
  47834. /**
  47835. * Defines if the framing behavior of the camera is enabled on the camera.
  47836. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47837. */
  47838. get useFramingBehavior(): boolean;
  47839. set useFramingBehavior(value: boolean);
  47840. private _autoRotationBehavior;
  47841. /**
  47842. * Gets the auto rotation behavior of the camera if it has been enabled.
  47843. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47844. */
  47845. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  47846. /**
  47847. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  47848. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47849. */
  47850. get useAutoRotationBehavior(): boolean;
  47851. set useAutoRotationBehavior(value: boolean);
  47852. /**
  47853. * Observable triggered when the mesh target has been changed on the camera.
  47854. */
  47855. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  47856. /**
  47857. * Event raised when the camera is colliding with a mesh.
  47858. */
  47859. onCollide: (collidedMesh: AbstractMesh) => void;
  47860. /**
  47861. * Defines whether the camera should check collision with the objects oh the scene.
  47862. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  47863. */
  47864. checkCollisions: boolean;
  47865. /**
  47866. * Defines the collision radius of the camera.
  47867. * This simulates a sphere around the camera.
  47868. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47869. */
  47870. collisionRadius: Vector3;
  47871. protected _collider: Collider;
  47872. protected _previousPosition: Vector3;
  47873. protected _collisionVelocity: Vector3;
  47874. protected _newPosition: Vector3;
  47875. protected _previousAlpha: number;
  47876. protected _previousBeta: number;
  47877. protected _previousRadius: number;
  47878. protected _collisionTriggered: boolean;
  47879. protected _targetBoundingCenter: Nullable<Vector3>;
  47880. private _computationVector;
  47881. /**
  47882. * Instantiates a new ArcRotateCamera in a given scene
  47883. * @param name Defines the name of the camera
  47884. * @param alpha Defines the camera rotation along the logitudinal axis
  47885. * @param beta Defines the camera rotation along the latitudinal axis
  47886. * @param radius Defines the camera distance from its target
  47887. * @param target Defines the camera target
  47888. * @param scene Defines the scene the camera belongs to
  47889. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  47890. */
  47891. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47892. /** @hidden */
  47893. _initCache(): void;
  47894. /** @hidden */
  47895. _updateCache(ignoreParentClass?: boolean): void;
  47896. protected _getTargetPosition(): Vector3;
  47897. private _storedAlpha;
  47898. private _storedBeta;
  47899. private _storedRadius;
  47900. private _storedTarget;
  47901. private _storedTargetScreenOffset;
  47902. /**
  47903. * Stores the current state of the camera (alpha, beta, radius and target)
  47904. * @returns the camera itself
  47905. */
  47906. storeState(): Camera;
  47907. /**
  47908. * @hidden
  47909. * Restored camera state. You must call storeState() first
  47910. */
  47911. _restoreStateValues(): boolean;
  47912. /** @hidden */
  47913. _isSynchronizedViewMatrix(): boolean;
  47914. /**
  47915. * Attached controls to the current camera.
  47916. * @param element Defines the element the controls should be listened from
  47917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47918. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  47919. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  47920. */
  47921. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  47922. /**
  47923. * Detach the current controls from the camera.
  47924. * The camera will stop reacting to inputs.
  47925. * @param element Defines the element to stop listening the inputs from
  47926. */
  47927. detachControl(element: HTMLElement): void;
  47928. /** @hidden */
  47929. _checkInputs(): void;
  47930. protected _checkLimits(): void;
  47931. /**
  47932. * Rebuilds angles (alpha, beta) and radius from the give position and target
  47933. */
  47934. rebuildAnglesAndRadius(): void;
  47935. /**
  47936. * Use a position to define the current camera related information like alpha, beta and radius
  47937. * @param position Defines the position to set the camera at
  47938. */
  47939. setPosition(position: Vector3): void;
  47940. /**
  47941. * Defines the target the camera should look at.
  47942. * This will automatically adapt alpha beta and radius to fit within the new target.
  47943. * @param target Defines the new target as a Vector or a mesh
  47944. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  47945. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  47946. */
  47947. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  47948. /** @hidden */
  47949. _getViewMatrix(): Matrix;
  47950. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  47951. /**
  47952. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  47953. * @param meshes Defines the mesh to zoom on
  47954. * @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)
  47955. */
  47956. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  47957. /**
  47958. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  47959. * The target will be changed but the radius
  47960. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  47961. * @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)
  47962. */
  47963. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  47964. min: Vector3;
  47965. max: Vector3;
  47966. distance: number;
  47967. }, doNotUpdateMaxZ?: boolean): void;
  47968. /**
  47969. * @override
  47970. * Override Camera.createRigCamera
  47971. */
  47972. createRigCamera(name: string, cameraIndex: number): Camera;
  47973. /**
  47974. * @hidden
  47975. * @override
  47976. * Override Camera._updateRigCameras
  47977. */
  47978. _updateRigCameras(): void;
  47979. /**
  47980. * Destroy the camera and release the current resources hold by it.
  47981. */
  47982. dispose(): void;
  47983. /**
  47984. * Gets the current object class name.
  47985. * @return the class name
  47986. */
  47987. getClassName(): string;
  47988. }
  47989. }
  47990. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  47991. import { Behavior } from "babylonjs/Behaviors/behavior";
  47992. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47993. /**
  47994. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  47995. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47996. */
  47997. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  47998. /**
  47999. * Gets the name of the behavior.
  48000. */
  48001. get name(): string;
  48002. private _zoomStopsAnimation;
  48003. private _idleRotationSpeed;
  48004. private _idleRotationWaitTime;
  48005. private _idleRotationSpinupTime;
  48006. /**
  48007. * Sets the flag that indicates if user zooming should stop animation.
  48008. */
  48009. set zoomStopsAnimation(flag: boolean);
  48010. /**
  48011. * Gets the flag that indicates if user zooming should stop animation.
  48012. */
  48013. get zoomStopsAnimation(): boolean;
  48014. /**
  48015. * Sets the default speed at which the camera rotates around the model.
  48016. */
  48017. set idleRotationSpeed(speed: number);
  48018. /**
  48019. * Gets the default speed at which the camera rotates around the model.
  48020. */
  48021. get idleRotationSpeed(): number;
  48022. /**
  48023. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48024. */
  48025. set idleRotationWaitTime(time: number);
  48026. /**
  48027. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48028. */
  48029. get idleRotationWaitTime(): number;
  48030. /**
  48031. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48032. */
  48033. set idleRotationSpinupTime(time: number);
  48034. /**
  48035. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48036. */
  48037. get idleRotationSpinupTime(): number;
  48038. /**
  48039. * Gets a value indicating if the camera is currently rotating because of this behavior
  48040. */
  48041. get rotationInProgress(): boolean;
  48042. private _onPrePointerObservableObserver;
  48043. private _onAfterCheckInputsObserver;
  48044. private _attachedCamera;
  48045. private _isPointerDown;
  48046. private _lastFrameTime;
  48047. private _lastInteractionTime;
  48048. private _cameraRotationSpeed;
  48049. /**
  48050. * Initializes the behavior.
  48051. */
  48052. init(): void;
  48053. /**
  48054. * Attaches the behavior to its arc rotate camera.
  48055. * @param camera Defines the camera to attach the behavior to
  48056. */
  48057. attach(camera: ArcRotateCamera): void;
  48058. /**
  48059. * Detaches the behavior from its current arc rotate camera.
  48060. */
  48061. detach(): void;
  48062. /**
  48063. * Returns true if user is scrolling.
  48064. * @return true if user is scrolling.
  48065. */
  48066. private _userIsZooming;
  48067. private _lastFrameRadius;
  48068. private _shouldAnimationStopForInteraction;
  48069. /**
  48070. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48071. */
  48072. private _applyUserInteraction;
  48073. private _userIsMoving;
  48074. }
  48075. }
  48076. declare module "babylonjs/Behaviors/Cameras/index" {
  48077. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48078. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48079. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48080. }
  48081. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48082. import { Mesh } from "babylonjs/Meshes/mesh";
  48083. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48084. import { Behavior } from "babylonjs/Behaviors/behavior";
  48085. /**
  48086. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48087. */
  48088. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48089. private ui;
  48090. /**
  48091. * The name of the behavior
  48092. */
  48093. name: string;
  48094. /**
  48095. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48096. */
  48097. distanceAwayFromFace: number;
  48098. /**
  48099. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48100. */
  48101. distanceAwayFromBottomOfFace: number;
  48102. private _faceVectors;
  48103. private _target;
  48104. private _scene;
  48105. private _onRenderObserver;
  48106. private _tmpMatrix;
  48107. private _tmpVector;
  48108. /**
  48109. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48110. * @param ui The transform node that should be attched to the mesh
  48111. */
  48112. constructor(ui: TransformNode);
  48113. /**
  48114. * Initializes the behavior
  48115. */
  48116. init(): void;
  48117. private _closestFace;
  48118. private _zeroVector;
  48119. private _lookAtTmpMatrix;
  48120. private _lookAtToRef;
  48121. /**
  48122. * Attaches the AttachToBoxBehavior to the passed in mesh
  48123. * @param target The mesh that the specified node will be attached to
  48124. */
  48125. attach(target: Mesh): void;
  48126. /**
  48127. * Detaches the behavior from the mesh
  48128. */
  48129. detach(): void;
  48130. }
  48131. }
  48132. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48133. import { Behavior } from "babylonjs/Behaviors/behavior";
  48134. import { Mesh } from "babylonjs/Meshes/mesh";
  48135. /**
  48136. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48137. */
  48138. export class FadeInOutBehavior implements Behavior<Mesh> {
  48139. /**
  48140. * Time in milliseconds to delay before fading in (Default: 0)
  48141. */
  48142. delay: number;
  48143. /**
  48144. * Time in milliseconds for the mesh to fade in (Default: 300)
  48145. */
  48146. fadeInTime: number;
  48147. private _millisecondsPerFrame;
  48148. private _hovered;
  48149. private _hoverValue;
  48150. private _ownerNode;
  48151. /**
  48152. * Instatiates the FadeInOutBehavior
  48153. */
  48154. constructor();
  48155. /**
  48156. * The name of the behavior
  48157. */
  48158. get name(): string;
  48159. /**
  48160. * Initializes the behavior
  48161. */
  48162. init(): void;
  48163. /**
  48164. * Attaches the fade behavior on the passed in mesh
  48165. * @param ownerNode The mesh that will be faded in/out once attached
  48166. */
  48167. attach(ownerNode: Mesh): void;
  48168. /**
  48169. * Detaches the behavior from the mesh
  48170. */
  48171. detach(): void;
  48172. /**
  48173. * Triggers the mesh to begin fading in or out
  48174. * @param value if the object should fade in or out (true to fade in)
  48175. */
  48176. fadeIn(value: boolean): void;
  48177. private _update;
  48178. private _setAllVisibility;
  48179. }
  48180. }
  48181. declare module "babylonjs/Misc/pivotTools" {
  48182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48183. /**
  48184. * Class containing a set of static utilities functions for managing Pivots
  48185. * @hidden
  48186. */
  48187. export class PivotTools {
  48188. private static _PivotCached;
  48189. private static _OldPivotPoint;
  48190. private static _PivotTranslation;
  48191. private static _PivotTmpVector;
  48192. private static _PivotPostMultiplyPivotMatrix;
  48193. /** @hidden */
  48194. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48195. /** @hidden */
  48196. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48197. }
  48198. }
  48199. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48200. import { Scene } from "babylonjs/scene";
  48201. import { Vector4 } from "babylonjs/Maths/math.vector";
  48202. import { Mesh } from "babylonjs/Meshes/mesh";
  48203. import { Nullable } from "babylonjs/types";
  48204. import { Plane } from "babylonjs/Maths/math.plane";
  48205. /**
  48206. * Class containing static functions to help procedurally build meshes
  48207. */
  48208. export class PlaneBuilder {
  48209. /**
  48210. * Creates a plane mesh
  48211. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48212. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48213. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48217. * @param name defines the name of the mesh
  48218. * @param options defines the options used to create the mesh
  48219. * @param scene defines the hosting scene
  48220. * @returns the plane mesh
  48221. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48222. */
  48223. static CreatePlane(name: string, options: {
  48224. size?: number;
  48225. width?: number;
  48226. height?: number;
  48227. sideOrientation?: number;
  48228. frontUVs?: Vector4;
  48229. backUVs?: Vector4;
  48230. updatable?: boolean;
  48231. sourcePlane?: Plane;
  48232. }, scene?: Nullable<Scene>): Mesh;
  48233. }
  48234. }
  48235. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48236. import { Behavior } from "babylonjs/Behaviors/behavior";
  48237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48238. import { Observable } from "babylonjs/Misc/observable";
  48239. import { Vector3 } from "babylonjs/Maths/math.vector";
  48240. import { Ray } from "babylonjs/Culling/ray";
  48241. import "babylonjs/Meshes/Builders/planeBuilder";
  48242. /**
  48243. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48244. */
  48245. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48246. private static _AnyMouseID;
  48247. /**
  48248. * Abstract mesh the behavior is set on
  48249. */
  48250. attachedNode: AbstractMesh;
  48251. private _dragPlane;
  48252. private _scene;
  48253. private _pointerObserver;
  48254. private _beforeRenderObserver;
  48255. private static _planeScene;
  48256. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48257. /**
  48258. * 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)
  48259. */
  48260. maxDragAngle: number;
  48261. /**
  48262. * @hidden
  48263. */
  48264. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48265. /**
  48266. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48267. */
  48268. currentDraggingPointerID: number;
  48269. /**
  48270. * The last position where the pointer hit the drag plane in world space
  48271. */
  48272. lastDragPosition: Vector3;
  48273. /**
  48274. * If the behavior is currently in a dragging state
  48275. */
  48276. dragging: boolean;
  48277. /**
  48278. * 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)
  48279. */
  48280. dragDeltaRatio: number;
  48281. /**
  48282. * If the drag plane orientation should be updated during the dragging (Default: true)
  48283. */
  48284. updateDragPlane: boolean;
  48285. private _debugMode;
  48286. private _moving;
  48287. /**
  48288. * Fires each time the attached mesh is dragged with the pointer
  48289. * * delta between last drag position and current drag position in world space
  48290. * * dragDistance along the drag axis
  48291. * * dragPlaneNormal normal of the current drag plane used during the drag
  48292. * * dragPlanePoint in world space where the drag intersects the drag plane
  48293. */
  48294. onDragObservable: Observable<{
  48295. delta: Vector3;
  48296. dragPlanePoint: Vector3;
  48297. dragPlaneNormal: Vector3;
  48298. dragDistance: number;
  48299. pointerId: number;
  48300. }>;
  48301. /**
  48302. * Fires each time a drag begins (eg. mouse down on mesh)
  48303. */
  48304. onDragStartObservable: Observable<{
  48305. dragPlanePoint: Vector3;
  48306. pointerId: number;
  48307. }>;
  48308. /**
  48309. * Fires each time a drag ends (eg. mouse release after drag)
  48310. */
  48311. onDragEndObservable: Observable<{
  48312. dragPlanePoint: Vector3;
  48313. pointerId: number;
  48314. }>;
  48315. /**
  48316. * If the attached mesh should be moved when dragged
  48317. */
  48318. moveAttached: boolean;
  48319. /**
  48320. * If the drag behavior will react to drag events (Default: true)
  48321. */
  48322. enabled: boolean;
  48323. /**
  48324. * If pointer events should start and release the drag (Default: true)
  48325. */
  48326. startAndReleaseDragOnPointerEvents: boolean;
  48327. /**
  48328. * If camera controls should be detached during the drag
  48329. */
  48330. detachCameraControls: boolean;
  48331. /**
  48332. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48333. */
  48334. useObjectOrientationForDragging: boolean;
  48335. private _options;
  48336. /**
  48337. * Gets the options used by the behavior
  48338. */
  48339. get options(): {
  48340. dragAxis?: Vector3;
  48341. dragPlaneNormal?: Vector3;
  48342. };
  48343. /**
  48344. * Sets the options used by the behavior
  48345. */
  48346. set options(options: {
  48347. dragAxis?: Vector3;
  48348. dragPlaneNormal?: Vector3;
  48349. });
  48350. /**
  48351. * Creates a pointer drag behavior that can be attached to a mesh
  48352. * @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)
  48353. */
  48354. constructor(options?: {
  48355. dragAxis?: Vector3;
  48356. dragPlaneNormal?: Vector3;
  48357. });
  48358. /**
  48359. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48360. */
  48361. validateDrag: (targetPosition: Vector3) => boolean;
  48362. /**
  48363. * The name of the behavior
  48364. */
  48365. get name(): string;
  48366. /**
  48367. * Initializes the behavior
  48368. */
  48369. init(): void;
  48370. private _tmpVector;
  48371. private _alternatePickedPoint;
  48372. private _worldDragAxis;
  48373. private _targetPosition;
  48374. private _attachedElement;
  48375. /**
  48376. * Attaches the drag behavior the passed in mesh
  48377. * @param ownerNode The mesh that will be dragged around once attached
  48378. * @param predicate Predicate to use for pick filtering
  48379. */
  48380. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48381. /**
  48382. * Force relase the drag action by code.
  48383. */
  48384. releaseDrag(): void;
  48385. private _startDragRay;
  48386. private _lastPointerRay;
  48387. /**
  48388. * Simulates the start of a pointer drag event on the behavior
  48389. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48390. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48391. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48392. */
  48393. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48394. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48395. private _dragDelta;
  48396. protected _moveDrag(ray: Ray): void;
  48397. private _pickWithRayOnDragPlane;
  48398. private _pointA;
  48399. private _pointC;
  48400. private _localAxis;
  48401. private _lookAt;
  48402. private _updateDragPlanePosition;
  48403. /**
  48404. * Detaches the behavior from the mesh
  48405. */
  48406. detach(): void;
  48407. }
  48408. }
  48409. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48410. import { Mesh } from "babylonjs/Meshes/mesh";
  48411. import { Behavior } from "babylonjs/Behaviors/behavior";
  48412. /**
  48413. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48414. */
  48415. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48416. private _dragBehaviorA;
  48417. private _dragBehaviorB;
  48418. private _startDistance;
  48419. private _initialScale;
  48420. private _targetScale;
  48421. private _ownerNode;
  48422. private _sceneRenderObserver;
  48423. /**
  48424. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48425. */
  48426. constructor();
  48427. /**
  48428. * The name of the behavior
  48429. */
  48430. get name(): string;
  48431. /**
  48432. * Initializes the behavior
  48433. */
  48434. init(): void;
  48435. private _getCurrentDistance;
  48436. /**
  48437. * Attaches the scale behavior the passed in mesh
  48438. * @param ownerNode The mesh that will be scaled around once attached
  48439. */
  48440. attach(ownerNode: Mesh): void;
  48441. /**
  48442. * Detaches the behavior from the mesh
  48443. */
  48444. detach(): void;
  48445. }
  48446. }
  48447. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48448. import { Behavior } from "babylonjs/Behaviors/behavior";
  48449. import { Mesh } from "babylonjs/Meshes/mesh";
  48450. import { Observable } from "babylonjs/Misc/observable";
  48451. /**
  48452. * 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
  48453. */
  48454. export class SixDofDragBehavior implements Behavior<Mesh> {
  48455. private static _virtualScene;
  48456. private _ownerNode;
  48457. private _sceneRenderObserver;
  48458. private _scene;
  48459. private _targetPosition;
  48460. private _virtualOriginMesh;
  48461. private _virtualDragMesh;
  48462. private _pointerObserver;
  48463. private _moving;
  48464. private _startingOrientation;
  48465. private _attachedElement;
  48466. /**
  48467. * 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)
  48468. */
  48469. private zDragFactor;
  48470. /**
  48471. * If the object should rotate to face the drag origin
  48472. */
  48473. rotateDraggedObject: boolean;
  48474. /**
  48475. * If the behavior is currently in a dragging state
  48476. */
  48477. dragging: boolean;
  48478. /**
  48479. * 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)
  48480. */
  48481. dragDeltaRatio: number;
  48482. /**
  48483. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48484. */
  48485. currentDraggingPointerID: number;
  48486. /**
  48487. * If camera controls should be detached during the drag
  48488. */
  48489. detachCameraControls: boolean;
  48490. /**
  48491. * Fires each time a drag starts
  48492. */
  48493. onDragStartObservable: Observable<{}>;
  48494. /**
  48495. * Fires each time a drag ends (eg. mouse release after drag)
  48496. */
  48497. onDragEndObservable: Observable<{}>;
  48498. /**
  48499. * 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
  48500. */
  48501. constructor();
  48502. /**
  48503. * The name of the behavior
  48504. */
  48505. get name(): string;
  48506. /**
  48507. * Initializes the behavior
  48508. */
  48509. init(): void;
  48510. /**
  48511. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48512. */
  48513. private get _pointerCamera();
  48514. /**
  48515. * Attaches the scale behavior the passed in mesh
  48516. * @param ownerNode The mesh that will be scaled around once attached
  48517. */
  48518. attach(ownerNode: Mesh): void;
  48519. /**
  48520. * Detaches the behavior from the mesh
  48521. */
  48522. detach(): void;
  48523. }
  48524. }
  48525. declare module "babylonjs/Behaviors/Meshes/index" {
  48526. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48527. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48528. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48529. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48530. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48531. }
  48532. declare module "babylonjs/Behaviors/index" {
  48533. export * from "babylonjs/Behaviors/behavior";
  48534. export * from "babylonjs/Behaviors/Cameras/index";
  48535. export * from "babylonjs/Behaviors/Meshes/index";
  48536. }
  48537. declare module "babylonjs/Bones/boneIKController" {
  48538. import { Bone } from "babylonjs/Bones/bone";
  48539. import { Vector3 } from "babylonjs/Maths/math.vector";
  48540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48541. import { Nullable } from "babylonjs/types";
  48542. /**
  48543. * Class used to apply inverse kinematics to bones
  48544. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48545. */
  48546. export class BoneIKController {
  48547. private static _tmpVecs;
  48548. private static _tmpQuat;
  48549. private static _tmpMats;
  48550. /**
  48551. * Gets or sets the target mesh
  48552. */
  48553. targetMesh: AbstractMesh;
  48554. /** Gets or sets the mesh used as pole */
  48555. poleTargetMesh: AbstractMesh;
  48556. /**
  48557. * Gets or sets the bone used as pole
  48558. */
  48559. poleTargetBone: Nullable<Bone>;
  48560. /**
  48561. * Gets or sets the target position
  48562. */
  48563. targetPosition: Vector3;
  48564. /**
  48565. * Gets or sets the pole target position
  48566. */
  48567. poleTargetPosition: Vector3;
  48568. /**
  48569. * Gets or sets the pole target local offset
  48570. */
  48571. poleTargetLocalOffset: Vector3;
  48572. /**
  48573. * Gets or sets the pole angle
  48574. */
  48575. poleAngle: number;
  48576. /**
  48577. * Gets or sets the mesh associated with the controller
  48578. */
  48579. mesh: AbstractMesh;
  48580. /**
  48581. * 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)
  48582. */
  48583. slerpAmount: number;
  48584. private _bone1Quat;
  48585. private _bone1Mat;
  48586. private _bone2Ang;
  48587. private _bone1;
  48588. private _bone2;
  48589. private _bone1Length;
  48590. private _bone2Length;
  48591. private _maxAngle;
  48592. private _maxReach;
  48593. private _rightHandedSystem;
  48594. private _bendAxis;
  48595. private _slerping;
  48596. private _adjustRoll;
  48597. /**
  48598. * Gets or sets maximum allowed angle
  48599. */
  48600. get maxAngle(): number;
  48601. set maxAngle(value: number);
  48602. /**
  48603. * Creates a new BoneIKController
  48604. * @param mesh defines the mesh to control
  48605. * @param bone defines the bone to control
  48606. * @param options defines options to set up the controller
  48607. */
  48608. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48609. targetMesh?: AbstractMesh;
  48610. poleTargetMesh?: AbstractMesh;
  48611. poleTargetBone?: Bone;
  48612. poleTargetLocalOffset?: Vector3;
  48613. poleAngle?: number;
  48614. bendAxis?: Vector3;
  48615. maxAngle?: number;
  48616. slerpAmount?: number;
  48617. });
  48618. private _setMaxAngle;
  48619. /**
  48620. * Force the controller to update the bones
  48621. */
  48622. update(): void;
  48623. }
  48624. }
  48625. declare module "babylonjs/Bones/boneLookController" {
  48626. import { Vector3 } from "babylonjs/Maths/math.vector";
  48627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48628. import { Bone } from "babylonjs/Bones/bone";
  48629. import { Space } from "babylonjs/Maths/math.axis";
  48630. /**
  48631. * Class used to make a bone look toward a point in space
  48632. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48633. */
  48634. export class BoneLookController {
  48635. private static _tmpVecs;
  48636. private static _tmpQuat;
  48637. private static _tmpMats;
  48638. /**
  48639. * The target Vector3 that the bone will look at
  48640. */
  48641. target: Vector3;
  48642. /**
  48643. * The mesh that the bone is attached to
  48644. */
  48645. mesh: AbstractMesh;
  48646. /**
  48647. * The bone that will be looking to the target
  48648. */
  48649. bone: Bone;
  48650. /**
  48651. * The up axis of the coordinate system that is used when the bone is rotated
  48652. */
  48653. upAxis: Vector3;
  48654. /**
  48655. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  48656. */
  48657. upAxisSpace: Space;
  48658. /**
  48659. * Used to make an adjustment to the yaw of the bone
  48660. */
  48661. adjustYaw: number;
  48662. /**
  48663. * Used to make an adjustment to the pitch of the bone
  48664. */
  48665. adjustPitch: number;
  48666. /**
  48667. * Used to make an adjustment to the roll of the bone
  48668. */
  48669. adjustRoll: number;
  48670. /**
  48671. * 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)
  48672. */
  48673. slerpAmount: number;
  48674. private _minYaw;
  48675. private _maxYaw;
  48676. private _minPitch;
  48677. private _maxPitch;
  48678. private _minYawSin;
  48679. private _minYawCos;
  48680. private _maxYawSin;
  48681. private _maxYawCos;
  48682. private _midYawConstraint;
  48683. private _minPitchTan;
  48684. private _maxPitchTan;
  48685. private _boneQuat;
  48686. private _slerping;
  48687. private _transformYawPitch;
  48688. private _transformYawPitchInv;
  48689. private _firstFrameSkipped;
  48690. private _yawRange;
  48691. private _fowardAxis;
  48692. /**
  48693. * Gets or sets the minimum yaw angle that the bone can look to
  48694. */
  48695. get minYaw(): number;
  48696. set minYaw(value: number);
  48697. /**
  48698. * Gets or sets the maximum yaw angle that the bone can look to
  48699. */
  48700. get maxYaw(): number;
  48701. set maxYaw(value: number);
  48702. /**
  48703. * Gets or sets the minimum pitch angle that the bone can look to
  48704. */
  48705. get minPitch(): number;
  48706. set minPitch(value: number);
  48707. /**
  48708. * Gets or sets the maximum pitch angle that the bone can look to
  48709. */
  48710. get maxPitch(): number;
  48711. set maxPitch(value: number);
  48712. /**
  48713. * Create a BoneLookController
  48714. * @param mesh the mesh that the bone belongs to
  48715. * @param bone the bone that will be looking to the target
  48716. * @param target the target Vector3 to look at
  48717. * @param options optional settings:
  48718. * * maxYaw: the maximum angle the bone will yaw to
  48719. * * minYaw: the minimum angle the bone will yaw to
  48720. * * maxPitch: the maximum angle the bone will pitch to
  48721. * * minPitch: the minimum angle the bone will yaw to
  48722. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  48723. * * upAxis: the up axis of the coordinate system
  48724. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  48725. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  48726. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  48727. * * adjustYaw: used to make an adjustment to the yaw of the bone
  48728. * * adjustPitch: used to make an adjustment to the pitch of the bone
  48729. * * adjustRoll: used to make an adjustment to the roll of the bone
  48730. **/
  48731. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  48732. maxYaw?: number;
  48733. minYaw?: number;
  48734. maxPitch?: number;
  48735. minPitch?: number;
  48736. slerpAmount?: number;
  48737. upAxis?: Vector3;
  48738. upAxisSpace?: Space;
  48739. yawAxis?: Vector3;
  48740. pitchAxis?: Vector3;
  48741. adjustYaw?: number;
  48742. adjustPitch?: number;
  48743. adjustRoll?: number;
  48744. });
  48745. /**
  48746. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  48747. */
  48748. update(): void;
  48749. private _getAngleDiff;
  48750. private _getAngleBetween;
  48751. private _isAngleBetween;
  48752. }
  48753. }
  48754. declare module "babylonjs/Bones/index" {
  48755. export * from "babylonjs/Bones/bone";
  48756. export * from "babylonjs/Bones/boneIKController";
  48757. export * from "babylonjs/Bones/boneLookController";
  48758. export * from "babylonjs/Bones/skeleton";
  48759. }
  48760. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  48761. import { Nullable } from "babylonjs/types";
  48762. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48763. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48764. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  48765. /**
  48766. * Manage the gamepad inputs to control an arc rotate camera.
  48767. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48768. */
  48769. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  48770. /**
  48771. * Defines the camera the input is attached to.
  48772. */
  48773. camera: ArcRotateCamera;
  48774. /**
  48775. * Defines the gamepad the input is gathering event from.
  48776. */
  48777. gamepad: Nullable<Gamepad>;
  48778. /**
  48779. * Defines the gamepad rotation sensiblity.
  48780. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48781. */
  48782. gamepadRotationSensibility: number;
  48783. /**
  48784. * Defines the gamepad move sensiblity.
  48785. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48786. */
  48787. gamepadMoveSensibility: number;
  48788. private _yAxisScale;
  48789. /**
  48790. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48791. */
  48792. get invertYAxis(): boolean;
  48793. set invertYAxis(value: boolean);
  48794. private _onGamepadConnectedObserver;
  48795. private _onGamepadDisconnectedObserver;
  48796. /**
  48797. * Attach the input controls to a specific dom element to get the input from.
  48798. * @param element Defines the element the controls should be listened from
  48799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48800. */
  48801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48802. /**
  48803. * Detach the current controls from the specified dom element.
  48804. * @param element Defines the element to stop listening the inputs from
  48805. */
  48806. detachControl(element: Nullable<HTMLElement>): void;
  48807. /**
  48808. * Update the current camera state depending on the inputs that have been used this frame.
  48809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48810. */
  48811. checkInputs(): void;
  48812. /**
  48813. * Gets the class name of the current intput.
  48814. * @returns the class name
  48815. */
  48816. getClassName(): string;
  48817. /**
  48818. * Get the friendly name associated with the input class.
  48819. * @returns the input friendly name
  48820. */
  48821. getSimpleName(): string;
  48822. }
  48823. }
  48824. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  48825. import { Nullable } from "babylonjs/types";
  48826. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48827. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48828. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48829. interface ArcRotateCameraInputsManager {
  48830. /**
  48831. * Add orientation input support to the input manager.
  48832. * @returns the current input manager
  48833. */
  48834. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  48835. }
  48836. }
  48837. /**
  48838. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  48839. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48840. */
  48841. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  48842. /**
  48843. * Defines the camera the input is attached to.
  48844. */
  48845. camera: ArcRotateCamera;
  48846. /**
  48847. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  48848. */
  48849. alphaCorrection: number;
  48850. /**
  48851. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  48852. */
  48853. gammaCorrection: number;
  48854. private _alpha;
  48855. private _gamma;
  48856. private _dirty;
  48857. private _deviceOrientationHandler;
  48858. /**
  48859. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  48860. */
  48861. constructor();
  48862. /**
  48863. * Attach the input controls to a specific dom element to get the input from.
  48864. * @param element Defines the element the controls should be listened from
  48865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48866. */
  48867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48868. /** @hidden */
  48869. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  48870. /**
  48871. * Update the current camera state depending on the inputs that have been used this frame.
  48872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48873. */
  48874. checkInputs(): void;
  48875. /**
  48876. * Detach the current controls from the specified dom element.
  48877. * @param element Defines the element to stop listening the inputs from
  48878. */
  48879. detachControl(element: Nullable<HTMLElement>): void;
  48880. /**
  48881. * Gets the class name of the current intput.
  48882. * @returns the class name
  48883. */
  48884. getClassName(): string;
  48885. /**
  48886. * Get the friendly name associated with the input class.
  48887. * @returns the input friendly name
  48888. */
  48889. getSimpleName(): string;
  48890. }
  48891. }
  48892. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  48893. import { Nullable } from "babylonjs/types";
  48894. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48895. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48896. /**
  48897. * Listen to mouse events to control the camera.
  48898. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48899. */
  48900. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  48901. /**
  48902. * Defines the camera the input is attached to.
  48903. */
  48904. camera: FlyCamera;
  48905. /**
  48906. * Defines if touch is enabled. (Default is true.)
  48907. */
  48908. touchEnabled: boolean;
  48909. /**
  48910. * Defines the buttons associated with the input to handle camera rotation.
  48911. */
  48912. buttons: number[];
  48913. /**
  48914. * Assign buttons for Yaw control.
  48915. */
  48916. buttonsYaw: number[];
  48917. /**
  48918. * Assign buttons for Pitch control.
  48919. */
  48920. buttonsPitch: number[];
  48921. /**
  48922. * Assign buttons for Roll control.
  48923. */
  48924. buttonsRoll: number[];
  48925. /**
  48926. * Detect if any button is being pressed while mouse is moved.
  48927. * -1 = Mouse locked.
  48928. * 0 = Left button.
  48929. * 1 = Middle Button.
  48930. * 2 = Right Button.
  48931. */
  48932. activeButton: number;
  48933. /**
  48934. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  48935. * Higher values reduce its sensitivity.
  48936. */
  48937. angularSensibility: number;
  48938. private _observer;
  48939. private _rollObserver;
  48940. private previousPosition;
  48941. private noPreventDefault;
  48942. private element;
  48943. /**
  48944. * Listen to mouse events to control the camera.
  48945. * @param touchEnabled Define if touch is enabled. (Default is true.)
  48946. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48947. */
  48948. constructor(touchEnabled?: boolean);
  48949. /**
  48950. * Attach the mouse control to the HTML DOM element.
  48951. * @param element Defines the element that listens to the input events.
  48952. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  48953. */
  48954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48955. /**
  48956. * Detach the current controls from the specified dom element.
  48957. * @param element Defines the element to stop listening the inputs from
  48958. */
  48959. detachControl(element: Nullable<HTMLElement>): void;
  48960. /**
  48961. * Gets the class name of the current input.
  48962. * @returns the class name.
  48963. */
  48964. getClassName(): string;
  48965. /**
  48966. * Get the friendly name associated with the input class.
  48967. * @returns the input's friendly name.
  48968. */
  48969. getSimpleName(): string;
  48970. private _pointerInput;
  48971. private _onMouseMove;
  48972. /**
  48973. * Rotate camera by mouse offset.
  48974. */
  48975. private rotateCamera;
  48976. }
  48977. }
  48978. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  48979. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48980. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48981. /**
  48982. * Default Inputs manager for the FlyCamera.
  48983. * It groups all the default supported inputs for ease of use.
  48984. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48985. */
  48986. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  48987. /**
  48988. * Instantiates a new FlyCameraInputsManager.
  48989. * @param camera Defines the camera the inputs belong to.
  48990. */
  48991. constructor(camera: FlyCamera);
  48992. /**
  48993. * Add keyboard input support to the input manager.
  48994. * @returns the new FlyCameraKeyboardMoveInput().
  48995. */
  48996. addKeyboard(): FlyCameraInputsManager;
  48997. /**
  48998. * Add mouse input support to the input manager.
  48999. * @param touchEnabled Enable touch screen support.
  49000. * @returns the new FlyCameraMouseInput().
  49001. */
  49002. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49003. }
  49004. }
  49005. declare module "babylonjs/Cameras/flyCamera" {
  49006. import { Scene } from "babylonjs/scene";
  49007. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49009. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49010. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49011. /**
  49012. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49013. * such as in a 3D Space Shooter or a Flight Simulator.
  49014. */
  49015. export class FlyCamera extends TargetCamera {
  49016. /**
  49017. * Define the collision ellipsoid of the camera.
  49018. * This is helpful for simulating a camera body, like a player's body.
  49019. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49020. */
  49021. ellipsoid: Vector3;
  49022. /**
  49023. * Define an offset for the position of the ellipsoid around the camera.
  49024. * This can be helpful if the camera is attached away from the player's body center,
  49025. * such as at its head.
  49026. */
  49027. ellipsoidOffset: Vector3;
  49028. /**
  49029. * Enable or disable collisions of the camera with the rest of the scene objects.
  49030. */
  49031. checkCollisions: boolean;
  49032. /**
  49033. * Enable or disable gravity on the camera.
  49034. */
  49035. applyGravity: boolean;
  49036. /**
  49037. * Define the current direction the camera is moving to.
  49038. */
  49039. cameraDirection: Vector3;
  49040. /**
  49041. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49042. * This overrides and empties cameraRotation.
  49043. */
  49044. rotationQuaternion: Quaternion;
  49045. /**
  49046. * Track Roll to maintain the wanted Rolling when looking around.
  49047. */
  49048. _trackRoll: number;
  49049. /**
  49050. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49051. */
  49052. rollCorrect: number;
  49053. /**
  49054. * Mimic a banked turn, Rolling the camera when Yawing.
  49055. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49056. */
  49057. bankedTurn: boolean;
  49058. /**
  49059. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49060. */
  49061. bankedTurnLimit: number;
  49062. /**
  49063. * Value of 0 disables the banked Roll.
  49064. * Value of 1 is equal to the Yaw angle in radians.
  49065. */
  49066. bankedTurnMultiplier: number;
  49067. /**
  49068. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49069. */
  49070. inputs: FlyCameraInputsManager;
  49071. /**
  49072. * Gets the input sensibility for mouse input.
  49073. * Higher values reduce sensitivity.
  49074. */
  49075. get angularSensibility(): number;
  49076. /**
  49077. * Sets the input sensibility for a mouse input.
  49078. * Higher values reduce sensitivity.
  49079. */
  49080. set angularSensibility(value: number);
  49081. /**
  49082. * Get the keys for camera movement forward.
  49083. */
  49084. get keysForward(): number[];
  49085. /**
  49086. * Set the keys for camera movement forward.
  49087. */
  49088. set keysForward(value: number[]);
  49089. /**
  49090. * Get the keys for camera movement backward.
  49091. */
  49092. get keysBackward(): number[];
  49093. set keysBackward(value: number[]);
  49094. /**
  49095. * Get the keys for camera movement up.
  49096. */
  49097. get keysUp(): number[];
  49098. /**
  49099. * Set the keys for camera movement up.
  49100. */
  49101. set keysUp(value: number[]);
  49102. /**
  49103. * Get the keys for camera movement down.
  49104. */
  49105. get keysDown(): number[];
  49106. /**
  49107. * Set the keys for camera movement down.
  49108. */
  49109. set keysDown(value: number[]);
  49110. /**
  49111. * Get the keys for camera movement left.
  49112. */
  49113. get keysLeft(): number[];
  49114. /**
  49115. * Set the keys for camera movement left.
  49116. */
  49117. set keysLeft(value: number[]);
  49118. /**
  49119. * Set the keys for camera movement right.
  49120. */
  49121. get keysRight(): number[];
  49122. /**
  49123. * Set the keys for camera movement right.
  49124. */
  49125. set keysRight(value: number[]);
  49126. /**
  49127. * Event raised when the camera collides with a mesh in the scene.
  49128. */
  49129. onCollide: (collidedMesh: AbstractMesh) => void;
  49130. private _collider;
  49131. private _needMoveForGravity;
  49132. private _oldPosition;
  49133. private _diffPosition;
  49134. private _newPosition;
  49135. /** @hidden */
  49136. _localDirection: Vector3;
  49137. /** @hidden */
  49138. _transformedDirection: Vector3;
  49139. /**
  49140. * Instantiates a FlyCamera.
  49141. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49142. * such as in a 3D Space Shooter or a Flight Simulator.
  49143. * @param name Define the name of the camera in the scene.
  49144. * @param position Define the starting position of the camera in the scene.
  49145. * @param scene Define the scene the camera belongs to.
  49146. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49147. */
  49148. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49149. /**
  49150. * Attach a control to the HTML DOM element.
  49151. * @param element Defines the element that listens to the input events.
  49152. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  49153. */
  49154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49155. /**
  49156. * Detach a control from the HTML DOM element.
  49157. * The camera will stop reacting to that input.
  49158. * @param element Defines the element that listens to the input events.
  49159. */
  49160. detachControl(element: HTMLElement): void;
  49161. private _collisionMask;
  49162. /**
  49163. * Get the mask that the camera ignores in collision events.
  49164. */
  49165. get collisionMask(): number;
  49166. /**
  49167. * Set the mask that the camera ignores in collision events.
  49168. */
  49169. set collisionMask(mask: number);
  49170. /** @hidden */
  49171. _collideWithWorld(displacement: Vector3): void;
  49172. /** @hidden */
  49173. private _onCollisionPositionChange;
  49174. /** @hidden */
  49175. _checkInputs(): void;
  49176. /** @hidden */
  49177. _decideIfNeedsToMove(): boolean;
  49178. /** @hidden */
  49179. _updatePosition(): void;
  49180. /**
  49181. * Restore the Roll to its target value at the rate specified.
  49182. * @param rate - Higher means slower restoring.
  49183. * @hidden
  49184. */
  49185. restoreRoll(rate: number): void;
  49186. /**
  49187. * Destroy the camera and release the current resources held by it.
  49188. */
  49189. dispose(): void;
  49190. /**
  49191. * Get the current object class name.
  49192. * @returns the class name.
  49193. */
  49194. getClassName(): string;
  49195. }
  49196. }
  49197. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49198. import { Nullable } from "babylonjs/types";
  49199. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49200. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49201. /**
  49202. * Listen to keyboard events to control the camera.
  49203. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49204. */
  49205. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49206. /**
  49207. * Defines the camera the input is attached to.
  49208. */
  49209. camera: FlyCamera;
  49210. /**
  49211. * The list of keyboard keys used to control the forward move of the camera.
  49212. */
  49213. keysForward: number[];
  49214. /**
  49215. * The list of keyboard keys used to control the backward move of the camera.
  49216. */
  49217. keysBackward: number[];
  49218. /**
  49219. * The list of keyboard keys used to control the forward move of the camera.
  49220. */
  49221. keysUp: number[];
  49222. /**
  49223. * The list of keyboard keys used to control the backward move of the camera.
  49224. */
  49225. keysDown: number[];
  49226. /**
  49227. * The list of keyboard keys used to control the right strafe move of the camera.
  49228. */
  49229. keysRight: number[];
  49230. /**
  49231. * The list of keyboard keys used to control the left strafe move of the camera.
  49232. */
  49233. keysLeft: number[];
  49234. private _keys;
  49235. private _onCanvasBlurObserver;
  49236. private _onKeyboardObserver;
  49237. private _engine;
  49238. private _scene;
  49239. /**
  49240. * Attach the input controls to a specific dom element to get the input from.
  49241. * @param element Defines the element the controls should be listened from
  49242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49243. */
  49244. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49245. /**
  49246. * Detach the current controls from the specified dom element.
  49247. * @param element Defines the element to stop listening the inputs from
  49248. */
  49249. detachControl(element: Nullable<HTMLElement>): void;
  49250. /**
  49251. * Gets the class name of the current intput.
  49252. * @returns the class name
  49253. */
  49254. getClassName(): string;
  49255. /** @hidden */
  49256. _onLostFocus(e: FocusEvent): void;
  49257. /**
  49258. * Get the friendly name associated with the input class.
  49259. * @returns the input friendly name
  49260. */
  49261. getSimpleName(): string;
  49262. /**
  49263. * Update the current camera state depending on the inputs that have been used this frame.
  49264. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49265. */
  49266. checkInputs(): void;
  49267. }
  49268. }
  49269. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49270. import { Nullable } from "babylonjs/types";
  49271. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49272. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49273. /**
  49274. * Manage the mouse wheel inputs to control a follow camera.
  49275. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49276. */
  49277. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49278. /**
  49279. * Defines the camera the input is attached to.
  49280. */
  49281. camera: FollowCamera;
  49282. /**
  49283. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49284. */
  49285. axisControlRadius: boolean;
  49286. /**
  49287. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49288. */
  49289. axisControlHeight: boolean;
  49290. /**
  49291. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49292. */
  49293. axisControlRotation: boolean;
  49294. /**
  49295. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49296. * relation to mouseWheel events.
  49297. */
  49298. wheelPrecision: number;
  49299. /**
  49300. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49301. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49302. */
  49303. wheelDeltaPercentage: number;
  49304. private _wheel;
  49305. private _observer;
  49306. /**
  49307. * Attach the input controls to a specific dom element to get the input from.
  49308. * @param element Defines the element the controls should be listened from
  49309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49310. */
  49311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49312. /**
  49313. * Detach the current controls from the specified dom element.
  49314. * @param element Defines the element to stop listening the inputs from
  49315. */
  49316. detachControl(element: Nullable<HTMLElement>): void;
  49317. /**
  49318. * Gets the class name of the current intput.
  49319. * @returns the class name
  49320. */
  49321. getClassName(): string;
  49322. /**
  49323. * Get the friendly name associated with the input class.
  49324. * @returns the input friendly name
  49325. */
  49326. getSimpleName(): string;
  49327. }
  49328. }
  49329. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49330. import { Nullable } from "babylonjs/types";
  49331. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49332. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49333. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49334. /**
  49335. * Manage the pointers inputs to control an follow camera.
  49336. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49337. */
  49338. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49339. /**
  49340. * Defines the camera the input is attached to.
  49341. */
  49342. camera: FollowCamera;
  49343. /**
  49344. * Gets the class name of the current input.
  49345. * @returns the class name
  49346. */
  49347. getClassName(): string;
  49348. /**
  49349. * Defines the pointer angular sensibility along the X axis or how fast is
  49350. * the camera rotating.
  49351. * A negative number will reverse the axis direction.
  49352. */
  49353. angularSensibilityX: number;
  49354. /**
  49355. * Defines the pointer angular sensibility along the Y axis or how fast is
  49356. * the camera rotating.
  49357. * A negative number will reverse the axis direction.
  49358. */
  49359. angularSensibilityY: number;
  49360. /**
  49361. * Defines the pointer pinch precision or how fast is the camera zooming.
  49362. * A negative number will reverse the axis direction.
  49363. */
  49364. pinchPrecision: number;
  49365. /**
  49366. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49367. * from 0.
  49368. * It defines the percentage of current camera.radius to use as delta when
  49369. * pinch zoom is used.
  49370. */
  49371. pinchDeltaPercentage: number;
  49372. /**
  49373. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49374. */
  49375. axisXControlRadius: boolean;
  49376. /**
  49377. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49378. */
  49379. axisXControlHeight: boolean;
  49380. /**
  49381. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49382. */
  49383. axisXControlRotation: boolean;
  49384. /**
  49385. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49386. */
  49387. axisYControlRadius: boolean;
  49388. /**
  49389. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49390. */
  49391. axisYControlHeight: boolean;
  49392. /**
  49393. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49394. */
  49395. axisYControlRotation: boolean;
  49396. /**
  49397. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49398. */
  49399. axisPinchControlRadius: boolean;
  49400. /**
  49401. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49402. */
  49403. axisPinchControlHeight: boolean;
  49404. /**
  49405. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49406. */
  49407. axisPinchControlRotation: boolean;
  49408. /**
  49409. * Log error messages if basic misconfiguration has occurred.
  49410. */
  49411. warningEnable: boolean;
  49412. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49413. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49414. private _warningCounter;
  49415. private _warning;
  49416. }
  49417. }
  49418. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49419. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49420. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49421. /**
  49422. * Default Inputs manager for the FollowCamera.
  49423. * It groups all the default supported inputs for ease of use.
  49424. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49425. */
  49426. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49427. /**
  49428. * Instantiates a new FollowCameraInputsManager.
  49429. * @param camera Defines the camera the inputs belong to
  49430. */
  49431. constructor(camera: FollowCamera);
  49432. /**
  49433. * Add keyboard input support to the input manager.
  49434. * @returns the current input manager
  49435. */
  49436. addKeyboard(): FollowCameraInputsManager;
  49437. /**
  49438. * Add mouse wheel input support to the input manager.
  49439. * @returns the current input manager
  49440. */
  49441. addMouseWheel(): FollowCameraInputsManager;
  49442. /**
  49443. * Add pointers input support to the input manager.
  49444. * @returns the current input manager
  49445. */
  49446. addPointers(): FollowCameraInputsManager;
  49447. /**
  49448. * Add orientation input support to the input manager.
  49449. * @returns the current input manager
  49450. */
  49451. addVRDeviceOrientation(): FollowCameraInputsManager;
  49452. }
  49453. }
  49454. declare module "babylonjs/Cameras/followCamera" {
  49455. import { Nullable } from "babylonjs/types";
  49456. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49457. import { Scene } from "babylonjs/scene";
  49458. import { Vector3 } from "babylonjs/Maths/math.vector";
  49459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49460. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49461. /**
  49462. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49463. * an arc rotate version arcFollowCamera are available.
  49464. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49465. */
  49466. export class FollowCamera extends TargetCamera {
  49467. /**
  49468. * Distance the follow camera should follow an object at
  49469. */
  49470. radius: number;
  49471. /**
  49472. * Minimum allowed distance of the camera to the axis of rotation
  49473. * (The camera can not get closer).
  49474. * This can help limiting how the Camera is able to move in the scene.
  49475. */
  49476. lowerRadiusLimit: Nullable<number>;
  49477. /**
  49478. * Maximum allowed distance of the camera to the axis of rotation
  49479. * (The camera can not get further).
  49480. * This can help limiting how the Camera is able to move in the scene.
  49481. */
  49482. upperRadiusLimit: Nullable<number>;
  49483. /**
  49484. * Define a rotation offset between the camera and the object it follows
  49485. */
  49486. rotationOffset: number;
  49487. /**
  49488. * Minimum allowed angle to camera position relative to target object.
  49489. * This can help limiting how the Camera is able to move in the scene.
  49490. */
  49491. lowerRotationOffsetLimit: Nullable<number>;
  49492. /**
  49493. * Maximum allowed angle to camera position relative to target object.
  49494. * This can help limiting how the Camera is able to move in the scene.
  49495. */
  49496. upperRotationOffsetLimit: Nullable<number>;
  49497. /**
  49498. * Define a height offset between the camera and the object it follows.
  49499. * It can help following an object from the top (like a car chaing a plane)
  49500. */
  49501. heightOffset: number;
  49502. /**
  49503. * Minimum allowed height of camera position relative to target object.
  49504. * This can help limiting how the Camera is able to move in the scene.
  49505. */
  49506. lowerHeightOffsetLimit: Nullable<number>;
  49507. /**
  49508. * Maximum allowed height of camera position relative to target object.
  49509. * This can help limiting how the Camera is able to move in the scene.
  49510. */
  49511. upperHeightOffsetLimit: Nullable<number>;
  49512. /**
  49513. * Define how fast the camera can accelerate to follow it s target.
  49514. */
  49515. cameraAcceleration: number;
  49516. /**
  49517. * Define the speed limit of the camera following an object.
  49518. */
  49519. maxCameraSpeed: number;
  49520. /**
  49521. * Define the target of the camera.
  49522. */
  49523. lockedTarget: Nullable<AbstractMesh>;
  49524. /**
  49525. * Defines the input associated with the camera.
  49526. */
  49527. inputs: FollowCameraInputsManager;
  49528. /**
  49529. * Instantiates the follow camera.
  49530. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49531. * @param name Define the name of the camera in the scene
  49532. * @param position Define the position of the camera
  49533. * @param scene Define the scene the camera belong to
  49534. * @param lockedTarget Define the target of the camera
  49535. */
  49536. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49537. private _follow;
  49538. /**
  49539. * Attached controls to the current camera.
  49540. * @param element Defines the element the controls should be listened from
  49541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49542. */
  49543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49544. /**
  49545. * Detach the current controls from the camera.
  49546. * The camera will stop reacting to inputs.
  49547. * @param element Defines the element to stop listening the inputs from
  49548. */
  49549. detachControl(element: HTMLElement): void;
  49550. /** @hidden */
  49551. _checkInputs(): void;
  49552. private _checkLimits;
  49553. /**
  49554. * Gets the camera class name.
  49555. * @returns the class name
  49556. */
  49557. getClassName(): string;
  49558. }
  49559. /**
  49560. * Arc Rotate version of the follow camera.
  49561. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49562. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49563. */
  49564. export class ArcFollowCamera extends TargetCamera {
  49565. /** The longitudinal angle of the camera */
  49566. alpha: number;
  49567. /** The latitudinal angle of the camera */
  49568. beta: number;
  49569. /** The radius of the camera from its target */
  49570. radius: number;
  49571. private _cartesianCoordinates;
  49572. /** Define the camera target (the mesh it should follow) */
  49573. private _meshTarget;
  49574. /**
  49575. * Instantiates a new ArcFollowCamera
  49576. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49577. * @param name Define the name of the camera
  49578. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49579. * @param beta Define the rotation angle of the camera around the elevation axis
  49580. * @param radius Define the radius of the camera from its target point
  49581. * @param target Define the target of the camera
  49582. * @param scene Define the scene the camera belongs to
  49583. */
  49584. constructor(name: string,
  49585. /** The longitudinal angle of the camera */
  49586. alpha: number,
  49587. /** The latitudinal angle of the camera */
  49588. beta: number,
  49589. /** The radius of the camera from its target */
  49590. radius: number,
  49591. /** Define the camera target (the mesh it should follow) */
  49592. target: Nullable<AbstractMesh>, scene: Scene);
  49593. private _follow;
  49594. /** @hidden */
  49595. _checkInputs(): void;
  49596. /**
  49597. * Returns the class name of the object.
  49598. * It is mostly used internally for serialization purposes.
  49599. */
  49600. getClassName(): string;
  49601. }
  49602. }
  49603. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49604. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49605. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49606. import { Nullable } from "babylonjs/types";
  49607. /**
  49608. * Manage the keyboard inputs to control the movement of a follow camera.
  49609. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49610. */
  49611. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49612. /**
  49613. * Defines the camera the input is attached to.
  49614. */
  49615. camera: FollowCamera;
  49616. /**
  49617. * Defines the list of key codes associated with the up action (increase heightOffset)
  49618. */
  49619. keysHeightOffsetIncr: number[];
  49620. /**
  49621. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49622. */
  49623. keysHeightOffsetDecr: number[];
  49624. /**
  49625. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49626. */
  49627. keysHeightOffsetModifierAlt: boolean;
  49628. /**
  49629. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49630. */
  49631. keysHeightOffsetModifierCtrl: boolean;
  49632. /**
  49633. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49634. */
  49635. keysHeightOffsetModifierShift: boolean;
  49636. /**
  49637. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49638. */
  49639. keysRotationOffsetIncr: number[];
  49640. /**
  49641. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49642. */
  49643. keysRotationOffsetDecr: number[];
  49644. /**
  49645. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49646. */
  49647. keysRotationOffsetModifierAlt: boolean;
  49648. /**
  49649. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49650. */
  49651. keysRotationOffsetModifierCtrl: boolean;
  49652. /**
  49653. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49654. */
  49655. keysRotationOffsetModifierShift: boolean;
  49656. /**
  49657. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49658. */
  49659. keysRadiusIncr: number[];
  49660. /**
  49661. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49662. */
  49663. keysRadiusDecr: number[];
  49664. /**
  49665. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49666. */
  49667. keysRadiusModifierAlt: boolean;
  49668. /**
  49669. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  49670. */
  49671. keysRadiusModifierCtrl: boolean;
  49672. /**
  49673. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  49674. */
  49675. keysRadiusModifierShift: boolean;
  49676. /**
  49677. * Defines the rate of change of heightOffset.
  49678. */
  49679. heightSensibility: number;
  49680. /**
  49681. * Defines the rate of change of rotationOffset.
  49682. */
  49683. rotationSensibility: number;
  49684. /**
  49685. * Defines the rate of change of radius.
  49686. */
  49687. radiusSensibility: number;
  49688. private _keys;
  49689. private _ctrlPressed;
  49690. private _altPressed;
  49691. private _shiftPressed;
  49692. private _onCanvasBlurObserver;
  49693. private _onKeyboardObserver;
  49694. private _engine;
  49695. private _scene;
  49696. /**
  49697. * Attach the input controls to a specific dom element to get the input from.
  49698. * @param element Defines the element the controls should be listened from
  49699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49700. */
  49701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49702. /**
  49703. * Detach the current controls from the specified dom element.
  49704. * @param element Defines the element to stop listening the inputs from
  49705. */
  49706. detachControl(element: Nullable<HTMLElement>): void;
  49707. /**
  49708. * Update the current camera state depending on the inputs that have been used this frame.
  49709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49710. */
  49711. checkInputs(): void;
  49712. /**
  49713. * Gets the class name of the current input.
  49714. * @returns the class name
  49715. */
  49716. getClassName(): string;
  49717. /**
  49718. * Get the friendly name associated with the input class.
  49719. * @returns the input friendly name
  49720. */
  49721. getSimpleName(): string;
  49722. /**
  49723. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49724. * allow modification of the heightOffset value.
  49725. */
  49726. private _modifierHeightOffset;
  49727. /**
  49728. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49729. * allow modification of the rotationOffset value.
  49730. */
  49731. private _modifierRotationOffset;
  49732. /**
  49733. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49734. * allow modification of the radius value.
  49735. */
  49736. private _modifierRadius;
  49737. }
  49738. }
  49739. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  49740. import { Nullable } from "babylonjs/types";
  49741. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49742. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49743. import { Observable } from "babylonjs/Misc/observable";
  49744. module "babylonjs/Cameras/freeCameraInputsManager" {
  49745. interface FreeCameraInputsManager {
  49746. /**
  49747. * @hidden
  49748. */
  49749. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  49750. /**
  49751. * Add orientation input support to the input manager.
  49752. * @returns the current input manager
  49753. */
  49754. addDeviceOrientation(): FreeCameraInputsManager;
  49755. }
  49756. }
  49757. /**
  49758. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  49759. * Screen rotation is taken into account.
  49760. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49761. */
  49762. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  49763. private _camera;
  49764. private _screenOrientationAngle;
  49765. private _constantTranform;
  49766. private _screenQuaternion;
  49767. private _alpha;
  49768. private _beta;
  49769. private _gamma;
  49770. /**
  49771. * Can be used to detect if a device orientation sensor is available on a device
  49772. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  49773. * @returns a promise that will resolve on orientation change
  49774. */
  49775. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  49776. /**
  49777. * @hidden
  49778. */
  49779. _onDeviceOrientationChangedObservable: Observable<void>;
  49780. /**
  49781. * Instantiates a new input
  49782. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49783. */
  49784. constructor();
  49785. /**
  49786. * Define the camera controlled by the input.
  49787. */
  49788. get camera(): FreeCamera;
  49789. set camera(camera: FreeCamera);
  49790. /**
  49791. * Attach the input controls to a specific dom element to get the input from.
  49792. * @param element Defines the element the controls should be listened from
  49793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49794. */
  49795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49796. private _orientationChanged;
  49797. private _deviceOrientation;
  49798. /**
  49799. * Detach the current controls from the specified dom element.
  49800. * @param element Defines the element to stop listening the inputs from
  49801. */
  49802. detachControl(element: Nullable<HTMLElement>): void;
  49803. /**
  49804. * Update the current camera state depending on the inputs that have been used this frame.
  49805. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49806. */
  49807. checkInputs(): void;
  49808. /**
  49809. * Gets the class name of the current intput.
  49810. * @returns the class name
  49811. */
  49812. getClassName(): string;
  49813. /**
  49814. * Get the friendly name associated with the input class.
  49815. * @returns the input friendly name
  49816. */
  49817. getSimpleName(): string;
  49818. }
  49819. }
  49820. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  49821. import { Nullable } from "babylonjs/types";
  49822. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49823. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49824. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49825. /**
  49826. * Manage the gamepad inputs to control a free camera.
  49827. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49828. */
  49829. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  49830. /**
  49831. * Define the camera the input is attached to.
  49832. */
  49833. camera: FreeCamera;
  49834. /**
  49835. * Define the Gamepad controlling the input
  49836. */
  49837. gamepad: Nullable<Gamepad>;
  49838. /**
  49839. * Defines the gamepad rotation sensiblity.
  49840. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49841. */
  49842. gamepadAngularSensibility: number;
  49843. /**
  49844. * Defines the gamepad move sensiblity.
  49845. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49846. */
  49847. gamepadMoveSensibility: number;
  49848. private _yAxisScale;
  49849. /**
  49850. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49851. */
  49852. get invertYAxis(): boolean;
  49853. set invertYAxis(value: boolean);
  49854. private _onGamepadConnectedObserver;
  49855. private _onGamepadDisconnectedObserver;
  49856. private _cameraTransform;
  49857. private _deltaTransform;
  49858. private _vector3;
  49859. private _vector2;
  49860. /**
  49861. * Attach the input controls to a specific dom element to get the input from.
  49862. * @param element Defines the element the controls should be listened from
  49863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49864. */
  49865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49866. /**
  49867. * Detach the current controls from the specified dom element.
  49868. * @param element Defines the element to stop listening the inputs from
  49869. */
  49870. detachControl(element: Nullable<HTMLElement>): void;
  49871. /**
  49872. * Update the current camera state depending on the inputs that have been used this frame.
  49873. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49874. */
  49875. checkInputs(): void;
  49876. /**
  49877. * Gets the class name of the current intput.
  49878. * @returns the class name
  49879. */
  49880. getClassName(): string;
  49881. /**
  49882. * Get the friendly name associated with the input class.
  49883. * @returns the input friendly name
  49884. */
  49885. getSimpleName(): string;
  49886. }
  49887. }
  49888. declare module "babylonjs/Misc/virtualJoystick" {
  49889. import { Nullable } from "babylonjs/types";
  49890. import { Vector3 } from "babylonjs/Maths/math.vector";
  49891. /**
  49892. * Defines the potential axis of a Joystick
  49893. */
  49894. export enum JoystickAxis {
  49895. /** X axis */
  49896. X = 0,
  49897. /** Y axis */
  49898. Y = 1,
  49899. /** Z axis */
  49900. Z = 2
  49901. }
  49902. /**
  49903. * Represents the different customization options available
  49904. * for VirtualJoystick
  49905. */
  49906. interface VirtualJoystickCustomizations {
  49907. /**
  49908. * Size of the joystick's puck
  49909. */
  49910. puckSize: number;
  49911. /**
  49912. * Size of the joystick's container
  49913. */
  49914. containerSize: number;
  49915. /**
  49916. * Color of the joystick && puck
  49917. */
  49918. color: string;
  49919. /**
  49920. * Image URL for the joystick's puck
  49921. */
  49922. puckImage?: string;
  49923. /**
  49924. * Image URL for the joystick's container
  49925. */
  49926. containerImage?: string;
  49927. /**
  49928. * Defines the unmoving position of the joystick container
  49929. */
  49930. position?: {
  49931. x: number;
  49932. y: number;
  49933. };
  49934. /**
  49935. * Defines whether or not the joystick container is always visible
  49936. */
  49937. alwaysVisible: boolean;
  49938. /**
  49939. * Defines whether or not to limit the movement of the puck to the joystick's container
  49940. */
  49941. limitToContainer: boolean;
  49942. }
  49943. /**
  49944. * Class used to define virtual joystick (used in touch mode)
  49945. */
  49946. export class VirtualJoystick {
  49947. /**
  49948. * Gets or sets a boolean indicating that left and right values must be inverted
  49949. */
  49950. reverseLeftRight: boolean;
  49951. /**
  49952. * Gets or sets a boolean indicating that up and down values must be inverted
  49953. */
  49954. reverseUpDown: boolean;
  49955. /**
  49956. * Gets the offset value for the position (ie. the change of the position value)
  49957. */
  49958. deltaPosition: Vector3;
  49959. /**
  49960. * Gets a boolean indicating if the virtual joystick was pressed
  49961. */
  49962. pressed: boolean;
  49963. /**
  49964. * Canvas the virtual joystick will render onto, default z-index of this is 5
  49965. */
  49966. static Canvas: Nullable<HTMLCanvasElement>;
  49967. /**
  49968. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  49969. */
  49970. limitToContainer: boolean;
  49971. private static _globalJoystickIndex;
  49972. private static _alwaysVisibleSticks;
  49973. private static vjCanvasContext;
  49974. private static vjCanvasWidth;
  49975. private static vjCanvasHeight;
  49976. private static halfWidth;
  49977. private static _GetDefaultOptions;
  49978. private _action;
  49979. private _axisTargetedByLeftAndRight;
  49980. private _axisTargetedByUpAndDown;
  49981. private _joystickSensibility;
  49982. private _inversedSensibility;
  49983. private _joystickPointerID;
  49984. private _joystickColor;
  49985. private _joystickPointerPos;
  49986. private _joystickPreviousPointerPos;
  49987. private _joystickPointerStartPos;
  49988. private _deltaJoystickVector;
  49989. private _leftJoystick;
  49990. private _touches;
  49991. private _joystickPosition;
  49992. private _alwaysVisible;
  49993. private _puckImage;
  49994. private _containerImage;
  49995. private _joystickPuckSize;
  49996. private _joystickContainerSize;
  49997. private _clearPuckSize;
  49998. private _clearContainerSize;
  49999. private _clearPuckSizeOffset;
  50000. private _clearContainerSizeOffset;
  50001. private _onPointerDownHandlerRef;
  50002. private _onPointerMoveHandlerRef;
  50003. private _onPointerUpHandlerRef;
  50004. private _onResize;
  50005. /**
  50006. * Creates a new virtual joystick
  50007. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50008. * @param customizations Defines the options we want to customize the VirtualJoystick
  50009. */
  50010. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50011. /**
  50012. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50013. * @param newJoystickSensibility defines the new sensibility
  50014. */
  50015. setJoystickSensibility(newJoystickSensibility: number): void;
  50016. private _onPointerDown;
  50017. private _onPointerMove;
  50018. private _onPointerUp;
  50019. /**
  50020. * Change the color of the virtual joystick
  50021. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50022. */
  50023. setJoystickColor(newColor: string): void;
  50024. /**
  50025. * Size of the joystick's container
  50026. */
  50027. set containerSize(newSize: number);
  50028. get containerSize(): number;
  50029. /**
  50030. * Size of the joystick's puck
  50031. */
  50032. set puckSize(newSize: number);
  50033. get puckSize(): number;
  50034. /**
  50035. * Clears the set position of the joystick
  50036. */
  50037. clearPosition(): void;
  50038. /**
  50039. * Defines whether or not the joystick container is always visible
  50040. */
  50041. set alwaysVisible(value: boolean);
  50042. get alwaysVisible(): boolean;
  50043. /**
  50044. * Sets the constant position of the Joystick container
  50045. * @param x X axis coordinate
  50046. * @param y Y axis coordinate
  50047. */
  50048. setPosition(x: number, y: number): void;
  50049. /**
  50050. * Defines a callback to call when the joystick is touched
  50051. * @param action defines the callback
  50052. */
  50053. setActionOnTouch(action: () => any): void;
  50054. /**
  50055. * Defines which axis you'd like to control for left & right
  50056. * @param axis defines the axis to use
  50057. */
  50058. setAxisForLeftRight(axis: JoystickAxis): void;
  50059. /**
  50060. * Defines which axis you'd like to control for up & down
  50061. * @param axis defines the axis to use
  50062. */
  50063. setAxisForUpDown(axis: JoystickAxis): void;
  50064. /**
  50065. * Clears the canvas from the previous puck / container draw
  50066. */
  50067. private _clearPreviousDraw;
  50068. /**
  50069. * Loads `urlPath` to be used for the container's image
  50070. * @param urlPath defines the urlPath of an image to use
  50071. */
  50072. setContainerImage(urlPath: string): void;
  50073. /**
  50074. * Loads `urlPath` to be used for the puck's image
  50075. * @param urlPath defines the urlPath of an image to use
  50076. */
  50077. setPuckImage(urlPath: string): void;
  50078. /**
  50079. * Draws the Virtual Joystick's container
  50080. */
  50081. private _drawContainer;
  50082. /**
  50083. * Draws the Virtual Joystick's puck
  50084. */
  50085. private _drawPuck;
  50086. private _drawVirtualJoystick;
  50087. /**
  50088. * Release internal HTML canvas
  50089. */
  50090. releaseCanvas(): void;
  50091. }
  50092. }
  50093. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50094. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50095. import { Nullable } from "babylonjs/types";
  50096. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50097. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50098. module "babylonjs/Cameras/freeCameraInputsManager" {
  50099. interface FreeCameraInputsManager {
  50100. /**
  50101. * Add virtual joystick input support to the input manager.
  50102. * @returns the current input manager
  50103. */
  50104. addVirtualJoystick(): FreeCameraInputsManager;
  50105. }
  50106. }
  50107. /**
  50108. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50109. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50110. */
  50111. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50112. /**
  50113. * Defines the camera the input is attached to.
  50114. */
  50115. camera: FreeCamera;
  50116. private _leftjoystick;
  50117. private _rightjoystick;
  50118. /**
  50119. * Gets the left stick of the virtual joystick.
  50120. * @returns The virtual Joystick
  50121. */
  50122. getLeftJoystick(): VirtualJoystick;
  50123. /**
  50124. * Gets the right stick of the virtual joystick.
  50125. * @returns The virtual Joystick
  50126. */
  50127. getRightJoystick(): VirtualJoystick;
  50128. /**
  50129. * Update the current camera state depending on the inputs that have been used this frame.
  50130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50131. */
  50132. checkInputs(): void;
  50133. /**
  50134. * Attach the input controls to a specific dom element to get the input from.
  50135. * @param element Defines the element the controls should be listened from
  50136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50137. */
  50138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50139. /**
  50140. * Detach the current controls from the specified dom element.
  50141. * @param element Defines the element to stop listening the inputs from
  50142. */
  50143. detachControl(element: Nullable<HTMLElement>): void;
  50144. /**
  50145. * Gets the class name of the current intput.
  50146. * @returns the class name
  50147. */
  50148. getClassName(): string;
  50149. /**
  50150. * Get the friendly name associated with the input class.
  50151. * @returns the input friendly name
  50152. */
  50153. getSimpleName(): string;
  50154. }
  50155. }
  50156. declare module "babylonjs/Cameras/Inputs/index" {
  50157. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50158. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50159. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50160. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50161. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50162. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50163. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50164. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50165. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50166. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50167. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50168. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50169. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50170. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50171. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50172. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50173. }
  50174. declare module "babylonjs/Cameras/touchCamera" {
  50175. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50176. import { Scene } from "babylonjs/scene";
  50177. import { Vector3 } from "babylonjs/Maths/math.vector";
  50178. /**
  50179. * This represents a FPS type of camera controlled by touch.
  50180. * This is like a universal camera minus the Gamepad controls.
  50181. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50182. */
  50183. export class TouchCamera extends FreeCamera {
  50184. /**
  50185. * Defines the touch sensibility for rotation.
  50186. * The higher the faster.
  50187. */
  50188. get touchAngularSensibility(): number;
  50189. set touchAngularSensibility(value: number);
  50190. /**
  50191. * Defines the touch sensibility for move.
  50192. * The higher the faster.
  50193. */
  50194. get touchMoveSensibility(): number;
  50195. set touchMoveSensibility(value: number);
  50196. /**
  50197. * Instantiates a new touch camera.
  50198. * This represents a FPS type of camera controlled by touch.
  50199. * This is like a universal camera minus the Gamepad controls.
  50200. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50201. * @param name Define the name of the camera in the scene
  50202. * @param position Define the start position of the camera in the scene
  50203. * @param scene Define the scene the camera belongs to
  50204. */
  50205. constructor(name: string, position: Vector3, scene: Scene);
  50206. /**
  50207. * Gets the current object class name.
  50208. * @return the class name
  50209. */
  50210. getClassName(): string;
  50211. /** @hidden */
  50212. _setupInputs(): void;
  50213. }
  50214. }
  50215. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50216. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50217. import { Scene } from "babylonjs/scene";
  50218. import { Vector3 } from "babylonjs/Maths/math.vector";
  50219. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50220. import { Axis } from "babylonjs/Maths/math.axis";
  50221. /**
  50222. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50223. * being tilted forward or back and left or right.
  50224. */
  50225. export class DeviceOrientationCamera extends FreeCamera {
  50226. private _initialQuaternion;
  50227. private _quaternionCache;
  50228. private _tmpDragQuaternion;
  50229. private _disablePointerInputWhenUsingDeviceOrientation;
  50230. /**
  50231. * Creates a new device orientation camera
  50232. * @param name The name of the camera
  50233. * @param position The start position camera
  50234. * @param scene The scene the camera belongs to
  50235. */
  50236. constructor(name: string, position: Vector3, scene: Scene);
  50237. /**
  50238. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50239. */
  50240. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50241. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50242. private _dragFactor;
  50243. /**
  50244. * Enabled turning on the y axis when the orientation sensor is active
  50245. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50246. */
  50247. enableHorizontalDragging(dragFactor?: number): void;
  50248. /**
  50249. * Gets the current instance class name ("DeviceOrientationCamera").
  50250. * This helps avoiding instanceof at run time.
  50251. * @returns the class name
  50252. */
  50253. getClassName(): string;
  50254. /**
  50255. * @hidden
  50256. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50257. */
  50258. _checkInputs(): void;
  50259. /**
  50260. * Reset the camera to its default orientation on the specified axis only.
  50261. * @param axis The axis to reset
  50262. */
  50263. resetToCurrentRotation(axis?: Axis): void;
  50264. }
  50265. }
  50266. declare module "babylonjs/Gamepads/xboxGamepad" {
  50267. import { Observable } from "babylonjs/Misc/observable";
  50268. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50269. /**
  50270. * Defines supported buttons for XBox360 compatible gamepads
  50271. */
  50272. export enum Xbox360Button {
  50273. /** A */
  50274. A = 0,
  50275. /** B */
  50276. B = 1,
  50277. /** X */
  50278. X = 2,
  50279. /** Y */
  50280. Y = 3,
  50281. /** Left button */
  50282. LB = 4,
  50283. /** Right button */
  50284. RB = 5,
  50285. /** Back */
  50286. Back = 8,
  50287. /** Start */
  50288. Start = 9,
  50289. /** Left stick */
  50290. LeftStick = 10,
  50291. /** Right stick */
  50292. RightStick = 11
  50293. }
  50294. /** Defines values for XBox360 DPad */
  50295. export enum Xbox360Dpad {
  50296. /** Up */
  50297. Up = 12,
  50298. /** Down */
  50299. Down = 13,
  50300. /** Left */
  50301. Left = 14,
  50302. /** Right */
  50303. Right = 15
  50304. }
  50305. /**
  50306. * Defines a XBox360 gamepad
  50307. */
  50308. export class Xbox360Pad extends Gamepad {
  50309. private _leftTrigger;
  50310. private _rightTrigger;
  50311. private _onlefttriggerchanged;
  50312. private _onrighttriggerchanged;
  50313. private _onbuttondown;
  50314. private _onbuttonup;
  50315. private _ondpaddown;
  50316. private _ondpadup;
  50317. /** Observable raised when a button is pressed */
  50318. onButtonDownObservable: Observable<Xbox360Button>;
  50319. /** Observable raised when a button is released */
  50320. onButtonUpObservable: Observable<Xbox360Button>;
  50321. /** Observable raised when a pad is pressed */
  50322. onPadDownObservable: Observable<Xbox360Dpad>;
  50323. /** Observable raised when a pad is released */
  50324. onPadUpObservable: Observable<Xbox360Dpad>;
  50325. private _buttonA;
  50326. private _buttonB;
  50327. private _buttonX;
  50328. private _buttonY;
  50329. private _buttonBack;
  50330. private _buttonStart;
  50331. private _buttonLB;
  50332. private _buttonRB;
  50333. private _buttonLeftStick;
  50334. private _buttonRightStick;
  50335. private _dPadUp;
  50336. private _dPadDown;
  50337. private _dPadLeft;
  50338. private _dPadRight;
  50339. private _isXboxOnePad;
  50340. /**
  50341. * Creates a new XBox360 gamepad object
  50342. * @param id defines the id of this gamepad
  50343. * @param index defines its index
  50344. * @param gamepad defines the internal HTML gamepad object
  50345. * @param xboxOne defines if it is a XBox One gamepad
  50346. */
  50347. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50348. /**
  50349. * Defines the callback to call when left trigger is pressed
  50350. * @param callback defines the callback to use
  50351. */
  50352. onlefttriggerchanged(callback: (value: number) => void): void;
  50353. /**
  50354. * Defines the callback to call when right trigger is pressed
  50355. * @param callback defines the callback to use
  50356. */
  50357. onrighttriggerchanged(callback: (value: number) => void): void;
  50358. /**
  50359. * Gets the left trigger value
  50360. */
  50361. get leftTrigger(): number;
  50362. /**
  50363. * Sets the left trigger value
  50364. */
  50365. set leftTrigger(newValue: number);
  50366. /**
  50367. * Gets the right trigger value
  50368. */
  50369. get rightTrigger(): number;
  50370. /**
  50371. * Sets the right trigger value
  50372. */
  50373. set rightTrigger(newValue: number);
  50374. /**
  50375. * Defines the callback to call when a button is pressed
  50376. * @param callback defines the callback to use
  50377. */
  50378. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50379. /**
  50380. * Defines the callback to call when a button is released
  50381. * @param callback defines the callback to use
  50382. */
  50383. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50384. /**
  50385. * Defines the callback to call when a pad is pressed
  50386. * @param callback defines the callback to use
  50387. */
  50388. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50389. /**
  50390. * Defines the callback to call when a pad is released
  50391. * @param callback defines the callback to use
  50392. */
  50393. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50394. private _setButtonValue;
  50395. private _setDPadValue;
  50396. /**
  50397. * Gets the value of the `A` button
  50398. */
  50399. get buttonA(): number;
  50400. /**
  50401. * Sets the value of the `A` button
  50402. */
  50403. set buttonA(value: number);
  50404. /**
  50405. * Gets the value of the `B` button
  50406. */
  50407. get buttonB(): number;
  50408. /**
  50409. * Sets the value of the `B` button
  50410. */
  50411. set buttonB(value: number);
  50412. /**
  50413. * Gets the value of the `X` button
  50414. */
  50415. get buttonX(): number;
  50416. /**
  50417. * Sets the value of the `X` button
  50418. */
  50419. set buttonX(value: number);
  50420. /**
  50421. * Gets the value of the `Y` button
  50422. */
  50423. get buttonY(): number;
  50424. /**
  50425. * Sets the value of the `Y` button
  50426. */
  50427. set buttonY(value: number);
  50428. /**
  50429. * Gets the value of the `Start` button
  50430. */
  50431. get buttonStart(): number;
  50432. /**
  50433. * Sets the value of the `Start` button
  50434. */
  50435. set buttonStart(value: number);
  50436. /**
  50437. * Gets the value of the `Back` button
  50438. */
  50439. get buttonBack(): number;
  50440. /**
  50441. * Sets the value of the `Back` button
  50442. */
  50443. set buttonBack(value: number);
  50444. /**
  50445. * Gets the value of the `Left` button
  50446. */
  50447. get buttonLB(): number;
  50448. /**
  50449. * Sets the value of the `Left` button
  50450. */
  50451. set buttonLB(value: number);
  50452. /**
  50453. * Gets the value of the `Right` button
  50454. */
  50455. get buttonRB(): number;
  50456. /**
  50457. * Sets the value of the `Right` button
  50458. */
  50459. set buttonRB(value: number);
  50460. /**
  50461. * Gets the value of the Left joystick
  50462. */
  50463. get buttonLeftStick(): number;
  50464. /**
  50465. * Sets the value of the Left joystick
  50466. */
  50467. set buttonLeftStick(value: number);
  50468. /**
  50469. * Gets the value of the Right joystick
  50470. */
  50471. get buttonRightStick(): number;
  50472. /**
  50473. * Sets the value of the Right joystick
  50474. */
  50475. set buttonRightStick(value: number);
  50476. /**
  50477. * Gets the value of D-pad up
  50478. */
  50479. get dPadUp(): number;
  50480. /**
  50481. * Sets the value of D-pad up
  50482. */
  50483. set dPadUp(value: number);
  50484. /**
  50485. * Gets the value of D-pad down
  50486. */
  50487. get dPadDown(): number;
  50488. /**
  50489. * Sets the value of D-pad down
  50490. */
  50491. set dPadDown(value: number);
  50492. /**
  50493. * Gets the value of D-pad left
  50494. */
  50495. get dPadLeft(): number;
  50496. /**
  50497. * Sets the value of D-pad left
  50498. */
  50499. set dPadLeft(value: number);
  50500. /**
  50501. * Gets the value of D-pad right
  50502. */
  50503. get dPadRight(): number;
  50504. /**
  50505. * Sets the value of D-pad right
  50506. */
  50507. set dPadRight(value: number);
  50508. /**
  50509. * Force the gamepad to synchronize with device values
  50510. */
  50511. update(): void;
  50512. /**
  50513. * Disposes the gamepad
  50514. */
  50515. dispose(): void;
  50516. }
  50517. }
  50518. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50519. import { Observable } from "babylonjs/Misc/observable";
  50520. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50521. /**
  50522. * Defines supported buttons for DualShock compatible gamepads
  50523. */
  50524. export enum DualShockButton {
  50525. /** Cross */
  50526. Cross = 0,
  50527. /** Circle */
  50528. Circle = 1,
  50529. /** Square */
  50530. Square = 2,
  50531. /** Triangle */
  50532. Triangle = 3,
  50533. /** L1 */
  50534. L1 = 4,
  50535. /** R1 */
  50536. R1 = 5,
  50537. /** Share */
  50538. Share = 8,
  50539. /** Options */
  50540. Options = 9,
  50541. /** Left stick */
  50542. LeftStick = 10,
  50543. /** Right stick */
  50544. RightStick = 11
  50545. }
  50546. /** Defines values for DualShock DPad */
  50547. export enum DualShockDpad {
  50548. /** Up */
  50549. Up = 12,
  50550. /** Down */
  50551. Down = 13,
  50552. /** Left */
  50553. Left = 14,
  50554. /** Right */
  50555. Right = 15
  50556. }
  50557. /**
  50558. * Defines a DualShock gamepad
  50559. */
  50560. export class DualShockPad extends Gamepad {
  50561. private _leftTrigger;
  50562. private _rightTrigger;
  50563. private _onlefttriggerchanged;
  50564. private _onrighttriggerchanged;
  50565. private _onbuttondown;
  50566. private _onbuttonup;
  50567. private _ondpaddown;
  50568. private _ondpadup;
  50569. /** Observable raised when a button is pressed */
  50570. onButtonDownObservable: Observable<DualShockButton>;
  50571. /** Observable raised when a button is released */
  50572. onButtonUpObservable: Observable<DualShockButton>;
  50573. /** Observable raised when a pad is pressed */
  50574. onPadDownObservable: Observable<DualShockDpad>;
  50575. /** Observable raised when a pad is released */
  50576. onPadUpObservable: Observable<DualShockDpad>;
  50577. private _buttonCross;
  50578. private _buttonCircle;
  50579. private _buttonSquare;
  50580. private _buttonTriangle;
  50581. private _buttonShare;
  50582. private _buttonOptions;
  50583. private _buttonL1;
  50584. private _buttonR1;
  50585. private _buttonLeftStick;
  50586. private _buttonRightStick;
  50587. private _dPadUp;
  50588. private _dPadDown;
  50589. private _dPadLeft;
  50590. private _dPadRight;
  50591. /**
  50592. * Creates a new DualShock gamepad object
  50593. * @param id defines the id of this gamepad
  50594. * @param index defines its index
  50595. * @param gamepad defines the internal HTML gamepad object
  50596. */
  50597. constructor(id: string, index: number, gamepad: any);
  50598. /**
  50599. * Defines the callback to call when left trigger is pressed
  50600. * @param callback defines the callback to use
  50601. */
  50602. onlefttriggerchanged(callback: (value: number) => void): void;
  50603. /**
  50604. * Defines the callback to call when right trigger is pressed
  50605. * @param callback defines the callback to use
  50606. */
  50607. onrighttriggerchanged(callback: (value: number) => void): void;
  50608. /**
  50609. * Gets the left trigger value
  50610. */
  50611. get leftTrigger(): number;
  50612. /**
  50613. * Sets the left trigger value
  50614. */
  50615. set leftTrigger(newValue: number);
  50616. /**
  50617. * Gets the right trigger value
  50618. */
  50619. get rightTrigger(): number;
  50620. /**
  50621. * Sets the right trigger value
  50622. */
  50623. set rightTrigger(newValue: number);
  50624. /**
  50625. * Defines the callback to call when a button is pressed
  50626. * @param callback defines the callback to use
  50627. */
  50628. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50629. /**
  50630. * Defines the callback to call when a button is released
  50631. * @param callback defines the callback to use
  50632. */
  50633. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50634. /**
  50635. * Defines the callback to call when a pad is pressed
  50636. * @param callback defines the callback to use
  50637. */
  50638. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50639. /**
  50640. * Defines the callback to call when a pad is released
  50641. * @param callback defines the callback to use
  50642. */
  50643. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50644. private _setButtonValue;
  50645. private _setDPadValue;
  50646. /**
  50647. * Gets the value of the `Cross` button
  50648. */
  50649. get buttonCross(): number;
  50650. /**
  50651. * Sets the value of the `Cross` button
  50652. */
  50653. set buttonCross(value: number);
  50654. /**
  50655. * Gets the value of the `Circle` button
  50656. */
  50657. get buttonCircle(): number;
  50658. /**
  50659. * Sets the value of the `Circle` button
  50660. */
  50661. set buttonCircle(value: number);
  50662. /**
  50663. * Gets the value of the `Square` button
  50664. */
  50665. get buttonSquare(): number;
  50666. /**
  50667. * Sets the value of the `Square` button
  50668. */
  50669. set buttonSquare(value: number);
  50670. /**
  50671. * Gets the value of the `Triangle` button
  50672. */
  50673. get buttonTriangle(): number;
  50674. /**
  50675. * Sets the value of the `Triangle` button
  50676. */
  50677. set buttonTriangle(value: number);
  50678. /**
  50679. * Gets the value of the `Options` button
  50680. */
  50681. get buttonOptions(): number;
  50682. /**
  50683. * Sets the value of the `Options` button
  50684. */
  50685. set buttonOptions(value: number);
  50686. /**
  50687. * Gets the value of the `Share` button
  50688. */
  50689. get buttonShare(): number;
  50690. /**
  50691. * Sets the value of the `Share` button
  50692. */
  50693. set buttonShare(value: number);
  50694. /**
  50695. * Gets the value of the `L1` button
  50696. */
  50697. get buttonL1(): number;
  50698. /**
  50699. * Sets the value of the `L1` button
  50700. */
  50701. set buttonL1(value: number);
  50702. /**
  50703. * Gets the value of the `R1` button
  50704. */
  50705. get buttonR1(): number;
  50706. /**
  50707. * Sets the value of the `R1` button
  50708. */
  50709. set buttonR1(value: number);
  50710. /**
  50711. * Gets the value of the Left joystick
  50712. */
  50713. get buttonLeftStick(): number;
  50714. /**
  50715. * Sets the value of the Left joystick
  50716. */
  50717. set buttonLeftStick(value: number);
  50718. /**
  50719. * Gets the value of the Right joystick
  50720. */
  50721. get buttonRightStick(): number;
  50722. /**
  50723. * Sets the value of the Right joystick
  50724. */
  50725. set buttonRightStick(value: number);
  50726. /**
  50727. * Gets the value of D-pad up
  50728. */
  50729. get dPadUp(): number;
  50730. /**
  50731. * Sets the value of D-pad up
  50732. */
  50733. set dPadUp(value: number);
  50734. /**
  50735. * Gets the value of D-pad down
  50736. */
  50737. get dPadDown(): number;
  50738. /**
  50739. * Sets the value of D-pad down
  50740. */
  50741. set dPadDown(value: number);
  50742. /**
  50743. * Gets the value of D-pad left
  50744. */
  50745. get dPadLeft(): number;
  50746. /**
  50747. * Sets the value of D-pad left
  50748. */
  50749. set dPadLeft(value: number);
  50750. /**
  50751. * Gets the value of D-pad right
  50752. */
  50753. get dPadRight(): number;
  50754. /**
  50755. * Sets the value of D-pad right
  50756. */
  50757. set dPadRight(value: number);
  50758. /**
  50759. * Force the gamepad to synchronize with device values
  50760. */
  50761. update(): void;
  50762. /**
  50763. * Disposes the gamepad
  50764. */
  50765. dispose(): void;
  50766. }
  50767. }
  50768. declare module "babylonjs/Gamepads/gamepadManager" {
  50769. import { Observable } from "babylonjs/Misc/observable";
  50770. import { Nullable } from "babylonjs/types";
  50771. import { Scene } from "babylonjs/scene";
  50772. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50773. /**
  50774. * Manager for handling gamepads
  50775. */
  50776. export class GamepadManager {
  50777. private _scene?;
  50778. private _babylonGamepads;
  50779. private _oneGamepadConnected;
  50780. /** @hidden */
  50781. _isMonitoring: boolean;
  50782. private _gamepadEventSupported;
  50783. private _gamepadSupport?;
  50784. /**
  50785. * observable to be triggered when the gamepad controller has been connected
  50786. */
  50787. onGamepadConnectedObservable: Observable<Gamepad>;
  50788. /**
  50789. * observable to be triggered when the gamepad controller has been disconnected
  50790. */
  50791. onGamepadDisconnectedObservable: Observable<Gamepad>;
  50792. private _onGamepadConnectedEvent;
  50793. private _onGamepadDisconnectedEvent;
  50794. /**
  50795. * Initializes the gamepad manager
  50796. * @param _scene BabylonJS scene
  50797. */
  50798. constructor(_scene?: Scene | undefined);
  50799. /**
  50800. * The gamepads in the game pad manager
  50801. */
  50802. get gamepads(): Gamepad[];
  50803. /**
  50804. * Get the gamepad controllers based on type
  50805. * @param type The type of gamepad controller
  50806. * @returns Nullable gamepad
  50807. */
  50808. getGamepadByType(type?: number): Nullable<Gamepad>;
  50809. /**
  50810. * Disposes the gamepad manager
  50811. */
  50812. dispose(): void;
  50813. private _addNewGamepad;
  50814. private _startMonitoringGamepads;
  50815. private _stopMonitoringGamepads;
  50816. /** @hidden */
  50817. _checkGamepadsStatus(): void;
  50818. private _updateGamepadObjects;
  50819. }
  50820. }
  50821. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  50822. import { Nullable } from "babylonjs/types";
  50823. import { Scene } from "babylonjs/scene";
  50824. import { ISceneComponent } from "babylonjs/sceneComponent";
  50825. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  50826. module "babylonjs/scene" {
  50827. interface Scene {
  50828. /** @hidden */
  50829. _gamepadManager: Nullable<GamepadManager>;
  50830. /**
  50831. * Gets the gamepad manager associated with the scene
  50832. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  50833. */
  50834. gamepadManager: GamepadManager;
  50835. }
  50836. }
  50837. module "babylonjs/Cameras/freeCameraInputsManager" {
  50838. /**
  50839. * Interface representing a free camera inputs manager
  50840. */
  50841. interface FreeCameraInputsManager {
  50842. /**
  50843. * Adds gamepad input support to the FreeCameraInputsManager.
  50844. * @returns the FreeCameraInputsManager
  50845. */
  50846. addGamepad(): FreeCameraInputsManager;
  50847. }
  50848. }
  50849. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  50850. /**
  50851. * Interface representing an arc rotate camera inputs manager
  50852. */
  50853. interface ArcRotateCameraInputsManager {
  50854. /**
  50855. * Adds gamepad input support to the ArcRotateCamera InputManager.
  50856. * @returns the camera inputs manager
  50857. */
  50858. addGamepad(): ArcRotateCameraInputsManager;
  50859. }
  50860. }
  50861. /**
  50862. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  50863. */
  50864. export class GamepadSystemSceneComponent implements ISceneComponent {
  50865. /**
  50866. * The component name helpfull to identify the component in the list of scene components.
  50867. */
  50868. readonly name: string;
  50869. /**
  50870. * The scene the component belongs to.
  50871. */
  50872. scene: Scene;
  50873. /**
  50874. * Creates a new instance of the component for the given scene
  50875. * @param scene Defines the scene to register the component in
  50876. */
  50877. constructor(scene: Scene);
  50878. /**
  50879. * Registers the component in a given scene
  50880. */
  50881. register(): void;
  50882. /**
  50883. * Rebuilds the elements related to this component in case of
  50884. * context lost for instance.
  50885. */
  50886. rebuild(): void;
  50887. /**
  50888. * Disposes the component and the associated ressources
  50889. */
  50890. dispose(): void;
  50891. private _beforeCameraUpdate;
  50892. }
  50893. }
  50894. declare module "babylonjs/Cameras/universalCamera" {
  50895. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  50896. import { Scene } from "babylonjs/scene";
  50897. import { Vector3 } from "babylonjs/Maths/math.vector";
  50898. import "babylonjs/Gamepads/gamepadSceneComponent";
  50899. /**
  50900. * 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,
  50901. * which still works and will still be found in many Playgrounds.
  50902. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50903. */
  50904. export class UniversalCamera extends TouchCamera {
  50905. /**
  50906. * Defines the gamepad rotation sensiblity.
  50907. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50908. */
  50909. get gamepadAngularSensibility(): number;
  50910. set gamepadAngularSensibility(value: number);
  50911. /**
  50912. * Defines the gamepad move sensiblity.
  50913. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50914. */
  50915. get gamepadMoveSensibility(): number;
  50916. set gamepadMoveSensibility(value: number);
  50917. /**
  50918. * 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,
  50919. * which still works and will still be found in many Playgrounds.
  50920. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50921. * @param name Define the name of the camera in the scene
  50922. * @param position Define the start position of the camera in the scene
  50923. * @param scene Define the scene the camera belongs to
  50924. */
  50925. constructor(name: string, position: Vector3, scene: Scene);
  50926. /**
  50927. * Gets the current object class name.
  50928. * @return the class name
  50929. */
  50930. getClassName(): string;
  50931. }
  50932. }
  50933. declare module "babylonjs/Cameras/gamepadCamera" {
  50934. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  50935. import { Scene } from "babylonjs/scene";
  50936. import { Vector3 } from "babylonjs/Maths/math.vector";
  50937. /**
  50938. * This represents a FPS type of camera. This is only here for back compat purpose.
  50939. * Please use the UniversalCamera instead as both are identical.
  50940. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50941. */
  50942. export class GamepadCamera extends UniversalCamera {
  50943. /**
  50944. * Instantiates a new Gamepad Camera
  50945. * This represents a FPS type of camera. This is only here for back compat purpose.
  50946. * Please use the UniversalCamera instead as both are identical.
  50947. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50948. * @param name Define the name of the camera in the scene
  50949. * @param position Define the start position of the camera in the scene
  50950. * @param scene Define the scene the camera belongs to
  50951. */
  50952. constructor(name: string, position: Vector3, scene: Scene);
  50953. /**
  50954. * Gets the current object class name.
  50955. * @return the class name
  50956. */
  50957. getClassName(): string;
  50958. }
  50959. }
  50960. declare module "babylonjs/Shaders/pass.fragment" {
  50961. /** @hidden */
  50962. export var passPixelShader: {
  50963. name: string;
  50964. shader: string;
  50965. };
  50966. }
  50967. declare module "babylonjs/Shaders/passCube.fragment" {
  50968. /** @hidden */
  50969. export var passCubePixelShader: {
  50970. name: string;
  50971. shader: string;
  50972. };
  50973. }
  50974. declare module "babylonjs/PostProcesses/passPostProcess" {
  50975. import { Nullable } from "babylonjs/types";
  50976. import { Camera } from "babylonjs/Cameras/camera";
  50977. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50978. import { Engine } from "babylonjs/Engines/engine";
  50979. import "babylonjs/Shaders/pass.fragment";
  50980. import "babylonjs/Shaders/passCube.fragment";
  50981. import { Scene } from "babylonjs/scene";
  50982. /**
  50983. * PassPostProcess which produces an output the same as it's input
  50984. */
  50985. export class PassPostProcess extends PostProcess {
  50986. /**
  50987. * Gets a string identifying the name of the class
  50988. * @returns "PassPostProcess" string
  50989. */
  50990. getClassName(): string;
  50991. /**
  50992. * Creates the PassPostProcess
  50993. * @param name The name of the effect.
  50994. * @param options The required width/height ratio to downsize to before computing the render pass.
  50995. * @param camera The camera to apply the render pass to.
  50996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50997. * @param engine The engine which the post process will be applied. (default: current engine)
  50998. * @param reusable If the post process can be reused on the same frame. (default: false)
  50999. * @param textureType The type of texture to be used when performing the post processing.
  51000. * @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)
  51001. */
  51002. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51003. /** @hidden */
  51004. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51005. }
  51006. /**
  51007. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51008. */
  51009. export class PassCubePostProcess extends PostProcess {
  51010. private _face;
  51011. /**
  51012. * Gets or sets the cube face to display.
  51013. * * 0 is +X
  51014. * * 1 is -X
  51015. * * 2 is +Y
  51016. * * 3 is -Y
  51017. * * 4 is +Z
  51018. * * 5 is -Z
  51019. */
  51020. get face(): number;
  51021. set face(value: number);
  51022. /**
  51023. * Gets a string identifying the name of the class
  51024. * @returns "PassCubePostProcess" string
  51025. */
  51026. getClassName(): string;
  51027. /**
  51028. * Creates the PassCubePostProcess
  51029. * @param name The name of the effect.
  51030. * @param options The required width/height ratio to downsize to before computing the render pass.
  51031. * @param camera The camera to apply the render pass to.
  51032. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51033. * @param engine The engine which the post process will be applied. (default: current engine)
  51034. * @param reusable If the post process can be reused on the same frame. (default: false)
  51035. * @param textureType The type of texture to be used when performing the post processing.
  51036. * @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)
  51037. */
  51038. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51039. /** @hidden */
  51040. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51041. }
  51042. }
  51043. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51044. /** @hidden */
  51045. export var anaglyphPixelShader: {
  51046. name: string;
  51047. shader: string;
  51048. };
  51049. }
  51050. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51051. import { Engine } from "babylonjs/Engines/engine";
  51052. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51053. import { Camera } from "babylonjs/Cameras/camera";
  51054. import "babylonjs/Shaders/anaglyph.fragment";
  51055. /**
  51056. * Postprocess used to generate anaglyphic rendering
  51057. */
  51058. export class AnaglyphPostProcess extends PostProcess {
  51059. private _passedProcess;
  51060. /**
  51061. * Gets a string identifying the name of the class
  51062. * @returns "AnaglyphPostProcess" string
  51063. */
  51064. getClassName(): string;
  51065. /**
  51066. * Creates a new AnaglyphPostProcess
  51067. * @param name defines postprocess name
  51068. * @param options defines creation options or target ratio scale
  51069. * @param rigCameras defines cameras using this postprocess
  51070. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51071. * @param engine defines hosting engine
  51072. * @param reusable defines if the postprocess will be reused multiple times per frame
  51073. */
  51074. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51075. }
  51076. }
  51077. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51078. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51079. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51080. import { Scene } from "babylonjs/scene";
  51081. import { Vector3 } from "babylonjs/Maths/math.vector";
  51082. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51083. /**
  51084. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51085. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51086. */
  51087. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51088. /**
  51089. * Creates a new AnaglyphArcRotateCamera
  51090. * @param name defines camera name
  51091. * @param alpha defines alpha angle (in radians)
  51092. * @param beta defines beta angle (in radians)
  51093. * @param radius defines radius
  51094. * @param target defines camera target
  51095. * @param interaxialDistance defines distance between each color axis
  51096. * @param scene defines the hosting scene
  51097. */
  51098. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51099. /**
  51100. * Gets camera class name
  51101. * @returns AnaglyphArcRotateCamera
  51102. */
  51103. getClassName(): string;
  51104. }
  51105. }
  51106. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51107. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51108. import { Scene } from "babylonjs/scene";
  51109. import { Vector3 } from "babylonjs/Maths/math.vector";
  51110. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51111. /**
  51112. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51113. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51114. */
  51115. export class AnaglyphFreeCamera extends FreeCamera {
  51116. /**
  51117. * Creates a new AnaglyphFreeCamera
  51118. * @param name defines camera name
  51119. * @param position defines initial position
  51120. * @param interaxialDistance defines distance between each color axis
  51121. * @param scene defines the hosting scene
  51122. */
  51123. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51124. /**
  51125. * Gets camera class name
  51126. * @returns AnaglyphFreeCamera
  51127. */
  51128. getClassName(): string;
  51129. }
  51130. }
  51131. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51132. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51133. import { Scene } from "babylonjs/scene";
  51134. import { Vector3 } from "babylonjs/Maths/math.vector";
  51135. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51136. /**
  51137. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51138. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51139. */
  51140. export class AnaglyphGamepadCamera extends GamepadCamera {
  51141. /**
  51142. * Creates a new AnaglyphGamepadCamera
  51143. * @param name defines camera name
  51144. * @param position defines initial position
  51145. * @param interaxialDistance defines distance between each color axis
  51146. * @param scene defines the hosting scene
  51147. */
  51148. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51149. /**
  51150. * Gets camera class name
  51151. * @returns AnaglyphGamepadCamera
  51152. */
  51153. getClassName(): string;
  51154. }
  51155. }
  51156. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51157. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51158. import { Scene } from "babylonjs/scene";
  51159. import { Vector3 } from "babylonjs/Maths/math.vector";
  51160. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51161. /**
  51162. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51163. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51164. */
  51165. export class AnaglyphUniversalCamera extends UniversalCamera {
  51166. /**
  51167. * Creates a new AnaglyphUniversalCamera
  51168. * @param name defines camera name
  51169. * @param position defines initial position
  51170. * @param interaxialDistance defines distance between each color axis
  51171. * @param scene defines the hosting scene
  51172. */
  51173. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51174. /**
  51175. * Gets camera class name
  51176. * @returns AnaglyphUniversalCamera
  51177. */
  51178. getClassName(): string;
  51179. }
  51180. }
  51181. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51182. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51183. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51184. import { Scene } from "babylonjs/scene";
  51185. import { Vector3 } from "babylonjs/Maths/math.vector";
  51186. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51187. /**
  51188. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51189. * @see https://doc.babylonjs.com/features/cameras
  51190. */
  51191. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51192. /**
  51193. * Creates a new StereoscopicArcRotateCamera
  51194. * @param name defines camera name
  51195. * @param alpha defines alpha angle (in radians)
  51196. * @param beta defines beta angle (in radians)
  51197. * @param radius defines radius
  51198. * @param target defines camera target
  51199. * @param interaxialDistance defines distance between each color axis
  51200. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51201. * @param scene defines the hosting scene
  51202. */
  51203. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51204. /**
  51205. * Gets camera class name
  51206. * @returns StereoscopicArcRotateCamera
  51207. */
  51208. getClassName(): string;
  51209. }
  51210. }
  51211. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51212. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51213. import { Scene } from "babylonjs/scene";
  51214. import { Vector3 } from "babylonjs/Maths/math.vector";
  51215. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51216. /**
  51217. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51218. * @see https://doc.babylonjs.com/features/cameras
  51219. */
  51220. export class StereoscopicFreeCamera extends FreeCamera {
  51221. /**
  51222. * Creates a new StereoscopicFreeCamera
  51223. * @param name defines camera name
  51224. * @param position defines initial position
  51225. * @param interaxialDistance defines distance between each color axis
  51226. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51227. * @param scene defines the hosting scene
  51228. */
  51229. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51230. /**
  51231. * Gets camera class name
  51232. * @returns StereoscopicFreeCamera
  51233. */
  51234. getClassName(): string;
  51235. }
  51236. }
  51237. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51238. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51239. import { Scene } from "babylonjs/scene";
  51240. import { Vector3 } from "babylonjs/Maths/math.vector";
  51241. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51242. /**
  51243. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51244. * @see https://doc.babylonjs.com/features/cameras
  51245. */
  51246. export class StereoscopicGamepadCamera extends GamepadCamera {
  51247. /**
  51248. * Creates a new StereoscopicGamepadCamera
  51249. * @param name defines camera name
  51250. * @param position defines initial position
  51251. * @param interaxialDistance defines distance between each color axis
  51252. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51253. * @param scene defines the hosting scene
  51254. */
  51255. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51256. /**
  51257. * Gets camera class name
  51258. * @returns StereoscopicGamepadCamera
  51259. */
  51260. getClassName(): string;
  51261. }
  51262. }
  51263. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51264. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51265. import { Scene } from "babylonjs/scene";
  51266. import { Vector3 } from "babylonjs/Maths/math.vector";
  51267. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51268. /**
  51269. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51270. * @see https://doc.babylonjs.com/features/cameras
  51271. */
  51272. export class StereoscopicUniversalCamera extends UniversalCamera {
  51273. /**
  51274. * Creates a new StereoscopicUniversalCamera
  51275. * @param name defines camera name
  51276. * @param position defines initial position
  51277. * @param interaxialDistance defines distance between each color axis
  51278. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51279. * @param scene defines the hosting scene
  51280. */
  51281. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51282. /**
  51283. * Gets camera class name
  51284. * @returns StereoscopicUniversalCamera
  51285. */
  51286. getClassName(): string;
  51287. }
  51288. }
  51289. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51290. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51291. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51292. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51293. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51294. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51295. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51296. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51297. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51298. }
  51299. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51300. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51301. import { Scene } from "babylonjs/scene";
  51302. import { Vector3 } from "babylonjs/Maths/math.vector";
  51303. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51304. /**
  51305. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51306. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51307. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51308. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51309. */
  51310. export class VirtualJoysticksCamera extends FreeCamera {
  51311. /**
  51312. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51313. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51314. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51315. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51316. * @param name Define the name of the camera in the scene
  51317. * @param position Define the start position of the camera in the scene
  51318. * @param scene Define the scene the camera belongs to
  51319. */
  51320. constructor(name: string, position: Vector3, scene: Scene);
  51321. /**
  51322. * Gets the current object class name.
  51323. * @return the class name
  51324. */
  51325. getClassName(): string;
  51326. }
  51327. }
  51328. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51329. import { Matrix } from "babylonjs/Maths/math.vector";
  51330. /**
  51331. * This represents all the required metrics to create a VR camera.
  51332. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51333. */
  51334. export class VRCameraMetrics {
  51335. /**
  51336. * Define the horizontal resolution off the screen.
  51337. */
  51338. hResolution: number;
  51339. /**
  51340. * Define the vertical resolution off the screen.
  51341. */
  51342. vResolution: number;
  51343. /**
  51344. * Define the horizontal screen size.
  51345. */
  51346. hScreenSize: number;
  51347. /**
  51348. * Define the vertical screen size.
  51349. */
  51350. vScreenSize: number;
  51351. /**
  51352. * Define the vertical screen center position.
  51353. */
  51354. vScreenCenter: number;
  51355. /**
  51356. * Define the distance of the eyes to the screen.
  51357. */
  51358. eyeToScreenDistance: number;
  51359. /**
  51360. * Define the distance between both lenses
  51361. */
  51362. lensSeparationDistance: number;
  51363. /**
  51364. * Define the distance between both viewer's eyes.
  51365. */
  51366. interpupillaryDistance: number;
  51367. /**
  51368. * Define the distortion factor of the VR postprocess.
  51369. * Please, touch with care.
  51370. */
  51371. distortionK: number[];
  51372. /**
  51373. * Define the chromatic aberration correction factors for the VR post process.
  51374. */
  51375. chromaAbCorrection: number[];
  51376. /**
  51377. * Define the scale factor of the post process.
  51378. * The smaller the better but the slower.
  51379. */
  51380. postProcessScaleFactor: number;
  51381. /**
  51382. * Define an offset for the lens center.
  51383. */
  51384. lensCenterOffset: number;
  51385. /**
  51386. * Define if the current vr camera should compensate the distortion of the lense or not.
  51387. */
  51388. compensateDistortion: boolean;
  51389. /**
  51390. * Defines if multiview should be enabled when rendering (Default: false)
  51391. */
  51392. multiviewEnabled: boolean;
  51393. /**
  51394. * Gets the rendering aspect ratio based on the provided resolutions.
  51395. */
  51396. get aspectRatio(): number;
  51397. /**
  51398. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51399. */
  51400. get aspectRatioFov(): number;
  51401. /**
  51402. * @hidden
  51403. */
  51404. get leftHMatrix(): Matrix;
  51405. /**
  51406. * @hidden
  51407. */
  51408. get rightHMatrix(): Matrix;
  51409. /**
  51410. * @hidden
  51411. */
  51412. get leftPreViewMatrix(): Matrix;
  51413. /**
  51414. * @hidden
  51415. */
  51416. get rightPreViewMatrix(): Matrix;
  51417. /**
  51418. * Get the default VRMetrics based on the most generic setup.
  51419. * @returns the default vr metrics
  51420. */
  51421. static GetDefault(): VRCameraMetrics;
  51422. }
  51423. }
  51424. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51425. /** @hidden */
  51426. export var vrDistortionCorrectionPixelShader: {
  51427. name: string;
  51428. shader: string;
  51429. };
  51430. }
  51431. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51432. import { Camera } from "babylonjs/Cameras/camera";
  51433. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51434. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51435. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51436. /**
  51437. * VRDistortionCorrectionPostProcess used for mobile VR
  51438. */
  51439. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51440. private _isRightEye;
  51441. private _distortionFactors;
  51442. private _postProcessScaleFactor;
  51443. private _lensCenterOffset;
  51444. private _scaleIn;
  51445. private _scaleFactor;
  51446. private _lensCenter;
  51447. /**
  51448. * Gets a string identifying the name of the class
  51449. * @returns "VRDistortionCorrectionPostProcess" string
  51450. */
  51451. getClassName(): string;
  51452. /**
  51453. * Initializes the VRDistortionCorrectionPostProcess
  51454. * @param name The name of the effect.
  51455. * @param camera The camera to apply the render pass to.
  51456. * @param isRightEye If this is for the right eye distortion
  51457. * @param vrMetrics All the required metrics for the VR camera
  51458. */
  51459. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51460. }
  51461. }
  51462. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51463. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51464. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51465. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51466. import { Scene } from "babylonjs/scene";
  51467. import { Vector3 } from "babylonjs/Maths/math.vector";
  51468. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51469. import "babylonjs/Cameras/RigModes/vrRigMode";
  51470. /**
  51471. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51472. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51473. */
  51474. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51475. /**
  51476. * Creates a new VRDeviceOrientationArcRotateCamera
  51477. * @param name defines camera name
  51478. * @param alpha defines the camera rotation along the logitudinal axis
  51479. * @param beta defines the camera rotation along the latitudinal axis
  51480. * @param radius defines the camera distance from its target
  51481. * @param target defines the camera target
  51482. * @param scene defines the scene the camera belongs to
  51483. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51484. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51485. */
  51486. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51487. /**
  51488. * Gets camera class name
  51489. * @returns VRDeviceOrientationArcRotateCamera
  51490. */
  51491. getClassName(): string;
  51492. }
  51493. }
  51494. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51495. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51496. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51497. import { Scene } from "babylonjs/scene";
  51498. import { Vector3 } from "babylonjs/Maths/math.vector";
  51499. import "babylonjs/Cameras/RigModes/vrRigMode";
  51500. /**
  51501. * Camera used to simulate VR rendering (based on FreeCamera)
  51502. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51503. */
  51504. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51505. /**
  51506. * Creates a new VRDeviceOrientationFreeCamera
  51507. * @param name defines camera name
  51508. * @param position defines the start position of the camera
  51509. * @param scene defines the scene the camera belongs to
  51510. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51511. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51512. */
  51513. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51514. /**
  51515. * Gets camera class name
  51516. * @returns VRDeviceOrientationFreeCamera
  51517. */
  51518. getClassName(): string;
  51519. }
  51520. }
  51521. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51522. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51523. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51524. import { Scene } from "babylonjs/scene";
  51525. import { Vector3 } from "babylonjs/Maths/math.vector";
  51526. import "babylonjs/Gamepads/gamepadSceneComponent";
  51527. /**
  51528. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51529. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51530. */
  51531. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51532. /**
  51533. * Creates a new VRDeviceOrientationGamepadCamera
  51534. * @param name defines camera name
  51535. * @param position defines the start position of the camera
  51536. * @param scene defines the scene the camera belongs to
  51537. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51538. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51539. */
  51540. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51541. /**
  51542. * Gets camera class name
  51543. * @returns VRDeviceOrientationGamepadCamera
  51544. */
  51545. getClassName(): string;
  51546. }
  51547. }
  51548. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51549. import { Scene } from "babylonjs/scene";
  51550. import { Texture } from "babylonjs/Materials/Textures/texture";
  51551. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51552. /**
  51553. * A class extending Texture allowing drawing on a texture
  51554. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51555. */
  51556. export class DynamicTexture extends Texture {
  51557. private _generateMipMaps;
  51558. private _canvas;
  51559. private _context;
  51560. /**
  51561. * Creates a DynamicTexture
  51562. * @param name defines the name of the texture
  51563. * @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
  51564. * @param scene defines the scene where you want the texture
  51565. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51566. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51567. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51568. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51569. */
  51570. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51571. /**
  51572. * Get the current class name of the texture useful for serialization or dynamic coding.
  51573. * @returns "DynamicTexture"
  51574. */
  51575. getClassName(): string;
  51576. /**
  51577. * Gets the current state of canRescale
  51578. */
  51579. get canRescale(): boolean;
  51580. private _recreate;
  51581. /**
  51582. * Scales the texture
  51583. * @param ratio the scale factor to apply to both width and height
  51584. */
  51585. scale(ratio: number): void;
  51586. /**
  51587. * Resizes the texture
  51588. * @param width the new width
  51589. * @param height the new height
  51590. */
  51591. scaleTo(width: number, height: number): void;
  51592. /**
  51593. * Gets the context of the canvas used by the texture
  51594. * @returns the canvas context of the dynamic texture
  51595. */
  51596. getContext(): CanvasRenderingContext2D;
  51597. /**
  51598. * Clears the texture
  51599. */
  51600. clear(): void;
  51601. /**
  51602. * Updates the texture
  51603. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51604. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51605. */
  51606. update(invertY?: boolean, premulAlpha?: boolean): void;
  51607. /**
  51608. * Draws text onto the texture
  51609. * @param text defines the text to be drawn
  51610. * @param x defines the placement of the text from the left
  51611. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51612. * @param font defines the font to be used with font-style, font-size, font-name
  51613. * @param color defines the color used for the text
  51614. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51615. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51616. * @param update defines whether texture is immediately update (default is true)
  51617. */
  51618. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51619. /**
  51620. * Clones the texture
  51621. * @returns the clone of the texture.
  51622. */
  51623. clone(): DynamicTexture;
  51624. /**
  51625. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51626. * @returns a serialized dynamic texture object
  51627. */
  51628. serialize(): any;
  51629. private _IsCanvasElement;
  51630. /** @hidden */
  51631. _rebuild(): void;
  51632. }
  51633. }
  51634. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51635. import { Scene } from "babylonjs/scene";
  51636. import { Color3 } from "babylonjs/Maths/math.color";
  51637. import { Mesh } from "babylonjs/Meshes/mesh";
  51638. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51639. import { Nullable } from "babylonjs/types";
  51640. /**
  51641. * Class containing static functions to help procedurally build meshes
  51642. */
  51643. export class GroundBuilder {
  51644. /**
  51645. * Creates a ground mesh
  51646. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51647. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51649. * @param name defines the name of the mesh
  51650. * @param options defines the options used to create the mesh
  51651. * @param scene defines the hosting scene
  51652. * @returns the ground mesh
  51653. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51654. */
  51655. static CreateGround(name: string, options: {
  51656. width?: number;
  51657. height?: number;
  51658. subdivisions?: number;
  51659. subdivisionsX?: number;
  51660. subdivisionsY?: number;
  51661. updatable?: boolean;
  51662. }, scene: any): Mesh;
  51663. /**
  51664. * Creates a tiled ground mesh
  51665. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51666. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51667. * * 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
  51668. * * 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
  51669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51670. * @param name defines the name of the mesh
  51671. * @param options defines the options used to create the mesh
  51672. * @param scene defines the hosting scene
  51673. * @returns the tiled ground mesh
  51674. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51675. */
  51676. static CreateTiledGround(name: string, options: {
  51677. xmin: number;
  51678. zmin: number;
  51679. xmax: number;
  51680. zmax: number;
  51681. subdivisions?: {
  51682. w: number;
  51683. h: number;
  51684. };
  51685. precision?: {
  51686. w: number;
  51687. h: number;
  51688. };
  51689. updatable?: boolean;
  51690. }, scene?: Nullable<Scene>): Mesh;
  51691. /**
  51692. * Creates a ground mesh from a height map
  51693. * * The parameter `url` sets the URL of the height map image resource.
  51694. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51695. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51696. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51697. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51698. * * 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.
  51699. * * 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).
  51700. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51702. * @param name defines the name of the mesh
  51703. * @param url defines the url to the height map
  51704. * @param options defines the options used to create the mesh
  51705. * @param scene defines the hosting scene
  51706. * @returns the ground mesh
  51707. * @see https://doc.babylonjs.com/babylon101/height_map
  51708. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51709. */
  51710. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51711. width?: number;
  51712. height?: number;
  51713. subdivisions?: number;
  51714. minHeight?: number;
  51715. maxHeight?: number;
  51716. colorFilter?: Color3;
  51717. alphaFilter?: number;
  51718. updatable?: boolean;
  51719. onReady?: (mesh: GroundMesh) => void;
  51720. }, scene?: Nullable<Scene>): GroundMesh;
  51721. }
  51722. }
  51723. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  51724. import { Vector4 } from "babylonjs/Maths/math.vector";
  51725. import { Mesh } from "babylonjs/Meshes/mesh";
  51726. /**
  51727. * Class containing static functions to help procedurally build meshes
  51728. */
  51729. export class TorusBuilder {
  51730. /**
  51731. * Creates a torus mesh
  51732. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51733. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51734. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51738. * @param name defines the name of the mesh
  51739. * @param options defines the options used to create the mesh
  51740. * @param scene defines the hosting scene
  51741. * @returns the torus mesh
  51742. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51743. */
  51744. static CreateTorus(name: string, options: {
  51745. diameter?: number;
  51746. thickness?: number;
  51747. tessellation?: number;
  51748. updatable?: boolean;
  51749. sideOrientation?: number;
  51750. frontUVs?: Vector4;
  51751. backUVs?: Vector4;
  51752. }, scene: any): Mesh;
  51753. }
  51754. }
  51755. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  51756. import { Vector4 } from "babylonjs/Maths/math.vector";
  51757. import { Color4 } from "babylonjs/Maths/math.color";
  51758. import { Mesh } from "babylonjs/Meshes/mesh";
  51759. /**
  51760. * Class containing static functions to help procedurally build meshes
  51761. */
  51762. export class CylinderBuilder {
  51763. /**
  51764. * Creates a cylinder or a cone mesh
  51765. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51766. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51767. * * 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.
  51768. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51769. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51770. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51771. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51772. * * 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).
  51773. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51774. * * 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).
  51775. * * 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
  51776. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51777. * * 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
  51778. * * 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.
  51779. * * If `enclose` is false, a ring surface is one element.
  51780. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51781. * * 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
  51782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51785. * @param name defines the name of the mesh
  51786. * @param options defines the options used to create the mesh
  51787. * @param scene defines the hosting scene
  51788. * @returns the cylinder mesh
  51789. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51790. */
  51791. static CreateCylinder(name: string, options: {
  51792. height?: number;
  51793. diameterTop?: number;
  51794. diameterBottom?: number;
  51795. diameter?: number;
  51796. tessellation?: number;
  51797. subdivisions?: number;
  51798. arc?: number;
  51799. faceColors?: Color4[];
  51800. faceUV?: Vector4[];
  51801. updatable?: boolean;
  51802. hasRings?: boolean;
  51803. enclose?: boolean;
  51804. cap?: number;
  51805. sideOrientation?: number;
  51806. frontUVs?: Vector4;
  51807. backUVs?: Vector4;
  51808. }, scene: any): Mesh;
  51809. }
  51810. }
  51811. declare module "babylonjs/XR/webXRTypes" {
  51812. import { Nullable } from "babylonjs/types";
  51813. import { IDisposable } from "babylonjs/scene";
  51814. /**
  51815. * States of the webXR experience
  51816. */
  51817. export enum WebXRState {
  51818. /**
  51819. * Transitioning to being in XR mode
  51820. */
  51821. ENTERING_XR = 0,
  51822. /**
  51823. * Transitioning to non XR mode
  51824. */
  51825. EXITING_XR = 1,
  51826. /**
  51827. * In XR mode and presenting
  51828. */
  51829. IN_XR = 2,
  51830. /**
  51831. * Not entered XR mode
  51832. */
  51833. NOT_IN_XR = 3
  51834. }
  51835. /**
  51836. * The state of the XR camera's tracking
  51837. */
  51838. export enum WebXRTrackingState {
  51839. /**
  51840. * No transformation received, device is not being tracked
  51841. */
  51842. NOT_TRACKING = 0,
  51843. /**
  51844. * Tracking lost - using emulated position
  51845. */
  51846. TRACKING_LOST = 1,
  51847. /**
  51848. * Transformation tracking works normally
  51849. */
  51850. TRACKING = 2
  51851. }
  51852. /**
  51853. * Abstraction of the XR render target
  51854. */
  51855. export interface WebXRRenderTarget extends IDisposable {
  51856. /**
  51857. * xrpresent context of the canvas which can be used to display/mirror xr content
  51858. */
  51859. canvasContext: WebGLRenderingContext;
  51860. /**
  51861. * xr layer for the canvas
  51862. */
  51863. xrLayer: Nullable<XRWebGLLayer>;
  51864. /**
  51865. * Initializes the xr layer for the session
  51866. * @param xrSession xr session
  51867. * @returns a promise that will resolve once the XR Layer has been created
  51868. */
  51869. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51870. }
  51871. }
  51872. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  51873. import { Nullable } from "babylonjs/types";
  51874. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51875. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51876. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51877. import { Observable } from "babylonjs/Misc/observable";
  51878. /**
  51879. * COnfiguration object for WebXR output canvas
  51880. */
  51881. export class WebXRManagedOutputCanvasOptions {
  51882. /**
  51883. * An optional canvas in case you wish to create it yourself and provide it here.
  51884. * If not provided, a new canvas will be created
  51885. */
  51886. canvasElement?: HTMLCanvasElement;
  51887. /**
  51888. * Options for this XR Layer output
  51889. */
  51890. canvasOptions?: XRWebGLLayerOptions;
  51891. /**
  51892. * CSS styling for a newly created canvas (if not provided)
  51893. */
  51894. newCanvasCssStyle?: string;
  51895. /**
  51896. * Get the default values of the configuration object
  51897. * @param engine defines the engine to use (can be null)
  51898. * @returns default values of this configuration object
  51899. */
  51900. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  51901. }
  51902. /**
  51903. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  51904. */
  51905. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  51906. private _options;
  51907. private _canvas;
  51908. private _engine;
  51909. private _originalCanvasSize;
  51910. /**
  51911. * Rendering context of the canvas which can be used to display/mirror xr content
  51912. */
  51913. canvasContext: WebGLRenderingContext;
  51914. /**
  51915. * xr layer for the canvas
  51916. */
  51917. xrLayer: Nullable<XRWebGLLayer>;
  51918. /**
  51919. * Obseervers registered here will be triggered when the xr layer was initialized
  51920. */
  51921. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  51922. /**
  51923. * Initializes the canvas to be added/removed upon entering/exiting xr
  51924. * @param _xrSessionManager The XR Session manager
  51925. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  51926. */
  51927. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  51928. /**
  51929. * Disposes of the object
  51930. */
  51931. dispose(): void;
  51932. /**
  51933. * Initializes the xr layer for the session
  51934. * @param xrSession xr session
  51935. * @returns a promise that will resolve once the XR Layer has been created
  51936. */
  51937. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51938. private _addCanvas;
  51939. private _removeCanvas;
  51940. private _setCanvasSize;
  51941. private _setManagedOutputCanvas;
  51942. }
  51943. }
  51944. declare module "babylonjs/XR/webXRSessionManager" {
  51945. import { Observable } from "babylonjs/Misc/observable";
  51946. import { Nullable } from "babylonjs/types";
  51947. import { IDisposable, Scene } from "babylonjs/scene";
  51948. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51949. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51950. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51951. /**
  51952. * Manages an XRSession to work with Babylon's engine
  51953. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  51954. */
  51955. export class WebXRSessionManager implements IDisposable {
  51956. /** The scene which the session should be created for */
  51957. scene: Scene;
  51958. private _referenceSpace;
  51959. private _rttProvider;
  51960. private _sessionEnded;
  51961. private _xrNavigator;
  51962. private baseLayer;
  51963. /**
  51964. * The base reference space from which the session started. good if you want to reset your
  51965. * reference space
  51966. */
  51967. baseReferenceSpace: XRReferenceSpace;
  51968. /**
  51969. * Current XR frame
  51970. */
  51971. currentFrame: Nullable<XRFrame>;
  51972. /** WebXR timestamp updated every frame */
  51973. currentTimestamp: number;
  51974. /**
  51975. * Used just in case of a failure to initialize an immersive session.
  51976. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  51977. */
  51978. defaultHeightCompensation: number;
  51979. /**
  51980. * Fires every time a new xrFrame arrives which can be used to update the camera
  51981. */
  51982. onXRFrameObservable: Observable<XRFrame>;
  51983. /**
  51984. * Fires when the reference space changed
  51985. */
  51986. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  51987. /**
  51988. * Fires when the xr session is ended either by the device or manually done
  51989. */
  51990. onXRSessionEnded: Observable<any>;
  51991. /**
  51992. * Fires when the xr session is ended either by the device or manually done
  51993. */
  51994. onXRSessionInit: Observable<XRSession>;
  51995. /**
  51996. * Underlying xr session
  51997. */
  51998. session: XRSession;
  51999. /**
  52000. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52001. * or get the offset the player is currently at.
  52002. */
  52003. viewerReferenceSpace: XRReferenceSpace;
  52004. /**
  52005. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52006. * @param scene The scene which the session should be created for
  52007. */
  52008. constructor(
  52009. /** The scene which the session should be created for */
  52010. scene: Scene);
  52011. /**
  52012. * The current reference space used in this session. This reference space can constantly change!
  52013. * It is mainly used to offset the camera's position.
  52014. */
  52015. get referenceSpace(): XRReferenceSpace;
  52016. /**
  52017. * Set a new reference space and triggers the observable
  52018. */
  52019. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52020. /**
  52021. * Disposes of the session manager
  52022. */
  52023. dispose(): void;
  52024. /**
  52025. * Stops the xrSession and restores the render loop
  52026. * @returns Promise which resolves after it exits XR
  52027. */
  52028. exitXRAsync(): Promise<void>;
  52029. /**
  52030. * Gets the correct render target texture to be rendered this frame for this eye
  52031. * @param eye the eye for which to get the render target
  52032. * @returns the render target for the specified eye
  52033. */
  52034. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52035. /**
  52036. * Creates a WebXRRenderTarget object for the XR session
  52037. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52038. * @param options optional options to provide when creating a new render target
  52039. * @returns a WebXR render target to which the session can render
  52040. */
  52041. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52042. /**
  52043. * Initializes the manager
  52044. * After initialization enterXR can be called to start an XR session
  52045. * @returns Promise which resolves after it is initialized
  52046. */
  52047. initializeAsync(): Promise<void>;
  52048. /**
  52049. * Initializes an xr session
  52050. * @param xrSessionMode mode to initialize
  52051. * @param xrSessionInit defines optional and required values to pass to the session builder
  52052. * @returns a promise which will resolve once the session has been initialized
  52053. */
  52054. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52055. /**
  52056. * Checks if a session would be supported for the creation options specified
  52057. * @param sessionMode session mode to check if supported eg. immersive-vr
  52058. * @returns A Promise that resolves to true if supported and false if not
  52059. */
  52060. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52061. /**
  52062. * Resets the reference space to the one started the session
  52063. */
  52064. resetReferenceSpace(): void;
  52065. /**
  52066. * Starts rendering to the xr layer
  52067. */
  52068. runXRRenderLoop(): void;
  52069. /**
  52070. * Sets the reference space on the xr session
  52071. * @param referenceSpaceType space to set
  52072. * @returns a promise that will resolve once the reference space has been set
  52073. */
  52074. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52075. /**
  52076. * Updates the render state of the session
  52077. * @param state state to set
  52078. * @returns a promise that resolves once the render state has been updated
  52079. */
  52080. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52081. /**
  52082. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52083. * @param sessionMode defines the session to test
  52084. * @returns a promise with boolean as final value
  52085. */
  52086. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52087. private _createRenderTargetTexture;
  52088. }
  52089. }
  52090. declare module "babylonjs/XR/webXRCamera" {
  52091. import { Vector3 } from "babylonjs/Maths/math.vector";
  52092. import { Scene } from "babylonjs/scene";
  52093. import { Camera } from "babylonjs/Cameras/camera";
  52094. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52095. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52096. import { Observable } from "babylonjs/Misc/observable";
  52097. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52098. /**
  52099. * WebXR Camera which holds the views for the xrSession
  52100. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52101. */
  52102. export class WebXRCamera extends FreeCamera {
  52103. private _xrSessionManager;
  52104. private _firstFrame;
  52105. private _referenceQuaternion;
  52106. private _referencedPosition;
  52107. private _xrInvPositionCache;
  52108. private _xrInvQuaternionCache;
  52109. private _trackingState;
  52110. /**
  52111. * Observable raised before camera teleportation
  52112. */
  52113. onBeforeCameraTeleport: Observable<Vector3>;
  52114. /**
  52115. * Observable raised after camera teleportation
  52116. */
  52117. onAfterCameraTeleport: Observable<Vector3>;
  52118. /**
  52119. * Notifies when the camera's tracking state has changed.
  52120. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52121. */
  52122. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52123. /**
  52124. * Should position compensation execute on first frame.
  52125. * This is used when copying the position from a native (non XR) camera
  52126. */
  52127. compensateOnFirstFrame: boolean;
  52128. /**
  52129. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52130. * @param name the name of the camera
  52131. * @param scene the scene to add the camera to
  52132. * @param _xrSessionManager a constructed xr session manager
  52133. */
  52134. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52135. /**
  52136. * Get the current XR tracking state of the camera
  52137. */
  52138. get trackingState(): WebXRTrackingState;
  52139. private _setTrackingState;
  52140. /**
  52141. * Return the user's height, unrelated to the current ground.
  52142. * This will be the y position of this camera, when ground level is 0.
  52143. */
  52144. get realWorldHeight(): number;
  52145. /** @hidden */
  52146. _updateForDualEyeDebugging(): void;
  52147. /**
  52148. * Sets this camera's transformation based on a non-vr camera
  52149. * @param otherCamera the non-vr camera to copy the transformation from
  52150. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52151. */
  52152. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52153. /**
  52154. * Gets the current instance class name ("WebXRCamera").
  52155. * @returns the class name
  52156. */
  52157. getClassName(): string;
  52158. private _rotate180;
  52159. private _updateFromXRSession;
  52160. private _updateNumberOfRigCameras;
  52161. private _updateReferenceSpace;
  52162. private _updateReferenceSpaceOffset;
  52163. }
  52164. }
  52165. declare module "babylonjs/XR/webXRFeaturesManager" {
  52166. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52167. import { IDisposable } from "babylonjs/scene";
  52168. /**
  52169. * Defining the interface required for a (webxr) feature
  52170. */
  52171. export interface IWebXRFeature extends IDisposable {
  52172. /**
  52173. * Is this feature attached
  52174. */
  52175. attached: boolean;
  52176. /**
  52177. * Should auto-attach be disabled?
  52178. */
  52179. disableAutoAttach: boolean;
  52180. /**
  52181. * Attach the feature to the session
  52182. * Will usually be called by the features manager
  52183. *
  52184. * @param force should attachment be forced (even when already attached)
  52185. * @returns true if successful.
  52186. */
  52187. attach(force?: boolean): boolean;
  52188. /**
  52189. * Detach the feature from the session
  52190. * Will usually be called by the features manager
  52191. *
  52192. * @returns true if successful.
  52193. */
  52194. detach(): boolean;
  52195. /**
  52196. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52197. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52198. *
  52199. * @returns whether or not the feature is compatible in this environment
  52200. */
  52201. isCompatible(): boolean;
  52202. /**
  52203. * Was this feature disposed;
  52204. */
  52205. isDisposed: boolean;
  52206. /**
  52207. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52208. */
  52209. xrNativeFeatureName?: string;
  52210. /**
  52211. * A list of (Babylon WebXR) features this feature depends on
  52212. */
  52213. dependsOn?: string[];
  52214. }
  52215. /**
  52216. * A list of the currently available features without referencing them
  52217. */
  52218. export class WebXRFeatureName {
  52219. /**
  52220. * The name of the anchor system feature
  52221. */
  52222. static readonly ANCHOR_SYSTEM: string;
  52223. /**
  52224. * The name of the background remover feature
  52225. */
  52226. static readonly BACKGROUND_REMOVER: string;
  52227. /**
  52228. * The name of the hit test feature
  52229. */
  52230. static readonly HIT_TEST: string;
  52231. /**
  52232. * physics impostors for xr controllers feature
  52233. */
  52234. static readonly PHYSICS_CONTROLLERS: string;
  52235. /**
  52236. * The name of the plane detection feature
  52237. */
  52238. static readonly PLANE_DETECTION: string;
  52239. /**
  52240. * The name of the pointer selection feature
  52241. */
  52242. static readonly POINTER_SELECTION: string;
  52243. /**
  52244. * The name of the teleportation feature
  52245. */
  52246. static readonly TELEPORTATION: string;
  52247. /**
  52248. * The name of the feature points feature.
  52249. */
  52250. static readonly FEATURE_POINTS: string;
  52251. /**
  52252. * The name of the hand tracking feature.
  52253. */
  52254. static readonly HAND_TRACKING: string;
  52255. }
  52256. /**
  52257. * Defining the constructor of a feature. Used to register the modules.
  52258. */
  52259. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52260. /**
  52261. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52262. * It is mainly used in AR sessions.
  52263. *
  52264. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52265. */
  52266. export class WebXRFeaturesManager implements IDisposable {
  52267. private _xrSessionManager;
  52268. private static readonly _AvailableFeatures;
  52269. private _features;
  52270. /**
  52271. * constructs a new features manages.
  52272. *
  52273. * @param _xrSessionManager an instance of WebXRSessionManager
  52274. */
  52275. constructor(_xrSessionManager: WebXRSessionManager);
  52276. /**
  52277. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52278. * Mainly used internally.
  52279. *
  52280. * @param featureName the name of the feature to register
  52281. * @param constructorFunction the function used to construct the module
  52282. * @param version the (babylon) version of the module
  52283. * @param stable is that a stable version of this module
  52284. */
  52285. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52286. /**
  52287. * Returns a constructor of a specific feature.
  52288. *
  52289. * @param featureName the name of the feature to construct
  52290. * @param version the version of the feature to load
  52291. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52292. * @param options optional options provided to the module.
  52293. * @returns a function that, when called, will return a new instance of this feature
  52294. */
  52295. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52296. /**
  52297. * Can be used to return the list of features currently registered
  52298. *
  52299. * @returns an Array of available features
  52300. */
  52301. static GetAvailableFeatures(): string[];
  52302. /**
  52303. * Gets the versions available for a specific feature
  52304. * @param featureName the name of the feature
  52305. * @returns an array with the available versions
  52306. */
  52307. static GetAvailableVersions(featureName: string): string[];
  52308. /**
  52309. * Return the latest unstable version of this feature
  52310. * @param featureName the name of the feature to search
  52311. * @returns the version number. if not found will return -1
  52312. */
  52313. static GetLatestVersionOfFeature(featureName: string): number;
  52314. /**
  52315. * Return the latest stable version of this feature
  52316. * @param featureName the name of the feature to search
  52317. * @returns the version number. if not found will return -1
  52318. */
  52319. static GetStableVersionOfFeature(featureName: string): number;
  52320. /**
  52321. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52322. * Can be used during a session to start a feature
  52323. * @param featureName the name of feature to attach
  52324. */
  52325. attachFeature(featureName: string): void;
  52326. /**
  52327. * Can be used inside a session or when the session ends to detach a specific feature
  52328. * @param featureName the name of the feature to detach
  52329. */
  52330. detachFeature(featureName: string): void;
  52331. /**
  52332. * Used to disable an already-enabled feature
  52333. * The feature will be disposed and will be recreated once enabled.
  52334. * @param featureName the feature to disable
  52335. * @returns true if disable was successful
  52336. */
  52337. disableFeature(featureName: string | {
  52338. Name: string;
  52339. }): boolean;
  52340. /**
  52341. * dispose this features manager
  52342. */
  52343. dispose(): void;
  52344. /**
  52345. * 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.
  52346. * 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.
  52347. *
  52348. * @param featureName the name of the feature to load or the class of the feature
  52349. * @param version optional version to load. if not provided the latest version will be enabled
  52350. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52351. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52352. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52353. * @returns a new constructed feature or throws an error if feature not found.
  52354. */
  52355. enableFeature(featureName: string | {
  52356. Name: string;
  52357. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52358. /**
  52359. * get the implementation of an enabled feature.
  52360. * @param featureName the name of the feature to load
  52361. * @returns the feature class, if found
  52362. */
  52363. getEnabledFeature(featureName: string): IWebXRFeature;
  52364. /**
  52365. * Get the list of enabled features
  52366. * @returns an array of enabled features
  52367. */
  52368. getEnabledFeatures(): string[];
  52369. /**
  52370. * This function will exten the session creation configuration object with enabled features.
  52371. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52372. * according to the defined "required" variable, provided during enableFeature call
  52373. * @param xrSessionInit the xr Session init object to extend
  52374. *
  52375. * @returns an extended XRSessionInit object
  52376. */
  52377. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52378. }
  52379. }
  52380. declare module "babylonjs/XR/webXRExperienceHelper" {
  52381. import { Observable } from "babylonjs/Misc/observable";
  52382. import { IDisposable, Scene } from "babylonjs/scene";
  52383. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52384. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52385. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52386. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52387. /**
  52388. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52389. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52390. */
  52391. export class WebXRExperienceHelper implements IDisposable {
  52392. private scene;
  52393. private _nonVRCamera;
  52394. private _originalSceneAutoClear;
  52395. private _supported;
  52396. /**
  52397. * Camera used to render xr content
  52398. */
  52399. camera: WebXRCamera;
  52400. /** A features manager for this xr session */
  52401. featuresManager: WebXRFeaturesManager;
  52402. /**
  52403. * Observers registered here will be triggered after the camera's initial transformation is set
  52404. * This can be used to set a different ground level or an extra rotation.
  52405. *
  52406. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52407. * to the position set after this observable is done executing.
  52408. */
  52409. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52410. /**
  52411. * Fires when the state of the experience helper has changed
  52412. */
  52413. onStateChangedObservable: Observable<WebXRState>;
  52414. /** Session manager used to keep track of xr session */
  52415. sessionManager: WebXRSessionManager;
  52416. /**
  52417. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52418. */
  52419. state: WebXRState;
  52420. /**
  52421. * Creates a WebXRExperienceHelper
  52422. * @param scene The scene the helper should be created in
  52423. */
  52424. private constructor();
  52425. /**
  52426. * Creates the experience helper
  52427. * @param scene the scene to attach the experience helper to
  52428. * @returns a promise for the experience helper
  52429. */
  52430. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52431. /**
  52432. * Disposes of the experience helper
  52433. */
  52434. dispose(): void;
  52435. /**
  52436. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52437. * @param sessionMode options for the XR session
  52438. * @param referenceSpaceType frame of reference of the XR session
  52439. * @param renderTarget the output canvas that will be used to enter XR mode
  52440. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52441. * @returns promise that resolves after xr mode has entered
  52442. */
  52443. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52444. /**
  52445. * Exits XR mode and returns the scene to its original state
  52446. * @returns promise that resolves after xr mode has exited
  52447. */
  52448. exitXRAsync(): Promise<void>;
  52449. private _nonXRToXRCamera;
  52450. private _setState;
  52451. }
  52452. }
  52453. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52454. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52455. import { Observable } from "babylonjs/Misc/observable";
  52456. import { IDisposable } from "babylonjs/scene";
  52457. /**
  52458. * X-Y values for axes in WebXR
  52459. */
  52460. export interface IWebXRMotionControllerAxesValue {
  52461. /**
  52462. * The value of the x axis
  52463. */
  52464. x: number;
  52465. /**
  52466. * The value of the y-axis
  52467. */
  52468. y: number;
  52469. }
  52470. /**
  52471. * changed / previous values for the values of this component
  52472. */
  52473. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52474. /**
  52475. * current (this frame) value
  52476. */
  52477. current: T;
  52478. /**
  52479. * previous (last change) value
  52480. */
  52481. previous: T;
  52482. }
  52483. /**
  52484. * Represents changes in the component between current frame and last values recorded
  52485. */
  52486. export interface IWebXRMotionControllerComponentChanges {
  52487. /**
  52488. * will be populated with previous and current values if axes changed
  52489. */
  52490. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52491. /**
  52492. * will be populated with previous and current values if pressed changed
  52493. */
  52494. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52495. /**
  52496. * will be populated with previous and current values if touched changed
  52497. */
  52498. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52499. /**
  52500. * will be populated with previous and current values if value changed
  52501. */
  52502. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52503. }
  52504. /**
  52505. * This class represents a single component (for example button or thumbstick) of a motion controller
  52506. */
  52507. export class WebXRControllerComponent implements IDisposable {
  52508. /**
  52509. * the id of this component
  52510. */
  52511. id: string;
  52512. /**
  52513. * the type of the component
  52514. */
  52515. type: MotionControllerComponentType;
  52516. private _buttonIndex;
  52517. private _axesIndices;
  52518. private _axes;
  52519. private _changes;
  52520. private _currentValue;
  52521. private _hasChanges;
  52522. private _pressed;
  52523. private _touched;
  52524. /**
  52525. * button component type
  52526. */
  52527. static BUTTON_TYPE: MotionControllerComponentType;
  52528. /**
  52529. * squeeze component type
  52530. */
  52531. static SQUEEZE_TYPE: MotionControllerComponentType;
  52532. /**
  52533. * Thumbstick component type
  52534. */
  52535. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52536. /**
  52537. * Touchpad component type
  52538. */
  52539. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52540. /**
  52541. * trigger component type
  52542. */
  52543. static TRIGGER_TYPE: MotionControllerComponentType;
  52544. /**
  52545. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52546. * the axes data changes
  52547. */
  52548. onAxisValueChangedObservable: Observable<{
  52549. x: number;
  52550. y: number;
  52551. }>;
  52552. /**
  52553. * Observers registered here will be triggered when the state of a button changes
  52554. * State change is either pressed / touched / value
  52555. */
  52556. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52557. /**
  52558. * Creates a new component for a motion controller.
  52559. * It is created by the motion controller itself
  52560. *
  52561. * @param id the id of this component
  52562. * @param type the type of the component
  52563. * @param _buttonIndex index in the buttons array of the gamepad
  52564. * @param _axesIndices indices of the values in the axes array of the gamepad
  52565. */
  52566. constructor(
  52567. /**
  52568. * the id of this component
  52569. */
  52570. id: string,
  52571. /**
  52572. * the type of the component
  52573. */
  52574. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52575. /**
  52576. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52577. */
  52578. get axes(): IWebXRMotionControllerAxesValue;
  52579. /**
  52580. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52581. */
  52582. get changes(): IWebXRMotionControllerComponentChanges;
  52583. /**
  52584. * Return whether or not the component changed the last frame
  52585. */
  52586. get hasChanges(): boolean;
  52587. /**
  52588. * is the button currently pressed
  52589. */
  52590. get pressed(): boolean;
  52591. /**
  52592. * is the button currently touched
  52593. */
  52594. get touched(): boolean;
  52595. /**
  52596. * Get the current value of this component
  52597. */
  52598. get value(): number;
  52599. /**
  52600. * Dispose this component
  52601. */
  52602. dispose(): void;
  52603. /**
  52604. * Are there axes correlating to this component
  52605. * @return true is axes data is available
  52606. */
  52607. isAxes(): boolean;
  52608. /**
  52609. * Is this component a button (hence - pressable)
  52610. * @returns true if can be pressed
  52611. */
  52612. isButton(): boolean;
  52613. /**
  52614. * update this component using the gamepad object it is in. Called on every frame
  52615. * @param nativeController the native gamepad controller object
  52616. */
  52617. update(nativeController: IMinimalMotionControllerObject): void;
  52618. }
  52619. }
  52620. declare module "babylonjs/Loading/sceneLoader" {
  52621. import { Observable } from "babylonjs/Misc/observable";
  52622. import { Nullable } from "babylonjs/types";
  52623. import { Scene } from "babylonjs/scene";
  52624. import { Engine } from "babylonjs/Engines/engine";
  52625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52626. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52627. import { AssetContainer } from "babylonjs/assetContainer";
  52628. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52629. import { Skeleton } from "babylonjs/Bones/skeleton";
  52630. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52631. import { WebRequest } from "babylonjs/Misc/webRequest";
  52632. /**
  52633. * Interface used to represent data loading progression
  52634. */
  52635. export interface ISceneLoaderProgressEvent {
  52636. /**
  52637. * Defines if data length to load can be evaluated
  52638. */
  52639. readonly lengthComputable: boolean;
  52640. /**
  52641. * Defines the loaded data length
  52642. */
  52643. readonly loaded: number;
  52644. /**
  52645. * Defines the data length to load
  52646. */
  52647. readonly total: number;
  52648. }
  52649. /**
  52650. * Interface used by SceneLoader plugins to define supported file extensions
  52651. */
  52652. export interface ISceneLoaderPluginExtensions {
  52653. /**
  52654. * Defines the list of supported extensions
  52655. */
  52656. [extension: string]: {
  52657. isBinary: boolean;
  52658. };
  52659. }
  52660. /**
  52661. * Interface used by SceneLoader plugin factory
  52662. */
  52663. export interface ISceneLoaderPluginFactory {
  52664. /**
  52665. * Defines the name of the factory
  52666. */
  52667. name: string;
  52668. /**
  52669. * Function called to create a new plugin
  52670. * @return the new plugin
  52671. */
  52672. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52673. /**
  52674. * The callback that returns true if the data can be directly loaded.
  52675. * @param data string containing the file data
  52676. * @returns if the data can be loaded directly
  52677. */
  52678. canDirectLoad?(data: string): boolean;
  52679. }
  52680. /**
  52681. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  52682. */
  52683. export interface ISceneLoaderPluginBase {
  52684. /**
  52685. * The friendly name of this plugin.
  52686. */
  52687. name: string;
  52688. /**
  52689. * The file extensions supported by this plugin.
  52690. */
  52691. extensions: string | ISceneLoaderPluginExtensions;
  52692. /**
  52693. * The callback called when loading from a url.
  52694. * @param scene scene loading this url
  52695. * @param url url to load
  52696. * @param onSuccess callback called when the file successfully loads
  52697. * @param onProgress callback called while file is loading (if the server supports this mode)
  52698. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  52699. * @param onError callback called when the file fails to load
  52700. * @returns a file request object
  52701. */
  52702. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52703. /**
  52704. * The callback called when loading from a file object.
  52705. * @param scene scene loading this file
  52706. * @param file defines the file to load
  52707. * @param onSuccess defines the callback to call when data is loaded
  52708. * @param onProgress defines the callback to call during loading process
  52709. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  52710. * @param onError defines the callback to call when an error occurs
  52711. * @returns a file request object
  52712. */
  52713. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52714. /**
  52715. * The callback that returns true if the data can be directly loaded.
  52716. * @param data string containing the file data
  52717. * @returns if the data can be loaded directly
  52718. */
  52719. canDirectLoad?(data: string): boolean;
  52720. /**
  52721. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  52722. * @param scene scene loading this data
  52723. * @param data string containing the data
  52724. * @returns data to pass to the plugin
  52725. */
  52726. directLoad?(scene: Scene, data: string): any;
  52727. /**
  52728. * The callback that allows custom handling of the root url based on the response url.
  52729. * @param rootUrl the original root url
  52730. * @param responseURL the response url if available
  52731. * @returns the new root url
  52732. */
  52733. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  52734. }
  52735. /**
  52736. * Interface used to define a SceneLoader plugin
  52737. */
  52738. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  52739. /**
  52740. * Import meshes into a scene.
  52741. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52742. * @param scene The scene to import into
  52743. * @param data The data to import
  52744. * @param rootUrl The root url for scene and resources
  52745. * @param meshes The meshes array to import into
  52746. * @param particleSystems The particle systems array to import into
  52747. * @param skeletons The skeletons array to import into
  52748. * @param onError The callback when import fails
  52749. * @returns True if successful or false otherwise
  52750. */
  52751. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  52752. /**
  52753. * Load into a scene.
  52754. * @param scene The scene to load into
  52755. * @param data The data to import
  52756. * @param rootUrl The root url for scene and resources
  52757. * @param onError The callback when import fails
  52758. * @returns True if successful or false otherwise
  52759. */
  52760. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  52761. /**
  52762. * Load into an asset container.
  52763. * @param scene The scene to load into
  52764. * @param data The data to import
  52765. * @param rootUrl The root url for scene and resources
  52766. * @param onError The callback when import fails
  52767. * @returns The loaded asset container
  52768. */
  52769. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  52770. }
  52771. /**
  52772. * Interface used to define an async SceneLoader plugin
  52773. */
  52774. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  52775. /**
  52776. * Import meshes into a scene.
  52777. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52778. * @param scene The scene to import into
  52779. * @param data The data to import
  52780. * @param rootUrl The root url for scene and resources
  52781. * @param onProgress The callback when the load progresses
  52782. * @param fileName Defines the name of the file to load
  52783. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  52784. */
  52785. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  52786. meshes: AbstractMesh[];
  52787. particleSystems: IParticleSystem[];
  52788. skeletons: Skeleton[];
  52789. animationGroups: AnimationGroup[];
  52790. }>;
  52791. /**
  52792. * Load into a scene.
  52793. * @param scene The scene to load into
  52794. * @param data The data to import
  52795. * @param rootUrl The root url for scene and resources
  52796. * @param onProgress The callback when the load progresses
  52797. * @param fileName Defines the name of the file to load
  52798. * @returns Nothing
  52799. */
  52800. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  52801. /**
  52802. * Load into an asset container.
  52803. * @param scene The scene to load into
  52804. * @param data The data to import
  52805. * @param rootUrl The root url for scene and resources
  52806. * @param onProgress The callback when the load progresses
  52807. * @param fileName Defines the name of the file to load
  52808. * @returns The loaded asset container
  52809. */
  52810. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  52811. }
  52812. /**
  52813. * Mode that determines how to handle old animation groups before loading new ones.
  52814. */
  52815. export enum SceneLoaderAnimationGroupLoadingMode {
  52816. /**
  52817. * Reset all old animations to initial state then dispose them.
  52818. */
  52819. Clean = 0,
  52820. /**
  52821. * Stop all old animations.
  52822. */
  52823. Stop = 1,
  52824. /**
  52825. * Restart old animations from first frame.
  52826. */
  52827. Sync = 2,
  52828. /**
  52829. * Old animations remains untouched.
  52830. */
  52831. NoSync = 3
  52832. }
  52833. /**
  52834. * Defines a plugin registered by the SceneLoader
  52835. */
  52836. interface IRegisteredPlugin {
  52837. /**
  52838. * Defines the plugin to use
  52839. */
  52840. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52841. /**
  52842. * Defines if the plugin supports binary data
  52843. */
  52844. isBinary: boolean;
  52845. }
  52846. /**
  52847. * Class used to load scene from various file formats using registered plugins
  52848. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  52849. */
  52850. export class SceneLoader {
  52851. /**
  52852. * No logging while loading
  52853. */
  52854. static readonly NO_LOGGING: number;
  52855. /**
  52856. * Minimal logging while loading
  52857. */
  52858. static readonly MINIMAL_LOGGING: number;
  52859. /**
  52860. * Summary logging while loading
  52861. */
  52862. static readonly SUMMARY_LOGGING: number;
  52863. /**
  52864. * Detailled logging while loading
  52865. */
  52866. static readonly DETAILED_LOGGING: number;
  52867. /**
  52868. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  52869. */
  52870. static get ForceFullSceneLoadingForIncremental(): boolean;
  52871. static set ForceFullSceneLoadingForIncremental(value: boolean);
  52872. /**
  52873. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  52874. */
  52875. static get ShowLoadingScreen(): boolean;
  52876. static set ShowLoadingScreen(value: boolean);
  52877. /**
  52878. * Defines the current logging level (while loading the scene)
  52879. * @ignorenaming
  52880. */
  52881. static get loggingLevel(): number;
  52882. static set loggingLevel(value: number);
  52883. /**
  52884. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  52885. */
  52886. static get CleanBoneMatrixWeights(): boolean;
  52887. static set CleanBoneMatrixWeights(value: boolean);
  52888. /**
  52889. * Event raised when a plugin is used to load a scene
  52890. */
  52891. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  52892. private static _registeredPlugins;
  52893. private static _showingLoadingScreen;
  52894. /**
  52895. * Gets the default plugin (used to load Babylon files)
  52896. * @returns the .babylon plugin
  52897. */
  52898. static GetDefaultPlugin(): IRegisteredPlugin;
  52899. private static _GetPluginForExtension;
  52900. private static _GetPluginForDirectLoad;
  52901. private static _GetPluginForFilename;
  52902. private static _GetDirectLoad;
  52903. private static _LoadData;
  52904. private static _GetFileInfo;
  52905. /**
  52906. * Gets a plugin that can load the given extension
  52907. * @param extension defines the extension to load
  52908. * @returns a plugin or null if none works
  52909. */
  52910. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52911. /**
  52912. * Gets a boolean indicating that the given extension can be loaded
  52913. * @param extension defines the extension to load
  52914. * @returns true if the extension is supported
  52915. */
  52916. static IsPluginForExtensionAvailable(extension: string): boolean;
  52917. /**
  52918. * Adds a new plugin to the list of registered plugins
  52919. * @param plugin defines the plugin to add
  52920. */
  52921. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  52922. /**
  52923. * Import meshes into a scene
  52924. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52925. * @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)
  52926. * @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)
  52927. * @param scene the instance of BABYLON.Scene to append to
  52928. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  52929. * @param onProgress a callback with a progress event for each file being loaded
  52930. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52931. * @param pluginExtension the extension used to determine the plugin
  52932. * @returns The loaded plugin
  52933. */
  52934. 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>;
  52935. /**
  52936. * Import meshes into a scene
  52937. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52938. * @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)
  52939. * @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)
  52940. * @param scene the instance of BABYLON.Scene to append to
  52941. * @param onProgress a callback with a progress event for each file being loaded
  52942. * @param pluginExtension the extension used to determine the plugin
  52943. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  52944. */
  52945. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  52946. meshes: AbstractMesh[];
  52947. particleSystems: IParticleSystem[];
  52948. skeletons: Skeleton[];
  52949. animationGroups: AnimationGroup[];
  52950. }>;
  52951. /**
  52952. * Load a scene
  52953. * @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)
  52954. * @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)
  52955. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52956. * @param onSuccess a callback with the scene when import succeeds
  52957. * @param onProgress a callback with a progress event for each file being loaded
  52958. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52959. * @param pluginExtension the extension used to determine the plugin
  52960. * @returns The loaded plugin
  52961. */
  52962. 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>;
  52963. /**
  52964. * Load a scene
  52965. * @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)
  52966. * @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)
  52967. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52968. * @param onProgress a callback with a progress event for each file being loaded
  52969. * @param pluginExtension the extension used to determine the plugin
  52970. * @returns The loaded scene
  52971. */
  52972. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52973. /**
  52974. * Append a scene
  52975. * @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)
  52976. * @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)
  52977. * @param scene is the instance of BABYLON.Scene to append to
  52978. * @param onSuccess a callback with the scene when import succeeds
  52979. * @param onProgress a callback with a progress event for each file being loaded
  52980. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52981. * @param pluginExtension the extension used to determine the plugin
  52982. * @returns The loaded plugin
  52983. */
  52984. 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>;
  52985. /**
  52986. * Append a scene
  52987. * @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)
  52988. * @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)
  52989. * @param scene is the instance of BABYLON.Scene to append to
  52990. * @param onProgress a callback with a progress event for each file being loaded
  52991. * @param pluginExtension the extension used to determine the plugin
  52992. * @returns The given scene
  52993. */
  52994. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52995. /**
  52996. * Load a scene into an asset container
  52997. * @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)
  52998. * @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)
  52999. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53000. * @param onSuccess a callback with the scene when import succeeds
  53001. * @param onProgress a callback with a progress event for each file being loaded
  53002. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53003. * @param pluginExtension the extension used to determine the plugin
  53004. * @returns The loaded plugin
  53005. */
  53006. 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>;
  53007. /**
  53008. * Load a scene into an asset container
  53009. * @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)
  53010. * @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)
  53011. * @param scene is the instance of Scene to append to
  53012. * @param onProgress a callback with a progress event for each file being loaded
  53013. * @param pluginExtension the extension used to determine the plugin
  53014. * @returns The loaded asset container
  53015. */
  53016. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53017. /**
  53018. * Import animations from a file into a scene
  53019. * @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)
  53020. * @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)
  53021. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53022. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53023. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53024. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53025. * @param onSuccess a callback with the scene when import succeeds
  53026. * @param onProgress a callback with a progress event for each file being loaded
  53027. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53028. * @param pluginExtension the extension used to determine the plugin
  53029. */
  53030. 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;
  53031. /**
  53032. * Import animations from a file into a scene
  53033. * @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)
  53034. * @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)
  53035. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53036. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53037. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53038. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53039. * @param onSuccess a callback with the scene when import succeeds
  53040. * @param onProgress a callback with a progress event for each file being loaded
  53041. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53042. * @param pluginExtension the extension used to determine the plugin
  53043. * @returns the updated scene with imported animations
  53044. */
  53045. 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>;
  53046. }
  53047. }
  53048. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53049. import { IDisposable, Scene } from "babylonjs/scene";
  53050. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53051. import { Observable } from "babylonjs/Misc/observable";
  53052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53053. import { Nullable } from "babylonjs/types";
  53054. /**
  53055. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53056. */
  53057. export type MotionControllerHandedness = "none" | "left" | "right";
  53058. /**
  53059. * The type of components available in motion controllers.
  53060. * This is not the name of the component.
  53061. */
  53062. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53063. /**
  53064. * The state of a controller component
  53065. */
  53066. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53067. /**
  53068. * The schema of motion controller layout.
  53069. * No object will be initialized using this interface
  53070. * This is used just to define the profile.
  53071. */
  53072. export interface IMotionControllerLayout {
  53073. /**
  53074. * Path to load the assets. Usually relative to the base path
  53075. */
  53076. assetPath: string;
  53077. /**
  53078. * Available components (unsorted)
  53079. */
  53080. components: {
  53081. /**
  53082. * A map of component Ids
  53083. */
  53084. [componentId: string]: {
  53085. /**
  53086. * The type of input the component outputs
  53087. */
  53088. type: MotionControllerComponentType;
  53089. /**
  53090. * The indices of this component in the gamepad object
  53091. */
  53092. gamepadIndices: {
  53093. /**
  53094. * Index of button
  53095. */
  53096. button?: number;
  53097. /**
  53098. * If available, index of x-axis
  53099. */
  53100. xAxis?: number;
  53101. /**
  53102. * If available, index of y-axis
  53103. */
  53104. yAxis?: number;
  53105. };
  53106. /**
  53107. * The mesh's root node name
  53108. */
  53109. rootNodeName: string;
  53110. /**
  53111. * Animation definitions for this model
  53112. */
  53113. visualResponses: {
  53114. [stateKey: string]: {
  53115. /**
  53116. * What property will be animated
  53117. */
  53118. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53119. /**
  53120. * What states influence this visual response
  53121. */
  53122. states: MotionControllerComponentStateType[];
  53123. /**
  53124. * Type of animation - movement or visibility
  53125. */
  53126. valueNodeProperty: "transform" | "visibility";
  53127. /**
  53128. * Base node name to move. Its position will be calculated according to the min and max nodes
  53129. */
  53130. valueNodeName?: string;
  53131. /**
  53132. * Minimum movement node
  53133. */
  53134. minNodeName?: string;
  53135. /**
  53136. * Max movement node
  53137. */
  53138. maxNodeName?: string;
  53139. };
  53140. };
  53141. /**
  53142. * If touch enabled, what is the name of node to display user feedback
  53143. */
  53144. touchPointNodeName?: string;
  53145. };
  53146. };
  53147. /**
  53148. * Is it xr standard mapping or not
  53149. */
  53150. gamepadMapping: "" | "xr-standard";
  53151. /**
  53152. * Base root node of this entire model
  53153. */
  53154. rootNodeName: string;
  53155. /**
  53156. * Defines the main button component id
  53157. */
  53158. selectComponentId: string;
  53159. }
  53160. /**
  53161. * A definition for the layout map in the input profile
  53162. */
  53163. export interface IMotionControllerLayoutMap {
  53164. /**
  53165. * Layouts with handedness type as a key
  53166. */
  53167. [handedness: string]: IMotionControllerLayout;
  53168. }
  53169. /**
  53170. * The XR Input profile schema
  53171. * Profiles can be found here:
  53172. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53173. */
  53174. export interface IMotionControllerProfile {
  53175. /**
  53176. * fallback profiles for this profileId
  53177. */
  53178. fallbackProfileIds: string[];
  53179. /**
  53180. * The layout map, with handedness as key
  53181. */
  53182. layouts: IMotionControllerLayoutMap;
  53183. /**
  53184. * The id of this profile
  53185. * correlates to the profile(s) in the xrInput.profiles array
  53186. */
  53187. profileId: string;
  53188. }
  53189. /**
  53190. * A helper-interface for the 3 meshes needed for controller button animation
  53191. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53192. */
  53193. export interface IMotionControllerButtonMeshMap {
  53194. /**
  53195. * the mesh that defines the pressed value mesh position.
  53196. * This is used to find the max-position of this button
  53197. */
  53198. pressedMesh: AbstractMesh;
  53199. /**
  53200. * the mesh that defines the unpressed value mesh position.
  53201. * This is used to find the min (or initial) position of this button
  53202. */
  53203. unpressedMesh: AbstractMesh;
  53204. /**
  53205. * The mesh that will be changed when value changes
  53206. */
  53207. valueMesh: AbstractMesh;
  53208. }
  53209. /**
  53210. * A helper-interface for the 3 meshes needed for controller axis animation.
  53211. * This will be expanded when touchpad animations are fully supported
  53212. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53213. */
  53214. export interface IMotionControllerMeshMap {
  53215. /**
  53216. * the mesh that defines the maximum value mesh position.
  53217. */
  53218. maxMesh?: AbstractMesh;
  53219. /**
  53220. * the mesh that defines the minimum value mesh position.
  53221. */
  53222. minMesh?: AbstractMesh;
  53223. /**
  53224. * The mesh that will be changed when axis value changes
  53225. */
  53226. valueMesh?: AbstractMesh;
  53227. }
  53228. /**
  53229. * The elements needed for change-detection of the gamepad objects in motion controllers
  53230. */
  53231. export interface IMinimalMotionControllerObject {
  53232. /**
  53233. * Available axes of this controller
  53234. */
  53235. axes: number[];
  53236. /**
  53237. * An array of available buttons
  53238. */
  53239. buttons: Array<{
  53240. /**
  53241. * Value of the button/trigger
  53242. */
  53243. value: number;
  53244. /**
  53245. * If the button/trigger is currently touched
  53246. */
  53247. touched: boolean;
  53248. /**
  53249. * If the button/trigger is currently pressed
  53250. */
  53251. pressed: boolean;
  53252. }>;
  53253. /**
  53254. * EXPERIMENTAL haptic support.
  53255. */
  53256. hapticActuators?: Array<{
  53257. pulse: (value: number, duration: number) => Promise<boolean>;
  53258. }>;
  53259. }
  53260. /**
  53261. * An Abstract Motion controller
  53262. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53263. * Each component has an observable to check for changes in value and state
  53264. */
  53265. export abstract class WebXRAbstractMotionController implements IDisposable {
  53266. protected scene: Scene;
  53267. protected layout: IMotionControllerLayout;
  53268. /**
  53269. * The gamepad object correlating to this controller
  53270. */
  53271. gamepadObject: IMinimalMotionControllerObject;
  53272. /**
  53273. * handedness (left/right/none) of this controller
  53274. */
  53275. handedness: MotionControllerHandedness;
  53276. private _initComponent;
  53277. private _modelReady;
  53278. /**
  53279. * A map of components (WebXRControllerComponent) in this motion controller
  53280. * Components have a ComponentType and can also have both button and axis definitions
  53281. */
  53282. readonly components: {
  53283. [id: string]: WebXRControllerComponent;
  53284. };
  53285. /**
  53286. * Disable the model's animation. Can be set at any time.
  53287. */
  53288. disableAnimation: boolean;
  53289. /**
  53290. * Observers registered here will be triggered when the model of this controller is done loading
  53291. */
  53292. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53293. /**
  53294. * The profile id of this motion controller
  53295. */
  53296. abstract profileId: string;
  53297. /**
  53298. * The root mesh of the model. It is null if the model was not yet initialized
  53299. */
  53300. rootMesh: Nullable<AbstractMesh>;
  53301. /**
  53302. * constructs a new abstract motion controller
  53303. * @param scene the scene to which the model of the controller will be added
  53304. * @param layout The profile layout to load
  53305. * @param gamepadObject The gamepad object correlating to this controller
  53306. * @param handedness handedness (left/right/none) of this controller
  53307. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53308. */
  53309. constructor(scene: Scene, layout: IMotionControllerLayout,
  53310. /**
  53311. * The gamepad object correlating to this controller
  53312. */
  53313. gamepadObject: IMinimalMotionControllerObject,
  53314. /**
  53315. * handedness (left/right/none) of this controller
  53316. */
  53317. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53318. /**
  53319. * Dispose this controller, the model mesh and all its components
  53320. */
  53321. dispose(): void;
  53322. /**
  53323. * Returns all components of specific type
  53324. * @param type the type to search for
  53325. * @return an array of components with this type
  53326. */
  53327. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53328. /**
  53329. * get a component based an its component id as defined in layout.components
  53330. * @param id the id of the component
  53331. * @returns the component correlates to the id or undefined if not found
  53332. */
  53333. getComponent(id: string): WebXRControllerComponent;
  53334. /**
  53335. * Get the list of components available in this motion controller
  53336. * @returns an array of strings correlating to available components
  53337. */
  53338. getComponentIds(): string[];
  53339. /**
  53340. * Get the first component of specific type
  53341. * @param type type of component to find
  53342. * @return a controller component or null if not found
  53343. */
  53344. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53345. /**
  53346. * Get the main (Select) component of this controller as defined in the layout
  53347. * @returns the main component of this controller
  53348. */
  53349. getMainComponent(): WebXRControllerComponent;
  53350. /**
  53351. * Loads the model correlating to this controller
  53352. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53353. * @returns A promise fulfilled with the result of the model loading
  53354. */
  53355. loadModel(): Promise<boolean>;
  53356. /**
  53357. * Update this model using the current XRFrame
  53358. * @param xrFrame the current xr frame to use and update the model
  53359. */
  53360. updateFromXRFrame(xrFrame: XRFrame): void;
  53361. /**
  53362. * Backwards compatibility due to a deeply-integrated typo
  53363. */
  53364. get handness(): XREye;
  53365. /**
  53366. * Pulse (vibrate) this controller
  53367. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53368. * Consecutive calls to this function will cancel the last pulse call
  53369. *
  53370. * @param value the strength of the pulse in 0.0...1.0 range
  53371. * @param duration Duration of the pulse in milliseconds
  53372. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53373. * @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
  53374. */
  53375. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53376. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53377. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53378. /**
  53379. * Moves the axis on the controller mesh based on its current state
  53380. * @param axis the index of the axis
  53381. * @param axisValue the value of the axis which determines the meshes new position
  53382. * @hidden
  53383. */
  53384. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53385. /**
  53386. * Update the model itself with the current frame data
  53387. * @param xrFrame the frame to use for updating the model mesh
  53388. */
  53389. protected updateModel(xrFrame: XRFrame): void;
  53390. /**
  53391. * Get the filename and path for this controller's model
  53392. * @returns a map of filename and path
  53393. */
  53394. protected abstract _getFilenameAndPath(): {
  53395. filename: string;
  53396. path: string;
  53397. };
  53398. /**
  53399. * This function is called before the mesh is loaded. It checks for loading constraints.
  53400. * For example, this function can check if the GLB loader is available
  53401. * If this function returns false, the generic controller will be loaded instead
  53402. * @returns Is the client ready to load the mesh
  53403. */
  53404. protected abstract _getModelLoadingConstraints(): boolean;
  53405. /**
  53406. * This function will be called after the model was successfully loaded and can be used
  53407. * for mesh transformations before it is available for the user
  53408. * @param meshes the loaded meshes
  53409. */
  53410. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53411. /**
  53412. * Set the root mesh for this controller. Important for the WebXR controller class
  53413. * @param meshes the loaded meshes
  53414. */
  53415. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53416. /**
  53417. * A function executed each frame that updates the mesh (if needed)
  53418. * @param xrFrame the current xrFrame
  53419. */
  53420. protected abstract _updateModel(xrFrame: XRFrame): void;
  53421. private _getGenericFilenameAndPath;
  53422. private _getGenericParentMesh;
  53423. }
  53424. }
  53425. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53426. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53428. import { Scene } from "babylonjs/scene";
  53429. /**
  53430. * A generic trigger-only motion controller for WebXR
  53431. */
  53432. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53433. /**
  53434. * Static version of the profile id of this controller
  53435. */
  53436. static ProfileId: string;
  53437. profileId: string;
  53438. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53439. protected _getFilenameAndPath(): {
  53440. filename: string;
  53441. path: string;
  53442. };
  53443. protected _getModelLoadingConstraints(): boolean;
  53444. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53445. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53446. protected _updateModel(): void;
  53447. }
  53448. }
  53449. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53450. import { Vector4 } from "babylonjs/Maths/math.vector";
  53451. import { Mesh } from "babylonjs/Meshes/mesh";
  53452. import { Scene } from "babylonjs/scene";
  53453. import { Nullable } from "babylonjs/types";
  53454. /**
  53455. * Class containing static functions to help procedurally build meshes
  53456. */
  53457. export class SphereBuilder {
  53458. /**
  53459. * Creates a sphere mesh
  53460. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53461. * * 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`)
  53462. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53463. * * 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
  53464. * * 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)
  53465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53468. * @param name defines the name of the mesh
  53469. * @param options defines the options used to create the mesh
  53470. * @param scene defines the hosting scene
  53471. * @returns the sphere mesh
  53472. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53473. */
  53474. static CreateSphere(name: string, options: {
  53475. segments?: number;
  53476. diameter?: number;
  53477. diameterX?: number;
  53478. diameterY?: number;
  53479. diameterZ?: number;
  53480. arc?: number;
  53481. slice?: number;
  53482. sideOrientation?: number;
  53483. frontUVs?: Vector4;
  53484. backUVs?: Vector4;
  53485. updatable?: boolean;
  53486. }, scene?: Nullable<Scene>): Mesh;
  53487. }
  53488. }
  53489. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53491. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53492. import { Scene } from "babylonjs/scene";
  53493. /**
  53494. * A profiled motion controller has its profile loaded from an online repository.
  53495. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53496. */
  53497. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53498. private _repositoryUrl;
  53499. private _buttonMeshMapping;
  53500. private _touchDots;
  53501. /**
  53502. * The profile ID of this controller. Will be populated when the controller initializes.
  53503. */
  53504. profileId: string;
  53505. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53506. dispose(): void;
  53507. protected _getFilenameAndPath(): {
  53508. filename: string;
  53509. path: string;
  53510. };
  53511. protected _getModelLoadingConstraints(): boolean;
  53512. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53513. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53514. protected _updateModel(_xrFrame: XRFrame): void;
  53515. }
  53516. }
  53517. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53518. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53519. import { Scene } from "babylonjs/scene";
  53520. /**
  53521. * A construction function type to create a new controller based on an xrInput object
  53522. */
  53523. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53524. /**
  53525. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53526. *
  53527. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53528. * it should be replaced with auto-loaded controllers.
  53529. *
  53530. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53531. */
  53532. export class WebXRMotionControllerManager {
  53533. private static _AvailableControllers;
  53534. private static _Fallbacks;
  53535. private static _ProfileLoadingPromises;
  53536. private static _ProfilesList;
  53537. /**
  53538. * The base URL of the online controller repository. Can be changed at any time.
  53539. */
  53540. static BaseRepositoryUrl: string;
  53541. /**
  53542. * Which repository gets priority - local or online
  53543. */
  53544. static PrioritizeOnlineRepository: boolean;
  53545. /**
  53546. * Use the online repository, or use only locally-defined controllers
  53547. */
  53548. static UseOnlineRepository: boolean;
  53549. /**
  53550. * Clear the cache used for profile loading and reload when requested again
  53551. */
  53552. static ClearProfilesCache(): void;
  53553. /**
  53554. * Register the default fallbacks.
  53555. * This function is called automatically when this file is imported.
  53556. */
  53557. static DefaultFallbacks(): void;
  53558. /**
  53559. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53560. * @param profileId the profile to which a fallback needs to be found
  53561. * @return an array with corresponding fallback profiles
  53562. */
  53563. static FindFallbackWithProfileId(profileId: string): string[];
  53564. /**
  53565. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53566. * The order of search:
  53567. *
  53568. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53569. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53570. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53571. * 4) return the generic trigger controller if none were found
  53572. *
  53573. * @param xrInput the xrInput to which a new controller is initialized
  53574. * @param scene the scene to which the model will be added
  53575. * @param forceProfile force a certain profile for this controller
  53576. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53577. */
  53578. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53579. /**
  53580. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53581. *
  53582. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53583. *
  53584. * @param type the profile type to register
  53585. * @param constructFunction the function to be called when loading this profile
  53586. */
  53587. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53588. /**
  53589. * Register a fallback to a specific profile.
  53590. * @param profileId the profileId that will receive the fallbacks
  53591. * @param fallbacks A list of fallback profiles
  53592. */
  53593. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53594. /**
  53595. * Will update the list of profiles available in the repository
  53596. * @return a promise that resolves to a map of profiles available online
  53597. */
  53598. static UpdateProfilesList(): Promise<{
  53599. [profile: string]: string;
  53600. }>;
  53601. private static _LoadProfileFromRepository;
  53602. private static _LoadProfilesFromAvailableControllers;
  53603. }
  53604. }
  53605. declare module "babylonjs/XR/webXRInputSource" {
  53606. import { Observable } from "babylonjs/Misc/observable";
  53607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53608. import { Ray } from "babylonjs/Culling/ray";
  53609. import { Scene } from "babylonjs/scene";
  53610. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53611. /**
  53612. * Configuration options for the WebXR controller creation
  53613. */
  53614. export interface IWebXRControllerOptions {
  53615. /**
  53616. * Should the controller mesh be animated when a user interacts with it
  53617. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53618. */
  53619. disableMotionControllerAnimation?: boolean;
  53620. /**
  53621. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53622. */
  53623. doNotLoadControllerMesh?: boolean;
  53624. /**
  53625. * Force a specific controller type for this controller.
  53626. * This can be used when creating your own profile or when testing different controllers
  53627. */
  53628. forceControllerProfile?: string;
  53629. /**
  53630. * Defines a rendering group ID for meshes that will be loaded.
  53631. * This is for the default controllers only.
  53632. */
  53633. renderingGroupId?: number;
  53634. }
  53635. /**
  53636. * Represents an XR controller
  53637. */
  53638. export class WebXRInputSource {
  53639. private _scene;
  53640. /** The underlying input source for the controller */
  53641. inputSource: XRInputSource;
  53642. private _options;
  53643. private _tmpVector;
  53644. private _uniqueId;
  53645. private _disposed;
  53646. /**
  53647. * 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
  53648. */
  53649. grip?: AbstractMesh;
  53650. /**
  53651. * If available, this is the gamepad object related to this controller.
  53652. * Using this object it is possible to get click events and trackpad changes of the
  53653. * webxr controller that is currently being used.
  53654. */
  53655. motionController?: WebXRAbstractMotionController;
  53656. /**
  53657. * Event that fires when the controller is removed/disposed.
  53658. * The object provided as event data is this controller, after associated assets were disposed.
  53659. * uniqueId is still available.
  53660. */
  53661. onDisposeObservable: Observable<WebXRInputSource>;
  53662. /**
  53663. * Will be triggered when the mesh associated with the motion controller is done loading.
  53664. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53665. * A shortened version of controller -> motion controller -> on mesh loaded.
  53666. */
  53667. onMeshLoadedObservable: Observable<AbstractMesh>;
  53668. /**
  53669. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53670. */
  53671. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53672. /**
  53673. * Pointer which can be used to select objects or attach a visible laser to
  53674. */
  53675. pointer: AbstractMesh;
  53676. /**
  53677. * Creates the input source object
  53678. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  53679. * @param _scene the scene which the controller should be associated to
  53680. * @param inputSource the underlying input source for the controller
  53681. * @param _options options for this controller creation
  53682. */
  53683. constructor(_scene: Scene,
  53684. /** The underlying input source for the controller */
  53685. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  53686. /**
  53687. * Get this controllers unique id
  53688. */
  53689. get uniqueId(): string;
  53690. /**
  53691. * Disposes of the object
  53692. */
  53693. dispose(): void;
  53694. /**
  53695. * Gets a world space ray coming from the pointer or grip
  53696. * @param result the resulting ray
  53697. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  53698. */
  53699. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  53700. /**
  53701. * Updates the controller pose based on the given XRFrame
  53702. * @param xrFrame xr frame to update the pose with
  53703. * @param referenceSpace reference space to use
  53704. */
  53705. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  53706. }
  53707. }
  53708. declare module "babylonjs/XR/webXRInput" {
  53709. import { Observable } from "babylonjs/Misc/observable";
  53710. import { IDisposable } from "babylonjs/scene";
  53711. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  53712. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53713. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53714. /**
  53715. * The schema for initialization options of the XR Input class
  53716. */
  53717. export interface IWebXRInputOptions {
  53718. /**
  53719. * If set to true no model will be automatically loaded
  53720. */
  53721. doNotLoadControllerMeshes?: boolean;
  53722. /**
  53723. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  53724. * If not found, the xr input profile data will be used.
  53725. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  53726. */
  53727. forceInputProfile?: string;
  53728. /**
  53729. * Do not send a request to the controller repository to load the profile.
  53730. *
  53731. * Instead, use the controllers available in babylon itself.
  53732. */
  53733. disableOnlineControllerRepository?: boolean;
  53734. /**
  53735. * A custom URL for the controllers repository
  53736. */
  53737. customControllersRepositoryURL?: string;
  53738. /**
  53739. * Should the controller model's components not move according to the user input
  53740. */
  53741. disableControllerAnimation?: boolean;
  53742. /**
  53743. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  53744. */
  53745. controllerOptions?: IWebXRControllerOptions;
  53746. }
  53747. /**
  53748. * XR input used to track XR inputs such as controllers/rays
  53749. */
  53750. export class WebXRInput implements IDisposable {
  53751. /**
  53752. * the xr session manager for this session
  53753. */
  53754. xrSessionManager: WebXRSessionManager;
  53755. /**
  53756. * the WebXR camera for this session. Mainly used for teleportation
  53757. */
  53758. xrCamera: WebXRCamera;
  53759. private readonly options;
  53760. /**
  53761. * XR controllers being tracked
  53762. */
  53763. controllers: Array<WebXRInputSource>;
  53764. private _frameObserver;
  53765. private _sessionEndedObserver;
  53766. private _sessionInitObserver;
  53767. /**
  53768. * Event when a controller has been connected/added
  53769. */
  53770. onControllerAddedObservable: Observable<WebXRInputSource>;
  53771. /**
  53772. * Event when a controller has been removed/disconnected
  53773. */
  53774. onControllerRemovedObservable: Observable<WebXRInputSource>;
  53775. /**
  53776. * Initializes the WebXRInput
  53777. * @param xrSessionManager the xr session manager for this session
  53778. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  53779. * @param options = initialization options for this xr input
  53780. */
  53781. constructor(
  53782. /**
  53783. * the xr session manager for this session
  53784. */
  53785. xrSessionManager: WebXRSessionManager,
  53786. /**
  53787. * the WebXR camera for this session. Mainly used for teleportation
  53788. */
  53789. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  53790. private _onInputSourcesChange;
  53791. private _addAndRemoveControllers;
  53792. /**
  53793. * Disposes of the object
  53794. */
  53795. dispose(): void;
  53796. }
  53797. }
  53798. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  53799. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  53800. import { Observable, EventState } from "babylonjs/Misc/observable";
  53801. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53802. /**
  53803. * This is the base class for all WebXR features.
  53804. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  53805. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  53806. */
  53807. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  53808. protected _xrSessionManager: WebXRSessionManager;
  53809. private _attached;
  53810. private _removeOnDetach;
  53811. /**
  53812. * Is this feature disposed?
  53813. */
  53814. isDisposed: boolean;
  53815. /**
  53816. * Should auto-attach be disabled?
  53817. */
  53818. disableAutoAttach: boolean;
  53819. /**
  53820. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  53821. */
  53822. xrNativeFeatureName: string;
  53823. /**
  53824. * Construct a new (abstract) WebXR feature
  53825. * @param _xrSessionManager the xr session manager for this feature
  53826. */
  53827. constructor(_xrSessionManager: WebXRSessionManager);
  53828. /**
  53829. * Is this feature attached
  53830. */
  53831. get attached(): boolean;
  53832. /**
  53833. * attach this feature
  53834. *
  53835. * @param force should attachment be forced (even when already attached)
  53836. * @returns true if successful, false is failed or already attached
  53837. */
  53838. attach(force?: boolean): boolean;
  53839. /**
  53840. * detach this feature.
  53841. *
  53842. * @returns true if successful, false if failed or already detached
  53843. */
  53844. detach(): boolean;
  53845. /**
  53846. * Dispose this feature and all of the resources attached
  53847. */
  53848. dispose(): void;
  53849. /**
  53850. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53851. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53852. *
  53853. * @returns whether or not the feature is compatible in this environment
  53854. */
  53855. isCompatible(): boolean;
  53856. /**
  53857. * This is used to register callbacks that will automatically be removed when detach is called.
  53858. * @param observable the observable to which the observer will be attached
  53859. * @param callback the callback to register
  53860. */
  53861. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  53862. /**
  53863. * Code in this function will be executed on each xrFrame received from the browser.
  53864. * This function will not execute after the feature is detached.
  53865. * @param _xrFrame the current frame
  53866. */
  53867. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  53868. }
  53869. }
  53870. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  53871. import { IDisposable, Scene } from "babylonjs/scene";
  53872. import { Nullable } from "babylonjs/types";
  53873. import { Observable } from "babylonjs/Misc/observable";
  53874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53875. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  53876. import { Camera } from "babylonjs/Cameras/camera";
  53877. /**
  53878. * Renders a layer on top of an existing scene
  53879. */
  53880. export class UtilityLayerRenderer implements IDisposable {
  53881. /** the original scene that will be rendered on top of */
  53882. originalScene: Scene;
  53883. private _pointerCaptures;
  53884. private _lastPointerEvents;
  53885. private static _DefaultUtilityLayer;
  53886. private static _DefaultKeepDepthUtilityLayer;
  53887. private _sharedGizmoLight;
  53888. private _renderCamera;
  53889. /**
  53890. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  53891. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  53892. * @returns the camera that is used when rendering the utility layer
  53893. */
  53894. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  53895. /**
  53896. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  53897. * @param cam the camera that should be used when rendering the utility layer
  53898. */
  53899. setRenderCamera(cam: Nullable<Camera>): void;
  53900. /**
  53901. * @hidden
  53902. * Light which used by gizmos to get light shading
  53903. */
  53904. _getSharedGizmoLight(): HemisphericLight;
  53905. /**
  53906. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  53907. */
  53908. pickUtilitySceneFirst: boolean;
  53909. /**
  53910. * 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)
  53911. */
  53912. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  53913. /**
  53914. * 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)
  53915. */
  53916. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  53917. /**
  53918. * The scene that is rendered on top of the original scene
  53919. */
  53920. utilityLayerScene: Scene;
  53921. /**
  53922. * If the utility layer should automatically be rendered on top of existing scene
  53923. */
  53924. shouldRender: boolean;
  53925. /**
  53926. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  53927. */
  53928. onlyCheckPointerDownEvents: boolean;
  53929. /**
  53930. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  53931. */
  53932. processAllEvents: boolean;
  53933. /**
  53934. * Observable raised when the pointer move from the utility layer scene to the main scene
  53935. */
  53936. onPointerOutObservable: Observable<number>;
  53937. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  53938. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  53939. private _afterRenderObserver;
  53940. private _sceneDisposeObserver;
  53941. private _originalPointerObserver;
  53942. /**
  53943. * Instantiates a UtilityLayerRenderer
  53944. * @param originalScene the original scene that will be rendered on top of
  53945. * @param handleEvents boolean indicating if the utility layer should handle events
  53946. */
  53947. constructor(
  53948. /** the original scene that will be rendered on top of */
  53949. originalScene: Scene, handleEvents?: boolean);
  53950. private _notifyObservers;
  53951. /**
  53952. * Renders the utility layers scene on top of the original scene
  53953. */
  53954. render(): void;
  53955. /**
  53956. * Disposes of the renderer
  53957. */
  53958. dispose(): void;
  53959. private _updateCamera;
  53960. }
  53961. }
  53962. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  53963. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53965. import { WebXRInput } from "babylonjs/XR/webXRInput";
  53966. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  53967. import { Scene } from "babylonjs/scene";
  53968. import { Nullable } from "babylonjs/types";
  53969. import { Color3 } from "babylonjs/Maths/math.color";
  53970. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  53971. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53972. /**
  53973. * Options interface for the pointer selection module
  53974. */
  53975. export interface IWebXRControllerPointerSelectionOptions {
  53976. /**
  53977. * if provided, this scene will be used to render meshes.
  53978. */
  53979. customUtilityLayerScene?: Scene;
  53980. /**
  53981. * 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)
  53982. * If not disabled, the last picked point will be used to execute a pointer up event
  53983. * If disabled, pointer up event will be triggered right after the pointer down event.
  53984. * Used in screen and gaze target ray mode only
  53985. */
  53986. disablePointerUpOnTouchOut: boolean;
  53987. /**
  53988. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  53989. */
  53990. forceGazeMode: boolean;
  53991. /**
  53992. * 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
  53993. * to start a new countdown to the pointer down event.
  53994. * Defaults to 1.
  53995. */
  53996. gazeModePointerMovedFactor?: number;
  53997. /**
  53998. * Different button type to use instead of the main component
  53999. */
  54000. overrideButtonId?: string;
  54001. /**
  54002. * use this rendering group id for the meshes (optional)
  54003. */
  54004. renderingGroupId?: number;
  54005. /**
  54006. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54007. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54008. * 3000 means 3 seconds between pointing at something and selecting it
  54009. */
  54010. timeToSelect?: number;
  54011. /**
  54012. * Should meshes created here be added to a utility layer or the main scene
  54013. */
  54014. useUtilityLayer?: boolean;
  54015. /**
  54016. * Optional WebXR camera to be used for gaze selection
  54017. */
  54018. gazeCamera?: WebXRCamera;
  54019. /**
  54020. * the xr input to use with this pointer selection
  54021. */
  54022. xrInput: WebXRInput;
  54023. /**
  54024. * Should the scene pointerX and pointerY update be disabled
  54025. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54026. * Disable in VR, if not needed.
  54027. * The first rig camera (left eye) will be used to calculate the projection
  54028. */
  54029. disableScenePointerVectorUpdate: boolean;
  54030. }
  54031. /**
  54032. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54033. */
  54034. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54035. private readonly _options;
  54036. private static _idCounter;
  54037. private _attachController;
  54038. private _controllers;
  54039. private _scene;
  54040. private _tmpVectorForPickCompare;
  54041. /**
  54042. * The module's name
  54043. */
  54044. static readonly Name: string;
  54045. /**
  54046. * The (Babylon) version of this module.
  54047. * This is an integer representing the implementation version.
  54048. * This number does not correspond to the WebXR specs version
  54049. */
  54050. static readonly Version: number;
  54051. /**
  54052. * Disable lighting on the laser pointer (so it will always be visible)
  54053. */
  54054. disablePointerLighting: boolean;
  54055. /**
  54056. * Disable lighting on the selection mesh (so it will always be visible)
  54057. */
  54058. disableSelectionMeshLighting: boolean;
  54059. /**
  54060. * Should the laser pointer be displayed
  54061. */
  54062. displayLaserPointer: boolean;
  54063. /**
  54064. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54065. */
  54066. displaySelectionMesh: boolean;
  54067. /**
  54068. * This color will be set to the laser pointer when selection is triggered
  54069. */
  54070. laserPointerPickedColor: Color3;
  54071. /**
  54072. * Default color of the laser pointer
  54073. */
  54074. laserPointerDefaultColor: Color3;
  54075. /**
  54076. * default color of the selection ring
  54077. */
  54078. selectionMeshDefaultColor: Color3;
  54079. /**
  54080. * This color will be applied to the selection ring when selection is triggered
  54081. */
  54082. selectionMeshPickedColor: Color3;
  54083. /**
  54084. * Optional filter to be used for ray selection. This predicate shares behavior with
  54085. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54086. */
  54087. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54088. /**
  54089. * constructs a new background remover module
  54090. * @param _xrSessionManager the session manager for this module
  54091. * @param _options read-only options to be used in this module
  54092. */
  54093. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54094. /**
  54095. * attach this feature
  54096. * Will usually be called by the features manager
  54097. *
  54098. * @returns true if successful.
  54099. */
  54100. attach(): boolean;
  54101. /**
  54102. * detach this feature.
  54103. * Will usually be called by the features manager
  54104. *
  54105. * @returns true if successful.
  54106. */
  54107. detach(): boolean;
  54108. /**
  54109. * Will get the mesh under a specific pointer.
  54110. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54111. * @param controllerId the controllerId to check
  54112. * @returns The mesh under pointer or null if no mesh is under the pointer
  54113. */
  54114. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54115. /**
  54116. * Get the xr controller that correlates to the pointer id in the pointer event
  54117. *
  54118. * @param id the pointer id to search for
  54119. * @returns the controller that correlates to this id or null if not found
  54120. */
  54121. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54122. private _identityMatrix;
  54123. private _screenCoordinatesRef;
  54124. private _viewportRef;
  54125. protected _onXRFrame(_xrFrame: XRFrame): void;
  54126. private _attachGazeMode;
  54127. private _attachScreenRayMode;
  54128. private _attachTrackedPointerRayMode;
  54129. private _convertNormalToDirectionOfRay;
  54130. private _detachController;
  54131. private _generateNewMeshPair;
  54132. private _pickingMoved;
  54133. private _updatePointerDistance;
  54134. /** @hidden */
  54135. get lasterPointerDefaultColor(): Color3;
  54136. }
  54137. }
  54138. declare module "babylonjs/XR/webXREnterExitUI" {
  54139. import { Nullable } from "babylonjs/types";
  54140. import { Observable } from "babylonjs/Misc/observable";
  54141. import { IDisposable, Scene } from "babylonjs/scene";
  54142. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54143. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54144. /**
  54145. * Button which can be used to enter a different mode of XR
  54146. */
  54147. export class WebXREnterExitUIButton {
  54148. /** button element */
  54149. element: HTMLElement;
  54150. /** XR initialization options for the button */
  54151. sessionMode: XRSessionMode;
  54152. /** Reference space type */
  54153. referenceSpaceType: XRReferenceSpaceType;
  54154. /**
  54155. * Creates a WebXREnterExitUIButton
  54156. * @param element button element
  54157. * @param sessionMode XR initialization session mode
  54158. * @param referenceSpaceType the type of reference space to be used
  54159. */
  54160. constructor(
  54161. /** button element */
  54162. element: HTMLElement,
  54163. /** XR initialization options for the button */
  54164. sessionMode: XRSessionMode,
  54165. /** Reference space type */
  54166. referenceSpaceType: XRReferenceSpaceType);
  54167. /**
  54168. * Extendable function which can be used to update the button's visuals when the state changes
  54169. * @param activeButton the current active button in the UI
  54170. */
  54171. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54172. }
  54173. /**
  54174. * Options to create the webXR UI
  54175. */
  54176. export class WebXREnterExitUIOptions {
  54177. /**
  54178. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54179. */
  54180. customButtons?: Array<WebXREnterExitUIButton>;
  54181. /**
  54182. * A reference space type to use when creating the default button.
  54183. * Default is local-floor
  54184. */
  54185. referenceSpaceType?: XRReferenceSpaceType;
  54186. /**
  54187. * Context to enter xr with
  54188. */
  54189. renderTarget?: Nullable<WebXRRenderTarget>;
  54190. /**
  54191. * A session mode to use when creating the default button.
  54192. * Default is immersive-vr
  54193. */
  54194. sessionMode?: XRSessionMode;
  54195. /**
  54196. * A list of optional features to init the session with
  54197. */
  54198. optionalFeatures?: string[];
  54199. /**
  54200. * A list of optional features to init the session with
  54201. */
  54202. requiredFeatures?: string[];
  54203. }
  54204. /**
  54205. * UI to allow the user to enter/exit XR mode
  54206. */
  54207. export class WebXREnterExitUI implements IDisposable {
  54208. private scene;
  54209. /** version of the options passed to this UI */
  54210. options: WebXREnterExitUIOptions;
  54211. private _activeButton;
  54212. private _buttons;
  54213. /**
  54214. * The HTML Div Element to which buttons are added.
  54215. */
  54216. readonly overlay: HTMLDivElement;
  54217. /**
  54218. * Fired every time the active button is changed.
  54219. *
  54220. * When xr is entered via a button that launches xr that button will be the callback parameter
  54221. *
  54222. * When exiting xr the callback parameter will be null)
  54223. */
  54224. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54225. /**
  54226. *
  54227. * @param scene babylon scene object to use
  54228. * @param options (read-only) version of the options passed to this UI
  54229. */
  54230. private constructor();
  54231. /**
  54232. * Creates UI to allow the user to enter/exit XR mode
  54233. * @param scene the scene to add the ui to
  54234. * @param helper the xr experience helper to enter/exit xr with
  54235. * @param options options to configure the UI
  54236. * @returns the created ui
  54237. */
  54238. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54239. /**
  54240. * Disposes of the XR UI component
  54241. */
  54242. dispose(): void;
  54243. private _updateButtons;
  54244. }
  54245. }
  54246. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54247. import { Vector3 } from "babylonjs/Maths/math.vector";
  54248. import { Color4 } from "babylonjs/Maths/math.color";
  54249. import { Nullable } from "babylonjs/types";
  54250. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54251. import { Scene } from "babylonjs/scene";
  54252. /**
  54253. * Class containing static functions to help procedurally build meshes
  54254. */
  54255. export class LinesBuilder {
  54256. /**
  54257. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54258. * * 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
  54259. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54260. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54261. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54262. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54263. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54264. * * 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
  54265. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54268. * @param name defines the name of the new line system
  54269. * @param options defines the options used to create the line system
  54270. * @param scene defines the hosting scene
  54271. * @returns a new line system mesh
  54272. */
  54273. static CreateLineSystem(name: string, options: {
  54274. lines: Vector3[][];
  54275. updatable?: boolean;
  54276. instance?: Nullable<LinesMesh>;
  54277. colors?: Nullable<Color4[][]>;
  54278. useVertexAlpha?: boolean;
  54279. }, scene: Nullable<Scene>): LinesMesh;
  54280. /**
  54281. * Creates a line mesh
  54282. * 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
  54283. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54284. * * The parameter `points` is an array successive Vector3
  54285. * * 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
  54286. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54287. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54288. * * When updating an instance, remember that only point positions can change, not the number of points
  54289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54291. * @param name defines the name of the new line system
  54292. * @param options defines the options used to create the line system
  54293. * @param scene defines the hosting scene
  54294. * @returns a new line mesh
  54295. */
  54296. static CreateLines(name: string, options: {
  54297. points: Vector3[];
  54298. updatable?: boolean;
  54299. instance?: Nullable<LinesMesh>;
  54300. colors?: Color4[];
  54301. useVertexAlpha?: boolean;
  54302. }, scene?: Nullable<Scene>): LinesMesh;
  54303. /**
  54304. * Creates a dashed line mesh
  54305. * * 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
  54306. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54307. * * The parameter `points` is an array successive Vector3
  54308. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54309. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54310. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54311. * * 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
  54312. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54313. * * When updating an instance, remember that only point positions can change, not the number of points
  54314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54315. * @param name defines the name of the mesh
  54316. * @param options defines the options used to create the mesh
  54317. * @param scene defines the hosting scene
  54318. * @returns the dashed line mesh
  54319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54320. */
  54321. static CreateDashedLines(name: string, options: {
  54322. points: Vector3[];
  54323. dashSize?: number;
  54324. gapSize?: number;
  54325. dashNb?: number;
  54326. updatable?: boolean;
  54327. instance?: LinesMesh;
  54328. useVertexAlpha?: boolean;
  54329. }, scene?: Nullable<Scene>): LinesMesh;
  54330. }
  54331. }
  54332. declare module "babylonjs/Misc/timer" {
  54333. import { Observable, Observer } from "babylonjs/Misc/observable";
  54334. import { Nullable } from "babylonjs/types";
  54335. import { IDisposable } from "babylonjs/scene";
  54336. /**
  54337. * Construction options for a timer
  54338. */
  54339. export interface ITimerOptions<T> {
  54340. /**
  54341. * Time-to-end
  54342. */
  54343. timeout: number;
  54344. /**
  54345. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54346. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54347. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54348. */
  54349. contextObservable: Observable<T>;
  54350. /**
  54351. * Optional parameters when adding an observer to the observable
  54352. */
  54353. observableParameters?: {
  54354. mask?: number;
  54355. insertFirst?: boolean;
  54356. scope?: any;
  54357. };
  54358. /**
  54359. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54360. */
  54361. breakCondition?: (data?: ITimerData<T>) => boolean;
  54362. /**
  54363. * Will be triggered when the time condition has met
  54364. */
  54365. onEnded?: (data: ITimerData<any>) => void;
  54366. /**
  54367. * Will be triggered when the break condition has met (prematurely ended)
  54368. */
  54369. onAborted?: (data: ITimerData<any>) => void;
  54370. /**
  54371. * Optional function to execute on each tick (or count)
  54372. */
  54373. onTick?: (data: ITimerData<any>) => void;
  54374. }
  54375. /**
  54376. * An interface defining the data sent by the timer
  54377. */
  54378. export interface ITimerData<T> {
  54379. /**
  54380. * When did it start
  54381. */
  54382. startTime: number;
  54383. /**
  54384. * Time now
  54385. */
  54386. currentTime: number;
  54387. /**
  54388. * Time passed since started
  54389. */
  54390. deltaTime: number;
  54391. /**
  54392. * How much is completed, in [0.0...1.0].
  54393. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54394. */
  54395. completeRate: number;
  54396. /**
  54397. * What the registered observable sent in the last count
  54398. */
  54399. payload: T;
  54400. }
  54401. /**
  54402. * The current state of the timer
  54403. */
  54404. export enum TimerState {
  54405. /**
  54406. * Timer initialized, not yet started
  54407. */
  54408. INIT = 0,
  54409. /**
  54410. * Timer started and counting
  54411. */
  54412. STARTED = 1,
  54413. /**
  54414. * Timer ended (whether aborted or time reached)
  54415. */
  54416. ENDED = 2
  54417. }
  54418. /**
  54419. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54420. *
  54421. * @param options options with which to initialize this timer
  54422. */
  54423. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54424. /**
  54425. * An advanced implementation of a timer class
  54426. */
  54427. export class AdvancedTimer<T = any> implements IDisposable {
  54428. /**
  54429. * Will notify each time the timer calculates the remaining time
  54430. */
  54431. onEachCountObservable: Observable<ITimerData<T>>;
  54432. /**
  54433. * Will trigger when the timer was aborted due to the break condition
  54434. */
  54435. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54436. /**
  54437. * Will trigger when the timer ended successfully
  54438. */
  54439. onTimerEndedObservable: Observable<ITimerData<T>>;
  54440. /**
  54441. * Will trigger when the timer state has changed
  54442. */
  54443. onStateChangedObservable: Observable<TimerState>;
  54444. private _observer;
  54445. private _contextObservable;
  54446. private _observableParameters;
  54447. private _startTime;
  54448. private _timer;
  54449. private _state;
  54450. private _breakCondition;
  54451. private _timeToEnd;
  54452. private _breakOnNextTick;
  54453. /**
  54454. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54455. * @param options construction options for this advanced timer
  54456. */
  54457. constructor(options: ITimerOptions<T>);
  54458. /**
  54459. * set a breaking condition for this timer. Default is to never break during count
  54460. * @param predicate the new break condition. Returns true to break, false otherwise
  54461. */
  54462. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54463. /**
  54464. * Reset ALL associated observables in this advanced timer
  54465. */
  54466. clearObservables(): void;
  54467. /**
  54468. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54469. *
  54470. * @param timeToEnd how much time to measure until timer ended
  54471. */
  54472. start(timeToEnd?: number): void;
  54473. /**
  54474. * Will force a stop on the next tick.
  54475. */
  54476. stop(): void;
  54477. /**
  54478. * Dispose this timer, clearing all resources
  54479. */
  54480. dispose(): void;
  54481. private _setState;
  54482. private _tick;
  54483. private _stop;
  54484. }
  54485. }
  54486. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54487. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54488. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54489. import { Nullable } from "babylonjs/types";
  54490. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54492. import { Vector3 } from "babylonjs/Maths/math.vector";
  54493. import { Material } from "babylonjs/Materials/material";
  54494. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54495. import { Scene } from "babylonjs/scene";
  54496. /**
  54497. * The options container for the teleportation module
  54498. */
  54499. export interface IWebXRTeleportationOptions {
  54500. /**
  54501. * if provided, this scene will be used to render meshes.
  54502. */
  54503. customUtilityLayerScene?: Scene;
  54504. /**
  54505. * Values to configure the default target mesh
  54506. */
  54507. defaultTargetMeshOptions?: {
  54508. /**
  54509. * Fill color of the teleportation area
  54510. */
  54511. teleportationFillColor?: string;
  54512. /**
  54513. * Border color for the teleportation area
  54514. */
  54515. teleportationBorderColor?: string;
  54516. /**
  54517. * Disable the mesh's animation sequence
  54518. */
  54519. disableAnimation?: boolean;
  54520. /**
  54521. * Disable lighting on the material or the ring and arrow
  54522. */
  54523. disableLighting?: boolean;
  54524. /**
  54525. * Override the default material of the torus and arrow
  54526. */
  54527. torusArrowMaterial?: Material;
  54528. };
  54529. /**
  54530. * A list of meshes to use as floor meshes.
  54531. * Meshes can be added and removed after initializing the feature using the
  54532. * addFloorMesh and removeFloorMesh functions
  54533. * If empty, rotation will still work
  54534. */
  54535. floorMeshes?: AbstractMesh[];
  54536. /**
  54537. * use this rendering group id for the meshes (optional)
  54538. */
  54539. renderingGroupId?: number;
  54540. /**
  54541. * Should teleportation move only to snap points
  54542. */
  54543. snapPointsOnly?: boolean;
  54544. /**
  54545. * An array of points to which the teleportation will snap to.
  54546. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54547. */
  54548. snapPositions?: Vector3[];
  54549. /**
  54550. * How close should the teleportation ray be in order to snap to position.
  54551. * Default to 0.8 units (meters)
  54552. */
  54553. snapToPositionRadius?: number;
  54554. /**
  54555. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54556. * If you want to support rotation, make sure your mesh has a direction indicator.
  54557. *
  54558. * When left untouched, the default mesh will be initialized.
  54559. */
  54560. teleportationTargetMesh?: AbstractMesh;
  54561. /**
  54562. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54563. */
  54564. timeToTeleport?: number;
  54565. /**
  54566. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54567. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54568. */
  54569. useMainComponentOnly?: boolean;
  54570. /**
  54571. * Should meshes created here be added to a utility layer or the main scene
  54572. */
  54573. useUtilityLayer?: boolean;
  54574. /**
  54575. * Babylon XR Input class for controller
  54576. */
  54577. xrInput: WebXRInput;
  54578. /**
  54579. * Meshes that the teleportation ray cannot go through
  54580. */
  54581. pickBlockerMeshes?: AbstractMesh[];
  54582. }
  54583. /**
  54584. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54585. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54586. * the input of the attached controllers.
  54587. */
  54588. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54589. private _options;
  54590. private _controllers;
  54591. private _currentTeleportationControllerId;
  54592. private _floorMeshes;
  54593. private _quadraticBezierCurve;
  54594. private _selectionFeature;
  54595. private _snapToPositions;
  54596. private _snappedToPoint;
  54597. private _teleportationRingMaterial?;
  54598. private _tmpRay;
  54599. private _tmpVector;
  54600. private _tmpQuaternion;
  54601. /**
  54602. * The module's name
  54603. */
  54604. static readonly Name: string;
  54605. /**
  54606. * The (Babylon) version of this module.
  54607. * This is an integer representing the implementation version.
  54608. * This number does not correspond to the webxr specs version
  54609. */
  54610. static readonly Version: number;
  54611. /**
  54612. * Is movement backwards enabled
  54613. */
  54614. backwardsMovementEnabled: boolean;
  54615. /**
  54616. * Distance to travel when moving backwards
  54617. */
  54618. backwardsTeleportationDistance: number;
  54619. /**
  54620. * The distance from the user to the inspection point in the direction of the controller
  54621. * A higher number will allow the user to move further
  54622. * defaults to 5 (meters, in xr units)
  54623. */
  54624. parabolicCheckRadius: number;
  54625. /**
  54626. * Should the module support parabolic ray on top of direct ray
  54627. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54628. * Very helpful when moving between floors / different heights
  54629. */
  54630. parabolicRayEnabled: boolean;
  54631. /**
  54632. * How much rotation should be applied when rotating right and left
  54633. */
  54634. rotationAngle: number;
  54635. /**
  54636. * Is rotation enabled when moving forward?
  54637. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54638. */
  54639. rotationEnabled: boolean;
  54640. /**
  54641. * constructs a new anchor system
  54642. * @param _xrSessionManager an instance of WebXRSessionManager
  54643. * @param _options configuration object for this feature
  54644. */
  54645. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54646. /**
  54647. * Get the snapPointsOnly flag
  54648. */
  54649. get snapPointsOnly(): boolean;
  54650. /**
  54651. * Sets the snapPointsOnly flag
  54652. * @param snapToPoints should teleportation be exclusively to snap points
  54653. */
  54654. set snapPointsOnly(snapToPoints: boolean);
  54655. /**
  54656. * Add a new mesh to the floor meshes array
  54657. * @param mesh the mesh to use as floor mesh
  54658. */
  54659. addFloorMesh(mesh: AbstractMesh): void;
  54660. /**
  54661. * Add a new snap-to point to fix teleportation to this position
  54662. * @param newSnapPoint The new Snap-To point
  54663. */
  54664. addSnapPoint(newSnapPoint: Vector3): void;
  54665. attach(): boolean;
  54666. detach(): boolean;
  54667. dispose(): void;
  54668. /**
  54669. * Remove a mesh from the floor meshes array
  54670. * @param mesh the mesh to remove
  54671. */
  54672. removeFloorMesh(mesh: AbstractMesh): void;
  54673. /**
  54674. * Remove a mesh from the floor meshes array using its name
  54675. * @param name the mesh name to remove
  54676. */
  54677. removeFloorMeshByName(name: string): void;
  54678. /**
  54679. * 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
  54680. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  54681. * @returns was the point found and removed or not
  54682. */
  54683. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  54684. /**
  54685. * This function sets a selection feature that will be disabled when
  54686. * the forward ray is shown and will be reattached when hidden.
  54687. * This is used to remove the selection rays when moving.
  54688. * @param selectionFeature the feature to disable when forward movement is enabled
  54689. */
  54690. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  54691. protected _onXRFrame(_xrFrame: XRFrame): void;
  54692. private _attachController;
  54693. private _createDefaultTargetMesh;
  54694. private _detachController;
  54695. private _findClosestSnapPointWithRadius;
  54696. private _setTargetMeshPosition;
  54697. private _setTargetMeshVisibility;
  54698. private _showParabolicPath;
  54699. private _teleportForward;
  54700. }
  54701. }
  54702. declare module "babylonjs/XR/webXRDefaultExperience" {
  54703. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54704. import { Scene } from "babylonjs/scene";
  54705. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  54706. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  54707. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54708. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  54709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54710. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  54711. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  54712. /**
  54713. * Options for the default xr helper
  54714. */
  54715. export class WebXRDefaultExperienceOptions {
  54716. /**
  54717. * Enable or disable default UI to enter XR
  54718. */
  54719. disableDefaultUI?: boolean;
  54720. /**
  54721. * Should teleportation not initialize. defaults to false.
  54722. */
  54723. disableTeleportation?: boolean;
  54724. /**
  54725. * Floor meshes that will be used for teleport
  54726. */
  54727. floorMeshes?: Array<AbstractMesh>;
  54728. /**
  54729. * If set to true, the first frame will not be used to reset position
  54730. * The first frame is mainly used when copying transformation from the old camera
  54731. * Mainly used in AR
  54732. */
  54733. ignoreNativeCameraTransformation?: boolean;
  54734. /**
  54735. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  54736. */
  54737. inputOptions?: IWebXRInputOptions;
  54738. /**
  54739. * optional configuration for the output canvas
  54740. */
  54741. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  54742. /**
  54743. * optional UI options. This can be used among other to change session mode and reference space type
  54744. */
  54745. uiOptions?: WebXREnterExitUIOptions;
  54746. /**
  54747. * When loading teleportation and pointer select, use stable versions instead of latest.
  54748. */
  54749. useStablePlugins?: boolean;
  54750. /**
  54751. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  54752. */
  54753. renderingGroupId?: number;
  54754. /**
  54755. * A list of optional features to init the session with
  54756. * If set to true, all features we support will be added
  54757. */
  54758. optionalFeatures?: boolean | string[];
  54759. }
  54760. /**
  54761. * Default experience which provides a similar setup to the previous webVRExperience
  54762. */
  54763. export class WebXRDefaultExperience {
  54764. /**
  54765. * Base experience
  54766. */
  54767. baseExperience: WebXRExperienceHelper;
  54768. /**
  54769. * Enables ui for entering/exiting xr
  54770. */
  54771. enterExitUI: WebXREnterExitUI;
  54772. /**
  54773. * Input experience extension
  54774. */
  54775. input: WebXRInput;
  54776. /**
  54777. * Enables laser pointer and selection
  54778. */
  54779. pointerSelection: WebXRControllerPointerSelection;
  54780. /**
  54781. * Default target xr should render to
  54782. */
  54783. renderTarget: WebXRRenderTarget;
  54784. /**
  54785. * Enables teleportation
  54786. */
  54787. teleportation: WebXRMotionControllerTeleportation;
  54788. private constructor();
  54789. /**
  54790. * Creates the default xr experience
  54791. * @param scene scene
  54792. * @param options options for basic configuration
  54793. * @returns resulting WebXRDefaultExperience
  54794. */
  54795. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54796. /**
  54797. * DIsposes of the experience helper
  54798. */
  54799. dispose(): void;
  54800. }
  54801. }
  54802. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  54803. import { Observable } from "babylonjs/Misc/observable";
  54804. import { Nullable } from "babylonjs/types";
  54805. import { Camera } from "babylonjs/Cameras/camera";
  54806. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  54807. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  54808. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  54809. import { Scene } from "babylonjs/scene";
  54810. import { Vector3 } from "babylonjs/Maths/math.vector";
  54811. import { Color3 } from "babylonjs/Maths/math.color";
  54812. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54814. import { Mesh } from "babylonjs/Meshes/mesh";
  54815. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  54816. import { EasingFunction } from "babylonjs/Animations/easing";
  54817. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54818. import "babylonjs/Meshes/Builders/groundBuilder";
  54819. import "babylonjs/Meshes/Builders/torusBuilder";
  54820. import "babylonjs/Meshes/Builders/cylinderBuilder";
  54821. import "babylonjs/Gamepads/gamepadSceneComponent";
  54822. import "babylonjs/Animations/animatable";
  54823. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  54824. /**
  54825. * Options to modify the vr teleportation behavior.
  54826. */
  54827. export interface VRTeleportationOptions {
  54828. /**
  54829. * The name of the mesh which should be used as the teleportation floor. (default: null)
  54830. */
  54831. floorMeshName?: string;
  54832. /**
  54833. * A list of meshes to be used as the teleportation floor. (default: empty)
  54834. */
  54835. floorMeshes?: Mesh[];
  54836. /**
  54837. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  54838. */
  54839. teleportationMode?: number;
  54840. /**
  54841. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  54842. */
  54843. teleportationTime?: number;
  54844. /**
  54845. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  54846. */
  54847. teleportationSpeed?: number;
  54848. /**
  54849. * The easing function used in the animation or null for Linear. (default CircleEase)
  54850. */
  54851. easingFunction?: EasingFunction;
  54852. }
  54853. /**
  54854. * Options to modify the vr experience helper's behavior.
  54855. */
  54856. export interface VRExperienceHelperOptions extends WebVROptions {
  54857. /**
  54858. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  54859. */
  54860. createDeviceOrientationCamera?: boolean;
  54861. /**
  54862. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  54863. */
  54864. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  54865. /**
  54866. * Uses the main button on the controller to toggle the laser casted. (default: true)
  54867. */
  54868. laserToggle?: boolean;
  54869. /**
  54870. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  54871. */
  54872. floorMeshes?: Mesh[];
  54873. /**
  54874. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  54875. */
  54876. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  54877. /**
  54878. * Defines if WebXR should be used instead of WebVR (if available)
  54879. */
  54880. useXR?: boolean;
  54881. }
  54882. /**
  54883. * Event containing information after VR has been entered
  54884. */
  54885. export class OnAfterEnteringVRObservableEvent {
  54886. /**
  54887. * If entering vr was successful
  54888. */
  54889. success: boolean;
  54890. }
  54891. /**
  54892. * Helps to quickly add VR support to an existing scene.
  54893. * See https://doc.babylonjs.com/how_to/webvr_helper
  54894. */
  54895. export class VRExperienceHelper {
  54896. /** Options to modify the vr experience helper's behavior. */
  54897. webVROptions: VRExperienceHelperOptions;
  54898. private _scene;
  54899. private _position;
  54900. private _btnVR;
  54901. private _btnVRDisplayed;
  54902. private _webVRsupported;
  54903. private _webVRready;
  54904. private _webVRrequesting;
  54905. private _webVRpresenting;
  54906. private _hasEnteredVR;
  54907. private _fullscreenVRpresenting;
  54908. private _inputElement;
  54909. private _webVRCamera;
  54910. private _vrDeviceOrientationCamera;
  54911. private _deviceOrientationCamera;
  54912. private _existingCamera;
  54913. private _onKeyDown;
  54914. private _onVrDisplayPresentChange;
  54915. private _onVRDisplayChanged;
  54916. private _onVRRequestPresentStart;
  54917. private _onVRRequestPresentComplete;
  54918. /**
  54919. * 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)
  54920. */
  54921. enableGazeEvenWhenNoPointerLock: boolean;
  54922. /**
  54923. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  54924. */
  54925. exitVROnDoubleTap: boolean;
  54926. /**
  54927. * Observable raised right before entering VR.
  54928. */
  54929. onEnteringVRObservable: Observable<VRExperienceHelper>;
  54930. /**
  54931. * Observable raised when entering VR has completed.
  54932. */
  54933. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  54934. /**
  54935. * Observable raised when exiting VR.
  54936. */
  54937. onExitingVRObservable: Observable<VRExperienceHelper>;
  54938. /**
  54939. * Observable raised when controller mesh is loaded.
  54940. */
  54941. onControllerMeshLoadedObservable: Observable<WebVRController>;
  54942. /** Return this.onEnteringVRObservable
  54943. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  54944. */
  54945. get onEnteringVR(): Observable<VRExperienceHelper>;
  54946. /** Return this.onExitingVRObservable
  54947. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  54948. */
  54949. get onExitingVR(): Observable<VRExperienceHelper>;
  54950. /** Return this.onControllerMeshLoadedObservable
  54951. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  54952. */
  54953. get onControllerMeshLoaded(): Observable<WebVRController>;
  54954. private _rayLength;
  54955. private _useCustomVRButton;
  54956. private _teleportationRequested;
  54957. private _teleportActive;
  54958. private _floorMeshName;
  54959. private _floorMeshesCollection;
  54960. private _teleportationMode;
  54961. private _teleportationTime;
  54962. private _teleportationSpeed;
  54963. private _teleportationEasing;
  54964. private _rotationAllowed;
  54965. private _teleportBackwardsVector;
  54966. private _teleportationTarget;
  54967. private _isDefaultTeleportationTarget;
  54968. private _postProcessMove;
  54969. private _teleportationFillColor;
  54970. private _teleportationBorderColor;
  54971. private _rotationAngle;
  54972. private _haloCenter;
  54973. private _cameraGazer;
  54974. private _padSensibilityUp;
  54975. private _padSensibilityDown;
  54976. private _leftController;
  54977. private _rightController;
  54978. private _gazeColor;
  54979. private _laserColor;
  54980. private _pickedLaserColor;
  54981. private _pickedGazeColor;
  54982. /**
  54983. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  54984. */
  54985. onNewMeshSelected: Observable<AbstractMesh>;
  54986. /**
  54987. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  54988. * This observable will provide the mesh and the controller used to select the mesh
  54989. */
  54990. onMeshSelectedWithController: Observable<{
  54991. mesh: AbstractMesh;
  54992. controller: WebVRController;
  54993. }>;
  54994. /**
  54995. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  54996. */
  54997. onNewMeshPicked: Observable<PickingInfo>;
  54998. private _circleEase;
  54999. /**
  55000. * Observable raised before camera teleportation
  55001. */
  55002. onBeforeCameraTeleport: Observable<Vector3>;
  55003. /**
  55004. * Observable raised after camera teleportation
  55005. */
  55006. onAfterCameraTeleport: Observable<Vector3>;
  55007. /**
  55008. * Observable raised when current selected mesh gets unselected
  55009. */
  55010. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55011. private _raySelectionPredicate;
  55012. /**
  55013. * To be optionaly changed by user to define custom ray selection
  55014. */
  55015. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55016. /**
  55017. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55018. */
  55019. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55020. /**
  55021. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55022. */
  55023. teleportationEnabled: boolean;
  55024. private _defaultHeight;
  55025. private _teleportationInitialized;
  55026. private _interactionsEnabled;
  55027. private _interactionsRequested;
  55028. private _displayGaze;
  55029. private _displayLaserPointer;
  55030. /**
  55031. * The mesh used to display where the user is going to teleport.
  55032. */
  55033. get teleportationTarget(): Mesh;
  55034. /**
  55035. * Sets the mesh to be used to display where the user is going to teleport.
  55036. */
  55037. set teleportationTarget(value: Mesh);
  55038. /**
  55039. * 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
  55040. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55041. * See https://doc.babylonjs.com/resources/baking_transformations
  55042. */
  55043. get gazeTrackerMesh(): Mesh;
  55044. set gazeTrackerMesh(value: Mesh);
  55045. /**
  55046. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55047. */
  55048. updateGazeTrackerScale: boolean;
  55049. /**
  55050. * If the gaze trackers color should be updated when selecting meshes
  55051. */
  55052. updateGazeTrackerColor: boolean;
  55053. /**
  55054. * If the controller laser color should be updated when selecting meshes
  55055. */
  55056. updateControllerLaserColor: boolean;
  55057. /**
  55058. * The gaze tracking mesh corresponding to the left controller
  55059. */
  55060. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55061. /**
  55062. * The gaze tracking mesh corresponding to the right controller
  55063. */
  55064. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55065. /**
  55066. * If the ray of the gaze should be displayed.
  55067. */
  55068. get displayGaze(): boolean;
  55069. /**
  55070. * Sets if the ray of the gaze should be displayed.
  55071. */
  55072. set displayGaze(value: boolean);
  55073. /**
  55074. * If the ray of the LaserPointer should be displayed.
  55075. */
  55076. get displayLaserPointer(): boolean;
  55077. /**
  55078. * Sets if the ray of the LaserPointer should be displayed.
  55079. */
  55080. set displayLaserPointer(value: boolean);
  55081. /**
  55082. * The deviceOrientationCamera used as the camera when not in VR.
  55083. */
  55084. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55085. /**
  55086. * Based on the current WebVR support, returns the current VR camera used.
  55087. */
  55088. get currentVRCamera(): Nullable<Camera>;
  55089. /**
  55090. * The webVRCamera which is used when in VR.
  55091. */
  55092. get webVRCamera(): WebVRFreeCamera;
  55093. /**
  55094. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55095. */
  55096. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55097. /**
  55098. * The html button that is used to trigger entering into VR.
  55099. */
  55100. get vrButton(): Nullable<HTMLButtonElement>;
  55101. private get _teleportationRequestInitiated();
  55102. /**
  55103. * Defines whether or not Pointer lock should be requested when switching to
  55104. * full screen.
  55105. */
  55106. requestPointerLockOnFullScreen: boolean;
  55107. /**
  55108. * If asking to force XR, this will be populated with the default xr experience
  55109. */
  55110. xr: WebXRDefaultExperience;
  55111. /**
  55112. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55113. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55114. */
  55115. xrTestDone: boolean;
  55116. /**
  55117. * Instantiates a VRExperienceHelper.
  55118. * Helps to quickly add VR support to an existing scene.
  55119. * @param scene The scene the VRExperienceHelper belongs to.
  55120. * @param webVROptions Options to modify the vr experience helper's behavior.
  55121. */
  55122. constructor(scene: Scene,
  55123. /** Options to modify the vr experience helper's behavior. */
  55124. webVROptions?: VRExperienceHelperOptions);
  55125. private completeVRInit;
  55126. private _onDefaultMeshLoaded;
  55127. private _onResize;
  55128. private _onFullscreenChange;
  55129. /**
  55130. * Gets a value indicating if we are currently in VR mode.
  55131. */
  55132. get isInVRMode(): boolean;
  55133. private onVrDisplayPresentChange;
  55134. private onVRDisplayChanged;
  55135. private moveButtonToBottomRight;
  55136. private displayVRButton;
  55137. private updateButtonVisibility;
  55138. private _cachedAngularSensibility;
  55139. /**
  55140. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55141. * Otherwise, will use the fullscreen API.
  55142. */
  55143. enterVR(): void;
  55144. /**
  55145. * Attempt to exit VR, or fullscreen.
  55146. */
  55147. exitVR(): void;
  55148. /**
  55149. * The position of the vr experience helper.
  55150. */
  55151. get position(): Vector3;
  55152. /**
  55153. * Sets the position of the vr experience helper.
  55154. */
  55155. set position(value: Vector3);
  55156. /**
  55157. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55158. */
  55159. enableInteractions(): void;
  55160. private get _noControllerIsActive();
  55161. private beforeRender;
  55162. private _isTeleportationFloor;
  55163. /**
  55164. * Adds a floor mesh to be used for teleportation.
  55165. * @param floorMesh the mesh to be used for teleportation.
  55166. */
  55167. addFloorMesh(floorMesh: Mesh): void;
  55168. /**
  55169. * Removes a floor mesh from being used for teleportation.
  55170. * @param floorMesh the mesh to be removed.
  55171. */
  55172. removeFloorMesh(floorMesh: Mesh): void;
  55173. /**
  55174. * Enables interactions and teleportation using the VR controllers and gaze.
  55175. * @param vrTeleportationOptions options to modify teleportation behavior.
  55176. */
  55177. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55178. private _onNewGamepadConnected;
  55179. private _tryEnableInteractionOnController;
  55180. private _onNewGamepadDisconnected;
  55181. private _enableInteractionOnController;
  55182. private _checkTeleportWithRay;
  55183. private _checkRotate;
  55184. private _checkTeleportBackwards;
  55185. private _enableTeleportationOnController;
  55186. private _createTeleportationCircles;
  55187. private _displayTeleportationTarget;
  55188. private _hideTeleportationTarget;
  55189. private _rotateCamera;
  55190. private _moveTeleportationSelectorTo;
  55191. private _workingVector;
  55192. private _workingQuaternion;
  55193. private _workingMatrix;
  55194. /**
  55195. * Time Constant Teleportation Mode
  55196. */
  55197. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55198. /**
  55199. * Speed Constant Teleportation Mode
  55200. */
  55201. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55202. /**
  55203. * Teleports the users feet to the desired location
  55204. * @param location The location where the user's feet should be placed
  55205. */
  55206. teleportCamera(location: Vector3): void;
  55207. private _convertNormalToDirectionOfRay;
  55208. private _castRayAndSelectObject;
  55209. private _notifySelectedMeshUnselected;
  55210. /**
  55211. * Permanently set new colors for the laser pointer
  55212. * @param color the new laser color
  55213. * @param pickedColor the new laser color when picked mesh detected
  55214. */
  55215. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55216. /**
  55217. * Set lighting enabled / disabled on the laser pointer of both controllers
  55218. * @param enabled should the lighting be enabled on the laser pointer
  55219. */
  55220. setLaserLightingState(enabled?: boolean): void;
  55221. /**
  55222. * Permanently set new colors for the gaze pointer
  55223. * @param color the new gaze color
  55224. * @param pickedColor the new gaze color when picked mesh detected
  55225. */
  55226. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55227. /**
  55228. * Sets the color of the laser ray from the vr controllers.
  55229. * @param color new color for the ray.
  55230. */
  55231. changeLaserColor(color: Color3): void;
  55232. /**
  55233. * Sets the color of the ray from the vr headsets gaze.
  55234. * @param color new color for the ray.
  55235. */
  55236. changeGazeColor(color: Color3): void;
  55237. /**
  55238. * Exits VR and disposes of the vr experience helper
  55239. */
  55240. dispose(): void;
  55241. /**
  55242. * Gets the name of the VRExperienceHelper class
  55243. * @returns "VRExperienceHelper"
  55244. */
  55245. getClassName(): string;
  55246. }
  55247. }
  55248. declare module "babylonjs/Cameras/VR/index" {
  55249. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55250. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55251. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55252. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55253. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55254. export * from "babylonjs/Cameras/VR/webVRCamera";
  55255. }
  55256. declare module "babylonjs/Cameras/RigModes/index" {
  55257. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55258. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55259. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55260. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55261. }
  55262. declare module "babylonjs/Cameras/index" {
  55263. export * from "babylonjs/Cameras/Inputs/index";
  55264. export * from "babylonjs/Cameras/cameraInputsManager";
  55265. export * from "babylonjs/Cameras/camera";
  55266. export * from "babylonjs/Cameras/targetCamera";
  55267. export * from "babylonjs/Cameras/freeCamera";
  55268. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55269. export * from "babylonjs/Cameras/touchCamera";
  55270. export * from "babylonjs/Cameras/arcRotateCamera";
  55271. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55272. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55273. export * from "babylonjs/Cameras/flyCamera";
  55274. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55275. export * from "babylonjs/Cameras/followCamera";
  55276. export * from "babylonjs/Cameras/followCameraInputsManager";
  55277. export * from "babylonjs/Cameras/gamepadCamera";
  55278. export * from "babylonjs/Cameras/Stereoscopic/index";
  55279. export * from "babylonjs/Cameras/universalCamera";
  55280. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55281. export * from "babylonjs/Cameras/VR/index";
  55282. export * from "babylonjs/Cameras/RigModes/index";
  55283. }
  55284. declare module "babylonjs/Collisions/index" {
  55285. export * from "babylonjs/Collisions/collider";
  55286. export * from "babylonjs/Collisions/collisionCoordinator";
  55287. export * from "babylonjs/Collisions/pickingInfo";
  55288. export * from "babylonjs/Collisions/intersectionInfo";
  55289. export * from "babylonjs/Collisions/meshCollisionData";
  55290. }
  55291. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55292. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55293. import { Vector3 } from "babylonjs/Maths/math.vector";
  55294. import { Ray } from "babylonjs/Culling/ray";
  55295. import { Plane } from "babylonjs/Maths/math.plane";
  55296. /**
  55297. * Contains an array of blocks representing the octree
  55298. */
  55299. export interface IOctreeContainer<T> {
  55300. /**
  55301. * Blocks within the octree
  55302. */
  55303. blocks: Array<OctreeBlock<T>>;
  55304. }
  55305. /**
  55306. * Class used to store a cell in an octree
  55307. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55308. */
  55309. export class OctreeBlock<T> {
  55310. /**
  55311. * Gets the content of the current block
  55312. */
  55313. entries: T[];
  55314. /**
  55315. * Gets the list of block children
  55316. */
  55317. blocks: Array<OctreeBlock<T>>;
  55318. private _depth;
  55319. private _maxDepth;
  55320. private _capacity;
  55321. private _minPoint;
  55322. private _maxPoint;
  55323. private _boundingVectors;
  55324. private _creationFunc;
  55325. /**
  55326. * Creates a new block
  55327. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55328. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55329. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55330. * @param depth defines the current depth of this block in the octree
  55331. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55332. * @param creationFunc defines a callback to call when an element is added to the block
  55333. */
  55334. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55335. /**
  55336. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55337. */
  55338. get capacity(): number;
  55339. /**
  55340. * Gets the minimum vector (in world space) of the block's bounding box
  55341. */
  55342. get minPoint(): Vector3;
  55343. /**
  55344. * Gets the maximum vector (in world space) of the block's bounding box
  55345. */
  55346. get maxPoint(): Vector3;
  55347. /**
  55348. * Add a new element to this block
  55349. * @param entry defines the element to add
  55350. */
  55351. addEntry(entry: T): void;
  55352. /**
  55353. * Remove an element from this block
  55354. * @param entry defines the element to remove
  55355. */
  55356. removeEntry(entry: T): void;
  55357. /**
  55358. * Add an array of elements to this block
  55359. * @param entries defines the array of elements to add
  55360. */
  55361. addEntries(entries: T[]): void;
  55362. /**
  55363. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55364. * @param frustumPlanes defines the frustum planes to test
  55365. * @param selection defines the array to store current content if selection is positive
  55366. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55367. */
  55368. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55369. /**
  55370. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55371. * @param sphereCenter defines the bounding sphere center
  55372. * @param sphereRadius defines the bounding sphere radius
  55373. * @param selection defines the array to store current content if selection is positive
  55374. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55375. */
  55376. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55377. /**
  55378. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55379. * @param ray defines the ray to test with
  55380. * @param selection defines the array to store current content if selection is positive
  55381. */
  55382. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55383. /**
  55384. * Subdivide the content into child blocks (this block will then be empty)
  55385. */
  55386. createInnerBlocks(): void;
  55387. /**
  55388. * @hidden
  55389. */
  55390. 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;
  55391. }
  55392. }
  55393. declare module "babylonjs/Culling/Octrees/octree" {
  55394. import { SmartArray } from "babylonjs/Misc/smartArray";
  55395. import { Vector3 } from "babylonjs/Maths/math.vector";
  55396. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55398. import { Ray } from "babylonjs/Culling/ray";
  55399. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55400. import { Plane } from "babylonjs/Maths/math.plane";
  55401. /**
  55402. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55403. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55404. */
  55405. export class Octree<T> {
  55406. /** 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.) */
  55407. maxDepth: number;
  55408. /**
  55409. * Blocks within the octree containing objects
  55410. */
  55411. blocks: Array<OctreeBlock<T>>;
  55412. /**
  55413. * Content stored in the octree
  55414. */
  55415. dynamicContent: T[];
  55416. private _maxBlockCapacity;
  55417. private _selectionContent;
  55418. private _creationFunc;
  55419. /**
  55420. * Creates a octree
  55421. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55422. * @param creationFunc function to be used to instatiate the octree
  55423. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55424. * @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.)
  55425. */
  55426. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55427. /** 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.) */
  55428. maxDepth?: number);
  55429. /**
  55430. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55431. * @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);
  55432. * @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);
  55433. * @param entries meshes to be added to the octree blocks
  55434. */
  55435. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55436. /**
  55437. * Adds a mesh to the octree
  55438. * @param entry Mesh to add to the octree
  55439. */
  55440. addMesh(entry: T): void;
  55441. /**
  55442. * Remove an element from the octree
  55443. * @param entry defines the element to remove
  55444. */
  55445. removeMesh(entry: T): void;
  55446. /**
  55447. * Selects an array of meshes within the frustum
  55448. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55449. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55450. * @returns array of meshes within the frustum
  55451. */
  55452. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55453. /**
  55454. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55455. * @param sphereCenter defines the bounding sphere center
  55456. * @param sphereRadius defines the bounding sphere radius
  55457. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55458. * @returns an array of objects that intersect the sphere
  55459. */
  55460. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55461. /**
  55462. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55463. * @param ray defines the ray to test with
  55464. * @returns array of intersected objects
  55465. */
  55466. intersectsRay(ray: Ray): SmartArray<T>;
  55467. /**
  55468. * Adds a mesh into the octree block if it intersects the block
  55469. */
  55470. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55471. /**
  55472. * Adds a submesh into the octree block if it intersects the block
  55473. */
  55474. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55475. }
  55476. }
  55477. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55478. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55479. import { Scene } from "babylonjs/scene";
  55480. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55482. import { Ray } from "babylonjs/Culling/ray";
  55483. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55484. import { Collider } from "babylonjs/Collisions/collider";
  55485. module "babylonjs/scene" {
  55486. interface Scene {
  55487. /**
  55488. * @hidden
  55489. * Backing Filed
  55490. */
  55491. _selectionOctree: Octree<AbstractMesh>;
  55492. /**
  55493. * Gets the octree used to boost mesh selection (picking)
  55494. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55495. */
  55496. selectionOctree: Octree<AbstractMesh>;
  55497. /**
  55498. * Creates or updates the octree used to boost selection (picking)
  55499. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55500. * @param maxCapacity defines the maximum capacity per leaf
  55501. * @param maxDepth defines the maximum depth of the octree
  55502. * @returns an octree of AbstractMesh
  55503. */
  55504. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55505. }
  55506. }
  55507. module "babylonjs/Meshes/abstractMesh" {
  55508. interface AbstractMesh {
  55509. /**
  55510. * @hidden
  55511. * Backing Field
  55512. */
  55513. _submeshesOctree: Octree<SubMesh>;
  55514. /**
  55515. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55516. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55517. * @param maxCapacity defines the maximum size of each block (64 by default)
  55518. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55519. * @returns the new octree
  55520. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55521. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55522. */
  55523. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55524. }
  55525. }
  55526. /**
  55527. * Defines the octree scene component responsible to manage any octrees
  55528. * in a given scene.
  55529. */
  55530. export class OctreeSceneComponent {
  55531. /**
  55532. * The component name help to identify the component in the list of scene components.
  55533. */
  55534. readonly name: string;
  55535. /**
  55536. * The scene the component belongs to.
  55537. */
  55538. scene: Scene;
  55539. /**
  55540. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55541. */
  55542. readonly checksIsEnabled: boolean;
  55543. /**
  55544. * Creates a new instance of the component for the given scene
  55545. * @param scene Defines the scene to register the component in
  55546. */
  55547. constructor(scene: Scene);
  55548. /**
  55549. * Registers the component in a given scene
  55550. */
  55551. register(): void;
  55552. /**
  55553. * Return the list of active meshes
  55554. * @returns the list of active meshes
  55555. */
  55556. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55557. /**
  55558. * Return the list of active sub meshes
  55559. * @param mesh The mesh to get the candidates sub meshes from
  55560. * @returns the list of active sub meshes
  55561. */
  55562. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55563. private _tempRay;
  55564. /**
  55565. * Return the list of sub meshes intersecting with a given local ray
  55566. * @param mesh defines the mesh to find the submesh for
  55567. * @param localRay defines the ray in local space
  55568. * @returns the list of intersecting sub meshes
  55569. */
  55570. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55571. /**
  55572. * Return the list of sub meshes colliding with a collider
  55573. * @param mesh defines the mesh to find the submesh for
  55574. * @param collider defines the collider to evaluate the collision against
  55575. * @returns the list of colliding sub meshes
  55576. */
  55577. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55578. /**
  55579. * Rebuilds the elements related to this component in case of
  55580. * context lost for instance.
  55581. */
  55582. rebuild(): void;
  55583. /**
  55584. * Disposes the component and the associated ressources.
  55585. */
  55586. dispose(): void;
  55587. }
  55588. }
  55589. declare module "babylonjs/Culling/Octrees/index" {
  55590. export * from "babylonjs/Culling/Octrees/octree";
  55591. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55592. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55593. }
  55594. declare module "babylonjs/Culling/index" {
  55595. export * from "babylonjs/Culling/boundingBox";
  55596. export * from "babylonjs/Culling/boundingInfo";
  55597. export * from "babylonjs/Culling/boundingSphere";
  55598. export * from "babylonjs/Culling/Octrees/index";
  55599. export * from "babylonjs/Culling/ray";
  55600. }
  55601. declare module "babylonjs/Gizmos/gizmo" {
  55602. import { Nullable } from "babylonjs/types";
  55603. import { IDisposable } from "babylonjs/scene";
  55604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55605. import { Mesh } from "babylonjs/Meshes/mesh";
  55606. import { Node } from "babylonjs/node";
  55607. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55608. /**
  55609. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55610. */
  55611. export class Gizmo implements IDisposable {
  55612. /** The utility layer the gizmo will be added to */
  55613. gizmoLayer: UtilityLayerRenderer;
  55614. /**
  55615. * The root mesh of the gizmo
  55616. */
  55617. _rootMesh: Mesh;
  55618. private _attachedMesh;
  55619. private _attachedNode;
  55620. /**
  55621. * Ratio for the scale of the gizmo (Default: 1)
  55622. */
  55623. protected _scaleRatio: number;
  55624. /**
  55625. * boolean updated by pointermove when a gizmo mesh is hovered
  55626. */
  55627. protected _isHovered: boolean;
  55628. /**
  55629. * Ratio for the scale of the gizmo (Default: 1)
  55630. */
  55631. set scaleRatio(value: number);
  55632. get scaleRatio(): number;
  55633. /**
  55634. * True when the mouse pointer is hovered a gizmo mesh
  55635. */
  55636. get isHovered(): boolean;
  55637. /**
  55638. * If a custom mesh has been set (Default: false)
  55639. */
  55640. protected _customMeshSet: boolean;
  55641. /**
  55642. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55643. * * When set, interactions will be enabled
  55644. */
  55645. get attachedMesh(): Nullable<AbstractMesh>;
  55646. set attachedMesh(value: Nullable<AbstractMesh>);
  55647. /**
  55648. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55649. * * When set, interactions will be enabled
  55650. */
  55651. get attachedNode(): Nullable<Node>;
  55652. set attachedNode(value: Nullable<Node>);
  55653. /**
  55654. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55655. * @param mesh The mesh to replace the default mesh of the gizmo
  55656. */
  55657. setCustomMesh(mesh: Mesh): void;
  55658. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  55659. /**
  55660. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  55661. */
  55662. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55663. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55664. /**
  55665. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  55666. */
  55667. updateGizmoPositionToMatchAttachedMesh: boolean;
  55668. /**
  55669. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  55670. */
  55671. updateScale: boolean;
  55672. protected _interactionsEnabled: boolean;
  55673. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55674. private _beforeRenderObserver;
  55675. private _tempQuaternion;
  55676. private _tempVector;
  55677. private _tempVector2;
  55678. private _tempMatrix1;
  55679. private _tempMatrix2;
  55680. private _rightHandtoLeftHandMatrix;
  55681. /**
  55682. * Creates a gizmo
  55683. * @param gizmoLayer The utility layer the gizmo will be added to
  55684. */
  55685. constructor(
  55686. /** The utility layer the gizmo will be added to */
  55687. gizmoLayer?: UtilityLayerRenderer);
  55688. /**
  55689. * Updates the gizmo to match the attached mesh's position/rotation
  55690. */
  55691. protected _update(): void;
  55692. /**
  55693. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  55694. * @param value Node, TransformNode or mesh
  55695. */
  55696. protected _matrixChanged(): void;
  55697. /**
  55698. * Disposes of the gizmo
  55699. */
  55700. dispose(): void;
  55701. }
  55702. }
  55703. declare module "babylonjs/Gizmos/planeDragGizmo" {
  55704. import { Observable } from "babylonjs/Misc/observable";
  55705. import { Nullable } from "babylonjs/types";
  55706. import { Vector3 } from "babylonjs/Maths/math.vector";
  55707. import { Color3 } from "babylonjs/Maths/math.color";
  55708. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55709. import { Node } from "babylonjs/node";
  55710. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55711. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55712. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55713. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55714. import { Scene } from "babylonjs/scene";
  55715. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55716. /**
  55717. * Single plane drag gizmo
  55718. */
  55719. export class PlaneDragGizmo extends Gizmo {
  55720. /**
  55721. * Drag behavior responsible for the gizmos dragging interactions
  55722. */
  55723. dragBehavior: PointerDragBehavior;
  55724. private _pointerObserver;
  55725. /**
  55726. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55727. */
  55728. snapDistance: number;
  55729. /**
  55730. * Event that fires each time the gizmo snaps to a new location.
  55731. * * snapDistance is the the change in distance
  55732. */
  55733. onSnapObservable: Observable<{
  55734. snapDistance: number;
  55735. }>;
  55736. private _plane;
  55737. private _coloredMaterial;
  55738. private _hoverMaterial;
  55739. private _isEnabled;
  55740. private _parent;
  55741. /** @hidden */
  55742. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  55743. /** @hidden */
  55744. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55745. /**
  55746. * Creates a PlaneDragGizmo
  55747. * @param gizmoLayer The utility layer the gizmo will be added to
  55748. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  55749. * @param color The color of the gizmo
  55750. */
  55751. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  55752. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55753. /**
  55754. * If the gizmo is enabled
  55755. */
  55756. set isEnabled(value: boolean);
  55757. get isEnabled(): boolean;
  55758. /**
  55759. * Disposes of the gizmo
  55760. */
  55761. dispose(): void;
  55762. }
  55763. }
  55764. declare module "babylonjs/Gizmos/positionGizmo" {
  55765. import { Observable } from "babylonjs/Misc/observable";
  55766. import { Nullable } from "babylonjs/types";
  55767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55768. import { Node } from "babylonjs/node";
  55769. import { Mesh } from "babylonjs/Meshes/mesh";
  55770. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55771. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  55772. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  55773. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55774. /**
  55775. * Gizmo that enables dragging a mesh along 3 axis
  55776. */
  55777. export class PositionGizmo extends Gizmo {
  55778. /**
  55779. * Internal gizmo used for interactions on the x axis
  55780. */
  55781. xGizmo: AxisDragGizmo;
  55782. /**
  55783. * Internal gizmo used for interactions on the y axis
  55784. */
  55785. yGizmo: AxisDragGizmo;
  55786. /**
  55787. * Internal gizmo used for interactions on the z axis
  55788. */
  55789. zGizmo: AxisDragGizmo;
  55790. /**
  55791. * Internal gizmo used for interactions on the yz plane
  55792. */
  55793. xPlaneGizmo: PlaneDragGizmo;
  55794. /**
  55795. * Internal gizmo used for interactions on the xz plane
  55796. */
  55797. yPlaneGizmo: PlaneDragGizmo;
  55798. /**
  55799. * Internal gizmo used for interactions on the xy plane
  55800. */
  55801. zPlaneGizmo: PlaneDragGizmo;
  55802. /**
  55803. * private variables
  55804. */
  55805. private _meshAttached;
  55806. private _nodeAttached;
  55807. private _snapDistance;
  55808. /** Fires an event when any of it's sub gizmos are dragged */
  55809. onDragStartObservable: Observable<unknown>;
  55810. /** Fires an event when any of it's sub gizmos are released from dragging */
  55811. onDragEndObservable: Observable<unknown>;
  55812. /**
  55813. * If set to true, planar drag is enabled
  55814. */
  55815. private _planarGizmoEnabled;
  55816. get attachedMesh(): Nullable<AbstractMesh>;
  55817. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55818. get attachedNode(): Nullable<Node>;
  55819. set attachedNode(node: Nullable<Node>);
  55820. /**
  55821. * True when the mouse pointer is hovering a gizmo mesh
  55822. */
  55823. get isHovered(): boolean;
  55824. /**
  55825. * Creates a PositionGizmo
  55826. * @param gizmoLayer The utility layer the gizmo will be added to
  55827. @param thickness display gizmo axis thickness
  55828. */
  55829. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55830. /**
  55831. * If the planar drag gizmo is enabled
  55832. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  55833. */
  55834. set planarGizmoEnabled(value: boolean);
  55835. get planarGizmoEnabled(): boolean;
  55836. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55837. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55838. /**
  55839. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55840. */
  55841. set snapDistance(value: number);
  55842. get snapDistance(): number;
  55843. /**
  55844. * Ratio for the scale of the gizmo (Default: 1)
  55845. */
  55846. set scaleRatio(value: number);
  55847. get scaleRatio(): number;
  55848. /**
  55849. * Disposes of the gizmo
  55850. */
  55851. dispose(): void;
  55852. /**
  55853. * CustomMeshes are not supported by this gizmo
  55854. * @param mesh The mesh to replace the default mesh of the gizmo
  55855. */
  55856. setCustomMesh(mesh: Mesh): void;
  55857. }
  55858. }
  55859. declare module "babylonjs/Gizmos/axisDragGizmo" {
  55860. import { Observable } from "babylonjs/Misc/observable";
  55861. import { Nullable } from "babylonjs/types";
  55862. import { Vector3 } from "babylonjs/Maths/math.vector";
  55863. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55864. import { Node } from "babylonjs/node";
  55865. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55866. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55867. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55868. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55869. import { Scene } from "babylonjs/scene";
  55870. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55871. import { Color3 } from "babylonjs/Maths/math.color";
  55872. /**
  55873. * Single axis drag gizmo
  55874. */
  55875. export class AxisDragGizmo extends Gizmo {
  55876. /**
  55877. * Drag behavior responsible for the gizmos dragging interactions
  55878. */
  55879. dragBehavior: PointerDragBehavior;
  55880. private _pointerObserver;
  55881. /**
  55882. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55883. */
  55884. snapDistance: number;
  55885. /**
  55886. * Event that fires each time the gizmo snaps to a new location.
  55887. * * snapDistance is the the change in distance
  55888. */
  55889. onSnapObservable: Observable<{
  55890. snapDistance: number;
  55891. }>;
  55892. private _isEnabled;
  55893. private _parent;
  55894. private _arrow;
  55895. private _coloredMaterial;
  55896. private _hoverMaterial;
  55897. /** @hidden */
  55898. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  55899. /** @hidden */
  55900. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55901. /**
  55902. * Creates an AxisDragGizmo
  55903. * @param gizmoLayer The utility layer the gizmo will be added to
  55904. * @param dragAxis The axis which the gizmo will be able to drag on
  55905. * @param color The color of the gizmo
  55906. * @param thickness display gizmo axis thickness
  55907. */
  55908. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55909. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55910. /**
  55911. * If the gizmo is enabled
  55912. */
  55913. set isEnabled(value: boolean);
  55914. get isEnabled(): boolean;
  55915. /**
  55916. * Disposes of the gizmo
  55917. */
  55918. dispose(): void;
  55919. }
  55920. }
  55921. declare module "babylonjs/Debug/axesViewer" {
  55922. import { Vector3 } from "babylonjs/Maths/math.vector";
  55923. import { Nullable } from "babylonjs/types";
  55924. import { Scene } from "babylonjs/scene";
  55925. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55926. /**
  55927. * The Axes viewer will show 3 axes in a specific point in space
  55928. */
  55929. export class AxesViewer {
  55930. private _xAxis;
  55931. private _yAxis;
  55932. private _zAxis;
  55933. private _scaleLinesFactor;
  55934. private _instanced;
  55935. /**
  55936. * Gets the hosting scene
  55937. */
  55938. scene: Nullable<Scene>;
  55939. /**
  55940. * Gets or sets a number used to scale line length
  55941. */
  55942. scaleLines: number;
  55943. /** Gets the node hierarchy used to render x-axis */
  55944. get xAxis(): TransformNode;
  55945. /** Gets the node hierarchy used to render y-axis */
  55946. get yAxis(): TransformNode;
  55947. /** Gets the node hierarchy used to render z-axis */
  55948. get zAxis(): TransformNode;
  55949. /**
  55950. * Creates a new AxesViewer
  55951. * @param scene defines the hosting scene
  55952. * @param scaleLines defines a number used to scale line length (1 by default)
  55953. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55954. * @param xAxis defines the node hierarchy used to render the x-axis
  55955. * @param yAxis defines the node hierarchy used to render the y-axis
  55956. * @param zAxis defines the node hierarchy used to render the z-axis
  55957. */
  55958. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55959. /**
  55960. * Force the viewer to update
  55961. * @param position defines the position of the viewer
  55962. * @param xaxis defines the x axis of the viewer
  55963. * @param yaxis defines the y axis of the viewer
  55964. * @param zaxis defines the z axis of the viewer
  55965. */
  55966. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55967. /**
  55968. * Creates an instance of this axes viewer.
  55969. * @returns a new axes viewer with instanced meshes
  55970. */
  55971. createInstance(): AxesViewer;
  55972. /** Releases resources */
  55973. dispose(): void;
  55974. private static _SetRenderingGroupId;
  55975. }
  55976. }
  55977. declare module "babylonjs/Debug/boneAxesViewer" {
  55978. import { Nullable } from "babylonjs/types";
  55979. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  55980. import { Vector3 } from "babylonjs/Maths/math.vector";
  55981. import { Mesh } from "babylonjs/Meshes/mesh";
  55982. import { Bone } from "babylonjs/Bones/bone";
  55983. import { Scene } from "babylonjs/scene";
  55984. /**
  55985. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55986. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55987. */
  55988. export class BoneAxesViewer extends AxesViewer {
  55989. /**
  55990. * Gets or sets the target mesh where to display the axes viewer
  55991. */
  55992. mesh: Nullable<Mesh>;
  55993. /**
  55994. * Gets or sets the target bone where to display the axes viewer
  55995. */
  55996. bone: Nullable<Bone>;
  55997. /** Gets current position */
  55998. pos: Vector3;
  55999. /** Gets direction of X axis */
  56000. xaxis: Vector3;
  56001. /** Gets direction of Y axis */
  56002. yaxis: Vector3;
  56003. /** Gets direction of Z axis */
  56004. zaxis: Vector3;
  56005. /**
  56006. * Creates a new BoneAxesViewer
  56007. * @param scene defines the hosting scene
  56008. * @param bone defines the target bone
  56009. * @param mesh defines the target mesh
  56010. * @param scaleLines defines a scaling factor for line length (1 by default)
  56011. */
  56012. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  56013. /**
  56014. * Force the viewer to update
  56015. */
  56016. update(): void;
  56017. /** Releases resources */
  56018. dispose(): void;
  56019. }
  56020. }
  56021. declare module "babylonjs/Debug/debugLayer" {
  56022. import { Scene } from "babylonjs/scene";
  56023. /**
  56024. * Interface used to define scene explorer extensibility option
  56025. */
  56026. export interface IExplorerExtensibilityOption {
  56027. /**
  56028. * Define the option label
  56029. */
  56030. label: string;
  56031. /**
  56032. * Defines the action to execute on click
  56033. */
  56034. action: (entity: any) => void;
  56035. }
  56036. /**
  56037. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  56038. */
  56039. export interface IExplorerExtensibilityGroup {
  56040. /**
  56041. * Defines a predicate to test if a given type mut be extended
  56042. */
  56043. predicate: (entity: any) => boolean;
  56044. /**
  56045. * Gets the list of options added to a type
  56046. */
  56047. entries: IExplorerExtensibilityOption[];
  56048. }
  56049. /**
  56050. * Interface used to define the options to use to create the Inspector
  56051. */
  56052. export interface IInspectorOptions {
  56053. /**
  56054. * Display in overlay mode (default: false)
  56055. */
  56056. overlay?: boolean;
  56057. /**
  56058. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  56059. */
  56060. globalRoot?: HTMLElement;
  56061. /**
  56062. * Display the Scene explorer
  56063. */
  56064. showExplorer?: boolean;
  56065. /**
  56066. * Display the property inspector
  56067. */
  56068. showInspector?: boolean;
  56069. /**
  56070. * Display in embed mode (both panes on the right)
  56071. */
  56072. embedMode?: boolean;
  56073. /**
  56074. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  56075. */
  56076. handleResize?: boolean;
  56077. /**
  56078. * Allow the panes to popup (default: true)
  56079. */
  56080. enablePopup?: boolean;
  56081. /**
  56082. * Allow the panes to be closed by users (default: true)
  56083. */
  56084. enableClose?: boolean;
  56085. /**
  56086. * Optional list of extensibility entries
  56087. */
  56088. explorerExtensibility?: IExplorerExtensibilityGroup[];
  56089. /**
  56090. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  56091. */
  56092. inspectorURL?: string;
  56093. /**
  56094. * Optional initial tab (default to DebugLayerTab.Properties)
  56095. */
  56096. initialTab?: DebugLayerTab;
  56097. }
  56098. module "babylonjs/scene" {
  56099. interface Scene {
  56100. /**
  56101. * @hidden
  56102. * Backing field
  56103. */
  56104. _debugLayer: DebugLayer;
  56105. /**
  56106. * Gets the debug layer (aka Inspector) associated with the scene
  56107. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56108. */
  56109. debugLayer: DebugLayer;
  56110. }
  56111. }
  56112. /**
  56113. * Enum of inspector action tab
  56114. */
  56115. export enum DebugLayerTab {
  56116. /**
  56117. * Properties tag (default)
  56118. */
  56119. Properties = 0,
  56120. /**
  56121. * Debug tab
  56122. */
  56123. Debug = 1,
  56124. /**
  56125. * Statistics tab
  56126. */
  56127. Statistics = 2,
  56128. /**
  56129. * Tools tab
  56130. */
  56131. Tools = 3,
  56132. /**
  56133. * Settings tab
  56134. */
  56135. Settings = 4
  56136. }
  56137. /**
  56138. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56139. * what is happening in your scene
  56140. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56141. */
  56142. export class DebugLayer {
  56143. /**
  56144. * Define the url to get the inspector script from.
  56145. * By default it uses the babylonjs CDN.
  56146. * @ignoreNaming
  56147. */
  56148. static InspectorURL: string;
  56149. private _scene;
  56150. private BJSINSPECTOR;
  56151. private _onPropertyChangedObservable?;
  56152. /**
  56153. * Observable triggered when a property is changed through the inspector.
  56154. */
  56155. get onPropertyChangedObservable(): any;
  56156. /**
  56157. * Instantiates a new debug layer.
  56158. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56159. * what is happening in your scene
  56160. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56161. * @param scene Defines the scene to inspect
  56162. */
  56163. constructor(scene: Scene);
  56164. /** Creates the inspector window. */
  56165. private _createInspector;
  56166. /**
  56167. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56168. * @param entity defines the entity to select
  56169. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56170. */
  56171. select(entity: any, lineContainerTitles?: string | string[]): void;
  56172. /** Get the inspector from bundle or global */
  56173. private _getGlobalInspector;
  56174. /**
  56175. * Get if the inspector is visible or not.
  56176. * @returns true if visible otherwise, false
  56177. */
  56178. isVisible(): boolean;
  56179. /**
  56180. * Hide the inspector and close its window.
  56181. */
  56182. hide(): void;
  56183. /**
  56184. * Update the scene in the inspector
  56185. */
  56186. setAsActiveScene(): void;
  56187. /**
  56188. * Launch the debugLayer.
  56189. * @param config Define the configuration of the inspector
  56190. * @return a promise fulfilled when the debug layer is visible
  56191. */
  56192. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56193. }
  56194. }
  56195. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56196. import { Nullable } from "babylonjs/types";
  56197. import { Scene } from "babylonjs/scene";
  56198. import { Vector4 } from "babylonjs/Maths/math.vector";
  56199. import { Color4 } from "babylonjs/Maths/math.color";
  56200. import { Mesh } from "babylonjs/Meshes/mesh";
  56201. /**
  56202. * Class containing static functions to help procedurally build meshes
  56203. */
  56204. export class BoxBuilder {
  56205. /**
  56206. * Creates a box mesh
  56207. * * The parameter `size` sets the size (float) of each box side (default 1)
  56208. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56209. * * 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)
  56210. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56214. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56215. * @param name defines the name of the mesh
  56216. * @param options defines the options used to create the mesh
  56217. * @param scene defines the hosting scene
  56218. * @returns the box mesh
  56219. */
  56220. static CreateBox(name: string, options: {
  56221. size?: number;
  56222. width?: number;
  56223. height?: number;
  56224. depth?: number;
  56225. faceUV?: Vector4[];
  56226. faceColors?: Color4[];
  56227. sideOrientation?: number;
  56228. frontUVs?: Vector4;
  56229. backUVs?: Vector4;
  56230. wrap?: boolean;
  56231. topBaseAt?: number;
  56232. bottomBaseAt?: number;
  56233. updatable?: boolean;
  56234. }, scene?: Nullable<Scene>): Mesh;
  56235. }
  56236. }
  56237. declare module "babylonjs/Debug/physicsViewer" {
  56238. import { Nullable } from "babylonjs/types";
  56239. import { Scene } from "babylonjs/scene";
  56240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56241. import { Mesh } from "babylonjs/Meshes/mesh";
  56242. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56243. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56244. /**
  56245. * Used to show the physics impostor around the specific mesh
  56246. */
  56247. export class PhysicsViewer {
  56248. /** @hidden */
  56249. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56250. /** @hidden */
  56251. protected _meshes: Array<Nullable<AbstractMesh>>;
  56252. /** @hidden */
  56253. protected _scene: Nullable<Scene>;
  56254. /** @hidden */
  56255. protected _numMeshes: number;
  56256. /** @hidden */
  56257. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56258. private _renderFunction;
  56259. private _utilityLayer;
  56260. private _debugBoxMesh;
  56261. private _debugSphereMesh;
  56262. private _debugCylinderMesh;
  56263. private _debugMaterial;
  56264. private _debugMeshMeshes;
  56265. /**
  56266. * Creates a new PhysicsViewer
  56267. * @param scene defines the hosting scene
  56268. */
  56269. constructor(scene: Scene);
  56270. /** @hidden */
  56271. protected _updateDebugMeshes(): void;
  56272. /**
  56273. * Renders a specified physic impostor
  56274. * @param impostor defines the impostor to render
  56275. * @param targetMesh defines the mesh represented by the impostor
  56276. * @returns the new debug mesh used to render the impostor
  56277. */
  56278. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56279. /**
  56280. * Hides a specified physic impostor
  56281. * @param impostor defines the impostor to hide
  56282. */
  56283. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56284. private _getDebugMaterial;
  56285. private _getDebugBoxMesh;
  56286. private _getDebugSphereMesh;
  56287. private _getDebugCylinderMesh;
  56288. private _getDebugMeshMesh;
  56289. private _getDebugMesh;
  56290. /** Releases all resources */
  56291. dispose(): void;
  56292. }
  56293. }
  56294. declare module "babylonjs/Debug/rayHelper" {
  56295. import { Nullable } from "babylonjs/types";
  56296. import { Ray } from "babylonjs/Culling/ray";
  56297. import { Vector3 } from "babylonjs/Maths/math.vector";
  56298. import { Color3 } from "babylonjs/Maths/math.color";
  56299. import { Scene } from "babylonjs/scene";
  56300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56301. import "babylonjs/Meshes/Builders/linesBuilder";
  56302. /**
  56303. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56304. * in order to better appreciate the issue one might have.
  56305. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56306. */
  56307. export class RayHelper {
  56308. /**
  56309. * Defines the ray we are currently tryin to visualize.
  56310. */
  56311. ray: Nullable<Ray>;
  56312. private _renderPoints;
  56313. private _renderLine;
  56314. private _renderFunction;
  56315. private _scene;
  56316. private _onAfterRenderObserver;
  56317. private _onAfterStepObserver;
  56318. private _attachedToMesh;
  56319. private _meshSpaceDirection;
  56320. private _meshSpaceOrigin;
  56321. /**
  56322. * Helper function to create a colored helper in a scene in one line.
  56323. * @param ray Defines the ray we are currently tryin to visualize
  56324. * @param scene Defines the scene the ray is used in
  56325. * @param color Defines the color we want to see the ray in
  56326. * @returns The newly created ray helper.
  56327. */
  56328. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56329. /**
  56330. * Instantiate a new ray helper.
  56331. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56332. * in order to better appreciate the issue one might have.
  56333. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56334. * @param ray Defines the ray we are currently tryin to visualize
  56335. */
  56336. constructor(ray: Ray);
  56337. /**
  56338. * Shows the ray we are willing to debug.
  56339. * @param scene Defines the scene the ray needs to be rendered in
  56340. * @param color Defines the color the ray needs to be rendered in
  56341. */
  56342. show(scene: Scene, color?: Color3): void;
  56343. /**
  56344. * Hides the ray we are debugging.
  56345. */
  56346. hide(): void;
  56347. private _render;
  56348. /**
  56349. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56350. * @param mesh Defines the mesh we want the helper attached to
  56351. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56352. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56353. * @param length Defines the length of the ray
  56354. */
  56355. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56356. /**
  56357. * Detach the ray helper from the mesh it has previously been attached to.
  56358. */
  56359. detachFromMesh(): void;
  56360. private _updateToMesh;
  56361. /**
  56362. * Dispose the helper and release its associated resources.
  56363. */
  56364. dispose(): void;
  56365. }
  56366. }
  56367. declare module "babylonjs/Debug/ISkeletonViewer" {
  56368. import { Skeleton } from "babylonjs/Bones/skeleton";
  56369. import { Color3 } from "babylonjs/Maths/math.color";
  56370. /**
  56371. * Defines the options associated with the creation of a SkeletonViewer.
  56372. */
  56373. export interface ISkeletonViewerOptions {
  56374. /** Should the system pause animations before building the Viewer? */
  56375. pauseAnimations: boolean;
  56376. /** Should the system return the skeleton to rest before building? */
  56377. returnToRest: boolean;
  56378. /** public Display Mode of the Viewer */
  56379. displayMode: number;
  56380. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56381. displayOptions: ISkeletonViewerDisplayOptions;
  56382. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56383. computeBonesUsingShaders: boolean;
  56384. /** Flag ignore non weighted bones */
  56385. useAllBones: boolean;
  56386. }
  56387. /**
  56388. * Defines how to display the various bone meshes for the viewer.
  56389. */
  56390. export interface ISkeletonViewerDisplayOptions {
  56391. /** How far down to start tapering the bone spurs */
  56392. midStep?: number;
  56393. /** How big is the midStep? */
  56394. midStepFactor?: number;
  56395. /** Base for the Sphere Size */
  56396. sphereBaseSize?: number;
  56397. /** The ratio of the sphere to the longest bone in units */
  56398. sphereScaleUnit?: number;
  56399. /** Ratio for the Sphere Size */
  56400. sphereFactor?: number;
  56401. /** Whether a spur should attach its far end to the child bone position */
  56402. spurFollowsChild?: boolean;
  56403. /** Whether to show local axes or not */
  56404. showLocalAxes?: boolean;
  56405. /** Length of each local axis */
  56406. localAxesSize?: number;
  56407. }
  56408. /**
  56409. * Defines the constructor options for the BoneWeight Shader.
  56410. */
  56411. export interface IBoneWeightShaderOptions {
  56412. /** Skeleton to Map */
  56413. skeleton: Skeleton;
  56414. /** Colors for Uninfluenced bones */
  56415. colorBase?: Color3;
  56416. /** Colors for 0.0-0.25 Weight bones */
  56417. colorZero?: Color3;
  56418. /** Color for 0.25-0.5 Weight Influence */
  56419. colorQuarter?: Color3;
  56420. /** Color for 0.5-0.75 Weight Influence */
  56421. colorHalf?: Color3;
  56422. /** Color for 0.75-1 Weight Influence */
  56423. colorFull?: Color3;
  56424. /** Color for Zero Weight Influence */
  56425. targetBoneIndex?: number;
  56426. }
  56427. /**
  56428. * Simple structure of the gradient steps for the Color Map.
  56429. */
  56430. export interface ISkeletonMapShaderColorMapKnot {
  56431. /** Color of the Knot */
  56432. color: Color3;
  56433. /** Location of the Knot */
  56434. location: number;
  56435. }
  56436. /**
  56437. * Defines the constructor options for the SkeletonMap Shader.
  56438. */
  56439. export interface ISkeletonMapShaderOptions {
  56440. /** Skeleton to Map */
  56441. skeleton: Skeleton;
  56442. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56443. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56444. }
  56445. }
  56446. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56447. import { Nullable } from "babylonjs/types";
  56448. import { Scene } from "babylonjs/scene";
  56449. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56450. import { Color4 } from "babylonjs/Maths/math.color";
  56451. import { Mesh } from "babylonjs/Meshes/mesh";
  56452. /**
  56453. * Class containing static functions to help procedurally build meshes
  56454. */
  56455. export class RibbonBuilder {
  56456. /**
  56457. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56458. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56459. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56460. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56461. * * 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
  56462. * * 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
  56463. * * 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
  56464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56467. * * 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
  56468. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56469. * * 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
  56470. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56472. * @param name defines the name of the mesh
  56473. * @param options defines the options used to create the mesh
  56474. * @param scene defines the hosting scene
  56475. * @returns the ribbon mesh
  56476. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56477. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56478. */
  56479. static CreateRibbon(name: string, options: {
  56480. pathArray: Vector3[][];
  56481. closeArray?: boolean;
  56482. closePath?: boolean;
  56483. offset?: number;
  56484. updatable?: boolean;
  56485. sideOrientation?: number;
  56486. frontUVs?: Vector4;
  56487. backUVs?: Vector4;
  56488. instance?: Mesh;
  56489. invertUV?: boolean;
  56490. uvs?: Vector2[];
  56491. colors?: Color4[];
  56492. }, scene?: Nullable<Scene>): Mesh;
  56493. }
  56494. }
  56495. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56496. import { Nullable } from "babylonjs/types";
  56497. import { Scene } from "babylonjs/scene";
  56498. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56499. import { Mesh } from "babylonjs/Meshes/mesh";
  56500. /**
  56501. * Class containing static functions to help procedurally build meshes
  56502. */
  56503. export class ShapeBuilder {
  56504. /**
  56505. * 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.
  56506. * * 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.
  56507. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56508. * * 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.
  56509. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56510. * * 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
  56511. * * 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
  56512. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56517. * @param name defines the name of the mesh
  56518. * @param options defines the options used to create the mesh
  56519. * @param scene defines the hosting scene
  56520. * @returns the extruded shape mesh
  56521. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56523. */
  56524. static ExtrudeShape(name: string, options: {
  56525. shape: Vector3[];
  56526. path: Vector3[];
  56527. scale?: number;
  56528. rotation?: number;
  56529. cap?: number;
  56530. updatable?: boolean;
  56531. sideOrientation?: number;
  56532. frontUVs?: Vector4;
  56533. backUVs?: Vector4;
  56534. instance?: Mesh;
  56535. invertUV?: boolean;
  56536. }, scene?: Nullable<Scene>): Mesh;
  56537. /**
  56538. * Creates an custom extruded shape mesh.
  56539. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56540. * * 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.
  56541. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56542. * * 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
  56543. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56544. * * 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
  56545. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56546. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56547. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56548. * * 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
  56549. * * 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
  56550. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56553. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56555. * @param name defines the name of the mesh
  56556. * @param options defines the options used to create the mesh
  56557. * @param scene defines the hosting scene
  56558. * @returns the custom extruded shape mesh
  56559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56562. */
  56563. static ExtrudeShapeCustom(name: string, options: {
  56564. shape: Vector3[];
  56565. path: Vector3[];
  56566. scaleFunction?: any;
  56567. rotationFunction?: any;
  56568. ribbonCloseArray?: boolean;
  56569. ribbonClosePath?: boolean;
  56570. cap?: number;
  56571. updatable?: boolean;
  56572. sideOrientation?: number;
  56573. frontUVs?: Vector4;
  56574. backUVs?: Vector4;
  56575. instance?: Mesh;
  56576. invertUV?: boolean;
  56577. }, scene?: Nullable<Scene>): Mesh;
  56578. private static _ExtrudeShapeGeneric;
  56579. }
  56580. }
  56581. declare module "babylonjs/Debug/skeletonViewer" {
  56582. import { Color3 } from "babylonjs/Maths/math.color";
  56583. import { Scene } from "babylonjs/scene";
  56584. import { Nullable } from "babylonjs/types";
  56585. import { Skeleton } from "babylonjs/Bones/skeleton";
  56586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56587. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56588. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56589. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56590. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56591. /**
  56592. * Class used to render a debug view of a given skeleton
  56593. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56594. */
  56595. export class SkeletonViewer {
  56596. /** defines the skeleton to render */
  56597. skeleton: Skeleton;
  56598. /** defines the mesh attached to the skeleton */
  56599. mesh: AbstractMesh;
  56600. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56601. autoUpdateBonesMatrices: boolean;
  56602. /** defines the rendering group id to use with the viewer */
  56603. renderingGroupId: number;
  56604. /** is the options for the viewer */
  56605. options: Partial<ISkeletonViewerOptions>;
  56606. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56607. static readonly DISPLAY_LINES: number;
  56608. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56609. static readonly DISPLAY_SPHERES: number;
  56610. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56611. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56612. /** public static method to create a BoneWeight Shader
  56613. * @param options The constructor options
  56614. * @param scene The scene that the shader is scoped to
  56615. * @returns The created ShaderMaterial
  56616. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56617. */
  56618. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56619. /** public static method to create a BoneWeight Shader
  56620. * @param options The constructor options
  56621. * @param scene The scene that the shader is scoped to
  56622. * @returns The created ShaderMaterial
  56623. */
  56624. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56625. /** private static method to create a BoneWeight Shader
  56626. * @param size The size of the buffer to create (usually the bone count)
  56627. * @param colorMap The gradient data to generate
  56628. * @param scene The scene that the shader is scoped to
  56629. * @returns an Array of floats from the color gradient values
  56630. */
  56631. private static _CreateBoneMapColorBuffer;
  56632. /** If SkeletonViewer scene scope. */
  56633. private _scene;
  56634. /** Gets or sets the color used to render the skeleton */
  56635. color: Color3;
  56636. /** Array of the points of the skeleton fo the line view. */
  56637. private _debugLines;
  56638. /** The SkeletonViewers Mesh. */
  56639. private _debugMesh;
  56640. /** The local axes Meshes. */
  56641. private _localAxes;
  56642. /** If SkeletonViewer is enabled. */
  56643. private _isEnabled;
  56644. /** If SkeletonViewer is ready. */
  56645. private _ready;
  56646. /** SkeletonViewer render observable. */
  56647. private _obs;
  56648. /** The Utility Layer to render the gizmos in. */
  56649. private _utilityLayer;
  56650. private _boneIndices;
  56651. /** Gets the Scene. */
  56652. get scene(): Scene;
  56653. /** Gets the utilityLayer. */
  56654. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  56655. /** Checks Ready Status. */
  56656. get isReady(): Boolean;
  56657. /** Sets Ready Status. */
  56658. set ready(value: boolean);
  56659. /** Gets the debugMesh */
  56660. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  56661. /** Sets the debugMesh */
  56662. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  56663. /** Gets the displayMode */
  56664. get displayMode(): number;
  56665. /** Sets the displayMode */
  56666. set displayMode(value: number);
  56667. /**
  56668. * Creates a new SkeletonViewer
  56669. * @param skeleton defines the skeleton to render
  56670. * @param mesh defines the mesh attached to the skeleton
  56671. * @param scene defines the hosting scene
  56672. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  56673. * @param renderingGroupId defines the rendering group id to use with the viewer
  56674. * @param options All of the extra constructor options for the SkeletonViewer
  56675. */
  56676. constructor(
  56677. /** defines the skeleton to render */
  56678. skeleton: Skeleton,
  56679. /** defines the mesh attached to the skeleton */
  56680. mesh: AbstractMesh,
  56681. /** The Scene scope*/
  56682. scene: Scene,
  56683. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56684. autoUpdateBonesMatrices?: boolean,
  56685. /** defines the rendering group id to use with the viewer */
  56686. renderingGroupId?: number,
  56687. /** is the options for the viewer */
  56688. options?: Partial<ISkeletonViewerOptions>);
  56689. /** The Dynamic bindings for the update functions */
  56690. private _bindObs;
  56691. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  56692. update(): void;
  56693. /** Gets or sets a boolean indicating if the viewer is enabled */
  56694. set isEnabled(value: boolean);
  56695. get isEnabled(): boolean;
  56696. private _getBonePosition;
  56697. private _getLinesForBonesWithLength;
  56698. private _getLinesForBonesNoLength;
  56699. /** function to revert the mesh and scene back to the initial state. */
  56700. private _revert;
  56701. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  56702. private _getAbsoluteBindPoseToRef;
  56703. /** function to build and bind sphere joint points and spur bone representations. */
  56704. private _buildSpheresAndSpurs;
  56705. private _buildLocalAxes;
  56706. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  56707. private _displayLinesUpdate;
  56708. /** Changes the displayMode of the skeleton viewer
  56709. * @param mode The displayMode numerical value
  56710. */
  56711. changeDisplayMode(mode: number): void;
  56712. /** Sets a display option of the skeleton viewer
  56713. *
  56714. * | Option | Type | Default | Description |
  56715. * | ---------------- | ------- | ------- | ----------- |
  56716. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56717. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56718. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56719. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56720. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  56721. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  56722. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  56723. *
  56724. * @param option String of the option name
  56725. * @param value The numerical option value
  56726. */
  56727. changeDisplayOptions(option: string, value: number): void;
  56728. /** Release associated resources */
  56729. dispose(): void;
  56730. }
  56731. }
  56732. declare module "babylonjs/Debug/index" {
  56733. export * from "babylonjs/Debug/axesViewer";
  56734. export * from "babylonjs/Debug/boneAxesViewer";
  56735. export * from "babylonjs/Debug/debugLayer";
  56736. export * from "babylonjs/Debug/physicsViewer";
  56737. export * from "babylonjs/Debug/rayHelper";
  56738. export * from "babylonjs/Debug/skeletonViewer";
  56739. export * from "babylonjs/Debug/ISkeletonViewer";
  56740. }
  56741. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  56742. /**
  56743. * Enum for Device Types
  56744. */
  56745. export enum DeviceType {
  56746. /** Generic */
  56747. Generic = 0,
  56748. /** Keyboard */
  56749. Keyboard = 1,
  56750. /** Mouse */
  56751. Mouse = 2,
  56752. /** Touch Pointers */
  56753. Touch = 3,
  56754. /** PS4 Dual Shock */
  56755. DualShock = 4,
  56756. /** Xbox */
  56757. Xbox = 5,
  56758. /** Switch Controller */
  56759. Switch = 6
  56760. }
  56761. /**
  56762. * Enum for All Pointers (Touch/Mouse)
  56763. */
  56764. export enum PointerInput {
  56765. /** Horizontal Axis */
  56766. Horizontal = 0,
  56767. /** Vertical Axis */
  56768. Vertical = 1,
  56769. /** Left Click or Touch */
  56770. LeftClick = 2,
  56771. /** Middle Click */
  56772. MiddleClick = 3,
  56773. /** Right Click */
  56774. RightClick = 4,
  56775. /** Browser Back */
  56776. BrowserBack = 5,
  56777. /** Browser Forward */
  56778. BrowserForward = 6
  56779. }
  56780. /**
  56781. * Enum for Dual Shock Gamepad
  56782. */
  56783. export enum DualShockInput {
  56784. /** Cross */
  56785. Cross = 0,
  56786. /** Circle */
  56787. Circle = 1,
  56788. /** Square */
  56789. Square = 2,
  56790. /** Triangle */
  56791. Triangle = 3,
  56792. /** L1 */
  56793. L1 = 4,
  56794. /** R1 */
  56795. R1 = 5,
  56796. /** L2 */
  56797. L2 = 6,
  56798. /** R2 */
  56799. R2 = 7,
  56800. /** Share */
  56801. Share = 8,
  56802. /** Options */
  56803. Options = 9,
  56804. /** L3 */
  56805. L3 = 10,
  56806. /** R3 */
  56807. R3 = 11,
  56808. /** DPadUp */
  56809. DPadUp = 12,
  56810. /** DPadDown */
  56811. DPadDown = 13,
  56812. /** DPadLeft */
  56813. DPadLeft = 14,
  56814. /** DRight */
  56815. DPadRight = 15,
  56816. /** Home */
  56817. Home = 16,
  56818. /** TouchPad */
  56819. TouchPad = 17,
  56820. /** LStickXAxis */
  56821. LStickXAxis = 18,
  56822. /** LStickYAxis */
  56823. LStickYAxis = 19,
  56824. /** RStickXAxis */
  56825. RStickXAxis = 20,
  56826. /** RStickYAxis */
  56827. RStickYAxis = 21
  56828. }
  56829. /**
  56830. * Enum for Xbox Gamepad
  56831. */
  56832. export enum XboxInput {
  56833. /** A */
  56834. A = 0,
  56835. /** B */
  56836. B = 1,
  56837. /** X */
  56838. X = 2,
  56839. /** Y */
  56840. Y = 3,
  56841. /** LB */
  56842. LB = 4,
  56843. /** RB */
  56844. RB = 5,
  56845. /** LT */
  56846. LT = 6,
  56847. /** RT */
  56848. RT = 7,
  56849. /** Back */
  56850. Back = 8,
  56851. /** Start */
  56852. Start = 9,
  56853. /** LS */
  56854. LS = 10,
  56855. /** RS */
  56856. RS = 11,
  56857. /** DPadUp */
  56858. DPadUp = 12,
  56859. /** DPadDown */
  56860. DPadDown = 13,
  56861. /** DPadLeft */
  56862. DPadLeft = 14,
  56863. /** DRight */
  56864. DPadRight = 15,
  56865. /** Home */
  56866. Home = 16,
  56867. /** LStickXAxis */
  56868. LStickXAxis = 17,
  56869. /** LStickYAxis */
  56870. LStickYAxis = 18,
  56871. /** RStickXAxis */
  56872. RStickXAxis = 19,
  56873. /** RStickYAxis */
  56874. RStickYAxis = 20
  56875. }
  56876. /**
  56877. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  56878. */
  56879. export enum SwitchInput {
  56880. /** B */
  56881. B = 0,
  56882. /** A */
  56883. A = 1,
  56884. /** Y */
  56885. Y = 2,
  56886. /** X */
  56887. X = 3,
  56888. /** L */
  56889. L = 4,
  56890. /** R */
  56891. R = 5,
  56892. /** ZL */
  56893. ZL = 6,
  56894. /** ZR */
  56895. ZR = 7,
  56896. /** Minus */
  56897. Minus = 8,
  56898. /** Plus */
  56899. Plus = 9,
  56900. /** LS */
  56901. LS = 10,
  56902. /** RS */
  56903. RS = 11,
  56904. /** DPadUp */
  56905. DPadUp = 12,
  56906. /** DPadDown */
  56907. DPadDown = 13,
  56908. /** DPadLeft */
  56909. DPadLeft = 14,
  56910. /** DRight */
  56911. DPadRight = 15,
  56912. /** Home */
  56913. Home = 16,
  56914. /** Capture */
  56915. Capture = 17,
  56916. /** LStickXAxis */
  56917. LStickXAxis = 18,
  56918. /** LStickYAxis */
  56919. LStickYAxis = 19,
  56920. /** RStickXAxis */
  56921. RStickXAxis = 20,
  56922. /** RStickYAxis */
  56923. RStickYAxis = 21
  56924. }
  56925. }
  56926. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  56927. import { Engine } from "babylonjs/Engines/engine";
  56928. import { IDisposable } from "babylonjs/scene";
  56929. import { Nullable } from "babylonjs/types";
  56930. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56931. /**
  56932. * This class will take all inputs from Keyboard, Pointer, and
  56933. * any Gamepads and provide a polling system that all devices
  56934. * will use. This class assumes that there will only be one
  56935. * pointer device and one keyboard.
  56936. */
  56937. export class DeviceInputSystem implements IDisposable {
  56938. /**
  56939. * Callback to be triggered when a device is connected
  56940. */
  56941. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56942. /**
  56943. * Callback to be triggered when a device is disconnected
  56944. */
  56945. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56946. /**
  56947. * Callback to be triggered when event driven input is updated
  56948. */
  56949. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  56950. private _inputs;
  56951. private _gamepads;
  56952. private _keyboardActive;
  56953. private _pointerActive;
  56954. private _elementToAttachTo;
  56955. private _keyboardDownEvent;
  56956. private _keyboardUpEvent;
  56957. private _pointerMoveEvent;
  56958. private _pointerDownEvent;
  56959. private _pointerUpEvent;
  56960. private _gamepadConnectedEvent;
  56961. private _gamepadDisconnectedEvent;
  56962. private static _MAX_KEYCODES;
  56963. private static _MAX_POINTER_INPUTS;
  56964. private constructor();
  56965. /**
  56966. * Creates a new DeviceInputSystem instance
  56967. * @param engine Engine to pull input element from
  56968. * @returns The new instance
  56969. */
  56970. static Create(engine: Engine): DeviceInputSystem;
  56971. /**
  56972. * Checks for current device input value, given an id and input index
  56973. * @param deviceName Id of connected device
  56974. * @param inputIndex Index of device input
  56975. * @returns Current value of input
  56976. */
  56977. /**
  56978. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  56979. * @param deviceType Enum specifiying device type
  56980. * @param deviceSlot "Slot" or index that device is referenced in
  56981. * @param inputIndex Id of input to be checked
  56982. * @returns Current value of input
  56983. */
  56984. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  56985. /**
  56986. * Dispose of all the eventlisteners
  56987. */
  56988. dispose(): void;
  56989. /**
  56990. * Add device and inputs to device array
  56991. * @param deviceType Enum specifiying device type
  56992. * @param deviceSlot "Slot" or index that device is referenced in
  56993. * @param numberOfInputs Number of input entries to create for given device
  56994. */
  56995. private _registerDevice;
  56996. /**
  56997. * Given a specific device name, remove that device from the device map
  56998. * @param deviceType Enum specifiying device type
  56999. * @param deviceSlot "Slot" or index that device is referenced in
  57000. */
  57001. private _unregisterDevice;
  57002. /**
  57003. * Handle all actions that come from keyboard interaction
  57004. */
  57005. private _handleKeyActions;
  57006. /**
  57007. * Handle all actions that come from pointer interaction
  57008. */
  57009. private _handlePointerActions;
  57010. /**
  57011. * Handle all actions that come from gamepad interaction
  57012. */
  57013. private _handleGamepadActions;
  57014. /**
  57015. * Update all non-event based devices with each frame
  57016. * @param deviceType Enum specifiying device type
  57017. * @param deviceSlot "Slot" or index that device is referenced in
  57018. * @param inputIndex Id of input to be checked
  57019. */
  57020. private _updateDevice;
  57021. /**
  57022. * Gets DeviceType from the device name
  57023. * @param deviceName Name of Device from DeviceInputSystem
  57024. * @returns DeviceType enum value
  57025. */
  57026. private _getGamepadDeviceType;
  57027. }
  57028. }
  57029. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  57030. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57031. /**
  57032. * Type to handle enforcement of inputs
  57033. */
  57034. 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;
  57035. }
  57036. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  57037. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  57038. import { Engine } from "babylonjs/Engines/engine";
  57039. import { IDisposable } from "babylonjs/scene";
  57040. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57041. import { Nullable } from "babylonjs/types";
  57042. import { Observable } from "babylonjs/Misc/observable";
  57043. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57044. /**
  57045. * Class that handles all input for a specific device
  57046. */
  57047. export class DeviceSource<T extends DeviceType> {
  57048. /** Type of device */
  57049. readonly deviceType: DeviceType;
  57050. /** "Slot" or index that device is referenced in */
  57051. readonly deviceSlot: number;
  57052. /**
  57053. * Observable to handle device input changes per device
  57054. */
  57055. readonly onInputChangedObservable: Observable<{
  57056. inputIndex: DeviceInput<T>;
  57057. previousState: Nullable<number>;
  57058. currentState: Nullable<number>;
  57059. }>;
  57060. private readonly _deviceInputSystem;
  57061. /**
  57062. * Default Constructor
  57063. * @param deviceInputSystem Reference to DeviceInputSystem
  57064. * @param deviceType Type of device
  57065. * @param deviceSlot "Slot" or index that device is referenced in
  57066. */
  57067. constructor(deviceInputSystem: DeviceInputSystem,
  57068. /** Type of device */
  57069. deviceType: DeviceType,
  57070. /** "Slot" or index that device is referenced in */
  57071. deviceSlot?: number);
  57072. /**
  57073. * Get input for specific input
  57074. * @param inputIndex index of specific input on device
  57075. * @returns Input value from DeviceInputSystem
  57076. */
  57077. getInput(inputIndex: DeviceInput<T>): number;
  57078. }
  57079. /**
  57080. * Class to keep track of devices
  57081. */
  57082. export class DeviceSourceManager implements IDisposable {
  57083. /**
  57084. * Observable to be triggered when before a device is connected
  57085. */
  57086. readonly onBeforeDeviceConnectedObservable: Observable<{
  57087. deviceType: DeviceType;
  57088. deviceSlot: number;
  57089. }>;
  57090. /**
  57091. * Observable to be triggered when before a device is disconnected
  57092. */
  57093. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  57094. deviceType: DeviceType;
  57095. deviceSlot: number;
  57096. }>;
  57097. /**
  57098. * Observable to be triggered when after a device is connected
  57099. */
  57100. readonly onAfterDeviceConnectedObservable: Observable<{
  57101. deviceType: DeviceType;
  57102. deviceSlot: number;
  57103. }>;
  57104. /**
  57105. * Observable to be triggered when after a device is disconnected
  57106. */
  57107. readonly onAfterDeviceDisconnectedObservable: Observable<{
  57108. deviceType: DeviceType;
  57109. deviceSlot: number;
  57110. }>;
  57111. private readonly _devices;
  57112. private readonly _firstDevice;
  57113. private readonly _deviceInputSystem;
  57114. /**
  57115. * Default Constructor
  57116. * @param engine engine to pull input element from
  57117. */
  57118. constructor(engine: Engine);
  57119. /**
  57120. * Gets a DeviceSource, given a type and slot
  57121. * @param deviceType Enum specifying device type
  57122. * @param deviceSlot "Slot" or index that device is referenced in
  57123. * @returns DeviceSource object
  57124. */
  57125. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  57126. /**
  57127. * Gets an array of DeviceSource objects for a given device type
  57128. * @param deviceType Enum specifying device type
  57129. * @returns Array of DeviceSource objects
  57130. */
  57131. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  57132. /**
  57133. * Dispose of DeviceInputSystem and other parts
  57134. */
  57135. dispose(): void;
  57136. /**
  57137. * Function to add device name to device list
  57138. * @param deviceType Enum specifying device type
  57139. * @param deviceSlot "Slot" or index that device is referenced in
  57140. */
  57141. private _addDevice;
  57142. /**
  57143. * Function to remove device name to device list
  57144. * @param deviceType Enum specifying device type
  57145. * @param deviceSlot "Slot" or index that device is referenced in
  57146. */
  57147. private _removeDevice;
  57148. /**
  57149. * Updates array storing first connected device of each type
  57150. * @param type Type of Device
  57151. */
  57152. private _updateFirstDevices;
  57153. }
  57154. }
  57155. declare module "babylonjs/DeviceInput/index" {
  57156. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57157. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57158. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57159. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57160. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57161. }
  57162. declare module "babylonjs/Engines/nullEngine" {
  57163. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57164. import { Engine } from "babylonjs/Engines/engine";
  57165. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57166. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57167. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57168. import { Effect } from "babylonjs/Materials/effect";
  57169. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57170. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57171. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57172. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57173. /**
  57174. * Options to create the null engine
  57175. */
  57176. export class NullEngineOptions {
  57177. /**
  57178. * Render width (Default: 512)
  57179. */
  57180. renderWidth: number;
  57181. /**
  57182. * Render height (Default: 256)
  57183. */
  57184. renderHeight: number;
  57185. /**
  57186. * Texture size (Default: 512)
  57187. */
  57188. textureSize: number;
  57189. /**
  57190. * If delta time between frames should be constant
  57191. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57192. */
  57193. deterministicLockstep: boolean;
  57194. /**
  57195. * Maximum about of steps between frames (Default: 4)
  57196. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57197. */
  57198. lockstepMaxSteps: number;
  57199. /**
  57200. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57201. */
  57202. useHighPrecisionMatrix?: boolean;
  57203. }
  57204. /**
  57205. * The null engine class provides support for headless version of babylon.js.
  57206. * This can be used in server side scenario or for testing purposes
  57207. */
  57208. export class NullEngine extends Engine {
  57209. private _options;
  57210. /**
  57211. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57212. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57213. * @returns true if engine is in deterministic lock step mode
  57214. */
  57215. isDeterministicLockStep(): boolean;
  57216. /**
  57217. * Gets the max steps when engine is running in deterministic lock step
  57218. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57219. * @returns the max steps
  57220. */
  57221. getLockstepMaxSteps(): number;
  57222. /**
  57223. * Gets the current hardware scaling level.
  57224. * By default the hardware scaling level is computed from the window device ratio.
  57225. * 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.
  57226. * @returns a number indicating the current hardware scaling level
  57227. */
  57228. getHardwareScalingLevel(): number;
  57229. constructor(options?: NullEngineOptions);
  57230. /**
  57231. * Creates a vertex buffer
  57232. * @param vertices the data for the vertex buffer
  57233. * @returns the new WebGL static buffer
  57234. */
  57235. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57236. /**
  57237. * Creates a new index buffer
  57238. * @param indices defines the content of the index buffer
  57239. * @param updatable defines if the index buffer must be updatable
  57240. * @returns a new webGL buffer
  57241. */
  57242. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57243. /**
  57244. * Clear the current render buffer or the current render target (if any is set up)
  57245. * @param color defines the color to use
  57246. * @param backBuffer defines if the back buffer must be cleared
  57247. * @param depth defines if the depth buffer must be cleared
  57248. * @param stencil defines if the stencil buffer must be cleared
  57249. */
  57250. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57251. /**
  57252. * Gets the current render width
  57253. * @param useScreen defines if screen size must be used (or the current render target if any)
  57254. * @returns a number defining the current render width
  57255. */
  57256. getRenderWidth(useScreen?: boolean): number;
  57257. /**
  57258. * Gets the current render height
  57259. * @param useScreen defines if screen size must be used (or the current render target if any)
  57260. * @returns a number defining the current render height
  57261. */
  57262. getRenderHeight(useScreen?: boolean): number;
  57263. /**
  57264. * Set the WebGL's viewport
  57265. * @param viewport defines the viewport element to be used
  57266. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57267. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57268. */
  57269. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57270. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57271. /**
  57272. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57273. * @param pipelineContext defines the pipeline context to use
  57274. * @param uniformsNames defines the list of uniform names
  57275. * @returns an array of webGL uniform locations
  57276. */
  57277. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57278. /**
  57279. * Gets the lsit of active attributes for a given webGL program
  57280. * @param pipelineContext defines the pipeline context to use
  57281. * @param attributesNames defines the list of attribute names to get
  57282. * @returns an array of indices indicating the offset of each attribute
  57283. */
  57284. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57285. /**
  57286. * Binds an effect to the webGL context
  57287. * @param effect defines the effect to bind
  57288. */
  57289. bindSamplers(effect: Effect): void;
  57290. /**
  57291. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57292. * @param effect defines the effect to activate
  57293. */
  57294. enableEffect(effect: Effect): void;
  57295. /**
  57296. * Set various states to the webGL context
  57297. * @param culling defines backface culling state
  57298. * @param zOffset defines the value to apply to zOffset (0 by default)
  57299. * @param force defines if states must be applied even if cache is up to date
  57300. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57301. */
  57302. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57303. /**
  57304. * Set the value of an uniform to an array of int32
  57305. * @param uniform defines the webGL uniform location where to store the value
  57306. * @param array defines the array of int32 to store
  57307. * @returns true if value was set
  57308. */
  57309. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57310. /**
  57311. * Set the value of an uniform to an array of int32 (stored as vec2)
  57312. * @param uniform defines the webGL uniform location where to store the value
  57313. * @param array defines the array of int32 to store
  57314. * @returns true if value was set
  57315. */
  57316. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57317. /**
  57318. * Set the value of an uniform to an array of int32 (stored as vec3)
  57319. * @param uniform defines the webGL uniform location where to store the value
  57320. * @param array defines the array of int32 to store
  57321. * @returns true if value was set
  57322. */
  57323. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57324. /**
  57325. * Set the value of an uniform to an array of int32 (stored as vec4)
  57326. * @param uniform defines the webGL uniform location where to store the value
  57327. * @param array defines the array of int32 to store
  57328. * @returns true if value was set
  57329. */
  57330. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57331. /**
  57332. * Set the value of an uniform to an array of float32
  57333. * @param uniform defines the webGL uniform location where to store the value
  57334. * @param array defines the array of float32 to store
  57335. * @returns true if value was set
  57336. */
  57337. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57338. /**
  57339. * Set the value of an uniform to an array of float32 (stored as vec2)
  57340. * @param uniform defines the webGL uniform location where to store the value
  57341. * @param array defines the array of float32 to store
  57342. * @returns true if value was set
  57343. */
  57344. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57345. /**
  57346. * Set the value of an uniform to an array of float32 (stored as vec3)
  57347. * @param uniform defines the webGL uniform location where to store the value
  57348. * @param array defines the array of float32 to store
  57349. * @returns true if value was set
  57350. */
  57351. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57352. /**
  57353. * Set the value of an uniform to an array of float32 (stored as vec4)
  57354. * @param uniform defines the webGL uniform location where to store the value
  57355. * @param array defines the array of float32 to store
  57356. * @returns true if value was set
  57357. */
  57358. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57359. /**
  57360. * Set the value of an uniform to an array of number
  57361. * @param uniform defines the webGL uniform location where to store the value
  57362. * @param array defines the array of number to store
  57363. * @returns true if value was set
  57364. */
  57365. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57366. /**
  57367. * Set the value of an uniform to an array of number (stored as vec2)
  57368. * @param uniform defines the webGL uniform location where to store the value
  57369. * @param array defines the array of number to store
  57370. * @returns true if value was set
  57371. */
  57372. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57373. /**
  57374. * Set the value of an uniform to an array of number (stored as vec3)
  57375. * @param uniform defines the webGL uniform location where to store the value
  57376. * @param array defines the array of number to store
  57377. * @returns true if value was set
  57378. */
  57379. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57380. /**
  57381. * Set the value of an uniform to an array of number (stored as vec4)
  57382. * @param uniform defines the webGL uniform location where to store the value
  57383. * @param array defines the array of number to store
  57384. * @returns true if value was set
  57385. */
  57386. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57387. /**
  57388. * Set the value of an uniform to an array of float32 (stored as matrices)
  57389. * @param uniform defines the webGL uniform location where to store the value
  57390. * @param matrices defines the array of float32 to store
  57391. * @returns true if value was set
  57392. */
  57393. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57394. /**
  57395. * Set the value of an uniform to a matrix (3x3)
  57396. * @param uniform defines the webGL uniform location where to store the value
  57397. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57398. * @returns true if value was set
  57399. */
  57400. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57401. /**
  57402. * Set the value of an uniform to a matrix (2x2)
  57403. * @param uniform defines the webGL uniform location where to store the value
  57404. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57405. * @returns true if value was set
  57406. */
  57407. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57408. /**
  57409. * Set the value of an uniform to a number (float)
  57410. * @param uniform defines the webGL uniform location where to store the value
  57411. * @param value defines the float number to store
  57412. * @returns true if value was set
  57413. */
  57414. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57415. /**
  57416. * Set the value of an uniform to a vec2
  57417. * @param uniform defines the webGL uniform location where to store the value
  57418. * @param x defines the 1st component of the value
  57419. * @param y defines the 2nd component of the value
  57420. * @returns true if value was set
  57421. */
  57422. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57423. /**
  57424. * Set the value of an uniform to a vec3
  57425. * @param uniform defines the webGL uniform location where to store the value
  57426. * @param x defines the 1st component of the value
  57427. * @param y defines the 2nd component of the value
  57428. * @param z defines the 3rd component of the value
  57429. * @returns true if value was set
  57430. */
  57431. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57432. /**
  57433. * Set the value of an uniform to a boolean
  57434. * @param uniform defines the webGL uniform location where to store the value
  57435. * @param bool defines the boolean to store
  57436. * @returns true if value was set
  57437. */
  57438. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57439. /**
  57440. * Set the value of an uniform to a vec4
  57441. * @param uniform defines the webGL uniform location where to store the value
  57442. * @param x defines the 1st component of the value
  57443. * @param y defines the 2nd component of the value
  57444. * @param z defines the 3rd component of the value
  57445. * @param w defines the 4th component of the value
  57446. * @returns true if value was set
  57447. */
  57448. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57449. /**
  57450. * Sets the current alpha mode
  57451. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57452. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57453. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57454. */
  57455. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57456. /**
  57457. * Bind webGl buffers directly to the webGL context
  57458. * @param vertexBuffers defines the vertex buffer to bind
  57459. * @param indexBuffer defines the index buffer to bind
  57460. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57461. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57462. * @param effect defines the effect associated with the vertex buffer
  57463. */
  57464. bindBuffers(vertexBuffers: {
  57465. [key: string]: VertexBuffer;
  57466. }, indexBuffer: DataBuffer, effect: Effect): void;
  57467. /**
  57468. * Force the entire cache to be cleared
  57469. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57470. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57471. */
  57472. wipeCaches(bruteForce?: boolean): void;
  57473. /**
  57474. * Send a draw order
  57475. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57476. * @param indexStart defines the starting index
  57477. * @param indexCount defines the number of index to draw
  57478. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57479. */
  57480. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57481. /**
  57482. * Draw a list of indexed primitives
  57483. * @param fillMode defines the primitive to use
  57484. * @param indexStart defines the starting index
  57485. * @param indexCount defines the number of index to draw
  57486. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57487. */
  57488. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57489. /**
  57490. * Draw a list of unindexed primitives
  57491. * @param fillMode defines the primitive to use
  57492. * @param verticesStart defines the index of first vertex to draw
  57493. * @param verticesCount defines the count of vertices to draw
  57494. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57495. */
  57496. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57497. /** @hidden */
  57498. _createTexture(): WebGLTexture;
  57499. /** @hidden */
  57500. _releaseTexture(texture: InternalTexture): void;
  57501. /**
  57502. * Usually called from Texture.ts.
  57503. * Passed information to create a WebGLTexture
  57504. * @param urlArg defines a value which contains one of the following:
  57505. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57506. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57507. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57509. * @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)
  57510. * @param scene needed for loading to the correct scene
  57511. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57512. * @param onLoad optional callback to be called upon successful completion
  57513. * @param onError optional callback to be called upon failure
  57514. * @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
  57515. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57516. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57517. * @param forcedExtension defines the extension to use to pick the right loader
  57518. * @param mimeType defines an optional mime type
  57519. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57520. */
  57521. 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;
  57522. /**
  57523. * Creates a new render target texture
  57524. * @param size defines the size of the texture
  57525. * @param options defines the options used to create the texture
  57526. * @returns a new render target texture stored in an InternalTexture
  57527. */
  57528. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57529. /**
  57530. * Update the sampling mode of a given texture
  57531. * @param samplingMode defines the required sampling mode
  57532. * @param texture defines the texture to update
  57533. */
  57534. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57535. /**
  57536. * Binds the frame buffer to the specified texture.
  57537. * @param texture The texture to render to or null for the default canvas
  57538. * @param faceIndex The face of the texture to render to in case of cube texture
  57539. * @param requiredWidth The width of the target to render to
  57540. * @param requiredHeight The height of the target to render to
  57541. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57542. * @param lodLevel defines le lod level to bind to the frame buffer
  57543. */
  57544. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57545. /**
  57546. * Unbind the current render target texture from the webGL context
  57547. * @param texture defines the render target texture to unbind
  57548. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57549. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57550. */
  57551. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57552. /**
  57553. * Creates a dynamic vertex buffer
  57554. * @param vertices the data for the dynamic vertex buffer
  57555. * @returns the new WebGL dynamic buffer
  57556. */
  57557. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57558. /**
  57559. * Update the content of a dynamic texture
  57560. * @param texture defines the texture to update
  57561. * @param canvas defines the canvas containing the source
  57562. * @param invertY defines if data must be stored with Y axis inverted
  57563. * @param premulAlpha defines if alpha is stored as premultiplied
  57564. * @param format defines the format of the data
  57565. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57566. */
  57567. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57568. /**
  57569. * Gets a boolean indicating if all created effects are ready
  57570. * @returns true if all effects are ready
  57571. */
  57572. areAllEffectsReady(): boolean;
  57573. /**
  57574. * @hidden
  57575. * Get the current error code of the webGL context
  57576. * @returns the error code
  57577. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57578. */
  57579. getError(): number;
  57580. /** @hidden */
  57581. _getUnpackAlignement(): number;
  57582. /** @hidden */
  57583. _unpackFlipY(value: boolean): void;
  57584. /**
  57585. * Update a dynamic index buffer
  57586. * @param indexBuffer defines the target index buffer
  57587. * @param indices defines the data to update
  57588. * @param offset defines the offset in the target index buffer where update should start
  57589. */
  57590. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57591. /**
  57592. * Updates a dynamic vertex buffer.
  57593. * @param vertexBuffer the vertex buffer to update
  57594. * @param vertices the data used to update the vertex buffer
  57595. * @param byteOffset the byte offset of the data (optional)
  57596. * @param byteLength the byte length of the data (optional)
  57597. */
  57598. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57599. /** @hidden */
  57600. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57601. /** @hidden */
  57602. _bindTexture(channel: number, texture: InternalTexture): void;
  57603. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57604. /**
  57605. * 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
  57606. */
  57607. releaseEffects(): void;
  57608. displayLoadingUI(): void;
  57609. hideLoadingUI(): void;
  57610. /** @hidden */
  57611. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57612. /** @hidden */
  57613. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57614. /** @hidden */
  57615. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57616. /** @hidden */
  57617. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57618. }
  57619. }
  57620. declare module "babylonjs/Instrumentation/timeToken" {
  57621. import { Nullable } from "babylonjs/types";
  57622. /**
  57623. * @hidden
  57624. **/
  57625. export class _TimeToken {
  57626. _startTimeQuery: Nullable<WebGLQuery>;
  57627. _endTimeQuery: Nullable<WebGLQuery>;
  57628. _timeElapsedQuery: Nullable<WebGLQuery>;
  57629. _timeElapsedQueryEnded: boolean;
  57630. }
  57631. }
  57632. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57633. import { Nullable, int } from "babylonjs/types";
  57634. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57635. /** @hidden */
  57636. export class _OcclusionDataStorage {
  57637. /** @hidden */
  57638. occlusionInternalRetryCounter: number;
  57639. /** @hidden */
  57640. isOcclusionQueryInProgress: boolean;
  57641. /** @hidden */
  57642. isOccluded: boolean;
  57643. /** @hidden */
  57644. occlusionRetryCount: number;
  57645. /** @hidden */
  57646. occlusionType: number;
  57647. /** @hidden */
  57648. occlusionQueryAlgorithmType: number;
  57649. }
  57650. module "babylonjs/Engines/engine" {
  57651. interface Engine {
  57652. /**
  57653. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  57654. * @return the new query
  57655. */
  57656. createQuery(): WebGLQuery;
  57657. /**
  57658. * Delete and release a webGL query
  57659. * @param query defines the query to delete
  57660. * @return the current engine
  57661. */
  57662. deleteQuery(query: WebGLQuery): Engine;
  57663. /**
  57664. * Check if a given query has resolved and got its value
  57665. * @param query defines the query to check
  57666. * @returns true if the query got its value
  57667. */
  57668. isQueryResultAvailable(query: WebGLQuery): boolean;
  57669. /**
  57670. * Gets the value of a given query
  57671. * @param query defines the query to check
  57672. * @returns the value of the query
  57673. */
  57674. getQueryResult(query: WebGLQuery): number;
  57675. /**
  57676. * Initiates an occlusion query
  57677. * @param algorithmType defines the algorithm to use
  57678. * @param query defines the query to use
  57679. * @returns the current engine
  57680. * @see https://doc.babylonjs.com/features/occlusionquery
  57681. */
  57682. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  57683. /**
  57684. * Ends an occlusion query
  57685. * @see https://doc.babylonjs.com/features/occlusionquery
  57686. * @param algorithmType defines the algorithm to use
  57687. * @returns the current engine
  57688. */
  57689. endOcclusionQuery(algorithmType: number): Engine;
  57690. /**
  57691. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  57692. * Please note that only one query can be issued at a time
  57693. * @returns a time token used to track the time span
  57694. */
  57695. startTimeQuery(): Nullable<_TimeToken>;
  57696. /**
  57697. * Ends a time query
  57698. * @param token defines the token used to measure the time span
  57699. * @returns the time spent (in ns)
  57700. */
  57701. endTimeQuery(token: _TimeToken): int;
  57702. /** @hidden */
  57703. _currentNonTimestampToken: Nullable<_TimeToken>;
  57704. /** @hidden */
  57705. _createTimeQuery(): WebGLQuery;
  57706. /** @hidden */
  57707. _deleteTimeQuery(query: WebGLQuery): void;
  57708. /** @hidden */
  57709. _getGlAlgorithmType(algorithmType: number): number;
  57710. /** @hidden */
  57711. _getTimeQueryResult(query: WebGLQuery): any;
  57712. /** @hidden */
  57713. _getTimeQueryAvailability(query: WebGLQuery): any;
  57714. }
  57715. }
  57716. module "babylonjs/Meshes/abstractMesh" {
  57717. interface AbstractMesh {
  57718. /**
  57719. * Backing filed
  57720. * @hidden
  57721. */
  57722. __occlusionDataStorage: _OcclusionDataStorage;
  57723. /**
  57724. * Access property
  57725. * @hidden
  57726. */
  57727. _occlusionDataStorage: _OcclusionDataStorage;
  57728. /**
  57729. * 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.
  57730. * The default value is -1 which means don't break the query and wait till the result
  57731. * @see https://doc.babylonjs.com/features/occlusionquery
  57732. */
  57733. occlusionRetryCount: number;
  57734. /**
  57735. * 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:
  57736. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  57737. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  57738. * * 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.
  57739. * @see https://doc.babylonjs.com/features/occlusionquery
  57740. */
  57741. occlusionType: number;
  57742. /**
  57743. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  57744. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  57745. * * 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.
  57746. * @see https://doc.babylonjs.com/features/occlusionquery
  57747. */
  57748. occlusionQueryAlgorithmType: number;
  57749. /**
  57750. * 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
  57751. * @see https://doc.babylonjs.com/features/occlusionquery
  57752. */
  57753. isOccluded: boolean;
  57754. /**
  57755. * Flag to check the progress status of the query
  57756. * @see https://doc.babylonjs.com/features/occlusionquery
  57757. */
  57758. isOcclusionQueryInProgress: boolean;
  57759. }
  57760. }
  57761. }
  57762. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  57763. import { Nullable } from "babylonjs/types";
  57764. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57765. /** @hidden */
  57766. export var _forceTransformFeedbackToBundle: boolean;
  57767. module "babylonjs/Engines/engine" {
  57768. interface Engine {
  57769. /**
  57770. * Creates a webGL transform feedback object
  57771. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  57772. * @returns the webGL transform feedback object
  57773. */
  57774. createTransformFeedback(): WebGLTransformFeedback;
  57775. /**
  57776. * Delete a webGL transform feedback object
  57777. * @param value defines the webGL transform feedback object to delete
  57778. */
  57779. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  57780. /**
  57781. * Bind a webGL transform feedback object to the webgl context
  57782. * @param value defines the webGL transform feedback object to bind
  57783. */
  57784. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  57785. /**
  57786. * Begins a transform feedback operation
  57787. * @param usePoints defines if points or triangles must be used
  57788. */
  57789. beginTransformFeedback(usePoints: boolean): void;
  57790. /**
  57791. * Ends a transform feedback operation
  57792. */
  57793. endTransformFeedback(): void;
  57794. /**
  57795. * Specify the varyings to use with transform feedback
  57796. * @param program defines the associated webGL program
  57797. * @param value defines the list of strings representing the varying names
  57798. */
  57799. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  57800. /**
  57801. * Bind a webGL buffer for a transform feedback operation
  57802. * @param value defines the webGL buffer to bind
  57803. */
  57804. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  57805. }
  57806. }
  57807. }
  57808. declare module "babylonjs/Engines/Extensions/engine.views" {
  57809. import { Camera } from "babylonjs/Cameras/camera";
  57810. import { Nullable } from "babylonjs/types";
  57811. /**
  57812. * Class used to define an additional view for the engine
  57813. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57814. */
  57815. export class EngineView {
  57816. /** Defines the canvas where to render the view */
  57817. target: HTMLCanvasElement;
  57818. /** Defines an optional camera used to render the view (will use active camera else) */
  57819. camera?: Camera;
  57820. }
  57821. module "babylonjs/Engines/engine" {
  57822. interface Engine {
  57823. /**
  57824. * Gets or sets the HTML element to use for attaching events
  57825. */
  57826. inputElement: Nullable<HTMLElement>;
  57827. /**
  57828. * Gets the current engine view
  57829. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57830. */
  57831. activeView: Nullable<EngineView>;
  57832. /** Gets or sets the list of views */
  57833. views: EngineView[];
  57834. /**
  57835. * Register a new child canvas
  57836. * @param canvas defines the canvas to register
  57837. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  57838. * @returns the associated view
  57839. */
  57840. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  57841. /**
  57842. * Remove a registered child canvas
  57843. * @param canvas defines the canvas to remove
  57844. * @returns the current engine
  57845. */
  57846. unRegisterView(canvas: HTMLCanvasElement): Engine;
  57847. }
  57848. }
  57849. }
  57850. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  57851. import { Nullable } from "babylonjs/types";
  57852. module "babylonjs/Engines/engine" {
  57853. interface Engine {
  57854. /** @hidden */
  57855. _excludedCompressedTextures: string[];
  57856. /** @hidden */
  57857. _textureFormatInUse: string;
  57858. /**
  57859. * Gets the list of texture formats supported
  57860. */
  57861. readonly texturesSupported: Array<string>;
  57862. /**
  57863. * Gets the texture format in use
  57864. */
  57865. readonly textureFormatInUse: Nullable<string>;
  57866. /**
  57867. * Set the compressed texture extensions or file names to skip.
  57868. *
  57869. * @param skippedFiles defines the list of those texture files you want to skip
  57870. * Example: [".dds", ".env", "myfile.png"]
  57871. */
  57872. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  57873. /**
  57874. * Set the compressed texture format to use, based on the formats you have, and the formats
  57875. * supported by the hardware / browser.
  57876. *
  57877. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  57878. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  57879. * to API arguments needed to compressed textures. This puts the burden on the container
  57880. * generator to house the arcane code for determining these for current & future formats.
  57881. *
  57882. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57883. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57884. *
  57885. * Note: The result of this call is not taken into account when a texture is base64.
  57886. *
  57887. * @param formatsAvailable defines the list of those format families you have created
  57888. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  57889. *
  57890. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  57891. * @returns The extension selected.
  57892. */
  57893. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  57894. }
  57895. }
  57896. }
  57897. declare module "babylonjs/Engines/Extensions/index" {
  57898. export * from "babylonjs/Engines/Extensions/engine.alpha";
  57899. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  57900. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  57901. export * from "babylonjs/Engines/Extensions/engine.multiview";
  57902. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  57903. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57904. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  57905. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  57906. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  57907. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  57908. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57909. export * from "babylonjs/Engines/Extensions/engine.webVR";
  57910. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  57911. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  57912. export * from "babylonjs/Engines/Extensions/engine.views";
  57913. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  57914. import "babylonjs/Engines/Extensions/engine.textureSelector";
  57915. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  57916. }
  57917. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  57918. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57919. /** @hidden */
  57920. export var rgbdEncodePixelShader: {
  57921. name: string;
  57922. shader: string;
  57923. };
  57924. }
  57925. declare module "babylonjs/Misc/environmentTextureTools" {
  57926. import { Nullable } from "babylonjs/types";
  57927. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57928. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57929. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57930. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57931. import "babylonjs/Engines/Extensions/engine.readTexture";
  57932. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57933. import "babylonjs/Shaders/rgbdEncode.fragment";
  57934. import "babylonjs/Shaders/rgbdDecode.fragment";
  57935. /**
  57936. * Raw texture data and descriptor sufficient for WebGL texture upload
  57937. */
  57938. export interface EnvironmentTextureInfo {
  57939. /**
  57940. * Version of the environment map
  57941. */
  57942. version: number;
  57943. /**
  57944. * Width of image
  57945. */
  57946. width: number;
  57947. /**
  57948. * Irradiance information stored in the file.
  57949. */
  57950. irradiance: any;
  57951. /**
  57952. * Specular information stored in the file.
  57953. */
  57954. specular: any;
  57955. }
  57956. /**
  57957. * Defines One Image in the file. It requires only the position in the file
  57958. * as well as the length.
  57959. */
  57960. interface BufferImageData {
  57961. /**
  57962. * Length of the image data.
  57963. */
  57964. length: number;
  57965. /**
  57966. * Position of the data from the null terminator delimiting the end of the JSON.
  57967. */
  57968. position: number;
  57969. }
  57970. /**
  57971. * Defines the specular data enclosed in the file.
  57972. * This corresponds to the version 1 of the data.
  57973. */
  57974. export interface EnvironmentTextureSpecularInfoV1 {
  57975. /**
  57976. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  57977. */
  57978. specularDataPosition?: number;
  57979. /**
  57980. * This contains all the images data needed to reconstruct the cubemap.
  57981. */
  57982. mipmaps: Array<BufferImageData>;
  57983. /**
  57984. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  57985. */
  57986. lodGenerationScale: number;
  57987. }
  57988. /**
  57989. * Sets of helpers addressing the serialization and deserialization of environment texture
  57990. * stored in a BabylonJS env file.
  57991. * Those files are usually stored as .env files.
  57992. */
  57993. export class EnvironmentTextureTools {
  57994. /**
  57995. * Magic number identifying the env file.
  57996. */
  57997. private static _MagicBytes;
  57998. /**
  57999. * Gets the environment info from an env file.
  58000. * @param data The array buffer containing the .env bytes.
  58001. * @returns the environment file info (the json header) if successfully parsed.
  58002. */
  58003. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  58004. /**
  58005. * Creates an environment texture from a loaded cube texture.
  58006. * @param texture defines the cube texture to convert in env file
  58007. * @return a promise containing the environment data if succesfull.
  58008. */
  58009. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  58010. /**
  58011. * Creates a JSON representation of the spherical data.
  58012. * @param texture defines the texture containing the polynomials
  58013. * @return the JSON representation of the spherical info
  58014. */
  58015. private static _CreateEnvTextureIrradiance;
  58016. /**
  58017. * Creates the ArrayBufferViews used for initializing environment texture image data.
  58018. * @param data the image data
  58019. * @param info parameters that determine what views will be created for accessing the underlying buffer
  58020. * @return the views described by info providing access to the underlying buffer
  58021. */
  58022. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  58023. /**
  58024. * Uploads the texture info contained in the env file to the GPU.
  58025. * @param texture defines the internal texture to upload to
  58026. * @param data defines the data to load
  58027. * @param info defines the texture info retrieved through the GetEnvInfo method
  58028. * @returns a promise
  58029. */
  58030. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  58031. private static _OnImageReadyAsync;
  58032. /**
  58033. * Uploads the levels of image data to the GPU.
  58034. * @param texture defines the internal texture to upload to
  58035. * @param imageData defines the array buffer views of image data [mipmap][face]
  58036. * @returns a promise
  58037. */
  58038. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  58039. /**
  58040. * Uploads spherical polynomials information to the texture.
  58041. * @param texture defines the texture we are trying to upload the information to
  58042. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  58043. */
  58044. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  58045. /** @hidden */
  58046. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58047. }
  58048. }
  58049. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  58050. /**
  58051. * Class used to inline functions in shader code
  58052. */
  58053. export class ShaderCodeInliner {
  58054. private static readonly _RegexpFindFunctionNameAndType;
  58055. private _sourceCode;
  58056. private _functionDescr;
  58057. private _numMaxIterations;
  58058. /** Gets or sets the token used to mark the functions to inline */
  58059. inlineToken: string;
  58060. /** Gets or sets the debug mode */
  58061. debug: boolean;
  58062. /** Gets the code after the inlining process */
  58063. get code(): string;
  58064. /**
  58065. * Initializes the inliner
  58066. * @param sourceCode shader code source to inline
  58067. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  58068. */
  58069. constructor(sourceCode: string, numMaxIterations?: number);
  58070. /**
  58071. * Start the processing of the shader code
  58072. */
  58073. processCode(): void;
  58074. private _collectFunctions;
  58075. private _processInlining;
  58076. private _extractBetweenMarkers;
  58077. private _skipWhitespaces;
  58078. private _removeComments;
  58079. private _replaceFunctionCallsByCode;
  58080. private _findBackward;
  58081. private _escapeRegExp;
  58082. private _replaceNames;
  58083. }
  58084. }
  58085. declare module "babylonjs/Engines/nativeEngine" {
  58086. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  58087. import { Engine } from "babylonjs/Engines/engine";
  58088. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58089. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58090. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58091. import { Effect } from "babylonjs/Materials/effect";
  58092. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58093. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  58094. import { IColor4Like } from "babylonjs/Maths/math.like";
  58095. import { Scene } from "babylonjs/scene";
  58096. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58097. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58098. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58099. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  58100. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  58101. /**
  58102. * Container for accessors for natively-stored mesh data buffers.
  58103. */
  58104. class NativeDataBuffer extends DataBuffer {
  58105. /**
  58106. * Accessor value used to identify/retrieve a natively-stored index buffer.
  58107. */
  58108. nativeIndexBuffer?: any;
  58109. /**
  58110. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  58111. */
  58112. nativeVertexBuffer?: any;
  58113. }
  58114. /** @hidden */
  58115. class NativeTexture extends InternalTexture {
  58116. getInternalTexture(): InternalTexture;
  58117. getViewCount(): number;
  58118. }
  58119. /** @hidden */
  58120. export class NativeEngine extends Engine {
  58121. private readonly _native;
  58122. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  58123. private readonly INVALID_HANDLE;
  58124. private _boundBuffersVertexArray;
  58125. private _currentDepthTest;
  58126. getHardwareScalingLevel(): number;
  58127. constructor();
  58128. dispose(): void;
  58129. /**
  58130. * Can be used to override the current requestAnimationFrame requester.
  58131. * @hidden
  58132. */
  58133. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  58134. /**
  58135. * Override default engine behavior.
  58136. * @param color
  58137. * @param backBuffer
  58138. * @param depth
  58139. * @param stencil
  58140. */
  58141. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  58142. /**
  58143. * Gets host document
  58144. * @returns the host document object
  58145. */
  58146. getHostDocument(): Nullable<Document>;
  58147. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58148. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58149. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58150. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58151. [key: string]: VertexBuffer;
  58152. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58153. bindBuffers(vertexBuffers: {
  58154. [key: string]: VertexBuffer;
  58155. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58156. recordVertexArrayObject(vertexBuffers: {
  58157. [key: string]: VertexBuffer;
  58158. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58159. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58160. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58161. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58162. /**
  58163. * Draw a list of indexed primitives
  58164. * @param fillMode defines the primitive to use
  58165. * @param indexStart defines the starting index
  58166. * @param indexCount defines the number of index to draw
  58167. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58168. */
  58169. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58170. /**
  58171. * Draw a list of unindexed primitives
  58172. * @param fillMode defines the primitive to use
  58173. * @param verticesStart defines the index of first vertex to draw
  58174. * @param verticesCount defines the count of vertices to draw
  58175. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58176. */
  58177. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58178. createPipelineContext(): IPipelineContext;
  58179. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58180. /** @hidden */
  58181. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58182. /** @hidden */
  58183. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58184. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58185. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58186. protected _setProgram(program: WebGLProgram): void;
  58187. _releaseEffect(effect: Effect): void;
  58188. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58189. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58190. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58191. bindSamplers(effect: Effect): void;
  58192. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58193. getRenderWidth(useScreen?: boolean): number;
  58194. getRenderHeight(useScreen?: boolean): number;
  58195. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58196. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58197. /**
  58198. * Set the z offset to apply to current rendering
  58199. * @param value defines the offset to apply
  58200. */
  58201. setZOffset(value: number): void;
  58202. /**
  58203. * Gets the current value of the zOffset
  58204. * @returns the current zOffset state
  58205. */
  58206. getZOffset(): number;
  58207. /**
  58208. * Enable or disable depth buffering
  58209. * @param enable defines the state to set
  58210. */
  58211. setDepthBuffer(enable: boolean): void;
  58212. /**
  58213. * Gets a boolean indicating if depth writing is enabled
  58214. * @returns the current depth writing state
  58215. */
  58216. getDepthWrite(): boolean;
  58217. setDepthFunctionToGreater(): void;
  58218. setDepthFunctionToGreaterOrEqual(): void;
  58219. setDepthFunctionToLess(): void;
  58220. setDepthFunctionToLessOrEqual(): void;
  58221. /**
  58222. * Enable or disable depth writing
  58223. * @param enable defines the state to set
  58224. */
  58225. setDepthWrite(enable: boolean): void;
  58226. /**
  58227. * Enable or disable color writing
  58228. * @param enable defines the state to set
  58229. */
  58230. setColorWrite(enable: boolean): void;
  58231. /**
  58232. * Gets a boolean indicating if color writing is enabled
  58233. * @returns the current color writing state
  58234. */
  58235. getColorWrite(): boolean;
  58236. /**
  58237. * Sets alpha constants used by some alpha blending modes
  58238. * @param r defines the red component
  58239. * @param g defines the green component
  58240. * @param b defines the blue component
  58241. * @param a defines the alpha component
  58242. */
  58243. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58244. /**
  58245. * Sets the current alpha mode
  58246. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58247. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58248. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58249. */
  58250. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58251. /**
  58252. * Gets the current alpha mode
  58253. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58254. * @returns the current alpha mode
  58255. */
  58256. getAlphaMode(): number;
  58257. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58258. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58259. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58260. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58261. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58262. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58263. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58264. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58265. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58266. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58267. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58268. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58269. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58270. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58271. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58272. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58273. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58274. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58275. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58276. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58277. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58278. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58279. wipeCaches(bruteForce?: boolean): void;
  58280. _createTexture(): WebGLTexture;
  58281. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58282. /**
  58283. * Update the content of a dynamic texture
  58284. * @param texture defines the texture to update
  58285. * @param canvas defines the canvas containing the source
  58286. * @param invertY defines if data must be stored with Y axis inverted
  58287. * @param premulAlpha defines if alpha is stored as premultiplied
  58288. * @param format defines the format of the data
  58289. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58290. */
  58291. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58292. /**
  58293. * Usually called from Texture.ts.
  58294. * Passed information to create a WebGLTexture
  58295. * @param url defines a value which contains one of the following:
  58296. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58297. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58298. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58299. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58300. * @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)
  58301. * @param scene needed for loading to the correct scene
  58302. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58303. * @param onLoad optional callback to be called upon successful completion
  58304. * @param onError optional callback to be called upon failure
  58305. * @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
  58306. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58307. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58308. * @param forcedExtension defines the extension to use to pick the right loader
  58309. * @param mimeType defines an optional mime type
  58310. * @param loaderOptions options to be passed to the loader
  58311. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58312. */
  58313. 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, loaderOptions?: any): InternalTexture;
  58314. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58315. _releaseFramebufferObjects(texture: InternalTexture): void;
  58316. /**
  58317. * Creates a cube texture
  58318. * @param rootUrl defines the url where the files to load is located
  58319. * @param scene defines the current scene
  58320. * @param files defines the list of files to load (1 per face)
  58321. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58322. * @param onLoad defines an optional callback raised when the texture is loaded
  58323. * @param onError defines an optional callback raised if there is an issue to load the texture
  58324. * @param format defines the format of the data
  58325. * @param forcedExtension defines the extension to use to pick the right loader
  58326. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58327. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58328. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58329. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58330. * @returns the cube texture as an InternalTexture
  58331. */
  58332. 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;
  58333. createRenderTargetTexture(size: number | {
  58334. width: number;
  58335. height: number;
  58336. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58337. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58338. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58339. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58340. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58341. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58342. /**
  58343. * Updates a dynamic vertex buffer.
  58344. * @param vertexBuffer the vertex buffer to update
  58345. * @param data the data used to update the vertex buffer
  58346. * @param byteOffset the byte offset of the data (optional)
  58347. * @param byteLength the byte length of the data (optional)
  58348. */
  58349. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58350. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58351. private _updateAnisotropicLevel;
  58352. private _getAddressMode;
  58353. /** @hidden */
  58354. _bindTexture(channel: number, texture: InternalTexture): void;
  58355. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58356. releaseEffects(): void;
  58357. /** @hidden */
  58358. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58359. /** @hidden */
  58360. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58361. /** @hidden */
  58362. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58363. /** @hidden */
  58364. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58365. private _getNativeSamplingMode;
  58366. private _getNativeTextureFormat;
  58367. private _getNativeAlphaMode;
  58368. private _getNativeAttribType;
  58369. }
  58370. }
  58371. declare module "babylonjs/Engines/index" {
  58372. export * from "babylonjs/Engines/constants";
  58373. export * from "babylonjs/Engines/engineCapabilities";
  58374. export * from "babylonjs/Engines/instancingAttributeInfo";
  58375. export * from "babylonjs/Engines/thinEngine";
  58376. export * from "babylonjs/Engines/engine";
  58377. export * from "babylonjs/Engines/engineStore";
  58378. export * from "babylonjs/Engines/nullEngine";
  58379. export * from "babylonjs/Engines/Extensions/index";
  58380. export * from "babylonjs/Engines/IPipelineContext";
  58381. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58382. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58383. export * from "babylonjs/Engines/nativeEngine";
  58384. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58385. export * from "babylonjs/Engines/performanceConfigurator";
  58386. }
  58387. declare module "babylonjs/Events/clipboardEvents" {
  58388. /**
  58389. * Gather the list of clipboard event types as constants.
  58390. */
  58391. export class ClipboardEventTypes {
  58392. /**
  58393. * The clipboard event is fired when a copy command is active (pressed).
  58394. */
  58395. static readonly COPY: number;
  58396. /**
  58397. * The clipboard event is fired when a cut command is active (pressed).
  58398. */
  58399. static readonly CUT: number;
  58400. /**
  58401. * The clipboard event is fired when a paste command is active (pressed).
  58402. */
  58403. static readonly PASTE: number;
  58404. }
  58405. /**
  58406. * This class is used to store clipboard related info for the onClipboardObservable event.
  58407. */
  58408. export class ClipboardInfo {
  58409. /**
  58410. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58411. */
  58412. type: number;
  58413. /**
  58414. * Defines the related dom event
  58415. */
  58416. event: ClipboardEvent;
  58417. /**
  58418. *Creates an instance of ClipboardInfo.
  58419. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58420. * @param event Defines the related dom event
  58421. */
  58422. constructor(
  58423. /**
  58424. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58425. */
  58426. type: number,
  58427. /**
  58428. * Defines the related dom event
  58429. */
  58430. event: ClipboardEvent);
  58431. /**
  58432. * Get the clipboard event's type from the keycode.
  58433. * @param keyCode Defines the keyCode for the current keyboard event.
  58434. * @return {number}
  58435. */
  58436. static GetTypeFromCharacter(keyCode: number): number;
  58437. }
  58438. }
  58439. declare module "babylonjs/Events/index" {
  58440. export * from "babylonjs/Events/keyboardEvents";
  58441. export * from "babylonjs/Events/pointerEvents";
  58442. export * from "babylonjs/Events/clipboardEvents";
  58443. }
  58444. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58445. import { Scene } from "babylonjs/scene";
  58446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58447. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58448. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58449. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58450. /**
  58451. * Google Daydream controller
  58452. */
  58453. export class DaydreamController extends WebVRController {
  58454. /**
  58455. * Base Url for the controller model.
  58456. */
  58457. static MODEL_BASE_URL: string;
  58458. /**
  58459. * File name for the controller model.
  58460. */
  58461. static MODEL_FILENAME: string;
  58462. /**
  58463. * Gamepad Id prefix used to identify Daydream Controller.
  58464. */
  58465. static readonly GAMEPAD_ID_PREFIX: string;
  58466. /**
  58467. * Creates a new DaydreamController from a gamepad
  58468. * @param vrGamepad the gamepad that the controller should be created from
  58469. */
  58470. constructor(vrGamepad: any);
  58471. /**
  58472. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58473. * @param scene scene in which to add meshes
  58474. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58475. */
  58476. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58477. /**
  58478. * Called once for each button that changed state since the last frame
  58479. * @param buttonIdx Which button index changed
  58480. * @param state New state of the button
  58481. * @param changes Which properties on the state changed since last frame
  58482. */
  58483. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58484. }
  58485. }
  58486. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58487. import { Scene } from "babylonjs/scene";
  58488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58489. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58490. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58491. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58492. /**
  58493. * Gear VR Controller
  58494. */
  58495. export class GearVRController extends WebVRController {
  58496. /**
  58497. * Base Url for the controller model.
  58498. */
  58499. static MODEL_BASE_URL: string;
  58500. /**
  58501. * File name for the controller model.
  58502. */
  58503. static MODEL_FILENAME: string;
  58504. /**
  58505. * Gamepad Id prefix used to identify this controller.
  58506. */
  58507. static readonly GAMEPAD_ID_PREFIX: string;
  58508. private readonly _buttonIndexToObservableNameMap;
  58509. /**
  58510. * Creates a new GearVRController from a gamepad
  58511. * @param vrGamepad the gamepad that the controller should be created from
  58512. */
  58513. constructor(vrGamepad: any);
  58514. /**
  58515. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58516. * @param scene scene in which to add meshes
  58517. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58518. */
  58519. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58520. /**
  58521. * Called once for each button that changed state since the last frame
  58522. * @param buttonIdx Which button index changed
  58523. * @param state New state of the button
  58524. * @param changes Which properties on the state changed since last frame
  58525. */
  58526. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58527. }
  58528. }
  58529. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58530. import { Scene } from "babylonjs/scene";
  58531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58532. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58533. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58534. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58535. /**
  58536. * Generic Controller
  58537. */
  58538. export class GenericController extends WebVRController {
  58539. /**
  58540. * Base Url for the controller model.
  58541. */
  58542. static readonly MODEL_BASE_URL: string;
  58543. /**
  58544. * File name for the controller model.
  58545. */
  58546. static readonly MODEL_FILENAME: string;
  58547. /**
  58548. * Creates a new GenericController from a gamepad
  58549. * @param vrGamepad the gamepad that the controller should be created from
  58550. */
  58551. constructor(vrGamepad: any);
  58552. /**
  58553. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58554. * @param scene scene in which to add meshes
  58555. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58556. */
  58557. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58558. /**
  58559. * Called once for each button that changed state since the last frame
  58560. * @param buttonIdx Which button index changed
  58561. * @param state New state of the button
  58562. * @param changes Which properties on the state changed since last frame
  58563. */
  58564. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58565. }
  58566. }
  58567. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58568. import { Observable } from "babylonjs/Misc/observable";
  58569. import { Scene } from "babylonjs/scene";
  58570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58571. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58572. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58573. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58574. /**
  58575. * Oculus Touch Controller
  58576. */
  58577. export class OculusTouchController extends WebVRController {
  58578. /**
  58579. * Base Url for the controller model.
  58580. */
  58581. static MODEL_BASE_URL: string;
  58582. /**
  58583. * File name for the left controller model.
  58584. */
  58585. static MODEL_LEFT_FILENAME: string;
  58586. /**
  58587. * File name for the right controller model.
  58588. */
  58589. static MODEL_RIGHT_FILENAME: string;
  58590. /**
  58591. * Base Url for the Quest controller model.
  58592. */
  58593. static QUEST_MODEL_BASE_URL: string;
  58594. /**
  58595. * @hidden
  58596. * If the controllers are running on a device that needs the updated Quest controller models
  58597. */
  58598. static _IsQuest: boolean;
  58599. /**
  58600. * Fired when the secondary trigger on this controller is modified
  58601. */
  58602. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58603. /**
  58604. * Fired when the thumb rest on this controller is modified
  58605. */
  58606. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58607. /**
  58608. * Creates a new OculusTouchController from a gamepad
  58609. * @param vrGamepad the gamepad that the controller should be created from
  58610. */
  58611. constructor(vrGamepad: any);
  58612. /**
  58613. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58614. * @param scene scene in which to add meshes
  58615. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58616. */
  58617. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58618. /**
  58619. * Fired when the A button on this controller is modified
  58620. */
  58621. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58622. /**
  58623. * Fired when the B button on this controller is modified
  58624. */
  58625. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58626. /**
  58627. * Fired when the X button on this controller is modified
  58628. */
  58629. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58630. /**
  58631. * Fired when the Y button on this controller is modified
  58632. */
  58633. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58634. /**
  58635. * Called once for each button that changed state since the last frame
  58636. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58637. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58638. * 2) secondary trigger (same)
  58639. * 3) A (right) X (left), touch, pressed = value
  58640. * 4) B / Y
  58641. * 5) thumb rest
  58642. * @param buttonIdx Which button index changed
  58643. * @param state New state of the button
  58644. * @param changes Which properties on the state changed since last frame
  58645. */
  58646. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58647. }
  58648. }
  58649. declare module "babylonjs/Gamepads/Controllers/viveController" {
  58650. import { Scene } from "babylonjs/scene";
  58651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58652. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58653. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58654. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58655. import { Observable } from "babylonjs/Misc/observable";
  58656. /**
  58657. * Vive Controller
  58658. */
  58659. export class ViveController extends WebVRController {
  58660. /**
  58661. * Base Url for the controller model.
  58662. */
  58663. static MODEL_BASE_URL: string;
  58664. /**
  58665. * File name for the controller model.
  58666. */
  58667. static MODEL_FILENAME: string;
  58668. /**
  58669. * Creates a new ViveController from a gamepad
  58670. * @param vrGamepad the gamepad that the controller should be created from
  58671. */
  58672. constructor(vrGamepad: any);
  58673. /**
  58674. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58675. * @param scene scene in which to add meshes
  58676. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58677. */
  58678. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58679. /**
  58680. * Fired when the left button on this controller is modified
  58681. */
  58682. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58683. /**
  58684. * Fired when the right button on this controller is modified
  58685. */
  58686. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58687. /**
  58688. * Fired when the menu button on this controller is modified
  58689. */
  58690. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58691. /**
  58692. * Called once for each button that changed state since the last frame
  58693. * Vive mapping:
  58694. * 0: touchpad
  58695. * 1: trigger
  58696. * 2: left AND right buttons
  58697. * 3: menu button
  58698. * @param buttonIdx Which button index changed
  58699. * @param state New state of the button
  58700. * @param changes Which properties on the state changed since last frame
  58701. */
  58702. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58703. }
  58704. }
  58705. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  58706. import { Observable } from "babylonjs/Misc/observable";
  58707. import { Scene } from "babylonjs/scene";
  58708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58709. import { Ray } from "babylonjs/Culling/ray";
  58710. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58711. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58712. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58713. /**
  58714. * Defines the WindowsMotionController object that the state of the windows motion controller
  58715. */
  58716. export class WindowsMotionController extends WebVRController {
  58717. /**
  58718. * The base url used to load the left and right controller models
  58719. */
  58720. static MODEL_BASE_URL: string;
  58721. /**
  58722. * The name of the left controller model file
  58723. */
  58724. static MODEL_LEFT_FILENAME: string;
  58725. /**
  58726. * The name of the right controller model file
  58727. */
  58728. static MODEL_RIGHT_FILENAME: string;
  58729. /**
  58730. * The controller name prefix for this controller type
  58731. */
  58732. static readonly GAMEPAD_ID_PREFIX: string;
  58733. /**
  58734. * The controller id pattern for this controller type
  58735. */
  58736. private static readonly GAMEPAD_ID_PATTERN;
  58737. private _loadedMeshInfo;
  58738. protected readonly _mapping: {
  58739. buttons: string[];
  58740. buttonMeshNames: {
  58741. trigger: string;
  58742. menu: string;
  58743. grip: string;
  58744. thumbstick: string;
  58745. trackpad: string;
  58746. };
  58747. buttonObservableNames: {
  58748. trigger: string;
  58749. menu: string;
  58750. grip: string;
  58751. thumbstick: string;
  58752. trackpad: string;
  58753. };
  58754. axisMeshNames: string[];
  58755. pointingPoseMeshName: string;
  58756. };
  58757. /**
  58758. * Fired when the trackpad on this controller is clicked
  58759. */
  58760. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58761. /**
  58762. * Fired when the trackpad on this controller is modified
  58763. */
  58764. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58765. /**
  58766. * The current x and y values of this controller's trackpad
  58767. */
  58768. trackpad: StickValues;
  58769. /**
  58770. * Creates a new WindowsMotionController from a gamepad
  58771. * @param vrGamepad the gamepad that the controller should be created from
  58772. */
  58773. constructor(vrGamepad: any);
  58774. /**
  58775. * Fired when the trigger on this controller is modified
  58776. */
  58777. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58778. /**
  58779. * Fired when the menu button on this controller is modified
  58780. */
  58781. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58782. /**
  58783. * Fired when the grip button on this controller is modified
  58784. */
  58785. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58786. /**
  58787. * Fired when the thumbstick button on this controller is modified
  58788. */
  58789. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58790. /**
  58791. * Fired when the touchpad button on this controller is modified
  58792. */
  58793. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58794. /**
  58795. * Fired when the touchpad values on this controller are modified
  58796. */
  58797. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  58798. protected _updateTrackpad(): void;
  58799. /**
  58800. * Called once per frame by the engine.
  58801. */
  58802. update(): void;
  58803. /**
  58804. * Called once for each button that changed state since the last frame
  58805. * @param buttonIdx Which button index changed
  58806. * @param state New state of the button
  58807. * @param changes Which properties on the state changed since last frame
  58808. */
  58809. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58810. /**
  58811. * Moves the buttons on the controller mesh based on their current state
  58812. * @param buttonName the name of the button to move
  58813. * @param buttonValue the value of the button which determines the buttons new position
  58814. */
  58815. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  58816. /**
  58817. * Moves the axis on the controller mesh based on its current state
  58818. * @param axis the index of the axis
  58819. * @param axisValue the value of the axis which determines the meshes new position
  58820. * @hidden
  58821. */
  58822. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  58823. /**
  58824. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58825. * @param scene scene in which to add meshes
  58826. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58827. */
  58828. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  58829. /**
  58830. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  58831. * can be transformed by button presses and axes values, based on this._mapping.
  58832. *
  58833. * @param scene scene in which the meshes exist
  58834. * @param meshes list of meshes that make up the controller model to process
  58835. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  58836. */
  58837. private processModel;
  58838. private createMeshInfo;
  58839. /**
  58840. * Gets the ray of the controller in the direction the controller is pointing
  58841. * @param length the length the resulting ray should be
  58842. * @returns a ray in the direction the controller is pointing
  58843. */
  58844. getForwardRay(length?: number): Ray;
  58845. /**
  58846. * Disposes of the controller
  58847. */
  58848. dispose(): void;
  58849. }
  58850. /**
  58851. * This class represents a new windows motion controller in XR.
  58852. */
  58853. export class XRWindowsMotionController extends WindowsMotionController {
  58854. /**
  58855. * Changing the original WIndowsMotionController mapping to fir the new mapping
  58856. */
  58857. protected readonly _mapping: {
  58858. buttons: string[];
  58859. buttonMeshNames: {
  58860. trigger: string;
  58861. menu: string;
  58862. grip: string;
  58863. thumbstick: string;
  58864. trackpad: string;
  58865. };
  58866. buttonObservableNames: {
  58867. trigger: string;
  58868. menu: string;
  58869. grip: string;
  58870. thumbstick: string;
  58871. trackpad: string;
  58872. };
  58873. axisMeshNames: string[];
  58874. pointingPoseMeshName: string;
  58875. };
  58876. /**
  58877. * Construct a new XR-Based windows motion controller
  58878. *
  58879. * @param gamepadInfo the gamepad object from the browser
  58880. */
  58881. constructor(gamepadInfo: any);
  58882. /**
  58883. * holds the thumbstick values (X,Y)
  58884. */
  58885. thumbstickValues: StickValues;
  58886. /**
  58887. * Fired when the thumbstick on this controller is clicked
  58888. */
  58889. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  58890. /**
  58891. * Fired when the thumbstick on this controller is modified
  58892. */
  58893. onThumbstickValuesChangedObservable: Observable<StickValues>;
  58894. /**
  58895. * Fired when the touchpad button on this controller is modified
  58896. */
  58897. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58898. /**
  58899. * Fired when the touchpad values on this controller are modified
  58900. */
  58901. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58902. /**
  58903. * Fired when the thumbstick button on this controller is modified
  58904. * here to prevent breaking changes
  58905. */
  58906. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58907. /**
  58908. * updating the thumbstick(!) and not the trackpad.
  58909. * This is named this way due to the difference between WebVR and XR and to avoid
  58910. * changing the parent class.
  58911. */
  58912. protected _updateTrackpad(): void;
  58913. /**
  58914. * Disposes the class with joy
  58915. */
  58916. dispose(): void;
  58917. }
  58918. }
  58919. declare module "babylonjs/Gamepads/Controllers/index" {
  58920. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  58921. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  58922. export * from "babylonjs/Gamepads/Controllers/genericController";
  58923. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  58924. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58925. export * from "babylonjs/Gamepads/Controllers/viveController";
  58926. export * from "babylonjs/Gamepads/Controllers/webVRController";
  58927. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  58928. }
  58929. declare module "babylonjs/Gamepads/index" {
  58930. export * from "babylonjs/Gamepads/Controllers/index";
  58931. export * from "babylonjs/Gamepads/gamepad";
  58932. export * from "babylonjs/Gamepads/gamepadManager";
  58933. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  58934. export * from "babylonjs/Gamepads/xboxGamepad";
  58935. export * from "babylonjs/Gamepads/dualShockGamepad";
  58936. }
  58937. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  58938. import { Scene } from "babylonjs/scene";
  58939. import { Vector4 } from "babylonjs/Maths/math.vector";
  58940. import { Color4 } from "babylonjs/Maths/math.color";
  58941. import { Mesh } from "babylonjs/Meshes/mesh";
  58942. import { Nullable } from "babylonjs/types";
  58943. /**
  58944. * Class containing static functions to help procedurally build meshes
  58945. */
  58946. export class PolyhedronBuilder {
  58947. /**
  58948. * Creates a polyhedron mesh
  58949. * * 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
  58950. * * The parameter `size` (positive float, default 1) sets the polygon size
  58951. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58952. * * 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`
  58953. * * 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
  58954. * * 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)`)
  58955. * * 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
  58956. * * 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
  58957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58960. * @param name defines the name of the mesh
  58961. * @param options defines the options used to create the mesh
  58962. * @param scene defines the hosting scene
  58963. * @returns the polyhedron mesh
  58964. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58965. */
  58966. static CreatePolyhedron(name: string, options: {
  58967. type?: number;
  58968. size?: number;
  58969. sizeX?: number;
  58970. sizeY?: number;
  58971. sizeZ?: number;
  58972. custom?: any;
  58973. faceUV?: Vector4[];
  58974. faceColors?: Color4[];
  58975. flat?: boolean;
  58976. updatable?: boolean;
  58977. sideOrientation?: number;
  58978. frontUVs?: Vector4;
  58979. backUVs?: Vector4;
  58980. }, scene?: Nullable<Scene>): Mesh;
  58981. }
  58982. }
  58983. declare module "babylonjs/Gizmos/scaleGizmo" {
  58984. import { Observable } from "babylonjs/Misc/observable";
  58985. import { Nullable } from "babylonjs/types";
  58986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58987. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58988. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  58989. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58990. import { Node } from "babylonjs/node";
  58991. /**
  58992. * Gizmo that enables scaling a mesh along 3 axis
  58993. */
  58994. export class ScaleGizmo extends Gizmo {
  58995. /**
  58996. * Internal gizmo used for interactions on the x axis
  58997. */
  58998. xGizmo: AxisScaleGizmo;
  58999. /**
  59000. * Internal gizmo used for interactions on the y axis
  59001. */
  59002. yGizmo: AxisScaleGizmo;
  59003. /**
  59004. * Internal gizmo used for interactions on the z axis
  59005. */
  59006. zGizmo: AxisScaleGizmo;
  59007. /**
  59008. * Internal gizmo used to scale all axis equally
  59009. */
  59010. uniformScaleGizmo: AxisScaleGizmo;
  59011. private _meshAttached;
  59012. private _nodeAttached;
  59013. private _snapDistance;
  59014. private _uniformScalingMesh;
  59015. private _octahedron;
  59016. private _sensitivity;
  59017. /** Fires an event when any of it's sub gizmos are dragged */
  59018. onDragStartObservable: Observable<unknown>;
  59019. /** Fires an event when any of it's sub gizmos are released from dragging */
  59020. onDragEndObservable: Observable<unknown>;
  59021. get attachedMesh(): Nullable<AbstractMesh>;
  59022. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59023. get attachedNode(): Nullable<Node>;
  59024. set attachedNode(node: Nullable<Node>);
  59025. /**
  59026. * True when the mouse pointer is hovering a gizmo mesh
  59027. */
  59028. get isHovered(): boolean;
  59029. /**
  59030. * Creates a ScaleGizmo
  59031. * @param gizmoLayer The utility layer the gizmo will be added to
  59032. * @param thickness display gizmo axis thickness
  59033. */
  59034. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  59035. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59036. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59037. /**
  59038. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59039. */
  59040. set snapDistance(value: number);
  59041. get snapDistance(): number;
  59042. /**
  59043. * Ratio for the scale of the gizmo (Default: 1)
  59044. */
  59045. set scaleRatio(value: number);
  59046. get scaleRatio(): number;
  59047. /**
  59048. * Sensitivity factor for dragging (Default: 1)
  59049. */
  59050. set sensitivity(value: number);
  59051. get sensitivity(): number;
  59052. /**
  59053. * Disposes of the gizmo
  59054. */
  59055. dispose(): void;
  59056. }
  59057. }
  59058. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  59059. import { Observable } from "babylonjs/Misc/observable";
  59060. import { Nullable } from "babylonjs/types";
  59061. import { Vector3 } from "babylonjs/Maths/math.vector";
  59062. import { Node } from "babylonjs/node";
  59063. import { Mesh } from "babylonjs/Meshes/mesh";
  59064. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59065. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59066. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59067. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59068. import { Color3 } from "babylonjs/Maths/math.color";
  59069. /**
  59070. * Single axis scale gizmo
  59071. */
  59072. export class AxisScaleGizmo extends Gizmo {
  59073. /**
  59074. * Drag behavior responsible for the gizmos dragging interactions
  59075. */
  59076. dragBehavior: PointerDragBehavior;
  59077. private _pointerObserver;
  59078. /**
  59079. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59080. */
  59081. snapDistance: number;
  59082. /**
  59083. * Event that fires each time the gizmo snaps to a new location.
  59084. * * snapDistance is the the change in distance
  59085. */
  59086. onSnapObservable: Observable<{
  59087. snapDistance: number;
  59088. }>;
  59089. /**
  59090. * If the scaling operation should be done on all axis (default: false)
  59091. */
  59092. uniformScaling: boolean;
  59093. /**
  59094. * Custom sensitivity value for the drag strength
  59095. */
  59096. sensitivity: number;
  59097. private _isEnabled;
  59098. private _parent;
  59099. private _arrow;
  59100. private _coloredMaterial;
  59101. private _hoverMaterial;
  59102. /**
  59103. * Creates an AxisScaleGizmo
  59104. * @param gizmoLayer The utility layer the gizmo will be added to
  59105. * @param dragAxis The axis which the gizmo will be able to scale on
  59106. * @param color The color of the gizmo
  59107. * @param thickness display gizmo axis thickness
  59108. */
  59109. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59110. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59111. /**
  59112. * If the gizmo is enabled
  59113. */
  59114. set isEnabled(value: boolean);
  59115. get isEnabled(): boolean;
  59116. /**
  59117. * Disposes of the gizmo
  59118. */
  59119. dispose(): void;
  59120. /**
  59121. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59122. * @param mesh The mesh to replace the default mesh of the gizmo
  59123. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59124. */
  59125. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59126. }
  59127. }
  59128. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59129. import { Observable } from "babylonjs/Misc/observable";
  59130. import { Nullable } from "babylonjs/types";
  59131. import { Vector3 } from "babylonjs/Maths/math.vector";
  59132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59133. import { Mesh } from "babylonjs/Meshes/mesh";
  59134. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59135. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59136. import { Color3 } from "babylonjs/Maths/math.color";
  59137. import "babylonjs/Meshes/Builders/boxBuilder";
  59138. /**
  59139. * Bounding box gizmo
  59140. */
  59141. export class BoundingBoxGizmo extends Gizmo {
  59142. private _lineBoundingBox;
  59143. private _rotateSpheresParent;
  59144. private _scaleBoxesParent;
  59145. private _boundingDimensions;
  59146. private _renderObserver;
  59147. private _pointerObserver;
  59148. private _scaleDragSpeed;
  59149. private _tmpQuaternion;
  59150. private _tmpVector;
  59151. private _tmpRotationMatrix;
  59152. /**
  59153. * 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)
  59154. */
  59155. ignoreChildren: boolean;
  59156. /**
  59157. * 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)
  59158. */
  59159. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59160. /**
  59161. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59162. */
  59163. rotationSphereSize: number;
  59164. /**
  59165. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59166. */
  59167. scaleBoxSize: number;
  59168. /**
  59169. * 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)
  59170. */
  59171. fixedDragMeshScreenSize: boolean;
  59172. /**
  59173. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59174. */
  59175. fixedDragMeshScreenSizeDistanceFactor: number;
  59176. /**
  59177. * Fired when a rotation sphere or scale box is dragged
  59178. */
  59179. onDragStartObservable: Observable<{}>;
  59180. /**
  59181. * Fired when a scale box is dragged
  59182. */
  59183. onScaleBoxDragObservable: Observable<{}>;
  59184. /**
  59185. * Fired when a scale box drag is ended
  59186. */
  59187. onScaleBoxDragEndObservable: Observable<{}>;
  59188. /**
  59189. * Fired when a rotation sphere is dragged
  59190. */
  59191. onRotationSphereDragObservable: Observable<{}>;
  59192. /**
  59193. * Fired when a rotation sphere drag is ended
  59194. */
  59195. onRotationSphereDragEndObservable: Observable<{}>;
  59196. /**
  59197. * 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)
  59198. */
  59199. scalePivot: Nullable<Vector3>;
  59200. /**
  59201. * Mesh used as a pivot to rotate the attached node
  59202. */
  59203. private _anchorMesh;
  59204. private _existingMeshScale;
  59205. private _dragMesh;
  59206. private pointerDragBehavior;
  59207. private coloredMaterial;
  59208. private hoverColoredMaterial;
  59209. /**
  59210. * Sets the color of the bounding box gizmo
  59211. * @param color the color to set
  59212. */
  59213. setColor(color: Color3): void;
  59214. /**
  59215. * Creates an BoundingBoxGizmo
  59216. * @param gizmoLayer The utility layer the gizmo will be added to
  59217. * @param color The color of the gizmo
  59218. */
  59219. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59220. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59221. private _selectNode;
  59222. /**
  59223. * Updates the bounding box information for the Gizmo
  59224. */
  59225. updateBoundingBox(): void;
  59226. private _updateRotationSpheres;
  59227. private _updateScaleBoxes;
  59228. /**
  59229. * Enables rotation on the specified axis and disables rotation on the others
  59230. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59231. */
  59232. setEnabledRotationAxis(axis: string): void;
  59233. /**
  59234. * Enables/disables scaling
  59235. * @param enable if scaling should be enabled
  59236. * @param homogeneousScaling defines if scaling should only be homogeneous
  59237. */
  59238. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59239. private _updateDummy;
  59240. /**
  59241. * Enables a pointer drag behavior on the bounding box of the gizmo
  59242. */
  59243. enableDragBehavior(): void;
  59244. /**
  59245. * Disposes of the gizmo
  59246. */
  59247. dispose(): void;
  59248. /**
  59249. * 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)
  59250. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59251. * @returns the bounding box mesh with the passed in mesh as a child
  59252. */
  59253. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59254. /**
  59255. * CustomMeshes are not supported by this gizmo
  59256. * @param mesh The mesh to replace the default mesh of the gizmo
  59257. */
  59258. setCustomMesh(mesh: Mesh): void;
  59259. }
  59260. }
  59261. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59262. import { Observable } from "babylonjs/Misc/observable";
  59263. import { Nullable } from "babylonjs/types";
  59264. import { Vector3 } from "babylonjs/Maths/math.vector";
  59265. import { Color3 } from "babylonjs/Maths/math.color";
  59266. import { Node } from "babylonjs/node";
  59267. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59268. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59269. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59270. import "babylonjs/Meshes/Builders/linesBuilder";
  59271. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59272. /**
  59273. * Single plane rotation gizmo
  59274. */
  59275. export class PlaneRotationGizmo extends Gizmo {
  59276. /**
  59277. * Drag behavior responsible for the gizmos dragging interactions
  59278. */
  59279. dragBehavior: PointerDragBehavior;
  59280. private _pointerObserver;
  59281. /**
  59282. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59283. */
  59284. snapDistance: number;
  59285. /**
  59286. * Event that fires each time the gizmo snaps to a new location.
  59287. * * snapDistance is the the change in distance
  59288. */
  59289. onSnapObservable: Observable<{
  59290. snapDistance: number;
  59291. }>;
  59292. private _isEnabled;
  59293. private _parent;
  59294. /**
  59295. * Creates a PlaneRotationGizmo
  59296. * @param gizmoLayer The utility layer the gizmo will be added to
  59297. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59298. * @param color The color of the gizmo
  59299. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59300. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59301. * @param thickness display gizmo axis thickness
  59302. */
  59303. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59304. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59305. /**
  59306. * If the gizmo is enabled
  59307. */
  59308. set isEnabled(value: boolean);
  59309. get isEnabled(): boolean;
  59310. /**
  59311. * Disposes of the gizmo
  59312. */
  59313. dispose(): void;
  59314. }
  59315. }
  59316. declare module "babylonjs/Gizmos/rotationGizmo" {
  59317. import { Observable } from "babylonjs/Misc/observable";
  59318. import { Nullable } from "babylonjs/types";
  59319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59320. import { Mesh } from "babylonjs/Meshes/mesh";
  59321. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59322. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59323. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59324. import { Node } from "babylonjs/node";
  59325. /**
  59326. * Gizmo that enables rotating a mesh along 3 axis
  59327. */
  59328. export class RotationGizmo extends Gizmo {
  59329. /**
  59330. * Internal gizmo used for interactions on the x axis
  59331. */
  59332. xGizmo: PlaneRotationGizmo;
  59333. /**
  59334. * Internal gizmo used for interactions on the y axis
  59335. */
  59336. yGizmo: PlaneRotationGizmo;
  59337. /**
  59338. * Internal gizmo used for interactions on the z axis
  59339. */
  59340. zGizmo: PlaneRotationGizmo;
  59341. /** Fires an event when any of it's sub gizmos are dragged */
  59342. onDragStartObservable: Observable<unknown>;
  59343. /** Fires an event when any of it's sub gizmos are released from dragging */
  59344. onDragEndObservable: Observable<unknown>;
  59345. private _meshAttached;
  59346. private _nodeAttached;
  59347. get attachedMesh(): Nullable<AbstractMesh>;
  59348. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59349. get attachedNode(): Nullable<Node>;
  59350. set attachedNode(node: Nullable<Node>);
  59351. protected _checkBillboardTransform(): void;
  59352. /**
  59353. * True when the mouse pointer is hovering a gizmo mesh
  59354. */
  59355. get isHovered(): boolean;
  59356. /**
  59357. * Creates a RotationGizmo
  59358. * @param gizmoLayer The utility layer the gizmo will be added to
  59359. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59360. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59361. * @param thickness display gizmo axis thickness
  59362. */
  59363. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59364. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59365. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59366. /**
  59367. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59368. */
  59369. set snapDistance(value: number);
  59370. get snapDistance(): number;
  59371. /**
  59372. * Ratio for the scale of the gizmo (Default: 1)
  59373. */
  59374. set scaleRatio(value: number);
  59375. get scaleRatio(): number;
  59376. /**
  59377. * Disposes of the gizmo
  59378. */
  59379. dispose(): void;
  59380. /**
  59381. * CustomMeshes are not supported by this gizmo
  59382. * @param mesh The mesh to replace the default mesh of the gizmo
  59383. */
  59384. setCustomMesh(mesh: Mesh): void;
  59385. }
  59386. }
  59387. declare module "babylonjs/Gizmos/gizmoManager" {
  59388. import { Observable } from "babylonjs/Misc/observable";
  59389. import { Nullable } from "babylonjs/types";
  59390. import { Scene, IDisposable } from "babylonjs/scene";
  59391. import { Node } from "babylonjs/node";
  59392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59393. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59394. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59395. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59396. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59397. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59398. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59399. /**
  59400. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59401. */
  59402. export class GizmoManager implements IDisposable {
  59403. private scene;
  59404. /**
  59405. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59406. */
  59407. gizmos: {
  59408. positionGizmo: Nullable<PositionGizmo>;
  59409. rotationGizmo: Nullable<RotationGizmo>;
  59410. scaleGizmo: Nullable<ScaleGizmo>;
  59411. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59412. };
  59413. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59414. clearGizmoOnEmptyPointerEvent: boolean;
  59415. /** Fires an event when the manager is attached to a mesh */
  59416. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59417. /** Fires an event when the manager is attached to a node */
  59418. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59419. private _gizmosEnabled;
  59420. private _pointerObserver;
  59421. private _attachedMesh;
  59422. private _attachedNode;
  59423. private _boundingBoxColor;
  59424. private _defaultUtilityLayer;
  59425. private _defaultKeepDepthUtilityLayer;
  59426. private _thickness;
  59427. /**
  59428. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59429. */
  59430. boundingBoxDragBehavior: SixDofDragBehavior;
  59431. /**
  59432. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59433. */
  59434. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59435. /**
  59436. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59437. */
  59438. attachableNodes: Nullable<Array<Node>>;
  59439. /**
  59440. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59441. */
  59442. usePointerToAttachGizmos: boolean;
  59443. /**
  59444. * Utility layer that the bounding box gizmo belongs to
  59445. */
  59446. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59447. /**
  59448. * Utility layer that all gizmos besides bounding box belong to
  59449. */
  59450. get utilityLayer(): UtilityLayerRenderer;
  59451. /**
  59452. * True when the mouse pointer is hovering a gizmo mesh
  59453. */
  59454. get isHovered(): boolean;
  59455. /**
  59456. * Instatiates a gizmo manager
  59457. * @param scene the scene to overlay the gizmos on top of
  59458. * @param thickness display gizmo axis thickness
  59459. */
  59460. constructor(scene: Scene, thickness?: number);
  59461. /**
  59462. * Attaches a set of gizmos to the specified mesh
  59463. * @param mesh The mesh the gizmo's should be attached to
  59464. */
  59465. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59466. /**
  59467. * Attaches a set of gizmos to the specified node
  59468. * @param node The node the gizmo's should be attached to
  59469. */
  59470. attachToNode(node: Nullable<Node>): void;
  59471. /**
  59472. * If the position gizmo is enabled
  59473. */
  59474. set positionGizmoEnabled(value: boolean);
  59475. get positionGizmoEnabled(): boolean;
  59476. /**
  59477. * If the rotation gizmo is enabled
  59478. */
  59479. set rotationGizmoEnabled(value: boolean);
  59480. get rotationGizmoEnabled(): boolean;
  59481. /**
  59482. * If the scale gizmo is enabled
  59483. */
  59484. set scaleGizmoEnabled(value: boolean);
  59485. get scaleGizmoEnabled(): boolean;
  59486. /**
  59487. * If the boundingBox gizmo is enabled
  59488. */
  59489. set boundingBoxGizmoEnabled(value: boolean);
  59490. get boundingBoxGizmoEnabled(): boolean;
  59491. /**
  59492. * Disposes of the gizmo manager
  59493. */
  59494. dispose(): void;
  59495. }
  59496. }
  59497. declare module "babylonjs/Lights/directionalLight" {
  59498. import { Camera } from "babylonjs/Cameras/camera";
  59499. import { Scene } from "babylonjs/scene";
  59500. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59502. import { Light } from "babylonjs/Lights/light";
  59503. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59504. import { Effect } from "babylonjs/Materials/effect";
  59505. /**
  59506. * A directional light is defined by a direction (what a surprise!).
  59507. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59508. * 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.
  59509. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59510. */
  59511. export class DirectionalLight extends ShadowLight {
  59512. private _shadowFrustumSize;
  59513. /**
  59514. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59515. */
  59516. get shadowFrustumSize(): number;
  59517. /**
  59518. * Specifies a fix frustum size for the shadow generation.
  59519. */
  59520. set shadowFrustumSize(value: number);
  59521. private _shadowOrthoScale;
  59522. /**
  59523. * Gets the shadow projection scale against the optimal computed one.
  59524. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59525. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59526. */
  59527. get shadowOrthoScale(): number;
  59528. /**
  59529. * Sets the shadow projection scale against the optimal computed one.
  59530. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59531. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59532. */
  59533. set shadowOrthoScale(value: number);
  59534. /**
  59535. * Automatically compute the projection matrix to best fit (including all the casters)
  59536. * on each frame.
  59537. */
  59538. autoUpdateExtends: boolean;
  59539. /**
  59540. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59541. * on each frame. autoUpdateExtends must be set to true for this to work
  59542. */
  59543. autoCalcShadowZBounds: boolean;
  59544. private _orthoLeft;
  59545. private _orthoRight;
  59546. private _orthoTop;
  59547. private _orthoBottom;
  59548. /**
  59549. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59550. * The directional light is emitted from everywhere in the given direction.
  59551. * It can cast shadows.
  59552. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59553. * @param name The friendly name of the light
  59554. * @param direction The direction of the light
  59555. * @param scene The scene the light belongs to
  59556. */
  59557. constructor(name: string, direction: Vector3, scene: Scene);
  59558. /**
  59559. * Returns the string "DirectionalLight".
  59560. * @return The class name
  59561. */
  59562. getClassName(): string;
  59563. /**
  59564. * Returns the integer 1.
  59565. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59566. */
  59567. getTypeID(): number;
  59568. /**
  59569. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59570. * Returns the DirectionalLight Shadow projection matrix.
  59571. */
  59572. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59573. /**
  59574. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59575. * Returns the DirectionalLight Shadow projection matrix.
  59576. */
  59577. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59578. /**
  59579. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59580. * Returns the DirectionalLight Shadow projection matrix.
  59581. */
  59582. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59583. protected _buildUniformLayout(): void;
  59584. /**
  59585. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59586. * @param effect The effect to update
  59587. * @param lightIndex The index of the light in the effect to update
  59588. * @returns The directional light
  59589. */
  59590. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59591. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59592. /**
  59593. * Gets the minZ used for shadow according to both the scene and the light.
  59594. *
  59595. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59596. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59597. * @param activeCamera The camera we are returning the min for
  59598. * @returns the depth min z
  59599. */
  59600. getDepthMinZ(activeCamera: Camera): number;
  59601. /**
  59602. * Gets the maxZ used for shadow according to both the scene and the light.
  59603. *
  59604. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59605. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59606. * @param activeCamera The camera we are returning the max for
  59607. * @returns the depth max z
  59608. */
  59609. getDepthMaxZ(activeCamera: Camera): number;
  59610. /**
  59611. * Prepares the list of defines specific to the light type.
  59612. * @param defines the list of defines
  59613. * @param lightIndex defines the index of the light for the effect
  59614. */
  59615. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59616. }
  59617. }
  59618. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59619. import { Mesh } from "babylonjs/Meshes/mesh";
  59620. /**
  59621. * Class containing static functions to help procedurally build meshes
  59622. */
  59623. export class HemisphereBuilder {
  59624. /**
  59625. * Creates a hemisphere mesh
  59626. * @param name defines the name of the mesh
  59627. * @param options defines the options used to create the mesh
  59628. * @param scene defines the hosting scene
  59629. * @returns the hemisphere mesh
  59630. */
  59631. static CreateHemisphere(name: string, options: {
  59632. segments?: number;
  59633. diameter?: number;
  59634. sideOrientation?: number;
  59635. }, scene: any): Mesh;
  59636. }
  59637. }
  59638. declare module "babylonjs/Lights/spotLight" {
  59639. import { Nullable } from "babylonjs/types";
  59640. import { Scene } from "babylonjs/scene";
  59641. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59643. import { Effect } from "babylonjs/Materials/effect";
  59644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59645. import { Light } from "babylonjs/Lights/light";
  59646. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59647. /**
  59648. * A spot light is defined by a position, a direction, an angle, and an exponent.
  59649. * These values define a cone of light starting from the position, emitting toward the direction.
  59650. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  59651. * and the exponent defines the speed of the decay of the light with distance (reach).
  59652. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59653. */
  59654. export class SpotLight extends ShadowLight {
  59655. private _angle;
  59656. private _innerAngle;
  59657. private _cosHalfAngle;
  59658. private _lightAngleScale;
  59659. private _lightAngleOffset;
  59660. /**
  59661. * Gets the cone angle of the spot light in Radians.
  59662. */
  59663. get angle(): number;
  59664. /**
  59665. * Sets the cone angle of the spot light in Radians.
  59666. */
  59667. set angle(value: number);
  59668. /**
  59669. * Only used in gltf falloff mode, this defines the angle where
  59670. * the directional falloff will start before cutting at angle which could be seen
  59671. * as outer angle.
  59672. */
  59673. get innerAngle(): number;
  59674. /**
  59675. * Only used in gltf falloff mode, this defines the angle where
  59676. * the directional falloff will start before cutting at angle which could be seen
  59677. * as outer angle.
  59678. */
  59679. set innerAngle(value: number);
  59680. private _shadowAngleScale;
  59681. /**
  59682. * Allows scaling the angle of the light for shadow generation only.
  59683. */
  59684. get shadowAngleScale(): number;
  59685. /**
  59686. * Allows scaling the angle of the light for shadow generation only.
  59687. */
  59688. set shadowAngleScale(value: number);
  59689. /**
  59690. * The light decay speed with the distance from the emission spot.
  59691. */
  59692. exponent: number;
  59693. private _projectionTextureMatrix;
  59694. /**
  59695. * Allows reading the projecton texture
  59696. */
  59697. get projectionTextureMatrix(): Matrix;
  59698. protected _projectionTextureLightNear: number;
  59699. /**
  59700. * Gets the near clip of the Spotlight for texture projection.
  59701. */
  59702. get projectionTextureLightNear(): number;
  59703. /**
  59704. * Sets the near clip of the Spotlight for texture projection.
  59705. */
  59706. set projectionTextureLightNear(value: number);
  59707. protected _projectionTextureLightFar: number;
  59708. /**
  59709. * Gets the far clip of the Spotlight for texture projection.
  59710. */
  59711. get projectionTextureLightFar(): number;
  59712. /**
  59713. * Sets the far clip of the Spotlight for texture projection.
  59714. */
  59715. set projectionTextureLightFar(value: number);
  59716. protected _projectionTextureUpDirection: Vector3;
  59717. /**
  59718. * Gets the Up vector of the Spotlight for texture projection.
  59719. */
  59720. get projectionTextureUpDirection(): Vector3;
  59721. /**
  59722. * Sets the Up vector of the Spotlight for texture projection.
  59723. */
  59724. set projectionTextureUpDirection(value: Vector3);
  59725. private _projectionTexture;
  59726. /**
  59727. * Gets the projection texture of the light.
  59728. */
  59729. get projectionTexture(): Nullable<BaseTexture>;
  59730. /**
  59731. * Sets the projection texture of the light.
  59732. */
  59733. set projectionTexture(value: Nullable<BaseTexture>);
  59734. private _projectionTextureViewLightDirty;
  59735. private _projectionTextureProjectionLightDirty;
  59736. private _projectionTextureDirty;
  59737. private _projectionTextureViewTargetVector;
  59738. private _projectionTextureViewLightMatrix;
  59739. private _projectionTextureProjectionLightMatrix;
  59740. private _projectionTextureScalingMatrix;
  59741. /**
  59742. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  59743. * It can cast shadows.
  59744. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59745. * @param name The light friendly name
  59746. * @param position The position of the spot light in the scene
  59747. * @param direction The direction of the light in the scene
  59748. * @param angle The cone angle of the light in Radians
  59749. * @param exponent The light decay speed with the distance from the emission spot
  59750. * @param scene The scene the lights belongs to
  59751. */
  59752. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  59753. /**
  59754. * Returns the string "SpotLight".
  59755. * @returns the class name
  59756. */
  59757. getClassName(): string;
  59758. /**
  59759. * Returns the integer 2.
  59760. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59761. */
  59762. getTypeID(): number;
  59763. /**
  59764. * Overrides the direction setter to recompute the projection texture view light Matrix.
  59765. */
  59766. protected _setDirection(value: Vector3): void;
  59767. /**
  59768. * Overrides the position setter to recompute the projection texture view light Matrix.
  59769. */
  59770. protected _setPosition(value: Vector3): void;
  59771. /**
  59772. * 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.
  59773. * Returns the SpotLight.
  59774. */
  59775. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59776. protected _computeProjectionTextureViewLightMatrix(): void;
  59777. protected _computeProjectionTextureProjectionLightMatrix(): void;
  59778. /**
  59779. * Main function for light texture projection matrix computing.
  59780. */
  59781. protected _computeProjectionTextureMatrix(): void;
  59782. protected _buildUniformLayout(): void;
  59783. private _computeAngleValues;
  59784. /**
  59785. * Sets the passed Effect "effect" with the Light textures.
  59786. * @param effect The effect to update
  59787. * @param lightIndex The index of the light in the effect to update
  59788. * @returns The light
  59789. */
  59790. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  59791. /**
  59792. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  59793. * @param effect The effect to update
  59794. * @param lightIndex The index of the light in the effect to update
  59795. * @returns The spot light
  59796. */
  59797. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  59798. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59799. /**
  59800. * Disposes the light and the associated resources.
  59801. */
  59802. dispose(): void;
  59803. /**
  59804. * Prepares the list of defines specific to the light type.
  59805. * @param defines the list of defines
  59806. * @param lightIndex defines the index of the light for the effect
  59807. */
  59808. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59809. }
  59810. }
  59811. declare module "babylonjs/Gizmos/lightGizmo" {
  59812. import { Nullable } from "babylonjs/types";
  59813. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59814. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59815. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59816. import { Light } from "babylonjs/Lights/light";
  59817. import { Observable } from "babylonjs/Misc/observable";
  59818. /**
  59819. * Gizmo that enables viewing a light
  59820. */
  59821. export class LightGizmo extends Gizmo {
  59822. private _lightMesh;
  59823. private _material;
  59824. private _cachedPosition;
  59825. private _cachedForward;
  59826. private _attachedMeshParent;
  59827. private _pointerObserver;
  59828. /**
  59829. * Event that fires each time the gizmo is clicked
  59830. */
  59831. onClickedObservable: Observable<Light>;
  59832. /**
  59833. * Creates a LightGizmo
  59834. * @param gizmoLayer The utility layer the gizmo will be added to
  59835. */
  59836. constructor(gizmoLayer?: UtilityLayerRenderer);
  59837. private _light;
  59838. /**
  59839. * The light that the gizmo is attached to
  59840. */
  59841. set light(light: Nullable<Light>);
  59842. get light(): Nullable<Light>;
  59843. /**
  59844. * Gets the material used to render the light gizmo
  59845. */
  59846. get material(): StandardMaterial;
  59847. /**
  59848. * @hidden
  59849. * Updates the gizmo to match the attached mesh's position/rotation
  59850. */
  59851. protected _update(): void;
  59852. private static _Scale;
  59853. /**
  59854. * Creates the lines for a light mesh
  59855. */
  59856. private static _CreateLightLines;
  59857. /**
  59858. * Disposes of the light gizmo
  59859. */
  59860. dispose(): void;
  59861. private static _CreateHemisphericLightMesh;
  59862. private static _CreatePointLightMesh;
  59863. private static _CreateSpotLightMesh;
  59864. private static _CreateDirectionalLightMesh;
  59865. }
  59866. }
  59867. declare module "babylonjs/Gizmos/cameraGizmo" {
  59868. import { Nullable } from "babylonjs/types";
  59869. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59870. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59871. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59872. import { Camera } from "babylonjs/Cameras/camera";
  59873. import { Observable } from "babylonjs/Misc/observable";
  59874. /**
  59875. * Gizmo that enables viewing a camera
  59876. */
  59877. export class CameraGizmo extends Gizmo {
  59878. private _cameraMesh;
  59879. private _cameraLinesMesh;
  59880. private _material;
  59881. private _pointerObserver;
  59882. /**
  59883. * Event that fires each time the gizmo is clicked
  59884. */
  59885. onClickedObservable: Observable<Camera>;
  59886. /**
  59887. * Creates a CameraGizmo
  59888. * @param gizmoLayer The utility layer the gizmo will be added to
  59889. */
  59890. constructor(gizmoLayer?: UtilityLayerRenderer);
  59891. private _camera;
  59892. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  59893. get displayFrustum(): boolean;
  59894. set displayFrustum(value: boolean);
  59895. /**
  59896. * The camera that the gizmo is attached to
  59897. */
  59898. set camera(camera: Nullable<Camera>);
  59899. get camera(): Nullable<Camera>;
  59900. /**
  59901. * Gets the material used to render the camera gizmo
  59902. */
  59903. get material(): StandardMaterial;
  59904. /**
  59905. * @hidden
  59906. * Updates the gizmo to match the attached mesh's position/rotation
  59907. */
  59908. protected _update(): void;
  59909. private static _Scale;
  59910. private _invProjection;
  59911. /**
  59912. * Disposes of the camera gizmo
  59913. */
  59914. dispose(): void;
  59915. private static _CreateCameraMesh;
  59916. private static _CreateCameraFrustum;
  59917. }
  59918. }
  59919. declare module "babylonjs/Gizmos/index" {
  59920. export * from "babylonjs/Gizmos/axisDragGizmo";
  59921. export * from "babylonjs/Gizmos/axisScaleGizmo";
  59922. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  59923. export * from "babylonjs/Gizmos/gizmo";
  59924. export * from "babylonjs/Gizmos/gizmoManager";
  59925. export * from "babylonjs/Gizmos/planeRotationGizmo";
  59926. export * from "babylonjs/Gizmos/positionGizmo";
  59927. export * from "babylonjs/Gizmos/rotationGizmo";
  59928. export * from "babylonjs/Gizmos/scaleGizmo";
  59929. export * from "babylonjs/Gizmos/lightGizmo";
  59930. export * from "babylonjs/Gizmos/cameraGizmo";
  59931. export * from "babylonjs/Gizmos/planeDragGizmo";
  59932. }
  59933. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  59934. /** @hidden */
  59935. export var backgroundFragmentDeclaration: {
  59936. name: string;
  59937. shader: string;
  59938. };
  59939. }
  59940. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  59941. /** @hidden */
  59942. export var backgroundUboDeclaration: {
  59943. name: string;
  59944. shader: string;
  59945. };
  59946. }
  59947. declare module "babylonjs/Shaders/background.fragment" {
  59948. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  59949. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59950. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59951. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59952. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59953. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59954. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59955. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59956. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59957. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59958. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  59959. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59960. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59961. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59962. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  59963. /** @hidden */
  59964. export var backgroundPixelShader: {
  59965. name: string;
  59966. shader: string;
  59967. };
  59968. }
  59969. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  59970. /** @hidden */
  59971. export var backgroundVertexDeclaration: {
  59972. name: string;
  59973. shader: string;
  59974. };
  59975. }
  59976. declare module "babylonjs/Shaders/background.vertex" {
  59977. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  59978. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59979. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59980. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59981. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59982. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59983. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59984. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59985. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59986. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59987. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59988. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59989. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59990. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59991. /** @hidden */
  59992. export var backgroundVertexShader: {
  59993. name: string;
  59994. shader: string;
  59995. };
  59996. }
  59997. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  59998. import { Nullable, int, float } from "babylonjs/types";
  59999. import { Scene } from "babylonjs/scene";
  60000. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60001. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60003. import { Mesh } from "babylonjs/Meshes/mesh";
  60004. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60005. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60006. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60007. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60008. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60009. import { Color3 } from "babylonjs/Maths/math.color";
  60010. import "babylonjs/Shaders/background.fragment";
  60011. import "babylonjs/Shaders/background.vertex";
  60012. /**
  60013. * Background material used to create an efficient environement around your scene.
  60014. */
  60015. export class BackgroundMaterial extends PushMaterial {
  60016. /**
  60017. * Standard reflectance value at parallel view angle.
  60018. */
  60019. static StandardReflectance0: number;
  60020. /**
  60021. * Standard reflectance value at grazing angle.
  60022. */
  60023. static StandardReflectance90: number;
  60024. protected _primaryColor: Color3;
  60025. /**
  60026. * Key light Color (multiply against the environement texture)
  60027. */
  60028. primaryColor: Color3;
  60029. protected __perceptualColor: Nullable<Color3>;
  60030. /**
  60031. * Experimental Internal Use Only.
  60032. *
  60033. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60034. * This acts as a helper to set the primary color to a more "human friendly" value.
  60035. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60036. * output color as close as possible from the chosen value.
  60037. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60038. * part of lighting setup.)
  60039. */
  60040. get _perceptualColor(): Nullable<Color3>;
  60041. set _perceptualColor(value: Nullable<Color3>);
  60042. protected _primaryColorShadowLevel: float;
  60043. /**
  60044. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60045. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60046. */
  60047. get primaryColorShadowLevel(): float;
  60048. set primaryColorShadowLevel(value: float);
  60049. protected _primaryColorHighlightLevel: float;
  60050. /**
  60051. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60052. * The primary color is used at the level chosen to define what the white area would look.
  60053. */
  60054. get primaryColorHighlightLevel(): float;
  60055. set primaryColorHighlightLevel(value: float);
  60056. protected _reflectionTexture: Nullable<BaseTexture>;
  60057. /**
  60058. * Reflection Texture used in the material.
  60059. * Should be author in a specific way for the best result (refer to the documentation).
  60060. */
  60061. reflectionTexture: Nullable<BaseTexture>;
  60062. protected _reflectionBlur: float;
  60063. /**
  60064. * Reflection Texture level of blur.
  60065. *
  60066. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60067. * texture twice.
  60068. */
  60069. reflectionBlur: float;
  60070. protected _diffuseTexture: Nullable<BaseTexture>;
  60071. /**
  60072. * Diffuse Texture used in the material.
  60073. * Should be author in a specific way for the best result (refer to the documentation).
  60074. */
  60075. diffuseTexture: Nullable<BaseTexture>;
  60076. protected _shadowLights: Nullable<IShadowLight[]>;
  60077. /**
  60078. * Specify the list of lights casting shadow on the material.
  60079. * All scene shadow lights will be included if null.
  60080. */
  60081. shadowLights: Nullable<IShadowLight[]>;
  60082. protected _shadowLevel: float;
  60083. /**
  60084. * Helps adjusting the shadow to a softer level if required.
  60085. * 0 means black shadows and 1 means no shadows.
  60086. */
  60087. shadowLevel: float;
  60088. protected _sceneCenter: Vector3;
  60089. /**
  60090. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60091. * It is usually zero but might be interesting to modify according to your setup.
  60092. */
  60093. sceneCenter: Vector3;
  60094. protected _opacityFresnel: boolean;
  60095. /**
  60096. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60097. * This helps ensuring a nice transition when the camera goes under the ground.
  60098. */
  60099. opacityFresnel: boolean;
  60100. protected _reflectionFresnel: boolean;
  60101. /**
  60102. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60103. * This helps adding a mirror texture on the ground.
  60104. */
  60105. reflectionFresnel: boolean;
  60106. protected _reflectionFalloffDistance: number;
  60107. /**
  60108. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60109. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60110. */
  60111. reflectionFalloffDistance: number;
  60112. protected _reflectionAmount: number;
  60113. /**
  60114. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60115. */
  60116. reflectionAmount: number;
  60117. protected _reflectionReflectance0: number;
  60118. /**
  60119. * This specifies the weight of the reflection at grazing angle.
  60120. */
  60121. reflectionReflectance0: number;
  60122. protected _reflectionReflectance90: number;
  60123. /**
  60124. * This specifies the weight of the reflection at a perpendicular point of view.
  60125. */
  60126. reflectionReflectance90: number;
  60127. /**
  60128. * Sets the reflection reflectance fresnel values according to the default standard
  60129. * empirically know to work well :-)
  60130. */
  60131. set reflectionStandardFresnelWeight(value: number);
  60132. protected _useRGBColor: boolean;
  60133. /**
  60134. * Helps to directly use the maps channels instead of their level.
  60135. */
  60136. useRGBColor: boolean;
  60137. protected _enableNoise: boolean;
  60138. /**
  60139. * This helps reducing the banding effect that could occur on the background.
  60140. */
  60141. enableNoise: boolean;
  60142. /**
  60143. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60144. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60145. * Recommended to be keep at 1.0 except for special cases.
  60146. */
  60147. get fovMultiplier(): number;
  60148. set fovMultiplier(value: number);
  60149. private _fovMultiplier;
  60150. /**
  60151. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60152. */
  60153. useEquirectangularFOV: boolean;
  60154. private _maxSimultaneousLights;
  60155. /**
  60156. * Number of Simultaneous lights allowed on the material.
  60157. */
  60158. maxSimultaneousLights: int;
  60159. private _shadowOnly;
  60160. /**
  60161. * Make the material only render shadows
  60162. */
  60163. shadowOnly: boolean;
  60164. /**
  60165. * Default configuration related to image processing available in the Background Material.
  60166. */
  60167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60168. /**
  60169. * Keep track of the image processing observer to allow dispose and replace.
  60170. */
  60171. private _imageProcessingObserver;
  60172. /**
  60173. * Attaches a new image processing configuration to the PBR Material.
  60174. * @param configuration (if null the scene configuration will be use)
  60175. */
  60176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60177. /**
  60178. * Gets the image processing configuration used either in this material.
  60179. */
  60180. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60181. /**
  60182. * Sets the Default image processing configuration used either in the this material.
  60183. *
  60184. * If sets to null, the scene one is in use.
  60185. */
  60186. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60187. /**
  60188. * Gets wether the color curves effect is enabled.
  60189. */
  60190. get cameraColorCurvesEnabled(): boolean;
  60191. /**
  60192. * Sets wether the color curves effect is enabled.
  60193. */
  60194. set cameraColorCurvesEnabled(value: boolean);
  60195. /**
  60196. * Gets wether the color grading effect is enabled.
  60197. */
  60198. get cameraColorGradingEnabled(): boolean;
  60199. /**
  60200. * Gets wether the color grading effect is enabled.
  60201. */
  60202. set cameraColorGradingEnabled(value: boolean);
  60203. /**
  60204. * Gets wether tonemapping is enabled or not.
  60205. */
  60206. get cameraToneMappingEnabled(): boolean;
  60207. /**
  60208. * Sets wether tonemapping is enabled or not
  60209. */
  60210. set cameraToneMappingEnabled(value: boolean);
  60211. /**
  60212. * The camera exposure used on this material.
  60213. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60214. * This corresponds to a photographic exposure.
  60215. */
  60216. get cameraExposure(): float;
  60217. /**
  60218. * The camera exposure used on this material.
  60219. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60220. * This corresponds to a photographic exposure.
  60221. */
  60222. set cameraExposure(value: float);
  60223. /**
  60224. * Gets The camera contrast used on this material.
  60225. */
  60226. get cameraContrast(): float;
  60227. /**
  60228. * Sets The camera contrast used on this material.
  60229. */
  60230. set cameraContrast(value: float);
  60231. /**
  60232. * Gets the Color Grading 2D Lookup Texture.
  60233. */
  60234. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60235. /**
  60236. * Sets the Color Grading 2D Lookup Texture.
  60237. */
  60238. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60239. /**
  60240. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60241. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60242. * 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;
  60243. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60244. */
  60245. get cameraColorCurves(): Nullable<ColorCurves>;
  60246. /**
  60247. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60248. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60249. * 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;
  60250. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60251. */
  60252. set cameraColorCurves(value: Nullable<ColorCurves>);
  60253. /**
  60254. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60255. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60256. */
  60257. switchToBGR: boolean;
  60258. private _renderTargets;
  60259. private _reflectionControls;
  60260. private _white;
  60261. private _primaryShadowColor;
  60262. private _primaryHighlightColor;
  60263. /**
  60264. * Instantiates a Background Material in the given scene
  60265. * @param name The friendly name of the material
  60266. * @param scene The scene to add the material to
  60267. */
  60268. constructor(name: string, scene: Scene);
  60269. /**
  60270. * Gets a boolean indicating that current material needs to register RTT
  60271. */
  60272. get hasRenderTargetTextures(): boolean;
  60273. /**
  60274. * The entire material has been created in order to prevent overdraw.
  60275. * @returns false
  60276. */
  60277. needAlphaTesting(): boolean;
  60278. /**
  60279. * The entire material has been created in order to prevent overdraw.
  60280. * @returns true if blending is enable
  60281. */
  60282. needAlphaBlending(): boolean;
  60283. /**
  60284. * Checks wether the material is ready to be rendered for a given mesh.
  60285. * @param mesh The mesh to render
  60286. * @param subMesh The submesh to check against
  60287. * @param useInstances Specify wether or not the material is used with instances
  60288. * @returns true if all the dependencies are ready (Textures, Effects...)
  60289. */
  60290. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60291. /**
  60292. * Compute the primary color according to the chosen perceptual color.
  60293. */
  60294. private _computePrimaryColorFromPerceptualColor;
  60295. /**
  60296. * Compute the highlights and shadow colors according to their chosen levels.
  60297. */
  60298. private _computePrimaryColors;
  60299. /**
  60300. * Build the uniform buffer used in the material.
  60301. */
  60302. buildUniformLayout(): void;
  60303. /**
  60304. * Unbind the material.
  60305. */
  60306. unbind(): void;
  60307. /**
  60308. * Bind only the world matrix to the material.
  60309. * @param world The world matrix to bind.
  60310. */
  60311. bindOnlyWorldMatrix(world: Matrix): void;
  60312. /**
  60313. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60314. * @param world The world matrix to bind.
  60315. * @param subMesh The submesh to bind for.
  60316. */
  60317. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60318. /**
  60319. * Checks to see if a texture is used in the material.
  60320. * @param texture - Base texture to use.
  60321. * @returns - Boolean specifying if a texture is used in the material.
  60322. */
  60323. hasTexture(texture: BaseTexture): boolean;
  60324. /**
  60325. * Dispose the material.
  60326. * @param forceDisposeEffect Force disposal of the associated effect.
  60327. * @param forceDisposeTextures Force disposal of the associated textures.
  60328. */
  60329. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60330. /**
  60331. * Clones the material.
  60332. * @param name The cloned name.
  60333. * @returns The cloned material.
  60334. */
  60335. clone(name: string): BackgroundMaterial;
  60336. /**
  60337. * Serializes the current material to its JSON representation.
  60338. * @returns The JSON representation.
  60339. */
  60340. serialize(): any;
  60341. /**
  60342. * Gets the class name of the material
  60343. * @returns "BackgroundMaterial"
  60344. */
  60345. getClassName(): string;
  60346. /**
  60347. * Parse a JSON input to create back a background material.
  60348. * @param source The JSON data to parse
  60349. * @param scene The scene to create the parsed material in
  60350. * @param rootUrl The root url of the assets the material depends upon
  60351. * @returns the instantiated BackgroundMaterial.
  60352. */
  60353. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60354. }
  60355. }
  60356. declare module "babylonjs/Helpers/environmentHelper" {
  60357. import { Observable } from "babylonjs/Misc/observable";
  60358. import { Nullable } from "babylonjs/types";
  60359. import { Scene } from "babylonjs/scene";
  60360. import { Vector3 } from "babylonjs/Maths/math.vector";
  60361. import { Color3 } from "babylonjs/Maths/math.color";
  60362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60363. import { Mesh } from "babylonjs/Meshes/mesh";
  60364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60365. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60366. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60367. import "babylonjs/Meshes/Builders/planeBuilder";
  60368. import "babylonjs/Meshes/Builders/boxBuilder";
  60369. /**
  60370. * Represents the different options available during the creation of
  60371. * a Environment helper.
  60372. *
  60373. * This can control the default ground, skybox and image processing setup of your scene.
  60374. */
  60375. export interface IEnvironmentHelperOptions {
  60376. /**
  60377. * Specifies whether or not to create a ground.
  60378. * True by default.
  60379. */
  60380. createGround: boolean;
  60381. /**
  60382. * Specifies the ground size.
  60383. * 15 by default.
  60384. */
  60385. groundSize: number;
  60386. /**
  60387. * The texture used on the ground for the main color.
  60388. * Comes from the BabylonJS CDN by default.
  60389. *
  60390. * Remarks: Can be either a texture or a url.
  60391. */
  60392. groundTexture: string | BaseTexture;
  60393. /**
  60394. * The color mixed in the ground texture by default.
  60395. * BabylonJS clearColor by default.
  60396. */
  60397. groundColor: Color3;
  60398. /**
  60399. * Specifies the ground opacity.
  60400. * 1 by default.
  60401. */
  60402. groundOpacity: number;
  60403. /**
  60404. * Enables the ground to receive shadows.
  60405. * True by default.
  60406. */
  60407. enableGroundShadow: boolean;
  60408. /**
  60409. * Helps preventing the shadow to be fully black on the ground.
  60410. * 0.5 by default.
  60411. */
  60412. groundShadowLevel: number;
  60413. /**
  60414. * Creates a mirror texture attach to the ground.
  60415. * false by default.
  60416. */
  60417. enableGroundMirror: boolean;
  60418. /**
  60419. * Specifies the ground mirror size ratio.
  60420. * 0.3 by default as the default kernel is 64.
  60421. */
  60422. groundMirrorSizeRatio: number;
  60423. /**
  60424. * Specifies the ground mirror blur kernel size.
  60425. * 64 by default.
  60426. */
  60427. groundMirrorBlurKernel: number;
  60428. /**
  60429. * Specifies the ground mirror visibility amount.
  60430. * 1 by default
  60431. */
  60432. groundMirrorAmount: number;
  60433. /**
  60434. * Specifies the ground mirror reflectance weight.
  60435. * This uses the standard weight of the background material to setup the fresnel effect
  60436. * of the mirror.
  60437. * 1 by default.
  60438. */
  60439. groundMirrorFresnelWeight: number;
  60440. /**
  60441. * Specifies the ground mirror Falloff distance.
  60442. * This can helps reducing the size of the reflection.
  60443. * 0 by Default.
  60444. */
  60445. groundMirrorFallOffDistance: number;
  60446. /**
  60447. * Specifies the ground mirror texture type.
  60448. * Unsigned Int by Default.
  60449. */
  60450. groundMirrorTextureType: number;
  60451. /**
  60452. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60453. * the shown objects.
  60454. */
  60455. groundYBias: number;
  60456. /**
  60457. * Specifies whether or not to create a skybox.
  60458. * True by default.
  60459. */
  60460. createSkybox: boolean;
  60461. /**
  60462. * Specifies the skybox size.
  60463. * 20 by default.
  60464. */
  60465. skyboxSize: number;
  60466. /**
  60467. * The texture used on the skybox for the main color.
  60468. * Comes from the BabylonJS CDN by default.
  60469. *
  60470. * Remarks: Can be either a texture or a url.
  60471. */
  60472. skyboxTexture: string | BaseTexture;
  60473. /**
  60474. * The color mixed in the skybox texture by default.
  60475. * BabylonJS clearColor by default.
  60476. */
  60477. skyboxColor: Color3;
  60478. /**
  60479. * The background rotation around the Y axis of the scene.
  60480. * This helps aligning the key lights of your scene with the background.
  60481. * 0 by default.
  60482. */
  60483. backgroundYRotation: number;
  60484. /**
  60485. * Compute automatically the size of the elements to best fit with the scene.
  60486. */
  60487. sizeAuto: boolean;
  60488. /**
  60489. * Default position of the rootMesh if autoSize is not true.
  60490. */
  60491. rootPosition: Vector3;
  60492. /**
  60493. * Sets up the image processing in the scene.
  60494. * true by default.
  60495. */
  60496. setupImageProcessing: boolean;
  60497. /**
  60498. * The texture used as your environment texture in the scene.
  60499. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60500. *
  60501. * Remarks: Can be either a texture or a url.
  60502. */
  60503. environmentTexture: string | BaseTexture;
  60504. /**
  60505. * The value of the exposure to apply to the scene.
  60506. * 0.6 by default if setupImageProcessing is true.
  60507. */
  60508. cameraExposure: number;
  60509. /**
  60510. * The value of the contrast to apply to the scene.
  60511. * 1.6 by default if setupImageProcessing is true.
  60512. */
  60513. cameraContrast: number;
  60514. /**
  60515. * Specifies whether or not tonemapping should be enabled in the scene.
  60516. * true by default if setupImageProcessing is true.
  60517. */
  60518. toneMappingEnabled: boolean;
  60519. }
  60520. /**
  60521. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60522. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60523. * It also helps with the default setup of your imageProcessing configuration.
  60524. */
  60525. export class EnvironmentHelper {
  60526. /**
  60527. * Default ground texture URL.
  60528. */
  60529. private static _groundTextureCDNUrl;
  60530. /**
  60531. * Default skybox texture URL.
  60532. */
  60533. private static _skyboxTextureCDNUrl;
  60534. /**
  60535. * Default environment texture URL.
  60536. */
  60537. private static _environmentTextureCDNUrl;
  60538. /**
  60539. * Creates the default options for the helper.
  60540. */
  60541. private static _getDefaultOptions;
  60542. private _rootMesh;
  60543. /**
  60544. * Gets the root mesh created by the helper.
  60545. */
  60546. get rootMesh(): Mesh;
  60547. private _skybox;
  60548. /**
  60549. * Gets the skybox created by the helper.
  60550. */
  60551. get skybox(): Nullable<Mesh>;
  60552. private _skyboxTexture;
  60553. /**
  60554. * Gets the skybox texture created by the helper.
  60555. */
  60556. get skyboxTexture(): Nullable<BaseTexture>;
  60557. private _skyboxMaterial;
  60558. /**
  60559. * Gets the skybox material created by the helper.
  60560. */
  60561. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60562. private _ground;
  60563. /**
  60564. * Gets the ground mesh created by the helper.
  60565. */
  60566. get ground(): Nullable<Mesh>;
  60567. private _groundTexture;
  60568. /**
  60569. * Gets the ground texture created by the helper.
  60570. */
  60571. get groundTexture(): Nullable<BaseTexture>;
  60572. private _groundMirror;
  60573. /**
  60574. * Gets the ground mirror created by the helper.
  60575. */
  60576. get groundMirror(): Nullable<MirrorTexture>;
  60577. /**
  60578. * Gets the ground mirror render list to helps pushing the meshes
  60579. * you wish in the ground reflection.
  60580. */
  60581. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60582. private _groundMaterial;
  60583. /**
  60584. * Gets the ground material created by the helper.
  60585. */
  60586. get groundMaterial(): Nullable<BackgroundMaterial>;
  60587. /**
  60588. * Stores the creation options.
  60589. */
  60590. private readonly _scene;
  60591. private _options;
  60592. /**
  60593. * This observable will be notified with any error during the creation of the environment,
  60594. * mainly texture creation errors.
  60595. */
  60596. onErrorObservable: Observable<{
  60597. message?: string;
  60598. exception?: any;
  60599. }>;
  60600. /**
  60601. * constructor
  60602. * @param options Defines the options we want to customize the helper
  60603. * @param scene The scene to add the material to
  60604. */
  60605. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60606. /**
  60607. * Updates the background according to the new options
  60608. * @param options
  60609. */
  60610. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60611. /**
  60612. * Sets the primary color of all the available elements.
  60613. * @param color the main color to affect to the ground and the background
  60614. */
  60615. setMainColor(color: Color3): void;
  60616. /**
  60617. * Setup the image processing according to the specified options.
  60618. */
  60619. private _setupImageProcessing;
  60620. /**
  60621. * Setup the environment texture according to the specified options.
  60622. */
  60623. private _setupEnvironmentTexture;
  60624. /**
  60625. * Setup the background according to the specified options.
  60626. */
  60627. private _setupBackground;
  60628. /**
  60629. * Get the scene sizes according to the setup.
  60630. */
  60631. private _getSceneSize;
  60632. /**
  60633. * Setup the ground according to the specified options.
  60634. */
  60635. private _setupGround;
  60636. /**
  60637. * Setup the ground material according to the specified options.
  60638. */
  60639. private _setupGroundMaterial;
  60640. /**
  60641. * Setup the ground diffuse texture according to the specified options.
  60642. */
  60643. private _setupGroundDiffuseTexture;
  60644. /**
  60645. * Setup the ground mirror texture according to the specified options.
  60646. */
  60647. private _setupGroundMirrorTexture;
  60648. /**
  60649. * Setup the ground to receive the mirror texture.
  60650. */
  60651. private _setupMirrorInGroundMaterial;
  60652. /**
  60653. * Setup the skybox according to the specified options.
  60654. */
  60655. private _setupSkybox;
  60656. /**
  60657. * Setup the skybox material according to the specified options.
  60658. */
  60659. private _setupSkyboxMaterial;
  60660. /**
  60661. * Setup the skybox reflection texture according to the specified options.
  60662. */
  60663. private _setupSkyboxReflectionTexture;
  60664. private _errorHandler;
  60665. /**
  60666. * Dispose all the elements created by the Helper.
  60667. */
  60668. dispose(): void;
  60669. }
  60670. }
  60671. declare module "babylonjs/Helpers/textureDome" {
  60672. import { Scene } from "babylonjs/scene";
  60673. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60674. import { Mesh } from "babylonjs/Meshes/mesh";
  60675. import { Texture } from "babylonjs/Materials/Textures/texture";
  60676. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60677. import "babylonjs/Meshes/Builders/sphereBuilder";
  60678. import { Nullable } from "babylonjs/types";
  60679. import { Observable } from "babylonjs/Misc/observable";
  60680. /**
  60681. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  60682. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  60683. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60684. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60685. */
  60686. export abstract class TextureDome<T extends Texture> extends TransformNode {
  60687. protected onError: Nullable<(message?: string, exception?: any) => void>;
  60688. /**
  60689. * Define the source as a Monoscopic panoramic 360/180.
  60690. */
  60691. static readonly MODE_MONOSCOPIC: number;
  60692. /**
  60693. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  60694. */
  60695. static readonly MODE_TOPBOTTOM: number;
  60696. /**
  60697. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  60698. */
  60699. static readonly MODE_SIDEBYSIDE: number;
  60700. private _halfDome;
  60701. private _crossEye;
  60702. protected _useDirectMapping: boolean;
  60703. /**
  60704. * The texture being displayed on the sphere
  60705. */
  60706. protected _texture: T;
  60707. /**
  60708. * Gets the texture being displayed on the sphere
  60709. */
  60710. get texture(): T;
  60711. /**
  60712. * Sets the texture being displayed on the sphere
  60713. */
  60714. set texture(newTexture: T);
  60715. /**
  60716. * The skybox material
  60717. */
  60718. protected _material: BackgroundMaterial;
  60719. /**
  60720. * The surface used for the dome
  60721. */
  60722. protected _mesh: Mesh;
  60723. /**
  60724. * Gets the mesh used for the dome.
  60725. */
  60726. get mesh(): Mesh;
  60727. /**
  60728. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  60729. */
  60730. private _halfDomeMask;
  60731. /**
  60732. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60733. * Also see the options.resolution property.
  60734. */
  60735. get fovMultiplier(): number;
  60736. set fovMultiplier(value: number);
  60737. protected _textureMode: number;
  60738. /**
  60739. * Gets or set the current texture mode for the texture. It can be:
  60740. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60741. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60742. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60743. */
  60744. get textureMode(): number;
  60745. /**
  60746. * Sets the current texture mode for the texture. It can be:
  60747. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60748. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60749. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60750. */
  60751. set textureMode(value: number);
  60752. /**
  60753. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  60754. */
  60755. get halfDome(): boolean;
  60756. /**
  60757. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60758. */
  60759. set halfDome(enabled: boolean);
  60760. /**
  60761. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  60762. */
  60763. set crossEye(enabled: boolean);
  60764. /**
  60765. * Is it a cross-eye texture?
  60766. */
  60767. get crossEye(): boolean;
  60768. /**
  60769. * The background material of this dome.
  60770. */
  60771. get material(): BackgroundMaterial;
  60772. /**
  60773. * Oberserver used in Stereoscopic VR Mode.
  60774. */
  60775. private _onBeforeCameraRenderObserver;
  60776. /**
  60777. * Observable raised when an error occured while loading the 360 image
  60778. */
  60779. onLoadErrorObservable: Observable<string>;
  60780. /**
  60781. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  60782. * @param name Element's name, child elements will append suffixes for their own names.
  60783. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  60784. * @param options An object containing optional or exposed sub element properties
  60785. */
  60786. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  60787. resolution?: number;
  60788. clickToPlay?: boolean;
  60789. autoPlay?: boolean;
  60790. loop?: boolean;
  60791. size?: number;
  60792. poster?: string;
  60793. faceForward?: boolean;
  60794. useDirectMapping?: boolean;
  60795. halfDomeMode?: boolean;
  60796. crossEyeMode?: boolean;
  60797. generateMipMaps?: boolean;
  60798. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  60799. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  60800. protected _changeTextureMode(value: number): void;
  60801. /**
  60802. * Releases resources associated with this node.
  60803. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60804. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60805. */
  60806. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60807. }
  60808. }
  60809. declare module "babylonjs/Helpers/photoDome" {
  60810. import { Scene } from "babylonjs/scene";
  60811. import { Texture } from "babylonjs/Materials/Textures/texture";
  60812. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60813. /**
  60814. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  60815. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  60816. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60817. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60818. */
  60819. export class PhotoDome extends TextureDome<Texture> {
  60820. /**
  60821. * Define the image as a Monoscopic panoramic 360 image.
  60822. */
  60823. static readonly MODE_MONOSCOPIC: number;
  60824. /**
  60825. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  60826. */
  60827. static readonly MODE_TOPBOTTOM: number;
  60828. /**
  60829. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  60830. */
  60831. static readonly MODE_SIDEBYSIDE: number;
  60832. /**
  60833. * Gets or sets the texture being displayed on the sphere
  60834. */
  60835. get photoTexture(): Texture;
  60836. /**
  60837. * sets the texture being displayed on the sphere
  60838. */
  60839. set photoTexture(value: Texture);
  60840. /**
  60841. * Gets the current video mode for the video. It can be:
  60842. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60843. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60844. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60845. */
  60846. get imageMode(): number;
  60847. /**
  60848. * Sets the current video mode for the video. It can be:
  60849. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60850. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60851. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60852. */
  60853. set imageMode(value: number);
  60854. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  60855. }
  60856. }
  60857. declare module "babylonjs/Misc/dds" {
  60858. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60859. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60860. import { Nullable } from "babylonjs/types";
  60861. import { Scene } from "babylonjs/scene";
  60862. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60863. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60864. /**
  60865. * Direct draw surface info
  60866. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60867. */
  60868. export interface DDSInfo {
  60869. /**
  60870. * Width of the texture
  60871. */
  60872. width: number;
  60873. /**
  60874. * Width of the texture
  60875. */
  60876. height: number;
  60877. /**
  60878. * Number of Mipmaps for the texture
  60879. * @see https://en.wikipedia.org/wiki/Mipmap
  60880. */
  60881. mipmapCount: number;
  60882. /**
  60883. * If the textures format is a known fourCC format
  60884. * @see https://www.fourcc.org/
  60885. */
  60886. isFourCC: boolean;
  60887. /**
  60888. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60889. */
  60890. isRGB: boolean;
  60891. /**
  60892. * If the texture is a lumincance format
  60893. */
  60894. isLuminance: boolean;
  60895. /**
  60896. * If this is a cube texture
  60897. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60898. */
  60899. isCube: boolean;
  60900. /**
  60901. * If the texture is a compressed format eg. FOURCC_DXT1
  60902. */
  60903. isCompressed: boolean;
  60904. /**
  60905. * The dxgiFormat of the texture
  60906. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60907. */
  60908. dxgiFormat: number;
  60909. /**
  60910. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60911. */
  60912. textureType: number;
  60913. /**
  60914. * Sphericle polynomial created for the dds texture
  60915. */
  60916. sphericalPolynomial?: SphericalPolynomial;
  60917. }
  60918. /**
  60919. * Class used to provide DDS decompression tools
  60920. */
  60921. export class DDSTools {
  60922. /**
  60923. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60924. */
  60925. static StoreLODInAlphaChannel: boolean;
  60926. /**
  60927. * Gets DDS information from an array buffer
  60928. * @param data defines the array buffer view to read data from
  60929. * @returns the DDS information
  60930. */
  60931. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60932. private static _FloatView;
  60933. private static _Int32View;
  60934. private static _ToHalfFloat;
  60935. private static _FromHalfFloat;
  60936. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60937. private static _GetHalfFloatRGBAArrayBuffer;
  60938. private static _GetFloatRGBAArrayBuffer;
  60939. private static _GetFloatAsUIntRGBAArrayBuffer;
  60940. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60941. private static _GetRGBAArrayBuffer;
  60942. private static _ExtractLongWordOrder;
  60943. private static _GetRGBArrayBuffer;
  60944. private static _GetLuminanceArrayBuffer;
  60945. /**
  60946. * Uploads DDS Levels to a Babylon Texture
  60947. * @hidden
  60948. */
  60949. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60950. }
  60951. module "babylonjs/Engines/thinEngine" {
  60952. interface ThinEngine {
  60953. /**
  60954. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60955. * @param rootUrl defines the url where the file to load is located
  60956. * @param scene defines the current scene
  60957. * @param lodScale defines scale to apply to the mip map selection
  60958. * @param lodOffset defines offset to apply to the mip map selection
  60959. * @param onLoad defines an optional callback raised when the texture is loaded
  60960. * @param onError defines an optional callback raised if there is an issue to load the texture
  60961. * @param format defines the format of the data
  60962. * @param forcedExtension defines the extension to use to pick the right loader
  60963. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60964. * @returns the cube texture as an InternalTexture
  60965. */
  60966. 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;
  60967. }
  60968. }
  60969. }
  60970. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60971. import { Nullable } from "babylonjs/types";
  60972. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60973. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60974. /**
  60975. * Implementation of the DDS Texture Loader.
  60976. * @hidden
  60977. */
  60978. export class _DDSTextureLoader implements IInternalTextureLoader {
  60979. /**
  60980. * Defines wether the loader supports cascade loading the different faces.
  60981. */
  60982. readonly supportCascades: boolean;
  60983. /**
  60984. * This returns if the loader support the current file information.
  60985. * @param extension defines the file extension of the file being loaded
  60986. * @returns true if the loader can load the specified file
  60987. */
  60988. canLoad(extension: string): boolean;
  60989. /**
  60990. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60991. * @param data contains the texture data
  60992. * @param texture defines the BabylonJS internal texture
  60993. * @param createPolynomials will be true if polynomials have been requested
  60994. * @param onLoad defines the callback to trigger once the texture is ready
  60995. * @param onError defines the callback to trigger in case of error
  60996. */
  60997. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60998. /**
  60999. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61000. * @param data contains the texture data
  61001. * @param texture defines the BabylonJS internal texture
  61002. * @param callback defines the method to call once ready to upload
  61003. */
  61004. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61005. }
  61006. }
  61007. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61008. import { Nullable } from "babylonjs/types";
  61009. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61010. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61011. /**
  61012. * Implementation of the ENV Texture Loader.
  61013. * @hidden
  61014. */
  61015. export class _ENVTextureLoader implements IInternalTextureLoader {
  61016. /**
  61017. * Defines wether the loader supports cascade loading the different faces.
  61018. */
  61019. readonly supportCascades: boolean;
  61020. /**
  61021. * This returns if the loader support the current file information.
  61022. * @param extension defines the file extension of the file being loaded
  61023. * @returns true if the loader can load the specified file
  61024. */
  61025. canLoad(extension: string): boolean;
  61026. /**
  61027. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61028. * @param data contains the texture data
  61029. * @param texture defines the BabylonJS internal texture
  61030. * @param createPolynomials will be true if polynomials have been requested
  61031. * @param onLoad defines the callback to trigger once the texture is ready
  61032. * @param onError defines the callback to trigger in case of error
  61033. */
  61034. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61035. /**
  61036. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61037. * @param data contains the texture data
  61038. * @param texture defines the BabylonJS internal texture
  61039. * @param callback defines the method to call once ready to upload
  61040. */
  61041. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61042. }
  61043. }
  61044. declare module "babylonjs/Misc/khronosTextureContainer" {
  61045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61046. /**
  61047. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61048. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61049. */
  61050. export class KhronosTextureContainer {
  61051. /** contents of the KTX container file */
  61052. data: ArrayBufferView;
  61053. private static HEADER_LEN;
  61054. private static COMPRESSED_2D;
  61055. private static COMPRESSED_3D;
  61056. private static TEX_2D;
  61057. private static TEX_3D;
  61058. /**
  61059. * Gets the openGL type
  61060. */
  61061. glType: number;
  61062. /**
  61063. * Gets the openGL type size
  61064. */
  61065. glTypeSize: number;
  61066. /**
  61067. * Gets the openGL format
  61068. */
  61069. glFormat: number;
  61070. /**
  61071. * Gets the openGL internal format
  61072. */
  61073. glInternalFormat: number;
  61074. /**
  61075. * Gets the base internal format
  61076. */
  61077. glBaseInternalFormat: number;
  61078. /**
  61079. * Gets image width in pixel
  61080. */
  61081. pixelWidth: number;
  61082. /**
  61083. * Gets image height in pixel
  61084. */
  61085. pixelHeight: number;
  61086. /**
  61087. * Gets image depth in pixels
  61088. */
  61089. pixelDepth: number;
  61090. /**
  61091. * Gets the number of array elements
  61092. */
  61093. numberOfArrayElements: number;
  61094. /**
  61095. * Gets the number of faces
  61096. */
  61097. numberOfFaces: number;
  61098. /**
  61099. * Gets the number of mipmap levels
  61100. */
  61101. numberOfMipmapLevels: number;
  61102. /**
  61103. * Gets the bytes of key value data
  61104. */
  61105. bytesOfKeyValueData: number;
  61106. /**
  61107. * Gets the load type
  61108. */
  61109. loadType: number;
  61110. /**
  61111. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61112. */
  61113. isInvalid: boolean;
  61114. /**
  61115. * Creates a new KhronosTextureContainer
  61116. * @param data contents of the KTX container file
  61117. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61118. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61119. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61120. */
  61121. constructor(
  61122. /** contents of the KTX container file */
  61123. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61124. /**
  61125. * Uploads KTX content to a Babylon Texture.
  61126. * It is assumed that the texture has already been created & is currently bound
  61127. * @hidden
  61128. */
  61129. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61130. private _upload2DCompressedLevels;
  61131. /**
  61132. * Checks if the given data starts with a KTX file identifier.
  61133. * @param data the data to check
  61134. * @returns true if the data is a KTX file or false otherwise
  61135. */
  61136. static IsValid(data: ArrayBufferView): boolean;
  61137. }
  61138. }
  61139. declare module "babylonjs/Misc/workerPool" {
  61140. import { IDisposable } from "babylonjs/scene";
  61141. /**
  61142. * Helper class to push actions to a pool of workers.
  61143. */
  61144. export class WorkerPool implements IDisposable {
  61145. private _workerInfos;
  61146. private _pendingActions;
  61147. /**
  61148. * Constructor
  61149. * @param workers Array of workers to use for actions
  61150. */
  61151. constructor(workers: Array<Worker>);
  61152. /**
  61153. * Terminates all workers and clears any pending actions.
  61154. */
  61155. dispose(): void;
  61156. /**
  61157. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61158. * pended until a worker has completed its action.
  61159. * @param action The action to perform. Call onComplete when the action is complete.
  61160. */
  61161. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61162. private _execute;
  61163. }
  61164. }
  61165. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61166. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61167. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61168. /**
  61169. * Class for loading KTX2 files
  61170. */
  61171. export class KhronosTextureContainer2 {
  61172. private static _WorkerPoolPromise?;
  61173. private static _Initialized;
  61174. private static _Ktx2Decoder;
  61175. /**
  61176. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61177. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61178. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61179. * Urls you can change:
  61180. * URLConfig.jsDecoderModule
  61181. * URLConfig.wasmUASTCToASTC
  61182. * URLConfig.wasmUASTCToBC7
  61183. * URLConfig.jsMSCTranscoder
  61184. * URLConfig.wasmMSCTranscoder
  61185. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61186. */
  61187. static URLConfig: {
  61188. jsDecoderModule: string;
  61189. wasmUASTCToASTC: null;
  61190. wasmUASTCToBC7: null;
  61191. jsMSCTranscoder: null;
  61192. wasmMSCTranscoder: null;
  61193. };
  61194. /**
  61195. * Default number of workers used to handle data decoding
  61196. */
  61197. static DefaultNumWorkers: number;
  61198. private static GetDefaultNumWorkers;
  61199. private _engine;
  61200. private static _CreateWorkerPool;
  61201. /**
  61202. * Constructor
  61203. * @param engine The engine to use
  61204. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61205. */
  61206. constructor(engine: ThinEngine, numWorkers?: number);
  61207. /** @hidden */
  61208. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  61209. /**
  61210. * Stop all async operations and release resources.
  61211. */
  61212. dispose(): void;
  61213. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  61214. /**
  61215. * Checks if the given data starts with a KTX2 file identifier.
  61216. * @param data the data to check
  61217. * @returns true if the data is a KTX2 file or false otherwise
  61218. */
  61219. static IsValid(data: ArrayBufferView): boolean;
  61220. }
  61221. }
  61222. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61223. import { Nullable } from "babylonjs/types";
  61224. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61225. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61226. /**
  61227. * Implementation of the KTX Texture Loader.
  61228. * @hidden
  61229. */
  61230. export class _KTXTextureLoader implements IInternalTextureLoader {
  61231. /**
  61232. * Defines wether the loader supports cascade loading the different faces.
  61233. */
  61234. readonly supportCascades: boolean;
  61235. /**
  61236. * This returns if the loader support the current file information.
  61237. * @param extension defines the file extension of the file being loaded
  61238. * @param mimeType defines the optional mime type of the file being loaded
  61239. * @returns true if the loader can load the specified file
  61240. */
  61241. canLoad(extension: string, mimeType?: string): boolean;
  61242. /**
  61243. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61244. * @param data contains the texture data
  61245. * @param texture defines the BabylonJS internal texture
  61246. * @param createPolynomials will be true if polynomials have been requested
  61247. * @param onLoad defines the callback to trigger once the texture is ready
  61248. * @param onError defines the callback to trigger in case of error
  61249. */
  61250. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61251. /**
  61252. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61253. * @param data contains the texture data
  61254. * @param texture defines the BabylonJS internal texture
  61255. * @param callback defines the method to call once ready to upload
  61256. */
  61257. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  61258. }
  61259. }
  61260. declare module "babylonjs/Helpers/sceneHelpers" {
  61261. import { Nullable } from "babylonjs/types";
  61262. import { Mesh } from "babylonjs/Meshes/mesh";
  61263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61264. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61265. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61266. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61267. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61268. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61269. import "babylonjs/Meshes/Builders/boxBuilder";
  61270. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61271. /** @hidden */
  61272. export var _forceSceneHelpersToBundle: boolean;
  61273. module "babylonjs/scene" {
  61274. interface Scene {
  61275. /**
  61276. * Creates a default light for the scene.
  61277. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61278. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61279. */
  61280. createDefaultLight(replace?: boolean): void;
  61281. /**
  61282. * Creates a default camera for the scene.
  61283. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61284. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61285. * @param replace has default false, when true replaces the active camera in the scene
  61286. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61287. */
  61288. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61289. /**
  61290. * Creates a default camera and a default light.
  61291. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61292. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61293. * @param replace has the default false, when true replaces the active camera/light in the scene
  61294. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61295. */
  61296. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61297. /**
  61298. * Creates a new sky box
  61299. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61300. * @param environmentTexture defines the texture to use as environment texture
  61301. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61302. * @param scale defines the overall scale of the skybox
  61303. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61304. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61305. * @returns a new mesh holding the sky box
  61306. */
  61307. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61308. /**
  61309. * Creates a new environment
  61310. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61311. * @param options defines the options you can use to configure the environment
  61312. * @returns the new EnvironmentHelper
  61313. */
  61314. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61315. /**
  61316. * Creates a new VREXperienceHelper
  61317. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61318. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61319. * @returns a new VREXperienceHelper
  61320. */
  61321. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61322. /**
  61323. * Creates a new WebXRDefaultExperience
  61324. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61325. * @param options experience options
  61326. * @returns a promise for a new WebXRDefaultExperience
  61327. */
  61328. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61329. }
  61330. }
  61331. }
  61332. declare module "babylonjs/Helpers/videoDome" {
  61333. import { Scene } from "babylonjs/scene";
  61334. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61335. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61336. /**
  61337. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61338. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61339. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61340. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61341. */
  61342. export class VideoDome extends TextureDome<VideoTexture> {
  61343. /**
  61344. * Define the video source as a Monoscopic panoramic 360 video.
  61345. */
  61346. static readonly MODE_MONOSCOPIC: number;
  61347. /**
  61348. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61349. */
  61350. static readonly MODE_TOPBOTTOM: number;
  61351. /**
  61352. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61353. */
  61354. static readonly MODE_SIDEBYSIDE: number;
  61355. /**
  61356. * Get the video texture associated with this video dome
  61357. */
  61358. get videoTexture(): VideoTexture;
  61359. /**
  61360. * Get the video mode of this dome
  61361. */
  61362. get videoMode(): number;
  61363. /**
  61364. * Set the video mode of this dome.
  61365. * @see textureMode
  61366. */
  61367. set videoMode(value: number);
  61368. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61369. }
  61370. }
  61371. declare module "babylonjs/Helpers/index" {
  61372. export * from "babylonjs/Helpers/environmentHelper";
  61373. export * from "babylonjs/Helpers/photoDome";
  61374. export * from "babylonjs/Helpers/sceneHelpers";
  61375. export * from "babylonjs/Helpers/videoDome";
  61376. }
  61377. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61378. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61379. import { IDisposable } from "babylonjs/scene";
  61380. import { Engine } from "babylonjs/Engines/engine";
  61381. /**
  61382. * This class can be used to get instrumentation data from a Babylon engine
  61383. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61384. */
  61385. export class EngineInstrumentation implements IDisposable {
  61386. /**
  61387. * Define the instrumented engine.
  61388. */
  61389. engine: Engine;
  61390. private _captureGPUFrameTime;
  61391. private _gpuFrameTimeToken;
  61392. private _gpuFrameTime;
  61393. private _captureShaderCompilationTime;
  61394. private _shaderCompilationTime;
  61395. private _onBeginFrameObserver;
  61396. private _onEndFrameObserver;
  61397. private _onBeforeShaderCompilationObserver;
  61398. private _onAfterShaderCompilationObserver;
  61399. /**
  61400. * Gets the perf counter used for GPU frame time
  61401. */
  61402. get gpuFrameTimeCounter(): PerfCounter;
  61403. /**
  61404. * Gets the GPU frame time capture status
  61405. */
  61406. get captureGPUFrameTime(): boolean;
  61407. /**
  61408. * Enable or disable the GPU frame time capture
  61409. */
  61410. set captureGPUFrameTime(value: boolean);
  61411. /**
  61412. * Gets the perf counter used for shader compilation time
  61413. */
  61414. get shaderCompilationTimeCounter(): PerfCounter;
  61415. /**
  61416. * Gets the shader compilation time capture status
  61417. */
  61418. get captureShaderCompilationTime(): boolean;
  61419. /**
  61420. * Enable or disable the shader compilation time capture
  61421. */
  61422. set captureShaderCompilationTime(value: boolean);
  61423. /**
  61424. * Instantiates a new engine instrumentation.
  61425. * This class can be used to get instrumentation data from a Babylon engine
  61426. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61427. * @param engine Defines the engine to instrument
  61428. */
  61429. constructor(
  61430. /**
  61431. * Define the instrumented engine.
  61432. */
  61433. engine: Engine);
  61434. /**
  61435. * Dispose and release associated resources.
  61436. */
  61437. dispose(): void;
  61438. }
  61439. }
  61440. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61441. import { Scene, IDisposable } from "babylonjs/scene";
  61442. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61443. /**
  61444. * This class can be used to get instrumentation data from a Babylon engine
  61445. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61446. */
  61447. export class SceneInstrumentation implements IDisposable {
  61448. /**
  61449. * Defines the scene to instrument
  61450. */
  61451. scene: Scene;
  61452. private _captureActiveMeshesEvaluationTime;
  61453. private _activeMeshesEvaluationTime;
  61454. private _captureRenderTargetsRenderTime;
  61455. private _renderTargetsRenderTime;
  61456. private _captureFrameTime;
  61457. private _frameTime;
  61458. private _captureRenderTime;
  61459. private _renderTime;
  61460. private _captureInterFrameTime;
  61461. private _interFrameTime;
  61462. private _captureParticlesRenderTime;
  61463. private _particlesRenderTime;
  61464. private _captureSpritesRenderTime;
  61465. private _spritesRenderTime;
  61466. private _capturePhysicsTime;
  61467. private _physicsTime;
  61468. private _captureAnimationsTime;
  61469. private _animationsTime;
  61470. private _captureCameraRenderTime;
  61471. private _cameraRenderTime;
  61472. private _onBeforeActiveMeshesEvaluationObserver;
  61473. private _onAfterActiveMeshesEvaluationObserver;
  61474. private _onBeforeRenderTargetsRenderObserver;
  61475. private _onAfterRenderTargetsRenderObserver;
  61476. private _onAfterRenderObserver;
  61477. private _onBeforeDrawPhaseObserver;
  61478. private _onAfterDrawPhaseObserver;
  61479. private _onBeforeAnimationsObserver;
  61480. private _onBeforeParticlesRenderingObserver;
  61481. private _onAfterParticlesRenderingObserver;
  61482. private _onBeforeSpritesRenderingObserver;
  61483. private _onAfterSpritesRenderingObserver;
  61484. private _onBeforePhysicsObserver;
  61485. private _onAfterPhysicsObserver;
  61486. private _onAfterAnimationsObserver;
  61487. private _onBeforeCameraRenderObserver;
  61488. private _onAfterCameraRenderObserver;
  61489. /**
  61490. * Gets the perf counter used for active meshes evaluation time
  61491. */
  61492. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61493. /**
  61494. * Gets the active meshes evaluation time capture status
  61495. */
  61496. get captureActiveMeshesEvaluationTime(): boolean;
  61497. /**
  61498. * Enable or disable the active meshes evaluation time capture
  61499. */
  61500. set captureActiveMeshesEvaluationTime(value: boolean);
  61501. /**
  61502. * Gets the perf counter used for render targets render time
  61503. */
  61504. get renderTargetsRenderTimeCounter(): PerfCounter;
  61505. /**
  61506. * Gets the render targets render time capture status
  61507. */
  61508. get captureRenderTargetsRenderTime(): boolean;
  61509. /**
  61510. * Enable or disable the render targets render time capture
  61511. */
  61512. set captureRenderTargetsRenderTime(value: boolean);
  61513. /**
  61514. * Gets the perf counter used for particles render time
  61515. */
  61516. get particlesRenderTimeCounter(): PerfCounter;
  61517. /**
  61518. * Gets the particles render time capture status
  61519. */
  61520. get captureParticlesRenderTime(): boolean;
  61521. /**
  61522. * Enable or disable the particles render time capture
  61523. */
  61524. set captureParticlesRenderTime(value: boolean);
  61525. /**
  61526. * Gets the perf counter used for sprites render time
  61527. */
  61528. get spritesRenderTimeCounter(): PerfCounter;
  61529. /**
  61530. * Gets the sprites render time capture status
  61531. */
  61532. get captureSpritesRenderTime(): boolean;
  61533. /**
  61534. * Enable or disable the sprites render time capture
  61535. */
  61536. set captureSpritesRenderTime(value: boolean);
  61537. /**
  61538. * Gets the perf counter used for physics time
  61539. */
  61540. get physicsTimeCounter(): PerfCounter;
  61541. /**
  61542. * Gets the physics time capture status
  61543. */
  61544. get capturePhysicsTime(): boolean;
  61545. /**
  61546. * Enable or disable the physics time capture
  61547. */
  61548. set capturePhysicsTime(value: boolean);
  61549. /**
  61550. * Gets the perf counter used for animations time
  61551. */
  61552. get animationsTimeCounter(): PerfCounter;
  61553. /**
  61554. * Gets the animations time capture status
  61555. */
  61556. get captureAnimationsTime(): boolean;
  61557. /**
  61558. * Enable or disable the animations time capture
  61559. */
  61560. set captureAnimationsTime(value: boolean);
  61561. /**
  61562. * Gets the perf counter used for frame time capture
  61563. */
  61564. get frameTimeCounter(): PerfCounter;
  61565. /**
  61566. * Gets the frame time capture status
  61567. */
  61568. get captureFrameTime(): boolean;
  61569. /**
  61570. * Enable or disable the frame time capture
  61571. */
  61572. set captureFrameTime(value: boolean);
  61573. /**
  61574. * Gets the perf counter used for inter-frames time capture
  61575. */
  61576. get interFrameTimeCounter(): PerfCounter;
  61577. /**
  61578. * Gets the inter-frames time capture status
  61579. */
  61580. get captureInterFrameTime(): boolean;
  61581. /**
  61582. * Enable or disable the inter-frames time capture
  61583. */
  61584. set captureInterFrameTime(value: boolean);
  61585. /**
  61586. * Gets the perf counter used for render time capture
  61587. */
  61588. get renderTimeCounter(): PerfCounter;
  61589. /**
  61590. * Gets the render time capture status
  61591. */
  61592. get captureRenderTime(): boolean;
  61593. /**
  61594. * Enable or disable the render time capture
  61595. */
  61596. set captureRenderTime(value: boolean);
  61597. /**
  61598. * Gets the perf counter used for camera render time capture
  61599. */
  61600. get cameraRenderTimeCounter(): PerfCounter;
  61601. /**
  61602. * Gets the camera render time capture status
  61603. */
  61604. get captureCameraRenderTime(): boolean;
  61605. /**
  61606. * Enable or disable the camera render time capture
  61607. */
  61608. set captureCameraRenderTime(value: boolean);
  61609. /**
  61610. * Gets the perf counter used for draw calls
  61611. */
  61612. get drawCallsCounter(): PerfCounter;
  61613. /**
  61614. * Instantiates a new scene instrumentation.
  61615. * This class can be used to get instrumentation data from a Babylon engine
  61616. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61617. * @param scene Defines the scene to instrument
  61618. */
  61619. constructor(
  61620. /**
  61621. * Defines the scene to instrument
  61622. */
  61623. scene: Scene);
  61624. /**
  61625. * Dispose and release associated resources.
  61626. */
  61627. dispose(): void;
  61628. }
  61629. }
  61630. declare module "babylonjs/Instrumentation/index" {
  61631. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61632. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61633. export * from "babylonjs/Instrumentation/timeToken";
  61634. }
  61635. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61636. /** @hidden */
  61637. export var glowMapGenerationPixelShader: {
  61638. name: string;
  61639. shader: string;
  61640. };
  61641. }
  61642. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61643. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61644. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61645. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61646. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61647. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61648. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61649. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61650. /** @hidden */
  61651. export var glowMapGenerationVertexShader: {
  61652. name: string;
  61653. shader: string;
  61654. };
  61655. }
  61656. declare module "babylonjs/Layers/effectLayer" {
  61657. import { Observable } from "babylonjs/Misc/observable";
  61658. import { Nullable } from "babylonjs/types";
  61659. import { Camera } from "babylonjs/Cameras/camera";
  61660. import { Scene } from "babylonjs/scene";
  61661. import { ISize } from "babylonjs/Maths/math.size";
  61662. import { Color4 } from "babylonjs/Maths/math.color";
  61663. import { Engine } from "babylonjs/Engines/engine";
  61664. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61666. import { Mesh } from "babylonjs/Meshes/mesh";
  61667. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61668. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61669. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61670. import { Effect } from "babylonjs/Materials/effect";
  61671. import { Material } from "babylonjs/Materials/material";
  61672. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61673. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61674. /**
  61675. * Effect layer options. This helps customizing the behaviour
  61676. * of the effect layer.
  61677. */
  61678. export interface IEffectLayerOptions {
  61679. /**
  61680. * Multiplication factor apply to the canvas size to compute the render target size
  61681. * used to generated the objects (the smaller the faster).
  61682. */
  61683. mainTextureRatio: number;
  61684. /**
  61685. * Enforces a fixed size texture to ensure effect stability across devices.
  61686. */
  61687. mainTextureFixedSize?: number;
  61688. /**
  61689. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61690. */
  61691. alphaBlendingMode: number;
  61692. /**
  61693. * The camera attached to the layer.
  61694. */
  61695. camera: Nullable<Camera>;
  61696. /**
  61697. * The rendering group to draw the layer in.
  61698. */
  61699. renderingGroupId: number;
  61700. }
  61701. /**
  61702. * The effect layer Helps adding post process effect blended with the main pass.
  61703. *
  61704. * This can be for instance use to generate glow or higlight effects on the scene.
  61705. *
  61706. * The effect layer class can not be used directly and is intented to inherited from to be
  61707. * customized per effects.
  61708. */
  61709. export abstract class EffectLayer {
  61710. private _vertexBuffers;
  61711. private _indexBuffer;
  61712. private _cachedDefines;
  61713. private _effectLayerMapGenerationEffect;
  61714. private _effectLayerOptions;
  61715. private _mergeEffect;
  61716. protected _scene: Scene;
  61717. protected _engine: Engine;
  61718. protected _maxSize: number;
  61719. protected _mainTextureDesiredSize: ISize;
  61720. protected _mainTexture: RenderTargetTexture;
  61721. protected _shouldRender: boolean;
  61722. protected _postProcesses: PostProcess[];
  61723. protected _textures: BaseTexture[];
  61724. protected _emissiveTextureAndColor: {
  61725. texture: Nullable<BaseTexture>;
  61726. color: Color4;
  61727. };
  61728. /**
  61729. * The name of the layer
  61730. */
  61731. name: string;
  61732. /**
  61733. * The clear color of the texture used to generate the glow map.
  61734. */
  61735. neutralColor: Color4;
  61736. /**
  61737. * Specifies whether the highlight layer is enabled or not.
  61738. */
  61739. isEnabled: boolean;
  61740. /**
  61741. * Gets the camera attached to the layer.
  61742. */
  61743. get camera(): Nullable<Camera>;
  61744. /**
  61745. * Gets the rendering group id the layer should render in.
  61746. */
  61747. get renderingGroupId(): number;
  61748. set renderingGroupId(renderingGroupId: number);
  61749. /**
  61750. * An event triggered when the effect layer has been disposed.
  61751. */
  61752. onDisposeObservable: Observable<EffectLayer>;
  61753. /**
  61754. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61755. */
  61756. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61757. /**
  61758. * An event triggered when the generated texture is being merged in the scene.
  61759. */
  61760. onBeforeComposeObservable: Observable<EffectLayer>;
  61761. /**
  61762. * An event triggered when the mesh is rendered into the effect render target.
  61763. */
  61764. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61765. /**
  61766. * An event triggered after the mesh has been rendered into the effect render target.
  61767. */
  61768. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61769. /**
  61770. * An event triggered when the generated texture has been merged in the scene.
  61771. */
  61772. onAfterComposeObservable: Observable<EffectLayer>;
  61773. /**
  61774. * An event triggered when the efffect layer changes its size.
  61775. */
  61776. onSizeChangedObservable: Observable<EffectLayer>;
  61777. /** @hidden */
  61778. static _SceneComponentInitialization: (scene: Scene) => void;
  61779. /**
  61780. * Instantiates a new effect Layer and references it in the scene.
  61781. * @param name The name of the layer
  61782. * @param scene The scene to use the layer in
  61783. */
  61784. constructor(
  61785. /** The Friendly of the effect in the scene */
  61786. name: string, scene: Scene);
  61787. /**
  61788. * Get the effect name of the layer.
  61789. * @return The effect name
  61790. */
  61791. abstract getEffectName(): string;
  61792. /**
  61793. * Checks for the readiness of the element composing the layer.
  61794. * @param subMesh the mesh to check for
  61795. * @param useInstances specify whether or not to use instances to render the mesh
  61796. * @return true if ready otherwise, false
  61797. */
  61798. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61799. /**
  61800. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61801. * @returns true if the effect requires stencil during the main canvas render pass.
  61802. */
  61803. abstract needStencil(): boolean;
  61804. /**
  61805. * Create the merge effect. This is the shader use to blit the information back
  61806. * to the main canvas at the end of the scene rendering.
  61807. * @returns The effect containing the shader used to merge the effect on the main canvas
  61808. */
  61809. protected abstract _createMergeEffect(): Effect;
  61810. /**
  61811. * Creates the render target textures and post processes used in the effect layer.
  61812. */
  61813. protected abstract _createTextureAndPostProcesses(): void;
  61814. /**
  61815. * Implementation specific of rendering the generating effect on the main canvas.
  61816. * @param effect The effect used to render through
  61817. */
  61818. protected abstract _internalRender(effect: Effect): void;
  61819. /**
  61820. * Sets the required values for both the emissive texture and and the main color.
  61821. */
  61822. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61823. /**
  61824. * Free any resources and references associated to a mesh.
  61825. * Internal use
  61826. * @param mesh The mesh to free.
  61827. */
  61828. abstract _disposeMesh(mesh: Mesh): void;
  61829. /**
  61830. * Serializes this layer (Glow or Highlight for example)
  61831. * @returns a serialized layer object
  61832. */
  61833. abstract serialize?(): any;
  61834. /**
  61835. * Initializes the effect layer with the required options.
  61836. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61837. */
  61838. protected _init(options: Partial<IEffectLayerOptions>): void;
  61839. /**
  61840. * Generates the index buffer of the full screen quad blending to the main canvas.
  61841. */
  61842. private _generateIndexBuffer;
  61843. /**
  61844. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61845. */
  61846. private _generateVertexBuffer;
  61847. /**
  61848. * Sets the main texture desired size which is the closest power of two
  61849. * of the engine canvas size.
  61850. */
  61851. private _setMainTextureSize;
  61852. /**
  61853. * Creates the main texture for the effect layer.
  61854. */
  61855. protected _createMainTexture(): void;
  61856. /**
  61857. * Adds specific effects defines.
  61858. * @param defines The defines to add specifics to.
  61859. */
  61860. protected _addCustomEffectDefines(defines: string[]): void;
  61861. /**
  61862. * Checks for the readiness of the element composing the layer.
  61863. * @param subMesh the mesh to check for
  61864. * @param useInstances specify whether or not to use instances to render the mesh
  61865. * @param emissiveTexture the associated emissive texture used to generate the glow
  61866. * @return true if ready otherwise, false
  61867. */
  61868. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61869. /**
  61870. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61871. */
  61872. render(): void;
  61873. /**
  61874. * Determine if a given mesh will be used in the current effect.
  61875. * @param mesh mesh to test
  61876. * @returns true if the mesh will be used
  61877. */
  61878. hasMesh(mesh: AbstractMesh): boolean;
  61879. /**
  61880. * Returns true if the layer contains information to display, otherwise false.
  61881. * @returns true if the glow layer should be rendered
  61882. */
  61883. shouldRender(): boolean;
  61884. /**
  61885. * Returns true if the mesh should render, otherwise false.
  61886. * @param mesh The mesh to render
  61887. * @returns true if it should render otherwise false
  61888. */
  61889. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61890. /**
  61891. * Returns true if the mesh can be rendered, otherwise false.
  61892. * @param mesh The mesh to render
  61893. * @param material The material used on the mesh
  61894. * @returns true if it can be rendered otherwise false
  61895. */
  61896. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61897. /**
  61898. * Returns true if the mesh should render, otherwise false.
  61899. * @param mesh The mesh to render
  61900. * @returns true if it should render otherwise false
  61901. */
  61902. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61903. /**
  61904. * Renders the submesh passed in parameter to the generation map.
  61905. */
  61906. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61907. /**
  61908. * Defines whether the current material of the mesh should be use to render the effect.
  61909. * @param mesh defines the current mesh to render
  61910. */
  61911. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61912. /**
  61913. * Rebuild the required buffers.
  61914. * @hidden Internal use only.
  61915. */
  61916. _rebuild(): void;
  61917. /**
  61918. * Dispose only the render target textures and post process.
  61919. */
  61920. private _disposeTextureAndPostProcesses;
  61921. /**
  61922. * Dispose the highlight layer and free resources.
  61923. */
  61924. dispose(): void;
  61925. /**
  61926. * Gets the class name of the effect layer
  61927. * @returns the string with the class name of the effect layer
  61928. */
  61929. getClassName(): string;
  61930. /**
  61931. * Creates an effect layer from parsed effect layer data
  61932. * @param parsedEffectLayer defines effect layer data
  61933. * @param scene defines the current scene
  61934. * @param rootUrl defines the root URL containing the effect layer information
  61935. * @returns a parsed effect Layer
  61936. */
  61937. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61938. }
  61939. }
  61940. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61941. import { Scene } from "babylonjs/scene";
  61942. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61943. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61944. import { AbstractScene } from "babylonjs/abstractScene";
  61945. module "babylonjs/abstractScene" {
  61946. interface AbstractScene {
  61947. /**
  61948. * The list of effect layers (highlights/glow) added to the scene
  61949. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61950. * @see https://doc.babylonjs.com/how_to/glow_layer
  61951. */
  61952. effectLayers: Array<EffectLayer>;
  61953. /**
  61954. * Removes the given effect layer from this scene.
  61955. * @param toRemove defines the effect layer to remove
  61956. * @returns the index of the removed effect layer
  61957. */
  61958. removeEffectLayer(toRemove: EffectLayer): number;
  61959. /**
  61960. * Adds the given effect layer to this scene
  61961. * @param newEffectLayer defines the effect layer to add
  61962. */
  61963. addEffectLayer(newEffectLayer: EffectLayer): void;
  61964. }
  61965. }
  61966. /**
  61967. * Defines the layer scene component responsible to manage any effect layers
  61968. * in a given scene.
  61969. */
  61970. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61971. /**
  61972. * The component name helpfull to identify the component in the list of scene components.
  61973. */
  61974. readonly name: string;
  61975. /**
  61976. * The scene the component belongs to.
  61977. */
  61978. scene: Scene;
  61979. private _engine;
  61980. private _renderEffects;
  61981. private _needStencil;
  61982. private _previousStencilState;
  61983. /**
  61984. * Creates a new instance of the component for the given scene
  61985. * @param scene Defines the scene to register the component in
  61986. */
  61987. constructor(scene: Scene);
  61988. /**
  61989. * Registers the component in a given scene
  61990. */
  61991. register(): void;
  61992. /**
  61993. * Rebuilds the elements related to this component in case of
  61994. * context lost for instance.
  61995. */
  61996. rebuild(): void;
  61997. /**
  61998. * Serializes the component data to the specified json object
  61999. * @param serializationObject The object to serialize to
  62000. */
  62001. serialize(serializationObject: any): void;
  62002. /**
  62003. * Adds all the elements from the container to the scene
  62004. * @param container the container holding the elements
  62005. */
  62006. addFromContainer(container: AbstractScene): void;
  62007. /**
  62008. * Removes all the elements in the container from the scene
  62009. * @param container contains the elements to remove
  62010. * @param dispose if the removed element should be disposed (default: false)
  62011. */
  62012. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62013. /**
  62014. * Disposes the component and the associated ressources.
  62015. */
  62016. dispose(): void;
  62017. private _isReadyForMesh;
  62018. private _renderMainTexture;
  62019. private _setStencil;
  62020. private _setStencilBack;
  62021. private _draw;
  62022. private _drawCamera;
  62023. private _drawRenderingGroup;
  62024. }
  62025. }
  62026. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62027. /** @hidden */
  62028. export var glowMapMergePixelShader: {
  62029. name: string;
  62030. shader: string;
  62031. };
  62032. }
  62033. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62034. /** @hidden */
  62035. export var glowMapMergeVertexShader: {
  62036. name: string;
  62037. shader: string;
  62038. };
  62039. }
  62040. declare module "babylonjs/Layers/glowLayer" {
  62041. import { Nullable } from "babylonjs/types";
  62042. import { Camera } from "babylonjs/Cameras/camera";
  62043. import { Scene } from "babylonjs/scene";
  62044. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62046. import { Mesh } from "babylonjs/Meshes/mesh";
  62047. import { Texture } from "babylonjs/Materials/Textures/texture";
  62048. import { Effect } from "babylonjs/Materials/effect";
  62049. import { Material } from "babylonjs/Materials/material";
  62050. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62051. import { Color4 } from "babylonjs/Maths/math.color";
  62052. import "babylonjs/Shaders/glowMapMerge.fragment";
  62053. import "babylonjs/Shaders/glowMapMerge.vertex";
  62054. import "babylonjs/Layers/effectLayerSceneComponent";
  62055. module "babylonjs/abstractScene" {
  62056. interface AbstractScene {
  62057. /**
  62058. * Return a the first highlight layer of the scene with a given name.
  62059. * @param name The name of the highlight layer to look for.
  62060. * @return The highlight layer if found otherwise null.
  62061. */
  62062. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62063. }
  62064. }
  62065. /**
  62066. * Glow layer options. This helps customizing the behaviour
  62067. * of the glow layer.
  62068. */
  62069. export interface IGlowLayerOptions {
  62070. /**
  62071. * Multiplication factor apply to the canvas size to compute the render target size
  62072. * used to generated the glowing objects (the smaller the faster).
  62073. */
  62074. mainTextureRatio: number;
  62075. /**
  62076. * Enforces a fixed size texture to ensure resize independant blur.
  62077. */
  62078. mainTextureFixedSize?: number;
  62079. /**
  62080. * How big is the kernel of the blur texture.
  62081. */
  62082. blurKernelSize: number;
  62083. /**
  62084. * The camera attached to the layer.
  62085. */
  62086. camera: Nullable<Camera>;
  62087. /**
  62088. * Enable MSAA by chosing the number of samples.
  62089. */
  62090. mainTextureSamples?: number;
  62091. /**
  62092. * The rendering group to draw the layer in.
  62093. */
  62094. renderingGroupId: number;
  62095. }
  62096. /**
  62097. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62098. *
  62099. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62100. *
  62101. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62102. */
  62103. export class GlowLayer extends EffectLayer {
  62104. /**
  62105. * Effect Name of the layer.
  62106. */
  62107. static readonly EffectName: string;
  62108. /**
  62109. * The default blur kernel size used for the glow.
  62110. */
  62111. static DefaultBlurKernelSize: number;
  62112. /**
  62113. * The default texture size ratio used for the glow.
  62114. */
  62115. static DefaultTextureRatio: number;
  62116. /**
  62117. * Sets the kernel size of the blur.
  62118. */
  62119. set blurKernelSize(value: number);
  62120. /**
  62121. * Gets the kernel size of the blur.
  62122. */
  62123. get blurKernelSize(): number;
  62124. /**
  62125. * Sets the glow intensity.
  62126. */
  62127. set intensity(value: number);
  62128. /**
  62129. * Gets the glow intensity.
  62130. */
  62131. get intensity(): number;
  62132. private _options;
  62133. private _intensity;
  62134. private _horizontalBlurPostprocess1;
  62135. private _verticalBlurPostprocess1;
  62136. private _horizontalBlurPostprocess2;
  62137. private _verticalBlurPostprocess2;
  62138. private _blurTexture1;
  62139. private _blurTexture2;
  62140. private _postProcesses1;
  62141. private _postProcesses2;
  62142. private _includedOnlyMeshes;
  62143. private _excludedMeshes;
  62144. private _meshesUsingTheirOwnMaterials;
  62145. /**
  62146. * Callback used to let the user override the color selection on a per mesh basis
  62147. */
  62148. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62149. /**
  62150. * Callback used to let the user override the texture selection on a per mesh basis
  62151. */
  62152. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62153. /**
  62154. * Instantiates a new glow Layer and references it to the scene.
  62155. * @param name The name of the layer
  62156. * @param scene The scene to use the layer in
  62157. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62158. */
  62159. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62160. /**
  62161. * Get the effect name of the layer.
  62162. * @return The effect name
  62163. */
  62164. getEffectName(): string;
  62165. /**
  62166. * Create the merge effect. This is the shader use to blit the information back
  62167. * to the main canvas at the end of the scene rendering.
  62168. */
  62169. protected _createMergeEffect(): Effect;
  62170. /**
  62171. * Creates the render target textures and post processes used in the glow layer.
  62172. */
  62173. protected _createTextureAndPostProcesses(): void;
  62174. /**
  62175. * Checks for the readiness of the element composing the layer.
  62176. * @param subMesh the mesh to check for
  62177. * @param useInstances specify wether or not to use instances to render the mesh
  62178. * @param emissiveTexture the associated emissive texture used to generate the glow
  62179. * @return true if ready otherwise, false
  62180. */
  62181. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62182. /**
  62183. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62184. */
  62185. needStencil(): boolean;
  62186. /**
  62187. * Returns true if the mesh can be rendered, otherwise false.
  62188. * @param mesh The mesh to render
  62189. * @param material The material used on the mesh
  62190. * @returns true if it can be rendered otherwise false
  62191. */
  62192. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62193. /**
  62194. * Implementation specific of rendering the generating effect on the main canvas.
  62195. * @param effect The effect used to render through
  62196. */
  62197. protected _internalRender(effect: Effect): void;
  62198. /**
  62199. * Sets the required values for both the emissive texture and and the main color.
  62200. */
  62201. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62202. /**
  62203. * Returns true if the mesh should render, otherwise false.
  62204. * @param mesh The mesh to render
  62205. * @returns true if it should render otherwise false
  62206. */
  62207. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62208. /**
  62209. * Adds specific effects defines.
  62210. * @param defines The defines to add specifics to.
  62211. */
  62212. protected _addCustomEffectDefines(defines: string[]): void;
  62213. /**
  62214. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62215. * @param mesh The mesh to exclude from the glow layer
  62216. */
  62217. addExcludedMesh(mesh: Mesh): void;
  62218. /**
  62219. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62220. * @param mesh The mesh to remove
  62221. */
  62222. removeExcludedMesh(mesh: Mesh): void;
  62223. /**
  62224. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62225. * @param mesh The mesh to include in the glow layer
  62226. */
  62227. addIncludedOnlyMesh(mesh: Mesh): void;
  62228. /**
  62229. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62230. * @param mesh The mesh to remove
  62231. */
  62232. removeIncludedOnlyMesh(mesh: Mesh): void;
  62233. /**
  62234. * Determine if a given mesh will be used in the glow layer
  62235. * @param mesh The mesh to test
  62236. * @returns true if the mesh will be highlighted by the current glow layer
  62237. */
  62238. hasMesh(mesh: AbstractMesh): boolean;
  62239. /**
  62240. * Defines whether the current material of the mesh should be use to render the effect.
  62241. * @param mesh defines the current mesh to render
  62242. */
  62243. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62244. /**
  62245. * Add a mesh to be rendered through its own material and not with emissive only.
  62246. * @param mesh The mesh for which we need to use its material
  62247. */
  62248. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62249. /**
  62250. * Remove a mesh from being rendered through its own material and not with emissive only.
  62251. * @param mesh The mesh for which we need to not use its material
  62252. */
  62253. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62254. /**
  62255. * Free any resources and references associated to a mesh.
  62256. * Internal use
  62257. * @param mesh The mesh to free.
  62258. * @hidden
  62259. */
  62260. _disposeMesh(mesh: Mesh): void;
  62261. /**
  62262. * Gets the class name of the effect layer
  62263. * @returns the string with the class name of the effect layer
  62264. */
  62265. getClassName(): string;
  62266. /**
  62267. * Serializes this glow layer
  62268. * @returns a serialized glow layer object
  62269. */
  62270. serialize(): any;
  62271. /**
  62272. * Creates a Glow Layer from parsed glow layer data
  62273. * @param parsedGlowLayer defines glow layer data
  62274. * @param scene defines the current scene
  62275. * @param rootUrl defines the root URL containing the glow layer information
  62276. * @returns a parsed Glow Layer
  62277. */
  62278. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62279. }
  62280. }
  62281. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62282. /** @hidden */
  62283. export var glowBlurPostProcessPixelShader: {
  62284. name: string;
  62285. shader: string;
  62286. };
  62287. }
  62288. declare module "babylonjs/Layers/highlightLayer" {
  62289. import { Observable } from "babylonjs/Misc/observable";
  62290. import { Nullable } from "babylonjs/types";
  62291. import { Camera } from "babylonjs/Cameras/camera";
  62292. import { Scene } from "babylonjs/scene";
  62293. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62295. import { Mesh } from "babylonjs/Meshes/mesh";
  62296. import { Effect } from "babylonjs/Materials/effect";
  62297. import { Material } from "babylonjs/Materials/material";
  62298. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62299. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62300. import "babylonjs/Shaders/glowMapMerge.fragment";
  62301. import "babylonjs/Shaders/glowMapMerge.vertex";
  62302. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62303. module "babylonjs/abstractScene" {
  62304. interface AbstractScene {
  62305. /**
  62306. * Return a the first highlight layer of the scene with a given name.
  62307. * @param name The name of the highlight layer to look for.
  62308. * @return The highlight layer if found otherwise null.
  62309. */
  62310. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62311. }
  62312. }
  62313. /**
  62314. * Highlight layer options. This helps customizing the behaviour
  62315. * of the highlight layer.
  62316. */
  62317. export interface IHighlightLayerOptions {
  62318. /**
  62319. * Multiplication factor apply to the canvas size to compute the render target size
  62320. * used to generated the glowing objects (the smaller the faster).
  62321. */
  62322. mainTextureRatio: number;
  62323. /**
  62324. * Enforces a fixed size texture to ensure resize independant blur.
  62325. */
  62326. mainTextureFixedSize?: number;
  62327. /**
  62328. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62329. * of the picture to blur (the smaller the faster).
  62330. */
  62331. blurTextureSizeRatio: number;
  62332. /**
  62333. * How big in texel of the blur texture is the vertical blur.
  62334. */
  62335. blurVerticalSize: number;
  62336. /**
  62337. * How big in texel of the blur texture is the horizontal blur.
  62338. */
  62339. blurHorizontalSize: number;
  62340. /**
  62341. * Alpha blending mode used to apply the blur. Default is combine.
  62342. */
  62343. alphaBlendingMode: number;
  62344. /**
  62345. * The camera attached to the layer.
  62346. */
  62347. camera: Nullable<Camera>;
  62348. /**
  62349. * Should we display highlight as a solid stroke?
  62350. */
  62351. isStroke?: boolean;
  62352. /**
  62353. * The rendering group to draw the layer in.
  62354. */
  62355. renderingGroupId: number;
  62356. }
  62357. /**
  62358. * The highlight layer Helps adding a glow effect around a mesh.
  62359. *
  62360. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62361. * glowy meshes to your scene.
  62362. *
  62363. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62364. */
  62365. export class HighlightLayer extends EffectLayer {
  62366. name: string;
  62367. /**
  62368. * Effect Name of the highlight layer.
  62369. */
  62370. static readonly EffectName: string;
  62371. /**
  62372. * The neutral color used during the preparation of the glow effect.
  62373. * This is black by default as the blend operation is a blend operation.
  62374. */
  62375. static NeutralColor: Color4;
  62376. /**
  62377. * Stencil value used for glowing meshes.
  62378. */
  62379. static GlowingMeshStencilReference: number;
  62380. /**
  62381. * Stencil value used for the other meshes in the scene.
  62382. */
  62383. static NormalMeshStencilReference: number;
  62384. /**
  62385. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62386. */
  62387. innerGlow: boolean;
  62388. /**
  62389. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62390. */
  62391. outerGlow: boolean;
  62392. /**
  62393. * Specifies the horizontal size of the blur.
  62394. */
  62395. set blurHorizontalSize(value: number);
  62396. /**
  62397. * Specifies the vertical size of the blur.
  62398. */
  62399. set blurVerticalSize(value: number);
  62400. /**
  62401. * Gets the horizontal size of the blur.
  62402. */
  62403. get blurHorizontalSize(): number;
  62404. /**
  62405. * Gets the vertical size of the blur.
  62406. */
  62407. get blurVerticalSize(): number;
  62408. /**
  62409. * An event triggered when the highlight layer is being blurred.
  62410. */
  62411. onBeforeBlurObservable: Observable<HighlightLayer>;
  62412. /**
  62413. * An event triggered when the highlight layer has been blurred.
  62414. */
  62415. onAfterBlurObservable: Observable<HighlightLayer>;
  62416. private _instanceGlowingMeshStencilReference;
  62417. private _options;
  62418. private _downSamplePostprocess;
  62419. private _horizontalBlurPostprocess;
  62420. private _verticalBlurPostprocess;
  62421. private _blurTexture;
  62422. private _meshes;
  62423. private _excludedMeshes;
  62424. /**
  62425. * Instantiates a new highlight Layer and references it to the scene..
  62426. * @param name The name of the layer
  62427. * @param scene The scene to use the layer in
  62428. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62429. */
  62430. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62431. /**
  62432. * Get the effect name of the layer.
  62433. * @return The effect name
  62434. */
  62435. getEffectName(): string;
  62436. /**
  62437. * Create the merge effect. This is the shader use to blit the information back
  62438. * to the main canvas at the end of the scene rendering.
  62439. */
  62440. protected _createMergeEffect(): Effect;
  62441. /**
  62442. * Creates the render target textures and post processes used in the highlight layer.
  62443. */
  62444. protected _createTextureAndPostProcesses(): void;
  62445. /**
  62446. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62447. */
  62448. needStencil(): boolean;
  62449. /**
  62450. * Checks for the readiness of the element composing the layer.
  62451. * @param subMesh the mesh to check for
  62452. * @param useInstances specify wether or not to use instances to render the mesh
  62453. * @param emissiveTexture the associated emissive texture used to generate the glow
  62454. * @return true if ready otherwise, false
  62455. */
  62456. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62457. /**
  62458. * Implementation specific of rendering the generating effect on the main canvas.
  62459. * @param effect The effect used to render through
  62460. */
  62461. protected _internalRender(effect: Effect): void;
  62462. /**
  62463. * Returns true if the layer contains information to display, otherwise false.
  62464. */
  62465. shouldRender(): boolean;
  62466. /**
  62467. * Returns true if the mesh should render, otherwise false.
  62468. * @param mesh The mesh to render
  62469. * @returns true if it should render otherwise false
  62470. */
  62471. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62472. /**
  62473. * Returns true if the mesh can be rendered, otherwise false.
  62474. * @param mesh The mesh to render
  62475. * @param material The material used on the mesh
  62476. * @returns true if it can be rendered otherwise false
  62477. */
  62478. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62479. /**
  62480. * Adds specific effects defines.
  62481. * @param defines The defines to add specifics to.
  62482. */
  62483. protected _addCustomEffectDefines(defines: string[]): void;
  62484. /**
  62485. * Sets the required values for both the emissive texture and and the main color.
  62486. */
  62487. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62488. /**
  62489. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62490. * @param mesh The mesh to exclude from the highlight layer
  62491. */
  62492. addExcludedMesh(mesh: Mesh): void;
  62493. /**
  62494. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62495. * @param mesh The mesh to highlight
  62496. */
  62497. removeExcludedMesh(mesh: Mesh): void;
  62498. /**
  62499. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62500. * @param mesh mesh to test
  62501. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62502. */
  62503. hasMesh(mesh: AbstractMesh): boolean;
  62504. /**
  62505. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62506. * @param mesh The mesh to highlight
  62507. * @param color The color of the highlight
  62508. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62509. */
  62510. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62511. /**
  62512. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62513. * @param mesh The mesh to highlight
  62514. */
  62515. removeMesh(mesh: Mesh): void;
  62516. /**
  62517. * Remove all the meshes currently referenced in the highlight layer
  62518. */
  62519. removeAllMeshes(): void;
  62520. /**
  62521. * Force the stencil to the normal expected value for none glowing parts
  62522. */
  62523. private _defaultStencilReference;
  62524. /**
  62525. * Free any resources and references associated to a mesh.
  62526. * Internal use
  62527. * @param mesh The mesh to free.
  62528. * @hidden
  62529. */
  62530. _disposeMesh(mesh: Mesh): void;
  62531. /**
  62532. * Dispose the highlight layer and free resources.
  62533. */
  62534. dispose(): void;
  62535. /**
  62536. * Gets the class name of the effect layer
  62537. * @returns the string with the class name of the effect layer
  62538. */
  62539. getClassName(): string;
  62540. /**
  62541. * Serializes this Highlight layer
  62542. * @returns a serialized Highlight layer object
  62543. */
  62544. serialize(): any;
  62545. /**
  62546. * Creates a Highlight layer from parsed Highlight layer data
  62547. * @param parsedHightlightLayer defines the Highlight layer data
  62548. * @param scene defines the current scene
  62549. * @param rootUrl defines the root URL containing the Highlight layer information
  62550. * @returns a parsed Highlight layer
  62551. */
  62552. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62553. }
  62554. }
  62555. declare module "babylonjs/Layers/layerSceneComponent" {
  62556. import { Scene } from "babylonjs/scene";
  62557. import { ISceneComponent } from "babylonjs/sceneComponent";
  62558. import { Layer } from "babylonjs/Layers/layer";
  62559. import { AbstractScene } from "babylonjs/abstractScene";
  62560. module "babylonjs/abstractScene" {
  62561. interface AbstractScene {
  62562. /**
  62563. * The list of layers (background and foreground) of the scene
  62564. */
  62565. layers: Array<Layer>;
  62566. }
  62567. }
  62568. /**
  62569. * Defines the layer scene component responsible to manage any layers
  62570. * in a given scene.
  62571. */
  62572. export class LayerSceneComponent implements ISceneComponent {
  62573. /**
  62574. * The component name helpfull to identify the component in the list of scene components.
  62575. */
  62576. readonly name: string;
  62577. /**
  62578. * The scene the component belongs to.
  62579. */
  62580. scene: Scene;
  62581. private _engine;
  62582. /**
  62583. * Creates a new instance of the component for the given scene
  62584. * @param scene Defines the scene to register the component in
  62585. */
  62586. constructor(scene: Scene);
  62587. /**
  62588. * Registers the component in a given scene
  62589. */
  62590. register(): void;
  62591. /**
  62592. * Rebuilds the elements related to this component in case of
  62593. * context lost for instance.
  62594. */
  62595. rebuild(): void;
  62596. /**
  62597. * Disposes the component and the associated ressources.
  62598. */
  62599. dispose(): void;
  62600. private _draw;
  62601. private _drawCameraPredicate;
  62602. private _drawCameraBackground;
  62603. private _drawCameraForeground;
  62604. private _drawRenderTargetPredicate;
  62605. private _drawRenderTargetBackground;
  62606. private _drawRenderTargetForeground;
  62607. /**
  62608. * Adds all the elements from the container to the scene
  62609. * @param container the container holding the elements
  62610. */
  62611. addFromContainer(container: AbstractScene): void;
  62612. /**
  62613. * Removes all the elements in the container from the scene
  62614. * @param container contains the elements to remove
  62615. * @param dispose if the removed element should be disposed (default: false)
  62616. */
  62617. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62618. }
  62619. }
  62620. declare module "babylonjs/Shaders/layer.fragment" {
  62621. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62622. /** @hidden */
  62623. export var layerPixelShader: {
  62624. name: string;
  62625. shader: string;
  62626. };
  62627. }
  62628. declare module "babylonjs/Shaders/layer.vertex" {
  62629. /** @hidden */
  62630. export var layerVertexShader: {
  62631. name: string;
  62632. shader: string;
  62633. };
  62634. }
  62635. declare module "babylonjs/Layers/layer" {
  62636. import { Observable } from "babylonjs/Misc/observable";
  62637. import { Nullable } from "babylonjs/types";
  62638. import { Scene } from "babylonjs/scene";
  62639. import { Vector2 } from "babylonjs/Maths/math.vector";
  62640. import { Color4 } from "babylonjs/Maths/math.color";
  62641. import { Texture } from "babylonjs/Materials/Textures/texture";
  62642. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62643. import "babylonjs/Shaders/layer.fragment";
  62644. import "babylonjs/Shaders/layer.vertex";
  62645. /**
  62646. * This represents a full screen 2d layer.
  62647. * This can be useful to display a picture in the background of your scene for instance.
  62648. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62649. */
  62650. export class Layer {
  62651. /**
  62652. * Define the name of the layer.
  62653. */
  62654. name: string;
  62655. /**
  62656. * Define the texture the layer should display.
  62657. */
  62658. texture: Nullable<Texture>;
  62659. /**
  62660. * Is the layer in background or foreground.
  62661. */
  62662. isBackground: boolean;
  62663. /**
  62664. * Define the color of the layer (instead of texture).
  62665. */
  62666. color: Color4;
  62667. /**
  62668. * Define the scale of the layer in order to zoom in out of the texture.
  62669. */
  62670. scale: Vector2;
  62671. /**
  62672. * Define an offset for the layer in order to shift the texture.
  62673. */
  62674. offset: Vector2;
  62675. /**
  62676. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62677. */
  62678. alphaBlendingMode: number;
  62679. /**
  62680. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62681. * Alpha test will not mix with the background color in case of transparency.
  62682. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62683. */
  62684. alphaTest: boolean;
  62685. /**
  62686. * Define a mask to restrict the layer to only some of the scene cameras.
  62687. */
  62688. layerMask: number;
  62689. /**
  62690. * Define the list of render target the layer is visible into.
  62691. */
  62692. renderTargetTextures: RenderTargetTexture[];
  62693. /**
  62694. * Define if the layer is only used in renderTarget or if it also
  62695. * renders in the main frame buffer of the canvas.
  62696. */
  62697. renderOnlyInRenderTargetTextures: boolean;
  62698. private _scene;
  62699. private _vertexBuffers;
  62700. private _indexBuffer;
  62701. private _effect;
  62702. private _previousDefines;
  62703. /**
  62704. * An event triggered when the layer is disposed.
  62705. */
  62706. onDisposeObservable: Observable<Layer>;
  62707. private _onDisposeObserver;
  62708. /**
  62709. * Back compatibility with callback before the onDisposeObservable existed.
  62710. * The set callback will be triggered when the layer has been disposed.
  62711. */
  62712. set onDispose(callback: () => void);
  62713. /**
  62714. * An event triggered before rendering the scene
  62715. */
  62716. onBeforeRenderObservable: Observable<Layer>;
  62717. private _onBeforeRenderObserver;
  62718. /**
  62719. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62720. * The set callback will be triggered just before rendering the layer.
  62721. */
  62722. set onBeforeRender(callback: () => void);
  62723. /**
  62724. * An event triggered after rendering the scene
  62725. */
  62726. onAfterRenderObservable: Observable<Layer>;
  62727. private _onAfterRenderObserver;
  62728. /**
  62729. * Back compatibility with callback before the onAfterRenderObservable existed.
  62730. * The set callback will be triggered just after rendering the layer.
  62731. */
  62732. set onAfterRender(callback: () => void);
  62733. /**
  62734. * Instantiates a new layer.
  62735. * This represents a full screen 2d layer.
  62736. * This can be useful to display a picture in the background of your scene for instance.
  62737. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62738. * @param name Define the name of the layer in the scene
  62739. * @param imgUrl Define the url of the texture to display in the layer
  62740. * @param scene Define the scene the layer belongs to
  62741. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62742. * @param color Defines a color for the layer
  62743. */
  62744. constructor(
  62745. /**
  62746. * Define the name of the layer.
  62747. */
  62748. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62749. private _createIndexBuffer;
  62750. /** @hidden */
  62751. _rebuild(): void;
  62752. /**
  62753. * Renders the layer in the scene.
  62754. */
  62755. render(): void;
  62756. /**
  62757. * Disposes and releases the associated ressources.
  62758. */
  62759. dispose(): void;
  62760. }
  62761. }
  62762. declare module "babylonjs/Layers/index" {
  62763. export * from "babylonjs/Layers/effectLayer";
  62764. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62765. export * from "babylonjs/Layers/glowLayer";
  62766. export * from "babylonjs/Layers/highlightLayer";
  62767. export * from "babylonjs/Layers/layer";
  62768. export * from "babylonjs/Layers/layerSceneComponent";
  62769. }
  62770. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62771. /** @hidden */
  62772. export var lensFlarePixelShader: {
  62773. name: string;
  62774. shader: string;
  62775. };
  62776. }
  62777. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62778. /** @hidden */
  62779. export var lensFlareVertexShader: {
  62780. name: string;
  62781. shader: string;
  62782. };
  62783. }
  62784. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62785. import { Scene } from "babylonjs/scene";
  62786. import { Vector3 } from "babylonjs/Maths/math.vector";
  62787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62788. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62789. import "babylonjs/Shaders/lensFlare.fragment";
  62790. import "babylonjs/Shaders/lensFlare.vertex";
  62791. import { Viewport } from "babylonjs/Maths/math.viewport";
  62792. /**
  62793. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62794. * It is usually composed of several `lensFlare`.
  62795. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62796. */
  62797. export class LensFlareSystem {
  62798. /**
  62799. * Define the name of the lens flare system
  62800. */
  62801. name: string;
  62802. /**
  62803. * List of lens flares used in this system.
  62804. */
  62805. lensFlares: LensFlare[];
  62806. /**
  62807. * Define a limit from the border the lens flare can be visible.
  62808. */
  62809. borderLimit: number;
  62810. /**
  62811. * Define a viewport border we do not want to see the lens flare in.
  62812. */
  62813. viewportBorder: number;
  62814. /**
  62815. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62816. */
  62817. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62818. /**
  62819. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62820. */
  62821. layerMask: number;
  62822. /**
  62823. * Define the id of the lens flare system in the scene.
  62824. * (equal to name by default)
  62825. */
  62826. id: string;
  62827. private _scene;
  62828. private _emitter;
  62829. private _vertexBuffers;
  62830. private _indexBuffer;
  62831. private _effect;
  62832. private _positionX;
  62833. private _positionY;
  62834. private _isEnabled;
  62835. /** @hidden */
  62836. static _SceneComponentInitialization: (scene: Scene) => void;
  62837. /**
  62838. * Instantiates a lens flare system.
  62839. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62840. * It is usually composed of several `lensFlare`.
  62841. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62842. * @param name Define the name of the lens flare system in the scene
  62843. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62844. * @param scene Define the scene the lens flare system belongs to
  62845. */
  62846. constructor(
  62847. /**
  62848. * Define the name of the lens flare system
  62849. */
  62850. name: string, emitter: any, scene: Scene);
  62851. /**
  62852. * Define if the lens flare system is enabled.
  62853. */
  62854. get isEnabled(): boolean;
  62855. set isEnabled(value: boolean);
  62856. /**
  62857. * Get the scene the effects belongs to.
  62858. * @returns the scene holding the lens flare system
  62859. */
  62860. getScene(): Scene;
  62861. /**
  62862. * Get the emitter of the lens flare system.
  62863. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62864. * @returns the emitter of the lens flare system
  62865. */
  62866. getEmitter(): any;
  62867. /**
  62868. * Set the emitter of the lens flare system.
  62869. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62870. * @param newEmitter Define the new emitter of the system
  62871. */
  62872. setEmitter(newEmitter: any): void;
  62873. /**
  62874. * Get the lens flare system emitter position.
  62875. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62876. * @returns the position
  62877. */
  62878. getEmitterPosition(): Vector3;
  62879. /**
  62880. * @hidden
  62881. */
  62882. computeEffectivePosition(globalViewport: Viewport): boolean;
  62883. /** @hidden */
  62884. _isVisible(): boolean;
  62885. /**
  62886. * @hidden
  62887. */
  62888. render(): boolean;
  62889. /**
  62890. * Dispose and release the lens flare with its associated resources.
  62891. */
  62892. dispose(): void;
  62893. /**
  62894. * Parse a lens flare system from a JSON repressentation
  62895. * @param parsedLensFlareSystem Define the JSON to parse
  62896. * @param scene Define the scene the parsed system should be instantiated in
  62897. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62898. * @returns the parsed system
  62899. */
  62900. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62901. /**
  62902. * Serialize the current Lens Flare System into a JSON representation.
  62903. * @returns the serialized JSON
  62904. */
  62905. serialize(): any;
  62906. }
  62907. }
  62908. declare module "babylonjs/LensFlares/lensFlare" {
  62909. import { Nullable } from "babylonjs/types";
  62910. import { Color3 } from "babylonjs/Maths/math.color";
  62911. import { Texture } from "babylonjs/Materials/Textures/texture";
  62912. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62913. /**
  62914. * This represents one of the lens effect in a `lensFlareSystem`.
  62915. * It controls one of the indiviual texture used in the effect.
  62916. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62917. */
  62918. export class LensFlare {
  62919. /**
  62920. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62921. */
  62922. size: number;
  62923. /**
  62924. * 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.
  62925. */
  62926. position: number;
  62927. /**
  62928. * Define the lens color.
  62929. */
  62930. color: Color3;
  62931. /**
  62932. * Define the lens texture.
  62933. */
  62934. texture: Nullable<Texture>;
  62935. /**
  62936. * Define the alpha mode to render this particular lens.
  62937. */
  62938. alphaMode: number;
  62939. private _system;
  62940. /**
  62941. * Creates a new Lens Flare.
  62942. * This represents one of the lens effect in a `lensFlareSystem`.
  62943. * It controls one of the indiviual texture used in the effect.
  62944. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62945. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62946. * @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.
  62947. * @param color Define the lens color
  62948. * @param imgUrl Define the lens texture url
  62949. * @param system Define the `lensFlareSystem` this flare is part of
  62950. * @returns The newly created Lens Flare
  62951. */
  62952. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62953. /**
  62954. * Instantiates a new Lens Flare.
  62955. * This represents one of the lens effect in a `lensFlareSystem`.
  62956. * It controls one of the indiviual texture used in the effect.
  62957. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62958. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62959. * @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.
  62960. * @param color Define the lens color
  62961. * @param imgUrl Define the lens texture url
  62962. * @param system Define the `lensFlareSystem` this flare is part of
  62963. */
  62964. constructor(
  62965. /**
  62966. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62967. */
  62968. size: number,
  62969. /**
  62970. * 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.
  62971. */
  62972. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62973. /**
  62974. * Dispose and release the lens flare with its associated resources.
  62975. */
  62976. dispose(): void;
  62977. }
  62978. }
  62979. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62980. import { Nullable } from "babylonjs/types";
  62981. import { Scene } from "babylonjs/scene";
  62982. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62983. import { AbstractScene } from "babylonjs/abstractScene";
  62984. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62985. module "babylonjs/abstractScene" {
  62986. interface AbstractScene {
  62987. /**
  62988. * The list of lens flare system added to the scene
  62989. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62990. */
  62991. lensFlareSystems: Array<LensFlareSystem>;
  62992. /**
  62993. * Removes the given lens flare system from this scene.
  62994. * @param toRemove The lens flare system to remove
  62995. * @returns The index of the removed lens flare system
  62996. */
  62997. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62998. /**
  62999. * Adds the given lens flare system to this scene
  63000. * @param newLensFlareSystem The lens flare system to add
  63001. */
  63002. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63003. /**
  63004. * Gets a lens flare system using its name
  63005. * @param name defines the name to look for
  63006. * @returns the lens flare system or null if not found
  63007. */
  63008. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63009. /**
  63010. * Gets a lens flare system using its id
  63011. * @param id defines the id to look for
  63012. * @returns the lens flare system or null if not found
  63013. */
  63014. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63015. }
  63016. }
  63017. /**
  63018. * Defines the lens flare scene component responsible to manage any lens flares
  63019. * in a given scene.
  63020. */
  63021. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63022. /**
  63023. * The component name helpfull to identify the component in the list of scene components.
  63024. */
  63025. readonly name: string;
  63026. /**
  63027. * The scene the component belongs to.
  63028. */
  63029. scene: Scene;
  63030. /**
  63031. * Creates a new instance of the component for the given scene
  63032. * @param scene Defines the scene to register the component in
  63033. */
  63034. constructor(scene: Scene);
  63035. /**
  63036. * Registers the component in a given scene
  63037. */
  63038. register(): void;
  63039. /**
  63040. * Rebuilds the elements related to this component in case of
  63041. * context lost for instance.
  63042. */
  63043. rebuild(): void;
  63044. /**
  63045. * Adds all the elements from the container to the scene
  63046. * @param container the container holding the elements
  63047. */
  63048. addFromContainer(container: AbstractScene): void;
  63049. /**
  63050. * Removes all the elements in the container from the scene
  63051. * @param container contains the elements to remove
  63052. * @param dispose if the removed element should be disposed (default: false)
  63053. */
  63054. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63055. /**
  63056. * Serializes the component data to the specified json object
  63057. * @param serializationObject The object to serialize to
  63058. */
  63059. serialize(serializationObject: any): void;
  63060. /**
  63061. * Disposes the component and the associated ressources.
  63062. */
  63063. dispose(): void;
  63064. private _draw;
  63065. }
  63066. }
  63067. declare module "babylonjs/LensFlares/index" {
  63068. export * from "babylonjs/LensFlares/lensFlare";
  63069. export * from "babylonjs/LensFlares/lensFlareSystem";
  63070. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63071. }
  63072. declare module "babylonjs/Shaders/depth.fragment" {
  63073. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63074. /** @hidden */
  63075. export var depthPixelShader: {
  63076. name: string;
  63077. shader: string;
  63078. };
  63079. }
  63080. declare module "babylonjs/Shaders/depth.vertex" {
  63081. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63082. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63083. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63084. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63085. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63086. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63087. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63088. /** @hidden */
  63089. export var depthVertexShader: {
  63090. name: string;
  63091. shader: string;
  63092. };
  63093. }
  63094. declare module "babylonjs/Rendering/depthRenderer" {
  63095. import { Nullable } from "babylonjs/types";
  63096. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63097. import { Scene } from "babylonjs/scene";
  63098. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63099. import { Camera } from "babylonjs/Cameras/camera";
  63100. import "babylonjs/Shaders/depth.fragment";
  63101. import "babylonjs/Shaders/depth.vertex";
  63102. /**
  63103. * This represents a depth renderer in Babylon.
  63104. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63105. */
  63106. export class DepthRenderer {
  63107. private _scene;
  63108. private _depthMap;
  63109. private _effect;
  63110. private readonly _storeNonLinearDepth;
  63111. private readonly _clearColor;
  63112. /** Get if the depth renderer is using packed depth or not */
  63113. readonly isPacked: boolean;
  63114. private _cachedDefines;
  63115. private _camera;
  63116. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63117. enabled: boolean;
  63118. /**
  63119. * Specifiess that the depth renderer will only be used within
  63120. * the camera it is created for.
  63121. * This can help forcing its rendering during the camera processing.
  63122. */
  63123. useOnlyInActiveCamera: boolean;
  63124. /** @hidden */
  63125. static _SceneComponentInitialization: (scene: Scene) => void;
  63126. /**
  63127. * Instantiates a depth renderer
  63128. * @param scene The scene the renderer belongs to
  63129. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63130. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63131. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63132. */
  63133. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63134. /**
  63135. * Creates the depth rendering effect and checks if the effect is ready.
  63136. * @param subMesh The submesh to be used to render the depth map of
  63137. * @param useInstances If multiple world instances should be used
  63138. * @returns if the depth renderer is ready to render the depth map
  63139. */
  63140. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63141. /**
  63142. * Gets the texture which the depth map will be written to.
  63143. * @returns The depth map texture
  63144. */
  63145. getDepthMap(): RenderTargetTexture;
  63146. /**
  63147. * Disposes of the depth renderer.
  63148. */
  63149. dispose(): void;
  63150. }
  63151. }
  63152. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63153. /** @hidden */
  63154. export var minmaxReduxPixelShader: {
  63155. name: string;
  63156. shader: string;
  63157. };
  63158. }
  63159. declare module "babylonjs/Misc/minMaxReducer" {
  63160. import { Nullable } from "babylonjs/types";
  63161. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63162. import { Camera } from "babylonjs/Cameras/camera";
  63163. import { Observer } from "babylonjs/Misc/observable";
  63164. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63165. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63166. import { Observable } from "babylonjs/Misc/observable";
  63167. import "babylonjs/Shaders/minmaxRedux.fragment";
  63168. /**
  63169. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63170. * and maximum values from all values of the texture.
  63171. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63172. * The source values are read from the red channel of the texture.
  63173. */
  63174. export class MinMaxReducer {
  63175. /**
  63176. * Observable triggered when the computation has been performed
  63177. */
  63178. onAfterReductionPerformed: Observable<{
  63179. min: number;
  63180. max: number;
  63181. }>;
  63182. protected _camera: Camera;
  63183. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63184. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63185. protected _postProcessManager: PostProcessManager;
  63186. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63187. protected _forceFullscreenViewport: boolean;
  63188. /**
  63189. * Creates a min/max reducer
  63190. * @param camera The camera to use for the post processes
  63191. */
  63192. constructor(camera: Camera);
  63193. /**
  63194. * Gets the texture used to read the values from.
  63195. */
  63196. get sourceTexture(): Nullable<RenderTargetTexture>;
  63197. /**
  63198. * Sets the source texture to read the values from.
  63199. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63200. * because in such textures '1' value must not be taken into account to compute the maximum
  63201. * as this value is used to clear the texture.
  63202. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63203. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63204. * @param depthRedux Indicates if the texture is a depth texture or not
  63205. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63206. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63207. */
  63208. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63209. /**
  63210. * Defines the refresh rate of the computation.
  63211. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63212. */
  63213. get refreshRate(): number;
  63214. set refreshRate(value: number);
  63215. protected _activated: boolean;
  63216. /**
  63217. * Gets the activation status of the reducer
  63218. */
  63219. get activated(): boolean;
  63220. /**
  63221. * Activates the reduction computation.
  63222. * When activated, the observers registered in onAfterReductionPerformed are
  63223. * called after the compuation is performed
  63224. */
  63225. activate(): void;
  63226. /**
  63227. * Deactivates the reduction computation.
  63228. */
  63229. deactivate(): void;
  63230. /**
  63231. * Disposes the min/max reducer
  63232. * @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.
  63233. */
  63234. dispose(disposeAll?: boolean): void;
  63235. }
  63236. }
  63237. declare module "babylonjs/Misc/depthReducer" {
  63238. import { Nullable } from "babylonjs/types";
  63239. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63240. import { Camera } from "babylonjs/Cameras/camera";
  63241. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63242. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63243. /**
  63244. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63245. */
  63246. export class DepthReducer extends MinMaxReducer {
  63247. private _depthRenderer;
  63248. private _depthRendererId;
  63249. /**
  63250. * Gets the depth renderer used for the computation.
  63251. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63252. */
  63253. get depthRenderer(): Nullable<DepthRenderer>;
  63254. /**
  63255. * Creates a depth reducer
  63256. * @param camera The camera used to render the depth texture
  63257. */
  63258. constructor(camera: Camera);
  63259. /**
  63260. * Sets the depth renderer to use to generate the depth map
  63261. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63262. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63263. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63264. */
  63265. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63266. /** @hidden */
  63267. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63268. /**
  63269. * Activates the reduction computation.
  63270. * When activated, the observers registered in onAfterReductionPerformed are
  63271. * called after the compuation is performed
  63272. */
  63273. activate(): void;
  63274. /**
  63275. * Deactivates the reduction computation.
  63276. */
  63277. deactivate(): void;
  63278. /**
  63279. * Disposes the depth reducer
  63280. * @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.
  63281. */
  63282. dispose(disposeAll?: boolean): void;
  63283. }
  63284. }
  63285. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63286. import { Nullable } from "babylonjs/types";
  63287. import { Scene } from "babylonjs/scene";
  63288. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63289. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63291. import { Effect } from "babylonjs/Materials/effect";
  63292. import "babylonjs/Shaders/shadowMap.fragment";
  63293. import "babylonjs/Shaders/shadowMap.vertex";
  63294. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63295. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63296. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63297. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63298. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63299. /**
  63300. * A CSM implementation allowing casting shadows on large scenes.
  63301. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63302. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63303. */
  63304. export class CascadedShadowGenerator extends ShadowGenerator {
  63305. private static readonly frustumCornersNDCSpace;
  63306. /**
  63307. * Name of the CSM class
  63308. */
  63309. static CLASSNAME: string;
  63310. /**
  63311. * Defines the default number of cascades used by the CSM.
  63312. */
  63313. static readonly DEFAULT_CASCADES_COUNT: number;
  63314. /**
  63315. * Defines the minimum number of cascades used by the CSM.
  63316. */
  63317. static readonly MIN_CASCADES_COUNT: number;
  63318. /**
  63319. * Defines the maximum number of cascades used by the CSM.
  63320. */
  63321. static readonly MAX_CASCADES_COUNT: number;
  63322. protected _validateFilter(filter: number): number;
  63323. /**
  63324. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63325. */
  63326. penumbraDarkness: number;
  63327. private _numCascades;
  63328. /**
  63329. * Gets or set the number of cascades used by the CSM.
  63330. */
  63331. get numCascades(): number;
  63332. set numCascades(value: number);
  63333. /**
  63334. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63335. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63336. */
  63337. stabilizeCascades: boolean;
  63338. private _freezeShadowCastersBoundingInfo;
  63339. private _freezeShadowCastersBoundingInfoObservable;
  63340. /**
  63341. * Enables or disables the shadow casters bounding info computation.
  63342. * If your shadow casters don't move, you can disable this feature.
  63343. * If it is enabled, the bounding box computation is done every frame.
  63344. */
  63345. get freezeShadowCastersBoundingInfo(): boolean;
  63346. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63347. private _scbiMin;
  63348. private _scbiMax;
  63349. protected _computeShadowCastersBoundingInfo(): void;
  63350. protected _shadowCastersBoundingInfo: BoundingInfo;
  63351. /**
  63352. * Gets or sets the shadow casters bounding info.
  63353. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63354. * so that the system won't overwrite the bounds you provide
  63355. */
  63356. get shadowCastersBoundingInfo(): BoundingInfo;
  63357. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63358. protected _breaksAreDirty: boolean;
  63359. protected _minDistance: number;
  63360. protected _maxDistance: number;
  63361. /**
  63362. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63363. *
  63364. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63365. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63366. * @param min minimal distance for the breaks (default to 0.)
  63367. * @param max maximal distance for the breaks (default to 1.)
  63368. */
  63369. setMinMaxDistance(min: number, max: number): void;
  63370. /** Gets the minimal distance used in the cascade break computation */
  63371. get minDistance(): number;
  63372. /** Gets the maximal distance used in the cascade break computation */
  63373. get maxDistance(): number;
  63374. /**
  63375. * Gets the class name of that object
  63376. * @returns "CascadedShadowGenerator"
  63377. */
  63378. getClassName(): string;
  63379. private _cascadeMinExtents;
  63380. private _cascadeMaxExtents;
  63381. /**
  63382. * Gets a cascade minimum extents
  63383. * @param cascadeIndex index of the cascade
  63384. * @returns the minimum cascade extents
  63385. */
  63386. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63387. /**
  63388. * Gets a cascade maximum extents
  63389. * @param cascadeIndex index of the cascade
  63390. * @returns the maximum cascade extents
  63391. */
  63392. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63393. private _cascades;
  63394. private _currentLayer;
  63395. private _viewSpaceFrustumsZ;
  63396. private _viewMatrices;
  63397. private _projectionMatrices;
  63398. private _transformMatrices;
  63399. private _transformMatricesAsArray;
  63400. private _frustumLengths;
  63401. private _lightSizeUVCorrection;
  63402. private _depthCorrection;
  63403. private _frustumCornersWorldSpace;
  63404. private _frustumCenter;
  63405. private _shadowCameraPos;
  63406. private _shadowMaxZ;
  63407. /**
  63408. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63409. * It defaults to camera.maxZ
  63410. */
  63411. get shadowMaxZ(): number;
  63412. /**
  63413. * Sets the shadow max z distance.
  63414. */
  63415. set shadowMaxZ(value: number);
  63416. protected _debug: boolean;
  63417. /**
  63418. * Gets or sets the debug flag.
  63419. * When enabled, the cascades are materialized by different colors on the screen.
  63420. */
  63421. get debug(): boolean;
  63422. set debug(dbg: boolean);
  63423. private _depthClamp;
  63424. /**
  63425. * Gets or sets the depth clamping value.
  63426. *
  63427. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63428. * to account for the shadow casters far away.
  63429. *
  63430. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63431. */
  63432. get depthClamp(): boolean;
  63433. set depthClamp(value: boolean);
  63434. private _cascadeBlendPercentage;
  63435. /**
  63436. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63437. * It defaults to 0.1 (10% blending).
  63438. */
  63439. get cascadeBlendPercentage(): number;
  63440. set cascadeBlendPercentage(value: number);
  63441. private _lambda;
  63442. /**
  63443. * Gets or set the lambda parameter.
  63444. * This parameter is used to split the camera frustum and create the cascades.
  63445. * 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.
  63446. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63447. */
  63448. get lambda(): number;
  63449. set lambda(value: number);
  63450. /**
  63451. * Gets the view matrix corresponding to a given cascade
  63452. * @param cascadeNum cascade to retrieve the view matrix from
  63453. * @returns the cascade view matrix
  63454. */
  63455. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63456. /**
  63457. * Gets the projection matrix corresponding to a given cascade
  63458. * @param cascadeNum cascade to retrieve the projection matrix from
  63459. * @returns the cascade projection matrix
  63460. */
  63461. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63462. /**
  63463. * Gets the transformation matrix corresponding to a given cascade
  63464. * @param cascadeNum cascade to retrieve the transformation matrix from
  63465. * @returns the cascade transformation matrix
  63466. */
  63467. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63468. private _depthRenderer;
  63469. /**
  63470. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63471. *
  63472. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63473. *
  63474. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63475. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63476. * @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
  63477. */
  63478. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63479. private _depthReducer;
  63480. private _autoCalcDepthBounds;
  63481. /**
  63482. * Gets or sets the autoCalcDepthBounds property.
  63483. *
  63484. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63485. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63486. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63487. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63488. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63489. */
  63490. get autoCalcDepthBounds(): boolean;
  63491. set autoCalcDepthBounds(value: boolean);
  63492. /**
  63493. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63494. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63495. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63496. * for setting the refresh rate on the renderer yourself!
  63497. */
  63498. get autoCalcDepthBoundsRefreshRate(): number;
  63499. set autoCalcDepthBoundsRefreshRate(value: number);
  63500. /**
  63501. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63502. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63503. * you change the camera near/far planes!
  63504. */
  63505. splitFrustum(): void;
  63506. private _splitFrustum;
  63507. private _computeMatrices;
  63508. private _computeFrustumInWorldSpace;
  63509. private _computeCascadeFrustum;
  63510. /**
  63511. * Support test.
  63512. */
  63513. static get IsSupported(): boolean;
  63514. /** @hidden */
  63515. static _SceneComponentInitialization: (scene: Scene) => void;
  63516. /**
  63517. * Creates a Cascaded Shadow Generator object.
  63518. * A ShadowGenerator is the required tool to use the shadows.
  63519. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63520. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63521. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63522. * @param light The directional light object generating the shadows.
  63523. * @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.
  63524. */
  63525. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63526. protected _initializeGenerator(): void;
  63527. protected _createTargetRenderTexture(): void;
  63528. protected _initializeShadowMap(): void;
  63529. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63530. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63531. /**
  63532. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63533. * @param defines Defines of the material we want to update
  63534. * @param lightIndex Index of the light in the enabled light list of the material
  63535. */
  63536. prepareDefines(defines: any, lightIndex: number): void;
  63537. /**
  63538. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63539. * defined in the generator but impacting the effect).
  63540. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63541. * @param effect The effect we are binfing the information for
  63542. */
  63543. bindShadowLight(lightIndex: string, effect: Effect): void;
  63544. /**
  63545. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63546. * (eq to view projection * shadow projection matrices)
  63547. * @returns The transform matrix used to create the shadow map
  63548. */
  63549. getTransformMatrix(): Matrix;
  63550. /**
  63551. * Disposes the ShadowGenerator.
  63552. * Returns nothing.
  63553. */
  63554. dispose(): void;
  63555. /**
  63556. * Serializes the shadow generator setup to a json object.
  63557. * @returns The serialized JSON object
  63558. */
  63559. serialize(): any;
  63560. /**
  63561. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63562. * @param parsedShadowGenerator The JSON object to parse
  63563. * @param scene The scene to create the shadow map for
  63564. * @returns The parsed shadow generator
  63565. */
  63566. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63567. }
  63568. }
  63569. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63570. import { Scene } from "babylonjs/scene";
  63571. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63572. import { AbstractScene } from "babylonjs/abstractScene";
  63573. /**
  63574. * Defines the shadow generator component responsible to manage any shadow generators
  63575. * in a given scene.
  63576. */
  63577. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63578. /**
  63579. * The component name helpfull to identify the component in the list of scene components.
  63580. */
  63581. readonly name: string;
  63582. /**
  63583. * The scene the component belongs to.
  63584. */
  63585. scene: Scene;
  63586. /**
  63587. * Creates a new instance of the component for the given scene
  63588. * @param scene Defines the scene to register the component in
  63589. */
  63590. constructor(scene: Scene);
  63591. /**
  63592. * Registers the component in a given scene
  63593. */
  63594. register(): void;
  63595. /**
  63596. * Rebuilds the elements related to this component in case of
  63597. * context lost for instance.
  63598. */
  63599. rebuild(): void;
  63600. /**
  63601. * Serializes the component data to the specified json object
  63602. * @param serializationObject The object to serialize to
  63603. */
  63604. serialize(serializationObject: any): void;
  63605. /**
  63606. * Adds all the elements from the container to the scene
  63607. * @param container the container holding the elements
  63608. */
  63609. addFromContainer(container: AbstractScene): void;
  63610. /**
  63611. * Removes all the elements in the container from the scene
  63612. * @param container contains the elements to remove
  63613. * @param dispose if the removed element should be disposed (default: false)
  63614. */
  63615. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63616. /**
  63617. * Rebuilds the elements related to this component in case of
  63618. * context lost for instance.
  63619. */
  63620. dispose(): void;
  63621. private _gatherRenderTargets;
  63622. }
  63623. }
  63624. declare module "babylonjs/Lights/Shadows/index" {
  63625. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63626. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63627. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63628. }
  63629. declare module "babylonjs/Lights/pointLight" {
  63630. import { Scene } from "babylonjs/scene";
  63631. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63633. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63634. import { Effect } from "babylonjs/Materials/effect";
  63635. /**
  63636. * A point light is a light defined by an unique point in world space.
  63637. * The light is emitted in every direction from this point.
  63638. * A good example of a point light is a standard light bulb.
  63639. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63640. */
  63641. export class PointLight extends ShadowLight {
  63642. private _shadowAngle;
  63643. /**
  63644. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63645. * This specifies what angle the shadow will use to be created.
  63646. *
  63647. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63648. */
  63649. get shadowAngle(): number;
  63650. /**
  63651. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63652. * This specifies what angle the shadow will use to be created.
  63653. *
  63654. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63655. */
  63656. set shadowAngle(value: number);
  63657. /**
  63658. * Gets the direction if it has been set.
  63659. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63660. */
  63661. get direction(): Vector3;
  63662. /**
  63663. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63664. */
  63665. set direction(value: Vector3);
  63666. /**
  63667. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63668. * A PointLight emits the light in every direction.
  63669. * It can cast shadows.
  63670. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63671. * ```javascript
  63672. * var pointLight = new PointLight("pl", camera.position, scene);
  63673. * ```
  63674. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63675. * @param name The light friendly name
  63676. * @param position The position of the point light in the scene
  63677. * @param scene The scene the lights belongs to
  63678. */
  63679. constructor(name: string, position: Vector3, scene: Scene);
  63680. /**
  63681. * Returns the string "PointLight"
  63682. * @returns the class name
  63683. */
  63684. getClassName(): string;
  63685. /**
  63686. * Returns the integer 0.
  63687. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63688. */
  63689. getTypeID(): number;
  63690. /**
  63691. * Specifies wether or not the shadowmap should be a cube texture.
  63692. * @returns true if the shadowmap needs to be a cube texture.
  63693. */
  63694. needCube(): boolean;
  63695. /**
  63696. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63697. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63698. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63699. */
  63700. getShadowDirection(faceIndex?: number): Vector3;
  63701. /**
  63702. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63703. * - fov = PI / 2
  63704. * - aspect ratio : 1.0
  63705. * - z-near and far equal to the active camera minZ and maxZ.
  63706. * Returns the PointLight.
  63707. */
  63708. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63709. protected _buildUniformLayout(): void;
  63710. /**
  63711. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63712. * @param effect The effect to update
  63713. * @param lightIndex The index of the light in the effect to update
  63714. * @returns The point light
  63715. */
  63716. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63717. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63718. /**
  63719. * Prepares the list of defines specific to the light type.
  63720. * @param defines the list of defines
  63721. * @param lightIndex defines the index of the light for the effect
  63722. */
  63723. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63724. }
  63725. }
  63726. declare module "babylonjs/Lights/index" {
  63727. export * from "babylonjs/Lights/light";
  63728. export * from "babylonjs/Lights/shadowLight";
  63729. export * from "babylonjs/Lights/Shadows/index";
  63730. export * from "babylonjs/Lights/directionalLight";
  63731. export * from "babylonjs/Lights/hemisphericLight";
  63732. export * from "babylonjs/Lights/pointLight";
  63733. export * from "babylonjs/Lights/spotLight";
  63734. }
  63735. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63736. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63737. /**
  63738. * Header information of HDR texture files.
  63739. */
  63740. export interface HDRInfo {
  63741. /**
  63742. * The height of the texture in pixels.
  63743. */
  63744. height: number;
  63745. /**
  63746. * The width of the texture in pixels.
  63747. */
  63748. width: number;
  63749. /**
  63750. * The index of the beginning of the data in the binary file.
  63751. */
  63752. dataPosition: number;
  63753. }
  63754. /**
  63755. * This groups tools to convert HDR texture to native colors array.
  63756. */
  63757. export class HDRTools {
  63758. private static Ldexp;
  63759. private static Rgbe2float;
  63760. private static readStringLine;
  63761. /**
  63762. * Reads header information from an RGBE texture stored in a native array.
  63763. * More information on this format are available here:
  63764. * https://en.wikipedia.org/wiki/RGBE_image_format
  63765. *
  63766. * @param uint8array The binary file stored in native array.
  63767. * @return The header information.
  63768. */
  63769. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63770. /**
  63771. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63772. * This RGBE texture needs to store the information as a panorama.
  63773. *
  63774. * More information on this format are available here:
  63775. * https://en.wikipedia.org/wiki/RGBE_image_format
  63776. *
  63777. * @param buffer The binary file stored in an array buffer.
  63778. * @param size The expected size of the extracted cubemap.
  63779. * @return The Cube Map information.
  63780. */
  63781. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63782. /**
  63783. * Returns the pixels data extracted from an RGBE texture.
  63784. * This pixels will be stored left to right up to down in the R G B order in one array.
  63785. *
  63786. * More information on this format are available here:
  63787. * https://en.wikipedia.org/wiki/RGBE_image_format
  63788. *
  63789. * @param uint8array The binary file stored in an array buffer.
  63790. * @param hdrInfo The header information of the file.
  63791. * @return The pixels data in RGB right to left up to down order.
  63792. */
  63793. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63794. private static RGBE_ReadPixels_RLE;
  63795. private static RGBE_ReadPixels_NOT_RLE;
  63796. }
  63797. }
  63798. declare module "babylonjs/Materials/effectRenderer" {
  63799. import { Nullable } from "babylonjs/types";
  63800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63801. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63802. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63803. import { Viewport } from "babylonjs/Maths/math.viewport";
  63804. import { Observable } from "babylonjs/Misc/observable";
  63805. import { Effect } from "babylonjs/Materials/effect";
  63806. import "babylonjs/Shaders/postprocess.vertex";
  63807. /**
  63808. * Effect Render Options
  63809. */
  63810. export interface IEffectRendererOptions {
  63811. /**
  63812. * Defines the vertices positions.
  63813. */
  63814. positions?: number[];
  63815. /**
  63816. * Defines the indices.
  63817. */
  63818. indices?: number[];
  63819. }
  63820. /**
  63821. * Helper class to render one or more effects.
  63822. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63823. */
  63824. export class EffectRenderer {
  63825. private engine;
  63826. private static _DefaultOptions;
  63827. private _vertexBuffers;
  63828. private _indexBuffer;
  63829. private _fullscreenViewport;
  63830. /**
  63831. * Creates an effect renderer
  63832. * @param engine the engine to use for rendering
  63833. * @param options defines the options of the effect renderer
  63834. */
  63835. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63836. /**
  63837. * Sets the current viewport in normalized coordinates 0-1
  63838. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63839. */
  63840. setViewport(viewport?: Viewport): void;
  63841. /**
  63842. * Binds the embedded attributes buffer to the effect.
  63843. * @param effect Defines the effect to bind the attributes for
  63844. */
  63845. bindBuffers(effect: Effect): void;
  63846. /**
  63847. * Sets the current effect wrapper to use during draw.
  63848. * The effect needs to be ready before calling this api.
  63849. * This also sets the default full screen position attribute.
  63850. * @param effectWrapper Defines the effect to draw with
  63851. */
  63852. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63853. /**
  63854. * Restores engine states
  63855. */
  63856. restoreStates(): void;
  63857. /**
  63858. * Draws a full screen quad.
  63859. */
  63860. draw(): void;
  63861. private isRenderTargetTexture;
  63862. /**
  63863. * renders one or more effects to a specified texture
  63864. * @param effectWrapper the effect to renderer
  63865. * @param outputTexture texture to draw to, if null it will render to the screen.
  63866. */
  63867. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63868. /**
  63869. * Disposes of the effect renderer
  63870. */
  63871. dispose(): void;
  63872. }
  63873. /**
  63874. * Options to create an EffectWrapper
  63875. */
  63876. interface EffectWrapperCreationOptions {
  63877. /**
  63878. * Engine to use to create the effect
  63879. */
  63880. engine: ThinEngine;
  63881. /**
  63882. * Fragment shader for the effect
  63883. */
  63884. fragmentShader: string;
  63885. /**
  63886. * Use the shader store instead of direct source code
  63887. */
  63888. useShaderStore?: boolean;
  63889. /**
  63890. * Vertex shader for the effect
  63891. */
  63892. vertexShader?: string;
  63893. /**
  63894. * Attributes to use in the shader
  63895. */
  63896. attributeNames?: Array<string>;
  63897. /**
  63898. * Uniforms to use in the shader
  63899. */
  63900. uniformNames?: Array<string>;
  63901. /**
  63902. * Texture sampler names to use in the shader
  63903. */
  63904. samplerNames?: Array<string>;
  63905. /**
  63906. * Defines to use in the shader
  63907. */
  63908. defines?: Array<string>;
  63909. /**
  63910. * Callback when effect is compiled
  63911. */
  63912. onCompiled?: Nullable<(effect: Effect) => void>;
  63913. /**
  63914. * The friendly name of the effect displayed in Spector.
  63915. */
  63916. name?: string;
  63917. }
  63918. /**
  63919. * Wraps an effect to be used for rendering
  63920. */
  63921. export class EffectWrapper {
  63922. /**
  63923. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63924. */
  63925. onApplyObservable: Observable<{}>;
  63926. /**
  63927. * The underlying effect
  63928. */
  63929. effect: Effect;
  63930. /**
  63931. * Creates an effect to be renderer
  63932. * @param creationOptions options to create the effect
  63933. */
  63934. constructor(creationOptions: EffectWrapperCreationOptions);
  63935. /**
  63936. * Disposes of the effect wrapper
  63937. */
  63938. dispose(): void;
  63939. }
  63940. }
  63941. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63942. /** @hidden */
  63943. export var hdrFilteringVertexShader: {
  63944. name: string;
  63945. shader: string;
  63946. };
  63947. }
  63948. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63949. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63950. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63951. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63952. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63953. /** @hidden */
  63954. export var hdrFilteringPixelShader: {
  63955. name: string;
  63956. shader: string;
  63957. };
  63958. }
  63959. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63960. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63961. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63962. import { Nullable } from "babylonjs/types";
  63963. import "babylonjs/Shaders/hdrFiltering.vertex";
  63964. import "babylonjs/Shaders/hdrFiltering.fragment";
  63965. /**
  63966. * Options for texture filtering
  63967. */
  63968. interface IHDRFilteringOptions {
  63969. /**
  63970. * Scales pixel intensity for the input HDR map.
  63971. */
  63972. hdrScale?: number;
  63973. /**
  63974. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63975. */
  63976. quality?: number;
  63977. }
  63978. /**
  63979. * Filters HDR maps to get correct renderings of PBR reflections
  63980. */
  63981. export class HDRFiltering {
  63982. private _engine;
  63983. private _effectRenderer;
  63984. private _effectWrapper;
  63985. private _lodGenerationOffset;
  63986. private _lodGenerationScale;
  63987. /**
  63988. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63989. * you care about baking speed.
  63990. */
  63991. quality: number;
  63992. /**
  63993. * Scales pixel intensity for the input HDR map.
  63994. */
  63995. hdrScale: number;
  63996. /**
  63997. * Instantiates HDR filter for reflection maps
  63998. *
  63999. * @param engine Thin engine
  64000. * @param options Options
  64001. */
  64002. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64003. private _createRenderTarget;
  64004. private _prefilterInternal;
  64005. private _createEffect;
  64006. /**
  64007. * Get a value indicating if the filter is ready to be used
  64008. * @param texture Texture to filter
  64009. * @returns true if the filter is ready
  64010. */
  64011. isReady(texture: BaseTexture): boolean;
  64012. /**
  64013. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64014. * Prefiltering will be invoked at the end of next rendering pass.
  64015. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64016. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64017. * @param texture Texture to filter
  64018. * @param onFinished Callback when filtering is done
  64019. * @return Promise called when prefiltering is done
  64020. */
  64021. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64022. }
  64023. }
  64024. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64025. import { Nullable } from "babylonjs/types";
  64026. import { Scene } from "babylonjs/scene";
  64027. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64028. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64029. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64030. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64031. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64032. /**
  64033. * This represents a texture coming from an HDR input.
  64034. *
  64035. * The only supported format is currently panorama picture stored in RGBE format.
  64036. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64037. */
  64038. export class HDRCubeTexture extends BaseTexture {
  64039. private static _facesMapping;
  64040. private _generateHarmonics;
  64041. private _noMipmap;
  64042. private _prefilterOnLoad;
  64043. private _textureMatrix;
  64044. private _size;
  64045. private _onLoad;
  64046. private _onError;
  64047. /**
  64048. * The texture URL.
  64049. */
  64050. url: string;
  64051. protected _isBlocking: boolean;
  64052. /**
  64053. * Sets wether or not the texture is blocking during loading.
  64054. */
  64055. set isBlocking(value: boolean);
  64056. /**
  64057. * Gets wether or not the texture is blocking during loading.
  64058. */
  64059. get isBlocking(): boolean;
  64060. protected _rotationY: number;
  64061. /**
  64062. * Sets texture matrix rotation angle around Y axis in radians.
  64063. */
  64064. set rotationY(value: number);
  64065. /**
  64066. * Gets texture matrix rotation angle around Y axis radians.
  64067. */
  64068. get rotationY(): number;
  64069. /**
  64070. * Gets or sets the center of the bounding box associated with the cube texture
  64071. * It must define where the camera used to render the texture was set
  64072. */
  64073. boundingBoxPosition: Vector3;
  64074. private _boundingBoxSize;
  64075. /**
  64076. * Gets or sets the size of the bounding box associated with the cube texture
  64077. * When defined, the cubemap will switch to local mode
  64078. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64079. * @example https://www.babylonjs-playground.com/#RNASML
  64080. */
  64081. set boundingBoxSize(value: Vector3);
  64082. get boundingBoxSize(): Vector3;
  64083. /**
  64084. * Instantiates an HDRTexture from the following parameters.
  64085. *
  64086. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64087. * @param sceneOrEngine The scene or engine the texture will be used in
  64088. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64089. * @param noMipmap Forces to not generate the mipmap if true
  64090. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64091. * @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)
  64092. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64093. */
  64094. 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>);
  64095. /**
  64096. * Get the current class name of the texture useful for serialization or dynamic coding.
  64097. * @returns "HDRCubeTexture"
  64098. */
  64099. getClassName(): string;
  64100. /**
  64101. * Occurs when the file is raw .hdr file.
  64102. */
  64103. private loadTexture;
  64104. clone(): HDRCubeTexture;
  64105. delayLoad(): void;
  64106. /**
  64107. * Get the texture reflection matrix used to rotate/transform the reflection.
  64108. * @returns the reflection matrix
  64109. */
  64110. getReflectionTextureMatrix(): Matrix;
  64111. /**
  64112. * Set the texture reflection matrix used to rotate/transform the reflection.
  64113. * @param value Define the reflection matrix to set
  64114. */
  64115. setReflectionTextureMatrix(value: Matrix): void;
  64116. /**
  64117. * Parses a JSON representation of an HDR Texture in order to create the texture
  64118. * @param parsedTexture Define the JSON representation
  64119. * @param scene Define the scene the texture should be created in
  64120. * @param rootUrl Define the root url in case we need to load relative dependencies
  64121. * @returns the newly created texture after parsing
  64122. */
  64123. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64124. serialize(): any;
  64125. }
  64126. }
  64127. declare module "babylonjs/Physics/physicsEngine" {
  64128. import { Nullable } from "babylonjs/types";
  64129. import { Vector3 } from "babylonjs/Maths/math.vector";
  64130. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64131. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64132. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64133. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64134. /**
  64135. * Class used to control physics engine
  64136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64137. */
  64138. export class PhysicsEngine implements IPhysicsEngine {
  64139. private _physicsPlugin;
  64140. /**
  64141. * Global value used to control the smallest number supported by the simulation
  64142. */
  64143. static Epsilon: number;
  64144. private _impostors;
  64145. private _joints;
  64146. private _subTimeStep;
  64147. /**
  64148. * Gets the gravity vector used by the simulation
  64149. */
  64150. gravity: Vector3;
  64151. /**
  64152. * Factory used to create the default physics plugin.
  64153. * @returns The default physics plugin
  64154. */
  64155. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64156. /**
  64157. * Creates a new Physics Engine
  64158. * @param gravity defines the gravity vector used by the simulation
  64159. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64160. */
  64161. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64162. /**
  64163. * Sets the gravity vector used by the simulation
  64164. * @param gravity defines the gravity vector to use
  64165. */
  64166. setGravity(gravity: Vector3): void;
  64167. /**
  64168. * Set the time step of the physics engine.
  64169. * Default is 1/60.
  64170. * To slow it down, enter 1/600 for example.
  64171. * To speed it up, 1/30
  64172. * @param newTimeStep defines the new timestep to apply to this world.
  64173. */
  64174. setTimeStep(newTimeStep?: number): void;
  64175. /**
  64176. * Get the time step of the physics engine.
  64177. * @returns the current time step
  64178. */
  64179. getTimeStep(): number;
  64180. /**
  64181. * Set the sub time step of the physics engine.
  64182. * Default is 0 meaning there is no sub steps
  64183. * To increase physics resolution precision, set a small value (like 1 ms)
  64184. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64185. */
  64186. setSubTimeStep(subTimeStep?: number): void;
  64187. /**
  64188. * Get the sub time step of the physics engine.
  64189. * @returns the current sub time step
  64190. */
  64191. getSubTimeStep(): number;
  64192. /**
  64193. * Release all resources
  64194. */
  64195. dispose(): void;
  64196. /**
  64197. * Gets the name of the current physics plugin
  64198. * @returns the name of the plugin
  64199. */
  64200. getPhysicsPluginName(): string;
  64201. /**
  64202. * Adding a new impostor for the impostor tracking.
  64203. * This will be done by the impostor itself.
  64204. * @param impostor the impostor to add
  64205. */
  64206. addImpostor(impostor: PhysicsImpostor): void;
  64207. /**
  64208. * Remove an impostor from the engine.
  64209. * This impostor and its mesh will not longer be updated by the physics engine.
  64210. * @param impostor the impostor to remove
  64211. */
  64212. removeImpostor(impostor: PhysicsImpostor): void;
  64213. /**
  64214. * Add a joint to the physics engine
  64215. * @param mainImpostor defines the main impostor to which the joint is added.
  64216. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64217. * @param joint defines the joint that will connect both impostors.
  64218. */
  64219. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64220. /**
  64221. * Removes a joint from the simulation
  64222. * @param mainImpostor defines the impostor used with the joint
  64223. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64224. * @param joint defines the joint to remove
  64225. */
  64226. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64227. /**
  64228. * Called by the scene. No need to call it.
  64229. * @param delta defines the timespam between frames
  64230. */
  64231. _step(delta: number): void;
  64232. /**
  64233. * Gets the current plugin used to run the simulation
  64234. * @returns current plugin
  64235. */
  64236. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64237. /**
  64238. * Gets the list of physic impostors
  64239. * @returns an array of PhysicsImpostor
  64240. */
  64241. getImpostors(): Array<PhysicsImpostor>;
  64242. /**
  64243. * Gets the impostor for a physics enabled object
  64244. * @param object defines the object impersonated by the impostor
  64245. * @returns the PhysicsImpostor or null if not found
  64246. */
  64247. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64248. /**
  64249. * Gets the impostor for a physics body object
  64250. * @param body defines physics body used by the impostor
  64251. * @returns the PhysicsImpostor or null if not found
  64252. */
  64253. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64254. /**
  64255. * Does a raycast in the physics world
  64256. * @param from when should the ray start?
  64257. * @param to when should the ray end?
  64258. * @returns PhysicsRaycastResult
  64259. */
  64260. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64261. }
  64262. }
  64263. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64264. import { Nullable } from "babylonjs/types";
  64265. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64267. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64268. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64269. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64270. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64271. /** @hidden */
  64272. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64273. private _useDeltaForWorldStep;
  64274. world: any;
  64275. name: string;
  64276. private _physicsMaterials;
  64277. private _fixedTimeStep;
  64278. private _cannonRaycastResult;
  64279. private _raycastResult;
  64280. private _physicsBodysToRemoveAfterStep;
  64281. private _firstFrame;
  64282. BJSCANNON: any;
  64283. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64284. setGravity(gravity: Vector3): void;
  64285. setTimeStep(timeStep: number): void;
  64286. getTimeStep(): number;
  64287. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64288. private _removeMarkedPhysicsBodiesFromWorld;
  64289. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64290. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64291. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64292. private _processChildMeshes;
  64293. removePhysicsBody(impostor: PhysicsImpostor): void;
  64294. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64295. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64296. private _addMaterial;
  64297. private _checkWithEpsilon;
  64298. private _createShape;
  64299. private _createHeightmap;
  64300. private _minus90X;
  64301. private _plus90X;
  64302. private _tmpPosition;
  64303. private _tmpDeltaPosition;
  64304. private _tmpUnityRotation;
  64305. private _updatePhysicsBodyTransformation;
  64306. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64307. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64308. isSupported(): boolean;
  64309. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64310. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64311. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64312. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64313. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64314. getBodyMass(impostor: PhysicsImpostor): number;
  64315. getBodyFriction(impostor: PhysicsImpostor): number;
  64316. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64317. getBodyRestitution(impostor: PhysicsImpostor): number;
  64318. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64319. sleepBody(impostor: PhysicsImpostor): void;
  64320. wakeUpBody(impostor: PhysicsImpostor): void;
  64321. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64322. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64323. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64324. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64325. getRadius(impostor: PhysicsImpostor): number;
  64326. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64327. dispose(): void;
  64328. private _extendNamespace;
  64329. /**
  64330. * Does a raycast in the physics world
  64331. * @param from when should the ray start?
  64332. * @param to when should the ray end?
  64333. * @returns PhysicsRaycastResult
  64334. */
  64335. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64336. }
  64337. }
  64338. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64339. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64340. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64341. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64343. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64344. import { Nullable } from "babylonjs/types";
  64345. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64346. /** @hidden */
  64347. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64348. private _useDeltaForWorldStep;
  64349. world: any;
  64350. name: string;
  64351. BJSOIMO: any;
  64352. private _raycastResult;
  64353. private _fixedTimeStep;
  64354. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64355. setGravity(gravity: Vector3): void;
  64356. setTimeStep(timeStep: number): void;
  64357. getTimeStep(): number;
  64358. private _tmpImpostorsArray;
  64359. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64360. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64361. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64362. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64363. private _tmpPositionVector;
  64364. removePhysicsBody(impostor: PhysicsImpostor): void;
  64365. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64366. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64367. isSupported(): boolean;
  64368. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64369. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64370. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64371. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64372. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64373. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64374. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64375. getBodyMass(impostor: PhysicsImpostor): number;
  64376. getBodyFriction(impostor: PhysicsImpostor): number;
  64377. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64378. getBodyRestitution(impostor: PhysicsImpostor): number;
  64379. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64380. sleepBody(impostor: PhysicsImpostor): void;
  64381. wakeUpBody(impostor: PhysicsImpostor): void;
  64382. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64383. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64384. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64385. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64386. getRadius(impostor: PhysicsImpostor): number;
  64387. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64388. dispose(): void;
  64389. /**
  64390. * Does a raycast in the physics world
  64391. * @param from when should the ray start?
  64392. * @param to when should the ray end?
  64393. * @returns PhysicsRaycastResult
  64394. */
  64395. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64396. }
  64397. }
  64398. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64399. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64400. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64401. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64402. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64403. import { Nullable } from "babylonjs/types";
  64404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64405. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64406. /**
  64407. * AmmoJS Physics plugin
  64408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64409. * @see https://github.com/kripken/ammo.js/
  64410. */
  64411. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64412. private _useDeltaForWorldStep;
  64413. /**
  64414. * Reference to the Ammo library
  64415. */
  64416. bjsAMMO: any;
  64417. /**
  64418. * Created ammoJS world which physics bodies are added to
  64419. */
  64420. world: any;
  64421. /**
  64422. * Name of the plugin
  64423. */
  64424. name: string;
  64425. private _timeStep;
  64426. private _fixedTimeStep;
  64427. private _maxSteps;
  64428. private _tmpQuaternion;
  64429. private _tmpAmmoTransform;
  64430. private _tmpAmmoQuaternion;
  64431. private _tmpAmmoConcreteContactResultCallback;
  64432. private _collisionConfiguration;
  64433. private _dispatcher;
  64434. private _overlappingPairCache;
  64435. private _solver;
  64436. private _softBodySolver;
  64437. private _tmpAmmoVectorA;
  64438. private _tmpAmmoVectorB;
  64439. private _tmpAmmoVectorC;
  64440. private _tmpAmmoVectorD;
  64441. private _tmpContactCallbackResult;
  64442. private _tmpAmmoVectorRCA;
  64443. private _tmpAmmoVectorRCB;
  64444. private _raycastResult;
  64445. private _tmpContactPoint;
  64446. private static readonly DISABLE_COLLISION_FLAG;
  64447. private static readonly KINEMATIC_FLAG;
  64448. private static readonly DISABLE_DEACTIVATION_FLAG;
  64449. /**
  64450. * Initializes the ammoJS plugin
  64451. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64452. * @param ammoInjection can be used to inject your own ammo reference
  64453. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64454. */
  64455. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64456. /**
  64457. * Sets the gravity of the physics world (m/(s^2))
  64458. * @param gravity Gravity to set
  64459. */
  64460. setGravity(gravity: Vector3): void;
  64461. /**
  64462. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64463. * @param timeStep timestep to use in seconds
  64464. */
  64465. setTimeStep(timeStep: number): void;
  64466. /**
  64467. * 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)
  64468. * @param fixedTimeStep fixedTimeStep to use in seconds
  64469. */
  64470. setFixedTimeStep(fixedTimeStep: number): void;
  64471. /**
  64472. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64473. * @param maxSteps the maximum number of steps by the physics engine per frame
  64474. */
  64475. setMaxSteps(maxSteps: number): void;
  64476. /**
  64477. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64478. * @returns the current timestep in seconds
  64479. */
  64480. getTimeStep(): number;
  64481. /**
  64482. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64483. */
  64484. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64485. private _isImpostorInContact;
  64486. private _isImpostorPairInContact;
  64487. private _stepSimulation;
  64488. /**
  64489. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64490. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64491. * After the step the babylon meshes are set to the position of the physics imposters
  64492. * @param delta amount of time to step forward
  64493. * @param impostors array of imposters to update before/after the step
  64494. */
  64495. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64496. /**
  64497. * Update babylon mesh to match physics world object
  64498. * @param impostor imposter to match
  64499. */
  64500. private _afterSoftStep;
  64501. /**
  64502. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64503. * @param impostor imposter to match
  64504. */
  64505. private _ropeStep;
  64506. /**
  64507. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64508. * @param impostor imposter to match
  64509. */
  64510. private _softbodyOrClothStep;
  64511. private _tmpMatrix;
  64512. /**
  64513. * Applies an impulse on the imposter
  64514. * @param impostor imposter to apply impulse to
  64515. * @param force amount of force to be applied to the imposter
  64516. * @param contactPoint the location to apply the impulse on the imposter
  64517. */
  64518. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64519. /**
  64520. * Applies a force on the imposter
  64521. * @param impostor imposter to apply force
  64522. * @param force amount of force to be applied to the imposter
  64523. * @param contactPoint the location to apply the force on the imposter
  64524. */
  64525. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64526. /**
  64527. * Creates a physics body using the plugin
  64528. * @param impostor the imposter to create the physics body on
  64529. */
  64530. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64531. /**
  64532. * Removes the physics body from the imposter and disposes of the body's memory
  64533. * @param impostor imposter to remove the physics body from
  64534. */
  64535. removePhysicsBody(impostor: PhysicsImpostor): void;
  64536. /**
  64537. * Generates a joint
  64538. * @param impostorJoint the imposter joint to create the joint with
  64539. */
  64540. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64541. /**
  64542. * Removes a joint
  64543. * @param impostorJoint the imposter joint to remove the joint from
  64544. */
  64545. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64546. private _addMeshVerts;
  64547. /**
  64548. * Initialise the soft body vertices to match its object's (mesh) vertices
  64549. * Softbody vertices (nodes) are in world space and to match this
  64550. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64551. * @param impostor to create the softbody for
  64552. */
  64553. private _softVertexData;
  64554. /**
  64555. * Create an impostor's soft body
  64556. * @param impostor to create the softbody for
  64557. */
  64558. private _createSoftbody;
  64559. /**
  64560. * Create cloth for an impostor
  64561. * @param impostor to create the softbody for
  64562. */
  64563. private _createCloth;
  64564. /**
  64565. * Create rope for an impostor
  64566. * @param impostor to create the softbody for
  64567. */
  64568. private _createRope;
  64569. /**
  64570. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64571. * @param impostor to create the custom physics shape for
  64572. */
  64573. private _createCustom;
  64574. private _addHullVerts;
  64575. private _createShape;
  64576. /**
  64577. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64578. * @param impostor imposter containing the physics body and babylon object
  64579. */
  64580. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64581. /**
  64582. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64583. * @param impostor imposter containing the physics body and babylon object
  64584. * @param newPosition new position
  64585. * @param newRotation new rotation
  64586. */
  64587. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64588. /**
  64589. * If this plugin is supported
  64590. * @returns true if its supported
  64591. */
  64592. isSupported(): boolean;
  64593. /**
  64594. * Sets the linear velocity of the physics body
  64595. * @param impostor imposter to set the velocity on
  64596. * @param velocity velocity to set
  64597. */
  64598. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64599. /**
  64600. * Sets the angular velocity of the physics body
  64601. * @param impostor imposter to set the velocity on
  64602. * @param velocity velocity to set
  64603. */
  64604. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64605. /**
  64606. * gets the linear velocity
  64607. * @param impostor imposter to get linear velocity from
  64608. * @returns linear velocity
  64609. */
  64610. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64611. /**
  64612. * gets the angular velocity
  64613. * @param impostor imposter to get angular velocity from
  64614. * @returns angular velocity
  64615. */
  64616. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64617. /**
  64618. * Sets the mass of physics body
  64619. * @param impostor imposter to set the mass on
  64620. * @param mass mass to set
  64621. */
  64622. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64623. /**
  64624. * Gets the mass of the physics body
  64625. * @param impostor imposter to get the mass from
  64626. * @returns mass
  64627. */
  64628. getBodyMass(impostor: PhysicsImpostor): number;
  64629. /**
  64630. * Gets friction of the impostor
  64631. * @param impostor impostor to get friction from
  64632. * @returns friction value
  64633. */
  64634. getBodyFriction(impostor: PhysicsImpostor): number;
  64635. /**
  64636. * Sets friction of the impostor
  64637. * @param impostor impostor to set friction on
  64638. * @param friction friction value
  64639. */
  64640. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64641. /**
  64642. * Gets restitution of the impostor
  64643. * @param impostor impostor to get restitution from
  64644. * @returns restitution value
  64645. */
  64646. getBodyRestitution(impostor: PhysicsImpostor): number;
  64647. /**
  64648. * Sets resitution of the impostor
  64649. * @param impostor impostor to set resitution on
  64650. * @param restitution resitution value
  64651. */
  64652. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64653. /**
  64654. * Gets pressure inside the impostor
  64655. * @param impostor impostor to get pressure from
  64656. * @returns pressure value
  64657. */
  64658. getBodyPressure(impostor: PhysicsImpostor): number;
  64659. /**
  64660. * Sets pressure inside a soft body impostor
  64661. * Cloth and rope must remain 0 pressure
  64662. * @param impostor impostor to set pressure on
  64663. * @param pressure pressure value
  64664. */
  64665. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64666. /**
  64667. * Gets stiffness of the impostor
  64668. * @param impostor impostor to get stiffness from
  64669. * @returns pressure value
  64670. */
  64671. getBodyStiffness(impostor: PhysicsImpostor): number;
  64672. /**
  64673. * Sets stiffness of the impostor
  64674. * @param impostor impostor to set stiffness on
  64675. * @param stiffness stiffness value from 0 to 1
  64676. */
  64677. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64678. /**
  64679. * Gets velocityIterations of the impostor
  64680. * @param impostor impostor to get velocity iterations from
  64681. * @returns velocityIterations value
  64682. */
  64683. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64684. /**
  64685. * Sets velocityIterations of the impostor
  64686. * @param impostor impostor to set velocity iterations on
  64687. * @param velocityIterations velocityIterations value
  64688. */
  64689. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64690. /**
  64691. * Gets positionIterations of the impostor
  64692. * @param impostor impostor to get position iterations from
  64693. * @returns positionIterations value
  64694. */
  64695. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64696. /**
  64697. * Sets positionIterations of the impostor
  64698. * @param impostor impostor to set position on
  64699. * @param positionIterations positionIterations value
  64700. */
  64701. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64702. /**
  64703. * Append an anchor to a cloth object
  64704. * @param impostor is the cloth impostor to add anchor to
  64705. * @param otherImpostor is the rigid impostor to anchor to
  64706. * @param width ratio across width from 0 to 1
  64707. * @param height ratio up height from 0 to 1
  64708. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64709. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64710. */
  64711. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64712. /**
  64713. * Append an hook to a rope object
  64714. * @param impostor is the rope impostor to add hook to
  64715. * @param otherImpostor is the rigid impostor to hook to
  64716. * @param length ratio along the rope from 0 to 1
  64717. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64718. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64719. */
  64720. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64721. /**
  64722. * Sleeps the physics body and stops it from being active
  64723. * @param impostor impostor to sleep
  64724. */
  64725. sleepBody(impostor: PhysicsImpostor): void;
  64726. /**
  64727. * Activates the physics body
  64728. * @param impostor impostor to activate
  64729. */
  64730. wakeUpBody(impostor: PhysicsImpostor): void;
  64731. /**
  64732. * Updates the distance parameters of the joint
  64733. * @param joint joint to update
  64734. * @param maxDistance maximum distance of the joint
  64735. * @param minDistance minimum distance of the joint
  64736. */
  64737. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64738. /**
  64739. * Sets a motor on the joint
  64740. * @param joint joint to set motor on
  64741. * @param speed speed of the motor
  64742. * @param maxForce maximum force of the motor
  64743. * @param motorIndex index of the motor
  64744. */
  64745. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64746. /**
  64747. * Sets the motors limit
  64748. * @param joint joint to set limit on
  64749. * @param upperLimit upper limit
  64750. * @param lowerLimit lower limit
  64751. */
  64752. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64753. /**
  64754. * Syncs the position and rotation of a mesh with the impostor
  64755. * @param mesh mesh to sync
  64756. * @param impostor impostor to update the mesh with
  64757. */
  64758. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64759. /**
  64760. * Gets the radius of the impostor
  64761. * @param impostor impostor to get radius from
  64762. * @returns the radius
  64763. */
  64764. getRadius(impostor: PhysicsImpostor): number;
  64765. /**
  64766. * Gets the box size of the impostor
  64767. * @param impostor impostor to get box size from
  64768. * @param result the resulting box size
  64769. */
  64770. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64771. /**
  64772. * Disposes of the impostor
  64773. */
  64774. dispose(): void;
  64775. /**
  64776. * Does a raycast in the physics world
  64777. * @param from when should the ray start?
  64778. * @param to when should the ray end?
  64779. * @returns PhysicsRaycastResult
  64780. */
  64781. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64782. }
  64783. }
  64784. declare module "babylonjs/Probes/reflectionProbe" {
  64785. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64786. import { Vector3 } from "babylonjs/Maths/math.vector";
  64787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64788. import { Nullable } from "babylonjs/types";
  64789. import { Scene } from "babylonjs/scene";
  64790. module "babylonjs/abstractScene" {
  64791. interface AbstractScene {
  64792. /**
  64793. * The list of reflection probes added to the scene
  64794. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64795. */
  64796. reflectionProbes: Array<ReflectionProbe>;
  64797. /**
  64798. * Removes the given reflection probe from this scene.
  64799. * @param toRemove The reflection probe to remove
  64800. * @returns The index of the removed reflection probe
  64801. */
  64802. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64803. /**
  64804. * Adds the given reflection probe to this scene.
  64805. * @param newReflectionProbe The reflection probe to add
  64806. */
  64807. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64808. }
  64809. }
  64810. /**
  64811. * Class used to generate realtime reflection / refraction cube textures
  64812. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64813. */
  64814. export class ReflectionProbe {
  64815. /** defines the name of the probe */
  64816. name: string;
  64817. private _scene;
  64818. private _renderTargetTexture;
  64819. private _projectionMatrix;
  64820. private _viewMatrix;
  64821. private _target;
  64822. private _add;
  64823. private _attachedMesh;
  64824. private _invertYAxis;
  64825. /** Gets or sets probe position (center of the cube map) */
  64826. position: Vector3;
  64827. /**
  64828. * Creates a new reflection probe
  64829. * @param name defines the name of the probe
  64830. * @param size defines the texture resolution (for each face)
  64831. * @param scene defines the hosting scene
  64832. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64833. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64834. */
  64835. constructor(
  64836. /** defines the name of the probe */
  64837. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64838. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64839. get samples(): number;
  64840. set samples(value: number);
  64841. /** Gets or sets the refresh rate to use (on every frame by default) */
  64842. get refreshRate(): number;
  64843. set refreshRate(value: number);
  64844. /**
  64845. * Gets the hosting scene
  64846. * @returns a Scene
  64847. */
  64848. getScene(): Scene;
  64849. /** Gets the internal CubeTexture used to render to */
  64850. get cubeTexture(): RenderTargetTexture;
  64851. /** Gets the list of meshes to render */
  64852. get renderList(): Nullable<AbstractMesh[]>;
  64853. /**
  64854. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64855. * @param mesh defines the mesh to attach to
  64856. */
  64857. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64858. /**
  64859. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64860. * @param renderingGroupId The rendering group id corresponding to its index
  64861. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64862. */
  64863. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64864. /**
  64865. * Clean all associated resources
  64866. */
  64867. dispose(): void;
  64868. /**
  64869. * Converts the reflection probe information to a readable string for debug purpose.
  64870. * @param fullDetails Supports for multiple levels of logging within scene loading
  64871. * @returns the human readable reflection probe info
  64872. */
  64873. toString(fullDetails?: boolean): string;
  64874. /**
  64875. * Get the class name of the relfection probe.
  64876. * @returns "ReflectionProbe"
  64877. */
  64878. getClassName(): string;
  64879. /**
  64880. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64881. * @returns The JSON representation of the texture
  64882. */
  64883. serialize(): any;
  64884. /**
  64885. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64886. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64887. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64888. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64889. * @returns The parsed reflection probe if successful
  64890. */
  64891. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64892. }
  64893. }
  64894. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64895. /** @hidden */
  64896. export var _BabylonLoaderRegistered: boolean;
  64897. /**
  64898. * Helps setting up some configuration for the babylon file loader.
  64899. */
  64900. export class BabylonFileLoaderConfiguration {
  64901. /**
  64902. * The loader does not allow injecting custom physix engine into the plugins.
  64903. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64904. * So you could set this variable to your engine import to make it work.
  64905. */
  64906. static LoaderInjectedPhysicsEngine: any;
  64907. }
  64908. }
  64909. declare module "babylonjs/Loading/Plugins/index" {
  64910. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64911. }
  64912. declare module "babylonjs/Loading/index" {
  64913. export * from "babylonjs/Loading/loadingScreen";
  64914. export * from "babylonjs/Loading/Plugins/index";
  64915. export * from "babylonjs/Loading/sceneLoader";
  64916. export * from "babylonjs/Loading/sceneLoaderFlags";
  64917. }
  64918. declare module "babylonjs/Materials/Background/index" {
  64919. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64920. }
  64921. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64922. import { Scene } from "babylonjs/scene";
  64923. import { Color3 } from "babylonjs/Maths/math.color";
  64924. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64925. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64926. /**
  64927. * The Physically based simple base material of BJS.
  64928. *
  64929. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64930. * It is used as the base class for both the specGloss and metalRough conventions.
  64931. */
  64932. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64933. /**
  64934. * Number of Simultaneous lights allowed on the material.
  64935. */
  64936. maxSimultaneousLights: number;
  64937. /**
  64938. * If sets to true, disables all the lights affecting the material.
  64939. */
  64940. disableLighting: boolean;
  64941. /**
  64942. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64943. */
  64944. environmentTexture: BaseTexture;
  64945. /**
  64946. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64947. */
  64948. invertNormalMapX: boolean;
  64949. /**
  64950. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64951. */
  64952. invertNormalMapY: boolean;
  64953. /**
  64954. * Normal map used in the model.
  64955. */
  64956. normalTexture: BaseTexture;
  64957. /**
  64958. * Emissivie color used to self-illuminate the model.
  64959. */
  64960. emissiveColor: Color3;
  64961. /**
  64962. * Emissivie texture used to self-illuminate the model.
  64963. */
  64964. emissiveTexture: BaseTexture;
  64965. /**
  64966. * Occlusion Channel Strenght.
  64967. */
  64968. occlusionStrength: number;
  64969. /**
  64970. * Occlusion Texture of the material (adding extra occlusion effects).
  64971. */
  64972. occlusionTexture: BaseTexture;
  64973. /**
  64974. * Defines the alpha limits in alpha test mode.
  64975. */
  64976. alphaCutOff: number;
  64977. /**
  64978. * Gets the current double sided mode.
  64979. */
  64980. get doubleSided(): boolean;
  64981. /**
  64982. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64983. */
  64984. set doubleSided(value: boolean);
  64985. /**
  64986. * Stores the pre-calculated light information of a mesh in a texture.
  64987. */
  64988. lightmapTexture: BaseTexture;
  64989. /**
  64990. * If true, the light map contains occlusion information instead of lighting info.
  64991. */
  64992. useLightmapAsShadowmap: boolean;
  64993. /**
  64994. * Instantiates a new PBRMaterial instance.
  64995. *
  64996. * @param name The material name
  64997. * @param scene The scene the material will be use in.
  64998. */
  64999. constructor(name: string, scene: Scene);
  65000. getClassName(): string;
  65001. }
  65002. }
  65003. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65004. import { Scene } from "babylonjs/scene";
  65005. import { Color3 } from "babylonjs/Maths/math.color";
  65006. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65007. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65008. /**
  65009. * The PBR material of BJS following the metal roughness convention.
  65010. *
  65011. * This fits to the PBR convention in the GLTF definition:
  65012. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65013. */
  65014. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65015. /**
  65016. * The base color has two different interpretations depending on the value of metalness.
  65017. * When the material is a metal, the base color is the specific measured reflectance value
  65018. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65019. * of the material.
  65020. */
  65021. baseColor: Color3;
  65022. /**
  65023. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65024. * well as opacity information in the alpha channel.
  65025. */
  65026. baseTexture: BaseTexture;
  65027. /**
  65028. * Specifies the metallic scalar value of the material.
  65029. * Can also be used to scale the metalness values of the metallic texture.
  65030. */
  65031. metallic: number;
  65032. /**
  65033. * Specifies the roughness scalar value of the material.
  65034. * Can also be used to scale the roughness values of the metallic texture.
  65035. */
  65036. roughness: number;
  65037. /**
  65038. * Texture containing both the metallic value in the B channel and the
  65039. * roughness value in the G channel to keep better precision.
  65040. */
  65041. metallicRoughnessTexture: BaseTexture;
  65042. /**
  65043. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65044. *
  65045. * @param name The material name
  65046. * @param scene The scene the material will be use in.
  65047. */
  65048. constructor(name: string, scene: Scene);
  65049. /**
  65050. * Return the currrent class name of the material.
  65051. */
  65052. getClassName(): string;
  65053. /**
  65054. * Makes a duplicate of the current material.
  65055. * @param name - name to use for the new material.
  65056. */
  65057. clone(name: string): PBRMetallicRoughnessMaterial;
  65058. /**
  65059. * Serialize the material to a parsable JSON object.
  65060. */
  65061. serialize(): any;
  65062. /**
  65063. * Parses a JSON object correponding to the serialize function.
  65064. */
  65065. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65066. }
  65067. }
  65068. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65069. import { Scene } from "babylonjs/scene";
  65070. import { Color3 } from "babylonjs/Maths/math.color";
  65071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65072. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65073. /**
  65074. * The PBR material of BJS following the specular glossiness convention.
  65075. *
  65076. * This fits to the PBR convention in the GLTF definition:
  65077. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65078. */
  65079. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65080. /**
  65081. * Specifies the diffuse color of the material.
  65082. */
  65083. diffuseColor: Color3;
  65084. /**
  65085. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65086. * channel.
  65087. */
  65088. diffuseTexture: BaseTexture;
  65089. /**
  65090. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65091. */
  65092. specularColor: Color3;
  65093. /**
  65094. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65095. */
  65096. glossiness: number;
  65097. /**
  65098. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65099. */
  65100. specularGlossinessTexture: BaseTexture;
  65101. /**
  65102. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65103. *
  65104. * @param name The material name
  65105. * @param scene The scene the material will be use in.
  65106. */
  65107. constructor(name: string, scene: Scene);
  65108. /**
  65109. * Return the currrent class name of the material.
  65110. */
  65111. getClassName(): string;
  65112. /**
  65113. * Makes a duplicate of the current material.
  65114. * @param name - name to use for the new material.
  65115. */
  65116. clone(name: string): PBRSpecularGlossinessMaterial;
  65117. /**
  65118. * Serialize the material to a parsable JSON object.
  65119. */
  65120. serialize(): any;
  65121. /**
  65122. * Parses a JSON object correponding to the serialize function.
  65123. */
  65124. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65125. }
  65126. }
  65127. declare module "babylonjs/Materials/PBR/index" {
  65128. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65129. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65130. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65131. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65132. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65133. }
  65134. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65135. import { Nullable } from "babylonjs/types";
  65136. import { Scene } from "babylonjs/scene";
  65137. import { Matrix } from "babylonjs/Maths/math.vector";
  65138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65139. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65140. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65141. /**
  65142. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65143. * It can help converting any input color in a desired output one. This can then be used to create effects
  65144. * from sepia, black and white to sixties or futuristic rendering...
  65145. *
  65146. * The only supported format is currently 3dl.
  65147. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65148. */
  65149. export class ColorGradingTexture extends BaseTexture {
  65150. /**
  65151. * The texture URL.
  65152. */
  65153. url: string;
  65154. /**
  65155. * Empty line regex stored for GC.
  65156. */
  65157. private static _noneEmptyLineRegex;
  65158. private _textureMatrix;
  65159. private _onLoad;
  65160. /**
  65161. * Instantiates a ColorGradingTexture from the following parameters.
  65162. *
  65163. * @param url The location of the color gradind data (currently only supporting 3dl)
  65164. * @param sceneOrEngine The scene or engine the texture will be used in
  65165. * @param onLoad defines a callback triggered when the texture has been loaded
  65166. */
  65167. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65168. /**
  65169. * Fires the onload event from the constructor if requested.
  65170. */
  65171. private _triggerOnLoad;
  65172. /**
  65173. * Returns the texture matrix used in most of the material.
  65174. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65175. */
  65176. getTextureMatrix(): Matrix;
  65177. /**
  65178. * Occurs when the file being loaded is a .3dl LUT file.
  65179. */
  65180. private load3dlTexture;
  65181. /**
  65182. * Starts the loading process of the texture.
  65183. */
  65184. private loadTexture;
  65185. /**
  65186. * Clones the color gradind texture.
  65187. */
  65188. clone(): ColorGradingTexture;
  65189. /**
  65190. * Called during delayed load for textures.
  65191. */
  65192. delayLoad(): void;
  65193. /**
  65194. * Parses a color grading texture serialized by Babylon.
  65195. * @param parsedTexture The texture information being parsedTexture
  65196. * @param scene The scene to load the texture in
  65197. * @param rootUrl The root url of the data assets to load
  65198. * @return A color gradind texture
  65199. */
  65200. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65201. /**
  65202. * Serializes the LUT texture to json format.
  65203. */
  65204. serialize(): any;
  65205. }
  65206. }
  65207. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65209. import { Scene } from "babylonjs/scene";
  65210. import { Nullable } from "babylonjs/types";
  65211. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65212. /**
  65213. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65214. */
  65215. export class EquiRectangularCubeTexture extends BaseTexture {
  65216. /** The six faces of the cube. */
  65217. private static _FacesMapping;
  65218. private _noMipmap;
  65219. private _onLoad;
  65220. private _onError;
  65221. /** The size of the cubemap. */
  65222. private _size;
  65223. /** The buffer of the image. */
  65224. private _buffer;
  65225. /** The width of the input image. */
  65226. private _width;
  65227. /** The height of the input image. */
  65228. private _height;
  65229. /** The URL to the image. */
  65230. url: string;
  65231. /**
  65232. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65233. * @param url The location of the image
  65234. * @param scene The scene the texture will be used in
  65235. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65236. * @param noMipmap Forces to not generate the mipmap if true
  65237. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65238. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65239. * @param onLoad — defines a callback called when texture is loaded
  65240. * @param onError — defines a callback called if there is an error
  65241. */
  65242. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65243. /**
  65244. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65245. */
  65246. private loadImage;
  65247. /**
  65248. * Convert the image buffer into a cubemap and create a CubeTexture.
  65249. */
  65250. private loadTexture;
  65251. /**
  65252. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65253. * @param buffer The ArrayBuffer that should be converted.
  65254. * @returns The buffer as Float32Array.
  65255. */
  65256. private getFloat32ArrayFromArrayBuffer;
  65257. /**
  65258. * Get the current class name of the texture useful for serialization or dynamic coding.
  65259. * @returns "EquiRectangularCubeTexture"
  65260. */
  65261. getClassName(): string;
  65262. /**
  65263. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65264. * @returns A clone of the current EquiRectangularCubeTexture.
  65265. */
  65266. clone(): EquiRectangularCubeTexture;
  65267. }
  65268. }
  65269. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65270. import { Nullable } from "babylonjs/types";
  65271. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65272. import { Matrix } from "babylonjs/Maths/math.vector";
  65273. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65274. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65275. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65276. import { Scene } from "babylonjs/scene";
  65277. /**
  65278. * Defines the options related to the creation of an HtmlElementTexture
  65279. */
  65280. export interface IHtmlElementTextureOptions {
  65281. /**
  65282. * Defines wether mip maps should be created or not.
  65283. */
  65284. generateMipMaps?: boolean;
  65285. /**
  65286. * Defines the sampling mode of the texture.
  65287. */
  65288. samplingMode?: number;
  65289. /**
  65290. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65291. */
  65292. engine: Nullable<ThinEngine>;
  65293. /**
  65294. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65295. */
  65296. scene: Nullable<Scene>;
  65297. }
  65298. /**
  65299. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65300. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65301. * is automatically managed.
  65302. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65303. * in your application.
  65304. *
  65305. * As the update is not automatic, you need to call them manually.
  65306. */
  65307. export class HtmlElementTexture extends BaseTexture {
  65308. /**
  65309. * The texture URL.
  65310. */
  65311. element: HTMLVideoElement | HTMLCanvasElement;
  65312. private static readonly DefaultOptions;
  65313. private _textureMatrix;
  65314. private _isVideo;
  65315. private _generateMipMaps;
  65316. private _samplingMode;
  65317. /**
  65318. * Instantiates a HtmlElementTexture from the following parameters.
  65319. *
  65320. * @param name Defines the name of the texture
  65321. * @param element Defines the video or canvas the texture is filled with
  65322. * @param options Defines the other none mandatory texture creation options
  65323. */
  65324. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65325. private _createInternalTexture;
  65326. /**
  65327. * Returns the texture matrix used in most of the material.
  65328. */
  65329. getTextureMatrix(): Matrix;
  65330. /**
  65331. * Updates the content of the texture.
  65332. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65333. */
  65334. update(invertY?: Nullable<boolean>): void;
  65335. }
  65336. }
  65337. declare module "babylonjs/Misc/tga" {
  65338. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65339. /**
  65340. * Based on jsTGALoader - Javascript loader for TGA file
  65341. * By Vincent Thibault
  65342. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65343. */
  65344. export class TGATools {
  65345. private static _TYPE_INDEXED;
  65346. private static _TYPE_RGB;
  65347. private static _TYPE_GREY;
  65348. private static _TYPE_RLE_INDEXED;
  65349. private static _TYPE_RLE_RGB;
  65350. private static _TYPE_RLE_GREY;
  65351. private static _ORIGIN_MASK;
  65352. private static _ORIGIN_SHIFT;
  65353. private static _ORIGIN_BL;
  65354. private static _ORIGIN_BR;
  65355. private static _ORIGIN_UL;
  65356. private static _ORIGIN_UR;
  65357. /**
  65358. * Gets the header of a TGA file
  65359. * @param data defines the TGA data
  65360. * @returns the header
  65361. */
  65362. static GetTGAHeader(data: Uint8Array): any;
  65363. /**
  65364. * Uploads TGA content to a Babylon Texture
  65365. * @hidden
  65366. */
  65367. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65368. /** @hidden */
  65369. 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;
  65370. /** @hidden */
  65371. 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;
  65372. /** @hidden */
  65373. 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;
  65374. /** @hidden */
  65375. 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;
  65376. /** @hidden */
  65377. 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;
  65378. /** @hidden */
  65379. 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;
  65380. }
  65381. }
  65382. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65383. import { Nullable } from "babylonjs/types";
  65384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65385. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65386. /**
  65387. * Implementation of the TGA Texture Loader.
  65388. * @hidden
  65389. */
  65390. export class _TGATextureLoader implements IInternalTextureLoader {
  65391. /**
  65392. * Defines wether the loader supports cascade loading the different faces.
  65393. */
  65394. readonly supportCascades: boolean;
  65395. /**
  65396. * This returns if the loader support the current file information.
  65397. * @param extension defines the file extension of the file being loaded
  65398. * @returns true if the loader can load the specified file
  65399. */
  65400. canLoad(extension: string): boolean;
  65401. /**
  65402. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65403. * @param data contains the texture data
  65404. * @param texture defines the BabylonJS internal texture
  65405. * @param createPolynomials will be true if polynomials have been requested
  65406. * @param onLoad defines the callback to trigger once the texture is ready
  65407. * @param onError defines the callback to trigger in case of error
  65408. */
  65409. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65410. /**
  65411. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65412. * @param data contains the texture data
  65413. * @param texture defines the BabylonJS internal texture
  65414. * @param callback defines the method to call once ready to upload
  65415. */
  65416. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65417. }
  65418. }
  65419. declare module "babylonjs/Misc/basis" {
  65420. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65421. /**
  65422. * Info about the .basis files
  65423. */
  65424. class BasisFileInfo {
  65425. /**
  65426. * If the file has alpha
  65427. */
  65428. hasAlpha: boolean;
  65429. /**
  65430. * Info about each image of the basis file
  65431. */
  65432. images: Array<{
  65433. levels: Array<{
  65434. width: number;
  65435. height: number;
  65436. transcodedPixels: ArrayBufferView;
  65437. }>;
  65438. }>;
  65439. }
  65440. /**
  65441. * Result of transcoding a basis file
  65442. */
  65443. class TranscodeResult {
  65444. /**
  65445. * Info about the .basis file
  65446. */
  65447. fileInfo: BasisFileInfo;
  65448. /**
  65449. * Format to use when loading the file
  65450. */
  65451. format: number;
  65452. }
  65453. /**
  65454. * Configuration options for the Basis transcoder
  65455. */
  65456. export class BasisTranscodeConfiguration {
  65457. /**
  65458. * Supported compression formats used to determine the supported output format of the transcoder
  65459. */
  65460. supportedCompressionFormats?: {
  65461. /**
  65462. * etc1 compression format
  65463. */
  65464. etc1?: boolean;
  65465. /**
  65466. * s3tc compression format
  65467. */
  65468. s3tc?: boolean;
  65469. /**
  65470. * pvrtc compression format
  65471. */
  65472. pvrtc?: boolean;
  65473. /**
  65474. * etc2 compression format
  65475. */
  65476. etc2?: boolean;
  65477. };
  65478. /**
  65479. * If mipmap levels should be loaded for transcoded images (Default: true)
  65480. */
  65481. loadMipmapLevels?: boolean;
  65482. /**
  65483. * Index of a single image to load (Default: all images)
  65484. */
  65485. loadSingleImage?: number;
  65486. }
  65487. /**
  65488. * Used to load .Basis files
  65489. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65490. */
  65491. export class BasisTools {
  65492. private static _IgnoreSupportedFormats;
  65493. /**
  65494. * URL to use when loading the basis transcoder
  65495. */
  65496. static JSModuleURL: string;
  65497. /**
  65498. * URL to use when loading the wasm module for the transcoder
  65499. */
  65500. static WasmModuleURL: string;
  65501. /**
  65502. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65503. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65504. * @returns internal format corresponding to the Basis format
  65505. */
  65506. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65507. private static _WorkerPromise;
  65508. private static _Worker;
  65509. private static _actionId;
  65510. private static _CreateWorkerAsync;
  65511. /**
  65512. * Transcodes a loaded image file to compressed pixel data
  65513. * @param data image data to transcode
  65514. * @param config configuration options for the transcoding
  65515. * @returns a promise resulting in the transcoded image
  65516. */
  65517. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65518. /**
  65519. * Loads a texture from the transcode result
  65520. * @param texture texture load to
  65521. * @param transcodeResult the result of transcoding the basis file to load from
  65522. */
  65523. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65524. }
  65525. }
  65526. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65527. import { Nullable } from "babylonjs/types";
  65528. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65529. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65530. /**
  65531. * Loader for .basis file format
  65532. */
  65533. export class _BasisTextureLoader implements IInternalTextureLoader {
  65534. /**
  65535. * Defines whether the loader supports cascade loading the different faces.
  65536. */
  65537. readonly supportCascades: boolean;
  65538. /**
  65539. * This returns if the loader support the current file information.
  65540. * @param extension defines the file extension of the file being loaded
  65541. * @returns true if the loader can load the specified file
  65542. */
  65543. canLoad(extension: string): boolean;
  65544. /**
  65545. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65546. * @param data contains the texture data
  65547. * @param texture defines the BabylonJS internal texture
  65548. * @param createPolynomials will be true if polynomials have been requested
  65549. * @param onLoad defines the callback to trigger once the texture is ready
  65550. * @param onError defines the callback to trigger in case of error
  65551. */
  65552. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65553. /**
  65554. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65555. * @param data contains the texture data
  65556. * @param texture defines the BabylonJS internal texture
  65557. * @param callback defines the method to call once ready to upload
  65558. */
  65559. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65560. }
  65561. }
  65562. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65563. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65564. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65565. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65566. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65567. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65568. }
  65569. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65570. import { Vector2 } from "babylonjs/Maths/math.vector";
  65571. /**
  65572. * Defines the basic options interface of a TexturePacker Frame
  65573. */
  65574. export interface ITexturePackerFrame {
  65575. /**
  65576. * The frame ID
  65577. */
  65578. id: number;
  65579. /**
  65580. * The frames Scale
  65581. */
  65582. scale: Vector2;
  65583. /**
  65584. * The Frames offset
  65585. */
  65586. offset: Vector2;
  65587. }
  65588. /**
  65589. * This is a support class for frame Data on texture packer sets.
  65590. */
  65591. export class TexturePackerFrame implements ITexturePackerFrame {
  65592. /**
  65593. * The frame ID
  65594. */
  65595. id: number;
  65596. /**
  65597. * The frames Scale
  65598. */
  65599. scale: Vector2;
  65600. /**
  65601. * The Frames offset
  65602. */
  65603. offset: Vector2;
  65604. /**
  65605. * Initializes a texture package frame.
  65606. * @param id The numerical frame identifier
  65607. * @param scale Scalar Vector2 for UV frame
  65608. * @param offset Vector2 for the frame position in UV units.
  65609. * @returns TexturePackerFrame
  65610. */
  65611. constructor(id: number, scale: Vector2, offset: Vector2);
  65612. }
  65613. }
  65614. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65616. import { Scene } from "babylonjs/scene";
  65617. import { Nullable } from "babylonjs/types";
  65618. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65619. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65620. /**
  65621. * Defines the basic options interface of a TexturePacker
  65622. */
  65623. export interface ITexturePackerOptions {
  65624. /**
  65625. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65626. */
  65627. map?: string[];
  65628. /**
  65629. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65630. */
  65631. uvsIn?: string;
  65632. /**
  65633. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65634. */
  65635. uvsOut?: string;
  65636. /**
  65637. * number representing the layout style. Defaults to LAYOUT_STRIP
  65638. */
  65639. layout?: number;
  65640. /**
  65641. * number of columns if using custom column count layout(2). This defaults to 4.
  65642. */
  65643. colnum?: number;
  65644. /**
  65645. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65646. */
  65647. updateInputMeshes?: boolean;
  65648. /**
  65649. * boolean flag to dispose all the source textures. Defaults to true.
  65650. */
  65651. disposeSources?: boolean;
  65652. /**
  65653. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65654. */
  65655. fillBlanks?: boolean;
  65656. /**
  65657. * string value representing the context fill style color. Defaults to 'black'.
  65658. */
  65659. customFillColor?: string;
  65660. /**
  65661. * Width and Height Value of each Frame in the TexturePacker Sets
  65662. */
  65663. frameSize?: number;
  65664. /**
  65665. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65666. */
  65667. paddingRatio?: number;
  65668. /**
  65669. * Number that declares the fill method for the padding gutter.
  65670. */
  65671. paddingMode?: number;
  65672. /**
  65673. * If in SUBUV_COLOR padding mode what color to use.
  65674. */
  65675. paddingColor?: Color3 | Color4;
  65676. }
  65677. /**
  65678. * Defines the basic interface of a TexturePacker JSON File
  65679. */
  65680. export interface ITexturePackerJSON {
  65681. /**
  65682. * The frame ID
  65683. */
  65684. name: string;
  65685. /**
  65686. * The base64 channel data
  65687. */
  65688. sets: any;
  65689. /**
  65690. * The options of the Packer
  65691. */
  65692. options: ITexturePackerOptions;
  65693. /**
  65694. * The frame data of the Packer
  65695. */
  65696. frames: Array<number>;
  65697. }
  65698. /**
  65699. * This is a support class that generates a series of packed texture sets.
  65700. * @see https://doc.babylonjs.com/babylon101/materials
  65701. */
  65702. export class TexturePacker {
  65703. /** Packer Layout Constant 0 */
  65704. static readonly LAYOUT_STRIP: number;
  65705. /** Packer Layout Constant 1 */
  65706. static readonly LAYOUT_POWER2: number;
  65707. /** Packer Layout Constant 2 */
  65708. static readonly LAYOUT_COLNUM: number;
  65709. /** Packer Layout Constant 0 */
  65710. static readonly SUBUV_WRAP: number;
  65711. /** Packer Layout Constant 1 */
  65712. static readonly SUBUV_EXTEND: number;
  65713. /** Packer Layout Constant 2 */
  65714. static readonly SUBUV_COLOR: number;
  65715. /** The Name of the Texture Package */
  65716. name: string;
  65717. /** The scene scope of the TexturePacker */
  65718. scene: Scene;
  65719. /** The Meshes to target */
  65720. meshes: AbstractMesh[];
  65721. /** Arguments passed with the Constructor */
  65722. options: ITexturePackerOptions;
  65723. /** The promise that is started upon initialization */
  65724. promise: Nullable<Promise<TexturePacker | string>>;
  65725. /** The Container object for the channel sets that are generated */
  65726. sets: object;
  65727. /** The Container array for the frames that are generated */
  65728. frames: TexturePackerFrame[];
  65729. /** The expected number of textures the system is parsing. */
  65730. private _expecting;
  65731. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65732. private _paddingValue;
  65733. /**
  65734. * Initializes a texture package series from an array of meshes or a single mesh.
  65735. * @param name The name of the package
  65736. * @param meshes The target meshes to compose the package from
  65737. * @param options The arguments that texture packer should follow while building.
  65738. * @param scene The scene which the textures are scoped to.
  65739. * @returns TexturePacker
  65740. */
  65741. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65742. /**
  65743. * Starts the package process
  65744. * @param resolve The promises resolution function
  65745. * @returns TexturePacker
  65746. */
  65747. private _createFrames;
  65748. /**
  65749. * Calculates the Size of the Channel Sets
  65750. * @returns Vector2
  65751. */
  65752. private _calculateSize;
  65753. /**
  65754. * Calculates the UV data for the frames.
  65755. * @param baseSize the base frameSize
  65756. * @param padding the base frame padding
  65757. * @param dtSize size of the Dynamic Texture for that channel
  65758. * @param dtUnits is 1/dtSize
  65759. * @param update flag to update the input meshes
  65760. */
  65761. private _calculateMeshUVFrames;
  65762. /**
  65763. * Calculates the frames Offset.
  65764. * @param index of the frame
  65765. * @returns Vector2
  65766. */
  65767. private _getFrameOffset;
  65768. /**
  65769. * Updates a Mesh to the frame data
  65770. * @param mesh that is the target
  65771. * @param frameID or the frame index
  65772. */
  65773. private _updateMeshUV;
  65774. /**
  65775. * Updates a Meshes materials to use the texture packer channels
  65776. * @param m is the mesh to target
  65777. * @param force all channels on the packer to be set.
  65778. */
  65779. private _updateTextureReferences;
  65780. /**
  65781. * Public method to set a Mesh to a frame
  65782. * @param m that is the target
  65783. * @param frameID or the frame index
  65784. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65785. */
  65786. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65787. /**
  65788. * Starts the async promise to compile the texture packer.
  65789. * @returns Promise<void>
  65790. */
  65791. processAsync(): Promise<void>;
  65792. /**
  65793. * Disposes all textures associated with this packer
  65794. */
  65795. dispose(): void;
  65796. /**
  65797. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65798. * @param imageType is the image type to use.
  65799. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65800. */
  65801. download(imageType?: string, quality?: number): void;
  65802. /**
  65803. * Public method to load a texturePacker JSON file.
  65804. * @param data of the JSON file in string format.
  65805. */
  65806. updateFromJSON(data: string): void;
  65807. }
  65808. }
  65809. declare module "babylonjs/Materials/Textures/Packer/index" {
  65810. export * from "babylonjs/Materials/Textures/Packer/packer";
  65811. export * from "babylonjs/Materials/Textures/Packer/frame";
  65812. }
  65813. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65814. import { Scene } from "babylonjs/scene";
  65815. import { Texture } from "babylonjs/Materials/Textures/texture";
  65816. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65817. /**
  65818. * 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.
  65819. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65820. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65821. */
  65822. export class CustomProceduralTexture extends ProceduralTexture {
  65823. private _animate;
  65824. private _time;
  65825. private _config;
  65826. private _texturePath;
  65827. /**
  65828. * Instantiates a new Custom Procedural Texture.
  65829. * 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.
  65830. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65831. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65832. * @param name Define the name of the texture
  65833. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65834. * @param size Define the size of the texture to create
  65835. * @param scene Define the scene the texture belongs to
  65836. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65837. * @param generateMipMaps Define if the texture should creates mip maps or not
  65838. */
  65839. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65840. private _loadJson;
  65841. /**
  65842. * Is the texture ready to be used ? (rendered at least once)
  65843. * @returns true if ready, otherwise, false.
  65844. */
  65845. isReady(): boolean;
  65846. /**
  65847. * Render the texture to its associated render target.
  65848. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65849. */
  65850. render(useCameraPostProcess?: boolean): void;
  65851. /**
  65852. * Update the list of dependant textures samplers in the shader.
  65853. */
  65854. updateTextures(): void;
  65855. /**
  65856. * Update the uniform values of the procedural texture in the shader.
  65857. */
  65858. updateShaderUniforms(): void;
  65859. /**
  65860. * Define if the texture animates or not.
  65861. */
  65862. get animate(): boolean;
  65863. set animate(value: boolean);
  65864. }
  65865. }
  65866. declare module "babylonjs/Shaders/noise.fragment" {
  65867. /** @hidden */
  65868. export var noisePixelShader: {
  65869. name: string;
  65870. shader: string;
  65871. };
  65872. }
  65873. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65874. import { Nullable } from "babylonjs/types";
  65875. import { Scene } from "babylonjs/scene";
  65876. import { Texture } from "babylonjs/Materials/Textures/texture";
  65877. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65878. import "babylonjs/Shaders/noise.fragment";
  65879. /**
  65880. * Class used to generate noise procedural textures
  65881. */
  65882. export class NoiseProceduralTexture extends ProceduralTexture {
  65883. /** Gets or sets the start time (default is 0) */
  65884. time: number;
  65885. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65886. brightness: number;
  65887. /** Defines the number of octaves to process */
  65888. octaves: number;
  65889. /** Defines the level of persistence (0.8 by default) */
  65890. persistence: number;
  65891. /** Gets or sets animation speed factor (default is 1) */
  65892. animationSpeedFactor: number;
  65893. /**
  65894. * Creates a new NoiseProceduralTexture
  65895. * @param name defines the name fo the texture
  65896. * @param size defines the size of the texture (default is 256)
  65897. * @param scene defines the hosting scene
  65898. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65899. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65900. */
  65901. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65902. private _updateShaderUniforms;
  65903. protected _getDefines(): string;
  65904. /** Generate the current state of the procedural texture */
  65905. render(useCameraPostProcess?: boolean): void;
  65906. /**
  65907. * Serializes this noise procedural texture
  65908. * @returns a serialized noise procedural texture object
  65909. */
  65910. serialize(): any;
  65911. /**
  65912. * Clone the texture.
  65913. * @returns the cloned texture
  65914. */
  65915. clone(): NoiseProceduralTexture;
  65916. /**
  65917. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65918. * @param parsedTexture defines parsed texture data
  65919. * @param scene defines the current scene
  65920. * @param rootUrl defines the root URL containing noise procedural texture information
  65921. * @returns a parsed NoiseProceduralTexture
  65922. */
  65923. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65924. }
  65925. }
  65926. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65927. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65928. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65929. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65930. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65931. }
  65932. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65933. import { Nullable } from "babylonjs/types";
  65934. import { Scene } from "babylonjs/scene";
  65935. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65936. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65937. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65938. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65939. /**
  65940. * Raw cube texture where the raw buffers are passed in
  65941. */
  65942. export class RawCubeTexture extends CubeTexture {
  65943. /**
  65944. * Creates a cube texture where the raw buffers are passed in.
  65945. * @param scene defines the scene the texture is attached to
  65946. * @param data defines the array of data to use to create each face
  65947. * @param size defines the size of the textures
  65948. * @param format defines the format of the data
  65949. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65950. * @param generateMipMaps defines if the engine should generate the mip levels
  65951. * @param invertY defines if data must be stored with Y axis inverted
  65952. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65953. * @param compression defines the compression used (null by default)
  65954. */
  65955. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65956. /**
  65957. * Updates the raw cube texture.
  65958. * @param data defines the data to store
  65959. * @param format defines the data format
  65960. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65961. * @param invertY defines if data must be stored with Y axis inverted
  65962. * @param compression defines the compression used (null by default)
  65963. * @param level defines which level of the texture to update
  65964. */
  65965. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65966. /**
  65967. * Updates a raw cube texture with RGBD encoded data.
  65968. * @param data defines the array of data [mipmap][face] to use to create each face
  65969. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65970. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65971. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65972. * @returns a promsie that resolves when the operation is complete
  65973. */
  65974. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65975. /**
  65976. * Clones the raw cube texture.
  65977. * @return a new cube texture
  65978. */
  65979. clone(): CubeTexture;
  65980. /** @hidden */
  65981. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65982. }
  65983. }
  65984. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65985. import { Scene } from "babylonjs/scene";
  65986. import { Texture } from "babylonjs/Materials/Textures/texture";
  65987. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65988. /**
  65989. * Class used to store 2D array textures containing user data
  65990. */
  65991. export class RawTexture2DArray extends Texture {
  65992. /** Gets or sets the texture format to use */
  65993. format: number;
  65994. /**
  65995. * Create a new RawTexture2DArray
  65996. * @param data defines the data of the texture
  65997. * @param width defines the width of the texture
  65998. * @param height defines the height of the texture
  65999. * @param depth defines the number of layers of the texture
  66000. * @param format defines the texture format to use
  66001. * @param scene defines the hosting scene
  66002. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66003. * @param invertY defines if texture must be stored with Y axis inverted
  66004. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66005. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66006. */
  66007. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66008. /** Gets or sets the texture format to use */
  66009. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66010. /**
  66011. * Update the texture with new data
  66012. * @param data defines the data to store in the texture
  66013. */
  66014. update(data: ArrayBufferView): void;
  66015. }
  66016. }
  66017. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66018. import { Scene } from "babylonjs/scene";
  66019. import { Texture } from "babylonjs/Materials/Textures/texture";
  66020. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66021. /**
  66022. * Class used to store 3D textures containing user data
  66023. */
  66024. export class RawTexture3D extends Texture {
  66025. /** Gets or sets the texture format to use */
  66026. format: number;
  66027. /**
  66028. * Create a new RawTexture3D
  66029. * @param data defines the data of the texture
  66030. * @param width defines the width of the texture
  66031. * @param height defines the height of the texture
  66032. * @param depth defines the depth of the texture
  66033. * @param format defines the texture format to use
  66034. * @param scene defines the hosting scene
  66035. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66036. * @param invertY defines if texture must be stored with Y axis inverted
  66037. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66038. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66039. */
  66040. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66041. /** Gets or sets the texture format to use */
  66042. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66043. /**
  66044. * Update the texture with new data
  66045. * @param data defines the data to store in the texture
  66046. */
  66047. update(data: ArrayBufferView): void;
  66048. }
  66049. }
  66050. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66051. import { Scene } from "babylonjs/scene";
  66052. import { Plane } from "babylonjs/Maths/math.plane";
  66053. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66054. /**
  66055. * Creates a refraction texture used by refraction channel of the standard material.
  66056. * It is like a mirror but to see through a material.
  66057. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66058. */
  66059. export class RefractionTexture extends RenderTargetTexture {
  66060. /**
  66061. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66062. * 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.
  66063. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66064. */
  66065. refractionPlane: Plane;
  66066. /**
  66067. * Define how deep under the surface we should see.
  66068. */
  66069. depth: number;
  66070. /**
  66071. * Creates a refraction texture used by refraction channel of the standard material.
  66072. * It is like a mirror but to see through a material.
  66073. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66074. * @param name Define the texture name
  66075. * @param size Define the size of the underlying texture
  66076. * @param scene Define the scene the refraction belongs to
  66077. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66078. */
  66079. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66080. /**
  66081. * Clone the refraction texture.
  66082. * @returns the cloned texture
  66083. */
  66084. clone(): RefractionTexture;
  66085. /**
  66086. * Serialize the texture to a JSON representation you could use in Parse later on
  66087. * @returns the serialized JSON representation
  66088. */
  66089. serialize(): any;
  66090. }
  66091. }
  66092. declare module "babylonjs/Materials/Textures/index" {
  66093. export * from "babylonjs/Materials/Textures/baseTexture";
  66094. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66095. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66096. export * from "babylonjs/Materials/Textures/cubeTexture";
  66097. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66098. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66099. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66100. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66101. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66102. export * from "babylonjs/Materials/Textures/internalTexture";
  66103. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66104. export * from "babylonjs/Materials/Textures/Loaders/index";
  66105. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66106. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66107. export * from "babylonjs/Materials/Textures/Packer/index";
  66108. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66109. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66110. export * from "babylonjs/Materials/Textures/rawTexture";
  66111. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66112. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66113. export * from "babylonjs/Materials/Textures/refractionTexture";
  66114. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66115. export * from "babylonjs/Materials/Textures/texture";
  66116. export * from "babylonjs/Materials/Textures/videoTexture";
  66117. }
  66118. declare module "babylonjs/Materials/Node/Enums/index" {
  66119. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66120. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66121. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66122. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66123. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66124. }
  66125. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66126. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66127. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66129. import { Mesh } from "babylonjs/Meshes/mesh";
  66130. import { Effect } from "babylonjs/Materials/effect";
  66131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66132. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66133. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66134. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66135. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66136. /**
  66137. * Block used to add support for vertex skinning (bones)
  66138. */
  66139. export class BonesBlock extends NodeMaterialBlock {
  66140. /**
  66141. * Creates a new BonesBlock
  66142. * @param name defines the block name
  66143. */
  66144. constructor(name: string);
  66145. /**
  66146. * Initialize the block and prepare the context for build
  66147. * @param state defines the state that will be used for the build
  66148. */
  66149. initialize(state: NodeMaterialBuildState): void;
  66150. /**
  66151. * Gets the current class name
  66152. * @returns the class name
  66153. */
  66154. getClassName(): string;
  66155. /**
  66156. * Gets the matrix indices input component
  66157. */
  66158. get matricesIndices(): NodeMaterialConnectionPoint;
  66159. /**
  66160. * Gets the matrix weights input component
  66161. */
  66162. get matricesWeights(): NodeMaterialConnectionPoint;
  66163. /**
  66164. * Gets the extra matrix indices input component
  66165. */
  66166. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66167. /**
  66168. * Gets the extra matrix weights input component
  66169. */
  66170. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66171. /**
  66172. * Gets the world input component
  66173. */
  66174. get world(): NodeMaterialConnectionPoint;
  66175. /**
  66176. * Gets the output component
  66177. */
  66178. get output(): NodeMaterialConnectionPoint;
  66179. autoConfigure(material: NodeMaterial): void;
  66180. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66181. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66182. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66183. protected _buildBlock(state: NodeMaterialBuildState): this;
  66184. }
  66185. }
  66186. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66187. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66191. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66192. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66193. /**
  66194. * Block used to add support for instances
  66195. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66196. */
  66197. export class InstancesBlock extends NodeMaterialBlock {
  66198. /**
  66199. * Creates a new InstancesBlock
  66200. * @param name defines the block name
  66201. */
  66202. constructor(name: string);
  66203. /**
  66204. * Gets the current class name
  66205. * @returns the class name
  66206. */
  66207. getClassName(): string;
  66208. /**
  66209. * Gets the first world row input component
  66210. */
  66211. get world0(): NodeMaterialConnectionPoint;
  66212. /**
  66213. * Gets the second world row input component
  66214. */
  66215. get world1(): NodeMaterialConnectionPoint;
  66216. /**
  66217. * Gets the third world row input component
  66218. */
  66219. get world2(): NodeMaterialConnectionPoint;
  66220. /**
  66221. * Gets the forth world row input component
  66222. */
  66223. get world3(): NodeMaterialConnectionPoint;
  66224. /**
  66225. * Gets the world input component
  66226. */
  66227. get world(): NodeMaterialConnectionPoint;
  66228. /**
  66229. * Gets the output component
  66230. */
  66231. get output(): NodeMaterialConnectionPoint;
  66232. /**
  66233. * Gets the isntanceID component
  66234. */
  66235. get instanceID(): NodeMaterialConnectionPoint;
  66236. autoConfigure(material: NodeMaterial): void;
  66237. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66238. protected _buildBlock(state: NodeMaterialBuildState): this;
  66239. }
  66240. }
  66241. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66246. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66247. import { Effect } from "babylonjs/Materials/effect";
  66248. import { Mesh } from "babylonjs/Meshes/mesh";
  66249. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66250. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66251. /**
  66252. * Block used to add morph targets support to vertex shader
  66253. */
  66254. export class MorphTargetsBlock extends NodeMaterialBlock {
  66255. private _repeatableContentAnchor;
  66256. /**
  66257. * Create a new MorphTargetsBlock
  66258. * @param name defines the block name
  66259. */
  66260. constructor(name: string);
  66261. /**
  66262. * Gets the current class name
  66263. * @returns the class name
  66264. */
  66265. getClassName(): string;
  66266. /**
  66267. * Gets the position input component
  66268. */
  66269. get position(): NodeMaterialConnectionPoint;
  66270. /**
  66271. * Gets the normal input component
  66272. */
  66273. get normal(): NodeMaterialConnectionPoint;
  66274. /**
  66275. * Gets the tangent input component
  66276. */
  66277. get tangent(): NodeMaterialConnectionPoint;
  66278. /**
  66279. * Gets the tangent input component
  66280. */
  66281. get uv(): NodeMaterialConnectionPoint;
  66282. /**
  66283. * Gets the position output component
  66284. */
  66285. get positionOutput(): NodeMaterialConnectionPoint;
  66286. /**
  66287. * Gets the normal output component
  66288. */
  66289. get normalOutput(): NodeMaterialConnectionPoint;
  66290. /**
  66291. * Gets the tangent output component
  66292. */
  66293. get tangentOutput(): NodeMaterialConnectionPoint;
  66294. /**
  66295. * Gets the tangent output component
  66296. */
  66297. get uvOutput(): NodeMaterialConnectionPoint;
  66298. initialize(state: NodeMaterialBuildState): void;
  66299. autoConfigure(material: NodeMaterial): void;
  66300. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66301. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66302. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66303. protected _buildBlock(state: NodeMaterialBuildState): this;
  66304. }
  66305. }
  66306. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  66307. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66308. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66309. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66310. import { Nullable } from "babylonjs/types";
  66311. import { Scene } from "babylonjs/scene";
  66312. import { Effect } from "babylonjs/Materials/effect";
  66313. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66314. import { Mesh } from "babylonjs/Meshes/mesh";
  66315. import { Light } from "babylonjs/Lights/light";
  66316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66317. /**
  66318. * Block used to get data information from a light
  66319. */
  66320. export class LightInformationBlock extends NodeMaterialBlock {
  66321. private _lightDataUniformName;
  66322. private _lightColorUniformName;
  66323. private _lightTypeDefineName;
  66324. /**
  66325. * Gets or sets the light associated with this block
  66326. */
  66327. light: Nullable<Light>;
  66328. /**
  66329. * Creates a new LightInformationBlock
  66330. * @param name defines the block name
  66331. */
  66332. constructor(name: string);
  66333. /**
  66334. * Gets the current class name
  66335. * @returns the class name
  66336. */
  66337. getClassName(): string;
  66338. /**
  66339. * Gets the world position input component
  66340. */
  66341. get worldPosition(): NodeMaterialConnectionPoint;
  66342. /**
  66343. * Gets the direction output component
  66344. */
  66345. get direction(): NodeMaterialConnectionPoint;
  66346. /**
  66347. * Gets the direction output component
  66348. */
  66349. get color(): NodeMaterialConnectionPoint;
  66350. /**
  66351. * Gets the direction output component
  66352. */
  66353. get intensity(): NodeMaterialConnectionPoint;
  66354. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66355. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66356. protected _buildBlock(state: NodeMaterialBuildState): this;
  66357. serialize(): any;
  66358. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66359. }
  66360. }
  66361. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66362. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66363. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66364. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66365. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66366. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66367. }
  66368. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  66369. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66370. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66371. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66373. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66374. import { Effect } from "babylonjs/Materials/effect";
  66375. import { Mesh } from "babylonjs/Meshes/mesh";
  66376. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66377. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66378. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66379. /**
  66380. * Block used to add image processing support to fragment shader
  66381. */
  66382. export class ImageProcessingBlock extends NodeMaterialBlock {
  66383. /**
  66384. * Create a new ImageProcessingBlock
  66385. * @param name defines the block name
  66386. */
  66387. constructor(name: string);
  66388. /**
  66389. * Gets the current class name
  66390. * @returns the class name
  66391. */
  66392. getClassName(): string;
  66393. /**
  66394. * Gets the color input component
  66395. */
  66396. get color(): NodeMaterialConnectionPoint;
  66397. /**
  66398. * Gets the output component
  66399. */
  66400. get output(): NodeMaterialConnectionPoint;
  66401. /**
  66402. * Initialize the block and prepare the context for build
  66403. * @param state defines the state that will be used for the build
  66404. */
  66405. initialize(state: NodeMaterialBuildState): void;
  66406. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66407. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66408. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66409. protected _buildBlock(state: NodeMaterialBuildState): this;
  66410. }
  66411. }
  66412. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66416. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66418. import { Effect } from "babylonjs/Materials/effect";
  66419. import { Mesh } from "babylonjs/Meshes/mesh";
  66420. import { Scene } from "babylonjs/scene";
  66421. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66422. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66423. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66424. /**
  66425. * Block used to pertub normals based on a normal map
  66426. */
  66427. export class PerturbNormalBlock extends NodeMaterialBlock {
  66428. private _tangentSpaceParameterName;
  66429. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66430. invertX: boolean;
  66431. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66432. invertY: boolean;
  66433. /**
  66434. * Create a new PerturbNormalBlock
  66435. * @param name defines the block name
  66436. */
  66437. constructor(name: string);
  66438. /**
  66439. * Gets the current class name
  66440. * @returns the class name
  66441. */
  66442. getClassName(): string;
  66443. /**
  66444. * Gets the world position input component
  66445. */
  66446. get worldPosition(): NodeMaterialConnectionPoint;
  66447. /**
  66448. * Gets the world normal input component
  66449. */
  66450. get worldNormal(): NodeMaterialConnectionPoint;
  66451. /**
  66452. * Gets the world tangent input component
  66453. */
  66454. get worldTangent(): NodeMaterialConnectionPoint;
  66455. /**
  66456. * Gets the uv input component
  66457. */
  66458. get uv(): NodeMaterialConnectionPoint;
  66459. /**
  66460. * Gets the normal map color input component
  66461. */
  66462. get normalMapColor(): NodeMaterialConnectionPoint;
  66463. /**
  66464. * Gets the strength input component
  66465. */
  66466. get strength(): NodeMaterialConnectionPoint;
  66467. /**
  66468. * Gets the output component
  66469. */
  66470. get output(): NodeMaterialConnectionPoint;
  66471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66472. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66473. autoConfigure(material: NodeMaterial): void;
  66474. protected _buildBlock(state: NodeMaterialBuildState): this;
  66475. protected _dumpPropertiesCode(): string;
  66476. serialize(): any;
  66477. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66478. }
  66479. }
  66480. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66483. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66484. /**
  66485. * Block used to discard a pixel if a value is smaller than a cutoff
  66486. */
  66487. export class DiscardBlock extends NodeMaterialBlock {
  66488. /**
  66489. * Create a new DiscardBlock
  66490. * @param name defines the block name
  66491. */
  66492. constructor(name: string);
  66493. /**
  66494. * Gets the current class name
  66495. * @returns the class name
  66496. */
  66497. getClassName(): string;
  66498. /**
  66499. * Gets the color input component
  66500. */
  66501. get value(): NodeMaterialConnectionPoint;
  66502. /**
  66503. * Gets the cutoff input component
  66504. */
  66505. get cutoff(): NodeMaterialConnectionPoint;
  66506. protected _buildBlock(state: NodeMaterialBuildState): this;
  66507. }
  66508. }
  66509. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66511. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66513. /**
  66514. * Block used to test if the fragment shader is front facing
  66515. */
  66516. export class FrontFacingBlock extends NodeMaterialBlock {
  66517. /**
  66518. * Creates a new FrontFacingBlock
  66519. * @param name defines the block name
  66520. */
  66521. constructor(name: string);
  66522. /**
  66523. * Gets the current class name
  66524. * @returns the class name
  66525. */
  66526. getClassName(): string;
  66527. /**
  66528. * Gets the output component
  66529. */
  66530. get output(): NodeMaterialConnectionPoint;
  66531. protected _buildBlock(state: NodeMaterialBuildState): this;
  66532. }
  66533. }
  66534. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66535. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66536. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66537. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66538. /**
  66539. * Block used to get the derivative value on x and y of a given input
  66540. */
  66541. export class DerivativeBlock extends NodeMaterialBlock {
  66542. /**
  66543. * Create a new DerivativeBlock
  66544. * @param name defines the block name
  66545. */
  66546. constructor(name: string);
  66547. /**
  66548. * Gets the current class name
  66549. * @returns the class name
  66550. */
  66551. getClassName(): string;
  66552. /**
  66553. * Gets the input component
  66554. */
  66555. get input(): NodeMaterialConnectionPoint;
  66556. /**
  66557. * Gets the derivative output on x
  66558. */
  66559. get dx(): NodeMaterialConnectionPoint;
  66560. /**
  66561. * Gets the derivative output on y
  66562. */
  66563. get dy(): NodeMaterialConnectionPoint;
  66564. protected _buildBlock(state: NodeMaterialBuildState): this;
  66565. }
  66566. }
  66567. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66569. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66570. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66571. /**
  66572. * Block used to make gl_FragCoord available
  66573. */
  66574. export class FragCoordBlock extends NodeMaterialBlock {
  66575. /**
  66576. * Creates a new FragCoordBlock
  66577. * @param name defines the block name
  66578. */
  66579. constructor(name: string);
  66580. /**
  66581. * Gets the current class name
  66582. * @returns the class name
  66583. */
  66584. getClassName(): string;
  66585. /**
  66586. * Gets the xy component
  66587. */
  66588. get xy(): NodeMaterialConnectionPoint;
  66589. /**
  66590. * Gets the xyz component
  66591. */
  66592. get xyz(): NodeMaterialConnectionPoint;
  66593. /**
  66594. * Gets the xyzw component
  66595. */
  66596. get xyzw(): NodeMaterialConnectionPoint;
  66597. /**
  66598. * Gets the x component
  66599. */
  66600. get x(): NodeMaterialConnectionPoint;
  66601. /**
  66602. * Gets the y component
  66603. */
  66604. get y(): NodeMaterialConnectionPoint;
  66605. /**
  66606. * Gets the z component
  66607. */
  66608. get z(): NodeMaterialConnectionPoint;
  66609. /**
  66610. * Gets the w component
  66611. */
  66612. get output(): NodeMaterialConnectionPoint;
  66613. protected writeOutputs(state: NodeMaterialBuildState): string;
  66614. protected _buildBlock(state: NodeMaterialBuildState): this;
  66615. }
  66616. }
  66617. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66621. import { Effect } from "babylonjs/Materials/effect";
  66622. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66623. import { Mesh } from "babylonjs/Meshes/mesh";
  66624. /**
  66625. * Block used to get the screen sizes
  66626. */
  66627. export class ScreenSizeBlock extends NodeMaterialBlock {
  66628. private _varName;
  66629. private _scene;
  66630. /**
  66631. * Creates a new ScreenSizeBlock
  66632. * @param name defines the block name
  66633. */
  66634. constructor(name: string);
  66635. /**
  66636. * Gets the current class name
  66637. * @returns the class name
  66638. */
  66639. getClassName(): string;
  66640. /**
  66641. * Gets the xy component
  66642. */
  66643. get xy(): NodeMaterialConnectionPoint;
  66644. /**
  66645. * Gets the x component
  66646. */
  66647. get x(): NodeMaterialConnectionPoint;
  66648. /**
  66649. * Gets the y component
  66650. */
  66651. get y(): NodeMaterialConnectionPoint;
  66652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66653. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66654. protected _buildBlock(state: NodeMaterialBuildState): this;
  66655. }
  66656. }
  66657. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66658. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66659. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66660. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66661. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66662. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66663. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66664. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66665. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66666. }
  66667. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66669. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66670. import { Mesh } from "babylonjs/Meshes/mesh";
  66671. import { Effect } from "babylonjs/Materials/effect";
  66672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66674. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66675. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66676. /**
  66677. * Block used to add support for scene fog
  66678. */
  66679. export class FogBlock extends NodeMaterialBlock {
  66680. private _fogDistanceName;
  66681. private _fogParameters;
  66682. /**
  66683. * Create a new FogBlock
  66684. * @param name defines the block name
  66685. */
  66686. constructor(name: string);
  66687. /**
  66688. * Gets the current class name
  66689. * @returns the class name
  66690. */
  66691. getClassName(): string;
  66692. /**
  66693. * Gets the world position input component
  66694. */
  66695. get worldPosition(): NodeMaterialConnectionPoint;
  66696. /**
  66697. * Gets the view input component
  66698. */
  66699. get view(): NodeMaterialConnectionPoint;
  66700. /**
  66701. * Gets the color input component
  66702. */
  66703. get input(): NodeMaterialConnectionPoint;
  66704. /**
  66705. * Gets the fog color input component
  66706. */
  66707. get fogColor(): NodeMaterialConnectionPoint;
  66708. /**
  66709. * Gets the output component
  66710. */
  66711. get output(): NodeMaterialConnectionPoint;
  66712. autoConfigure(material: NodeMaterial): void;
  66713. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66714. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66715. protected _buildBlock(state: NodeMaterialBuildState): this;
  66716. }
  66717. }
  66718. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66719. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66720. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66721. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66723. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66724. import { Effect } from "babylonjs/Materials/effect";
  66725. import { Mesh } from "babylonjs/Meshes/mesh";
  66726. import { Light } from "babylonjs/Lights/light";
  66727. import { Nullable } from "babylonjs/types";
  66728. import { Scene } from "babylonjs/scene";
  66729. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66730. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66731. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66732. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66733. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66734. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66735. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66736. /**
  66737. * Block used to add light in the fragment shader
  66738. */
  66739. export class LightBlock extends NodeMaterialBlock {
  66740. private _lightId;
  66741. /**
  66742. * Gets or sets the light associated with this block
  66743. */
  66744. light: Nullable<Light>;
  66745. /**
  66746. * Create a new LightBlock
  66747. * @param name defines the block name
  66748. */
  66749. constructor(name: string);
  66750. /**
  66751. * Gets the current class name
  66752. * @returns the class name
  66753. */
  66754. getClassName(): string;
  66755. /**
  66756. * Gets the world position input component
  66757. */
  66758. get worldPosition(): NodeMaterialConnectionPoint;
  66759. /**
  66760. * Gets the world normal input component
  66761. */
  66762. get worldNormal(): NodeMaterialConnectionPoint;
  66763. /**
  66764. * Gets the camera (or eye) position component
  66765. */
  66766. get cameraPosition(): NodeMaterialConnectionPoint;
  66767. /**
  66768. * Gets the glossiness component
  66769. */
  66770. get glossiness(): NodeMaterialConnectionPoint;
  66771. /**
  66772. * Gets the glossinness power component
  66773. */
  66774. get glossPower(): NodeMaterialConnectionPoint;
  66775. /**
  66776. * Gets the diffuse color component
  66777. */
  66778. get diffuseColor(): NodeMaterialConnectionPoint;
  66779. /**
  66780. * Gets the specular color component
  66781. */
  66782. get specularColor(): NodeMaterialConnectionPoint;
  66783. /**
  66784. * Gets the diffuse output component
  66785. */
  66786. get diffuseOutput(): NodeMaterialConnectionPoint;
  66787. /**
  66788. * Gets the specular output component
  66789. */
  66790. get specularOutput(): NodeMaterialConnectionPoint;
  66791. /**
  66792. * Gets the shadow output component
  66793. */
  66794. get shadow(): NodeMaterialConnectionPoint;
  66795. autoConfigure(material: NodeMaterial): void;
  66796. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66797. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66799. private _injectVertexCode;
  66800. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66801. serialize(): any;
  66802. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66803. }
  66804. }
  66805. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66808. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66809. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66810. /**
  66811. * Block used to read a reflection texture from a sampler
  66812. */
  66813. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66814. /**
  66815. * Create a new ReflectionTextureBlock
  66816. * @param name defines the block name
  66817. */
  66818. constructor(name: string);
  66819. /**
  66820. * Gets the current class name
  66821. * @returns the class name
  66822. */
  66823. getClassName(): string;
  66824. /**
  66825. * Gets the world position input component
  66826. */
  66827. get position(): NodeMaterialConnectionPoint;
  66828. /**
  66829. * Gets the world position input component
  66830. */
  66831. get worldPosition(): NodeMaterialConnectionPoint;
  66832. /**
  66833. * Gets the world normal input component
  66834. */
  66835. get worldNormal(): NodeMaterialConnectionPoint;
  66836. /**
  66837. * Gets the world input component
  66838. */
  66839. get world(): NodeMaterialConnectionPoint;
  66840. /**
  66841. * Gets the camera (or eye) position component
  66842. */
  66843. get cameraPosition(): NodeMaterialConnectionPoint;
  66844. /**
  66845. * Gets the view input component
  66846. */
  66847. get view(): NodeMaterialConnectionPoint;
  66848. /**
  66849. * Gets the rgb output component
  66850. */
  66851. get rgb(): NodeMaterialConnectionPoint;
  66852. /**
  66853. * Gets the rgba output component
  66854. */
  66855. get rgba(): NodeMaterialConnectionPoint;
  66856. /**
  66857. * Gets the r output component
  66858. */
  66859. get r(): NodeMaterialConnectionPoint;
  66860. /**
  66861. * Gets the g output component
  66862. */
  66863. get g(): NodeMaterialConnectionPoint;
  66864. /**
  66865. * Gets the b output component
  66866. */
  66867. get b(): NodeMaterialConnectionPoint;
  66868. /**
  66869. * Gets the a output component
  66870. */
  66871. get a(): NodeMaterialConnectionPoint;
  66872. autoConfigure(material: NodeMaterial): void;
  66873. protected _buildBlock(state: NodeMaterialBuildState): this;
  66874. }
  66875. }
  66876. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66877. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66878. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66879. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66880. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66881. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66882. }
  66883. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66884. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66885. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66886. }
  66887. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66888. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66889. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66890. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66891. /**
  66892. * Block used to add 2 vectors
  66893. */
  66894. export class AddBlock extends NodeMaterialBlock {
  66895. /**
  66896. * Creates a new AddBlock
  66897. * @param name defines the block name
  66898. */
  66899. constructor(name: string);
  66900. /**
  66901. * Gets the current class name
  66902. * @returns the class name
  66903. */
  66904. getClassName(): string;
  66905. /**
  66906. * Gets the left operand input component
  66907. */
  66908. get left(): NodeMaterialConnectionPoint;
  66909. /**
  66910. * Gets the right operand input component
  66911. */
  66912. get right(): NodeMaterialConnectionPoint;
  66913. /**
  66914. * Gets the output component
  66915. */
  66916. get output(): NodeMaterialConnectionPoint;
  66917. protected _buildBlock(state: NodeMaterialBuildState): this;
  66918. }
  66919. }
  66920. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66924. /**
  66925. * Block used to scale a vector by a float
  66926. */
  66927. export class ScaleBlock extends NodeMaterialBlock {
  66928. /**
  66929. * Creates a new ScaleBlock
  66930. * @param name defines the block name
  66931. */
  66932. constructor(name: string);
  66933. /**
  66934. * Gets the current class name
  66935. * @returns the class name
  66936. */
  66937. getClassName(): string;
  66938. /**
  66939. * Gets the input component
  66940. */
  66941. get input(): NodeMaterialConnectionPoint;
  66942. /**
  66943. * Gets the factor input component
  66944. */
  66945. get factor(): NodeMaterialConnectionPoint;
  66946. /**
  66947. * Gets the output component
  66948. */
  66949. get output(): NodeMaterialConnectionPoint;
  66950. protected _buildBlock(state: NodeMaterialBuildState): this;
  66951. }
  66952. }
  66953. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66957. import { Scene } from "babylonjs/scene";
  66958. /**
  66959. * Block used to clamp a float
  66960. */
  66961. export class ClampBlock extends NodeMaterialBlock {
  66962. /** Gets or sets the minimum range */
  66963. minimum: number;
  66964. /** Gets or sets the maximum range */
  66965. maximum: number;
  66966. /**
  66967. * Creates a new ClampBlock
  66968. * @param name defines the block name
  66969. */
  66970. constructor(name: string);
  66971. /**
  66972. * Gets the current class name
  66973. * @returns the class name
  66974. */
  66975. getClassName(): string;
  66976. /**
  66977. * Gets the value input component
  66978. */
  66979. get value(): NodeMaterialConnectionPoint;
  66980. /**
  66981. * Gets the output component
  66982. */
  66983. get output(): NodeMaterialConnectionPoint;
  66984. protected _buildBlock(state: NodeMaterialBuildState): this;
  66985. protected _dumpPropertiesCode(): string;
  66986. serialize(): any;
  66987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66988. }
  66989. }
  66990. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66994. /**
  66995. * Block used to apply a cross product between 2 vectors
  66996. */
  66997. export class CrossBlock extends NodeMaterialBlock {
  66998. /**
  66999. * Creates a new CrossBlock
  67000. * @param name defines the block name
  67001. */
  67002. constructor(name: string);
  67003. /**
  67004. * Gets the current class name
  67005. * @returns the class name
  67006. */
  67007. getClassName(): string;
  67008. /**
  67009. * Gets the left operand input component
  67010. */
  67011. get left(): NodeMaterialConnectionPoint;
  67012. /**
  67013. * Gets the right operand input component
  67014. */
  67015. get right(): NodeMaterialConnectionPoint;
  67016. /**
  67017. * Gets the output component
  67018. */
  67019. get output(): NodeMaterialConnectionPoint;
  67020. protected _buildBlock(state: NodeMaterialBuildState): this;
  67021. }
  67022. }
  67023. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67027. /**
  67028. * Block used to apply a dot product between 2 vectors
  67029. */
  67030. export class DotBlock extends NodeMaterialBlock {
  67031. /**
  67032. * Creates a new DotBlock
  67033. * @param name defines the block name
  67034. */
  67035. constructor(name: string);
  67036. /**
  67037. * Gets the current class name
  67038. * @returns the class name
  67039. */
  67040. getClassName(): string;
  67041. /**
  67042. * Gets the left operand input component
  67043. */
  67044. get left(): NodeMaterialConnectionPoint;
  67045. /**
  67046. * Gets the right operand input component
  67047. */
  67048. get right(): NodeMaterialConnectionPoint;
  67049. /**
  67050. * Gets the output component
  67051. */
  67052. get output(): NodeMaterialConnectionPoint;
  67053. protected _buildBlock(state: NodeMaterialBuildState): this;
  67054. }
  67055. }
  67056. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67060. /**
  67061. * Block used to normalize a vector
  67062. */
  67063. export class NormalizeBlock extends NodeMaterialBlock {
  67064. /**
  67065. * Creates a new NormalizeBlock
  67066. * @param name defines the block name
  67067. */
  67068. constructor(name: string);
  67069. /**
  67070. * Gets the current class name
  67071. * @returns the class name
  67072. */
  67073. getClassName(): string;
  67074. /**
  67075. * Gets the input component
  67076. */
  67077. get input(): NodeMaterialConnectionPoint;
  67078. /**
  67079. * Gets the output component
  67080. */
  67081. get output(): NodeMaterialConnectionPoint;
  67082. protected _buildBlock(state: NodeMaterialBuildState): this;
  67083. }
  67084. }
  67085. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67089. /**
  67090. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67091. */
  67092. export class ColorMergerBlock extends NodeMaterialBlock {
  67093. /**
  67094. * Create a new ColorMergerBlock
  67095. * @param name defines the block name
  67096. */
  67097. constructor(name: string);
  67098. /**
  67099. * Gets the current class name
  67100. * @returns the class name
  67101. */
  67102. getClassName(): string;
  67103. /**
  67104. * Gets the rgb component (input)
  67105. */
  67106. get rgbIn(): NodeMaterialConnectionPoint;
  67107. /**
  67108. * Gets the r component (input)
  67109. */
  67110. get r(): NodeMaterialConnectionPoint;
  67111. /**
  67112. * Gets the g component (input)
  67113. */
  67114. get g(): NodeMaterialConnectionPoint;
  67115. /**
  67116. * Gets the b component (input)
  67117. */
  67118. get b(): NodeMaterialConnectionPoint;
  67119. /**
  67120. * Gets the a component (input)
  67121. */
  67122. get a(): NodeMaterialConnectionPoint;
  67123. /**
  67124. * Gets the rgba component (output)
  67125. */
  67126. get rgba(): NodeMaterialConnectionPoint;
  67127. /**
  67128. * Gets the rgb component (output)
  67129. */
  67130. get rgbOut(): NodeMaterialConnectionPoint;
  67131. /**
  67132. * Gets the rgb component (output)
  67133. * @deprecated Please use rgbOut instead.
  67134. */
  67135. get rgb(): NodeMaterialConnectionPoint;
  67136. protected _buildBlock(state: NodeMaterialBuildState): this;
  67137. }
  67138. }
  67139. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67140. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67141. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67142. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67143. /**
  67144. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67145. */
  67146. export class VectorSplitterBlock extends NodeMaterialBlock {
  67147. /**
  67148. * Create a new VectorSplitterBlock
  67149. * @param name defines the block name
  67150. */
  67151. constructor(name: string);
  67152. /**
  67153. * Gets the current class name
  67154. * @returns the class name
  67155. */
  67156. getClassName(): string;
  67157. /**
  67158. * Gets the xyzw component (input)
  67159. */
  67160. get xyzw(): NodeMaterialConnectionPoint;
  67161. /**
  67162. * Gets the xyz component (input)
  67163. */
  67164. get xyzIn(): NodeMaterialConnectionPoint;
  67165. /**
  67166. * Gets the xy component (input)
  67167. */
  67168. get xyIn(): NodeMaterialConnectionPoint;
  67169. /**
  67170. * Gets the xyz component (output)
  67171. */
  67172. get xyzOut(): NodeMaterialConnectionPoint;
  67173. /**
  67174. * Gets the xy component (output)
  67175. */
  67176. get xyOut(): NodeMaterialConnectionPoint;
  67177. /**
  67178. * Gets the x component (output)
  67179. */
  67180. get x(): NodeMaterialConnectionPoint;
  67181. /**
  67182. * Gets the y component (output)
  67183. */
  67184. get y(): NodeMaterialConnectionPoint;
  67185. /**
  67186. * Gets the z component (output)
  67187. */
  67188. get z(): NodeMaterialConnectionPoint;
  67189. /**
  67190. * Gets the w component (output)
  67191. */
  67192. get w(): NodeMaterialConnectionPoint;
  67193. protected _inputRename(name: string): string;
  67194. protected _outputRename(name: string): string;
  67195. protected _buildBlock(state: NodeMaterialBuildState): this;
  67196. }
  67197. }
  67198. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67199. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67200. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67201. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67202. /**
  67203. * Block used to lerp between 2 values
  67204. */
  67205. export class LerpBlock extends NodeMaterialBlock {
  67206. /**
  67207. * Creates a new LerpBlock
  67208. * @param name defines the block name
  67209. */
  67210. constructor(name: string);
  67211. /**
  67212. * Gets the current class name
  67213. * @returns the class name
  67214. */
  67215. getClassName(): string;
  67216. /**
  67217. * Gets the left operand input component
  67218. */
  67219. get left(): NodeMaterialConnectionPoint;
  67220. /**
  67221. * Gets the right operand input component
  67222. */
  67223. get right(): NodeMaterialConnectionPoint;
  67224. /**
  67225. * Gets the gradient operand input component
  67226. */
  67227. get gradient(): NodeMaterialConnectionPoint;
  67228. /**
  67229. * Gets the output component
  67230. */
  67231. get output(): NodeMaterialConnectionPoint;
  67232. protected _buildBlock(state: NodeMaterialBuildState): this;
  67233. }
  67234. }
  67235. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67239. /**
  67240. * Block used to divide 2 vectors
  67241. */
  67242. export class DivideBlock extends NodeMaterialBlock {
  67243. /**
  67244. * Creates a new DivideBlock
  67245. * @param name defines the block name
  67246. */
  67247. constructor(name: string);
  67248. /**
  67249. * Gets the current class name
  67250. * @returns the class name
  67251. */
  67252. getClassName(): string;
  67253. /**
  67254. * Gets the left operand input component
  67255. */
  67256. get left(): NodeMaterialConnectionPoint;
  67257. /**
  67258. * Gets the right operand input component
  67259. */
  67260. get right(): NodeMaterialConnectionPoint;
  67261. /**
  67262. * Gets the output component
  67263. */
  67264. get output(): NodeMaterialConnectionPoint;
  67265. protected _buildBlock(state: NodeMaterialBuildState): this;
  67266. }
  67267. }
  67268. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67270. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67271. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67272. /**
  67273. * Block used to subtract 2 vectors
  67274. */
  67275. export class SubtractBlock extends NodeMaterialBlock {
  67276. /**
  67277. * Creates a new SubtractBlock
  67278. * @param name defines the block name
  67279. */
  67280. constructor(name: string);
  67281. /**
  67282. * Gets the current class name
  67283. * @returns the class name
  67284. */
  67285. getClassName(): string;
  67286. /**
  67287. * Gets the left operand input component
  67288. */
  67289. get left(): NodeMaterialConnectionPoint;
  67290. /**
  67291. * Gets the right operand input component
  67292. */
  67293. get right(): NodeMaterialConnectionPoint;
  67294. /**
  67295. * Gets the output component
  67296. */
  67297. get output(): NodeMaterialConnectionPoint;
  67298. protected _buildBlock(state: NodeMaterialBuildState): this;
  67299. }
  67300. }
  67301. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  67302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67305. /**
  67306. * Block used to step a value
  67307. */
  67308. export class StepBlock extends NodeMaterialBlock {
  67309. /**
  67310. * Creates a new StepBlock
  67311. * @param name defines the block name
  67312. */
  67313. constructor(name: string);
  67314. /**
  67315. * Gets the current class name
  67316. * @returns the class name
  67317. */
  67318. getClassName(): string;
  67319. /**
  67320. * Gets the value operand input component
  67321. */
  67322. get value(): NodeMaterialConnectionPoint;
  67323. /**
  67324. * Gets the edge operand input component
  67325. */
  67326. get edge(): NodeMaterialConnectionPoint;
  67327. /**
  67328. * Gets the output component
  67329. */
  67330. get output(): NodeMaterialConnectionPoint;
  67331. protected _buildBlock(state: NodeMaterialBuildState): this;
  67332. }
  67333. }
  67334. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67338. /**
  67339. * Block used to get the opposite (1 - x) of a value
  67340. */
  67341. export class OneMinusBlock extends NodeMaterialBlock {
  67342. /**
  67343. * Creates a new OneMinusBlock
  67344. * @param name defines the block name
  67345. */
  67346. constructor(name: string);
  67347. /**
  67348. * Gets the current class name
  67349. * @returns the class name
  67350. */
  67351. getClassName(): string;
  67352. /**
  67353. * Gets the input component
  67354. */
  67355. get input(): NodeMaterialConnectionPoint;
  67356. /**
  67357. * Gets the output component
  67358. */
  67359. get output(): NodeMaterialConnectionPoint;
  67360. protected _buildBlock(state: NodeMaterialBuildState): this;
  67361. }
  67362. }
  67363. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67367. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67368. /**
  67369. * Block used to get the view direction
  67370. */
  67371. export class ViewDirectionBlock extends NodeMaterialBlock {
  67372. /**
  67373. * Creates a new ViewDirectionBlock
  67374. * @param name defines the block name
  67375. */
  67376. constructor(name: string);
  67377. /**
  67378. * Gets the current class name
  67379. * @returns the class name
  67380. */
  67381. getClassName(): string;
  67382. /**
  67383. * Gets the world position component
  67384. */
  67385. get worldPosition(): NodeMaterialConnectionPoint;
  67386. /**
  67387. * Gets the camera position component
  67388. */
  67389. get cameraPosition(): NodeMaterialConnectionPoint;
  67390. /**
  67391. * Gets the output component
  67392. */
  67393. get output(): NodeMaterialConnectionPoint;
  67394. autoConfigure(material: NodeMaterial): void;
  67395. protected _buildBlock(state: NodeMaterialBuildState): this;
  67396. }
  67397. }
  67398. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67399. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67400. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67401. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67402. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67403. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67404. /**
  67405. * Block used to compute fresnel value
  67406. */
  67407. export class FresnelBlock extends NodeMaterialBlock {
  67408. /**
  67409. * Create a new FresnelBlock
  67410. * @param name defines the block name
  67411. */
  67412. constructor(name: string);
  67413. /**
  67414. * Gets the current class name
  67415. * @returns the class name
  67416. */
  67417. getClassName(): string;
  67418. /**
  67419. * Gets the world normal input component
  67420. */
  67421. get worldNormal(): NodeMaterialConnectionPoint;
  67422. /**
  67423. * Gets the view direction input component
  67424. */
  67425. get viewDirection(): NodeMaterialConnectionPoint;
  67426. /**
  67427. * Gets the bias input component
  67428. */
  67429. get bias(): NodeMaterialConnectionPoint;
  67430. /**
  67431. * Gets the camera (or eye) position component
  67432. */
  67433. get power(): NodeMaterialConnectionPoint;
  67434. /**
  67435. * Gets the fresnel output component
  67436. */
  67437. get fresnel(): NodeMaterialConnectionPoint;
  67438. autoConfigure(material: NodeMaterial): void;
  67439. protected _buildBlock(state: NodeMaterialBuildState): this;
  67440. }
  67441. }
  67442. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67443. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67444. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67446. /**
  67447. * Block used to get the max of 2 values
  67448. */
  67449. export class MaxBlock extends NodeMaterialBlock {
  67450. /**
  67451. * Creates a new MaxBlock
  67452. * @param name defines the block name
  67453. */
  67454. constructor(name: string);
  67455. /**
  67456. * Gets the current class name
  67457. * @returns the class name
  67458. */
  67459. getClassName(): string;
  67460. /**
  67461. * Gets the left operand input component
  67462. */
  67463. get left(): NodeMaterialConnectionPoint;
  67464. /**
  67465. * Gets the right operand input component
  67466. */
  67467. get right(): NodeMaterialConnectionPoint;
  67468. /**
  67469. * Gets the output component
  67470. */
  67471. get output(): NodeMaterialConnectionPoint;
  67472. protected _buildBlock(state: NodeMaterialBuildState): this;
  67473. }
  67474. }
  67475. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67479. /**
  67480. * Block used to get the min of 2 values
  67481. */
  67482. export class MinBlock extends NodeMaterialBlock {
  67483. /**
  67484. * Creates a new MinBlock
  67485. * @param name defines the block name
  67486. */
  67487. constructor(name: string);
  67488. /**
  67489. * Gets the current class name
  67490. * @returns the class name
  67491. */
  67492. getClassName(): string;
  67493. /**
  67494. * Gets the left operand input component
  67495. */
  67496. get left(): NodeMaterialConnectionPoint;
  67497. /**
  67498. * Gets the right operand input component
  67499. */
  67500. get right(): NodeMaterialConnectionPoint;
  67501. /**
  67502. * Gets the output component
  67503. */
  67504. get output(): NodeMaterialConnectionPoint;
  67505. protected _buildBlock(state: NodeMaterialBuildState): this;
  67506. }
  67507. }
  67508. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67510. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67512. /**
  67513. * Block used to get the distance between 2 values
  67514. */
  67515. export class DistanceBlock extends NodeMaterialBlock {
  67516. /**
  67517. * Creates a new DistanceBlock
  67518. * @param name defines the block name
  67519. */
  67520. constructor(name: string);
  67521. /**
  67522. * Gets the current class name
  67523. * @returns the class name
  67524. */
  67525. getClassName(): string;
  67526. /**
  67527. * Gets the left operand input component
  67528. */
  67529. get left(): NodeMaterialConnectionPoint;
  67530. /**
  67531. * Gets the right operand input component
  67532. */
  67533. get right(): NodeMaterialConnectionPoint;
  67534. /**
  67535. * Gets the output component
  67536. */
  67537. get output(): NodeMaterialConnectionPoint;
  67538. protected _buildBlock(state: NodeMaterialBuildState): this;
  67539. }
  67540. }
  67541. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67542. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67543. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67544. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67545. /**
  67546. * Block used to get the length of a vector
  67547. */
  67548. export class LengthBlock extends NodeMaterialBlock {
  67549. /**
  67550. * Creates a new LengthBlock
  67551. * @param name defines the block name
  67552. */
  67553. constructor(name: string);
  67554. /**
  67555. * Gets the current class name
  67556. * @returns the class name
  67557. */
  67558. getClassName(): string;
  67559. /**
  67560. * Gets the value input component
  67561. */
  67562. get value(): NodeMaterialConnectionPoint;
  67563. /**
  67564. * Gets the output component
  67565. */
  67566. get output(): NodeMaterialConnectionPoint;
  67567. protected _buildBlock(state: NodeMaterialBuildState): this;
  67568. }
  67569. }
  67570. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67574. /**
  67575. * Block used to get negative version of a value (i.e. x * -1)
  67576. */
  67577. export class NegateBlock extends NodeMaterialBlock {
  67578. /**
  67579. * Creates a new NegateBlock
  67580. * @param name defines the block name
  67581. */
  67582. constructor(name: string);
  67583. /**
  67584. * Gets the current class name
  67585. * @returns the class name
  67586. */
  67587. getClassName(): string;
  67588. /**
  67589. * Gets the value input component
  67590. */
  67591. get value(): NodeMaterialConnectionPoint;
  67592. /**
  67593. * Gets the output component
  67594. */
  67595. get output(): NodeMaterialConnectionPoint;
  67596. protected _buildBlock(state: NodeMaterialBuildState): this;
  67597. }
  67598. }
  67599. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67603. /**
  67604. * Block used to get the value of the first parameter raised to the power of the second
  67605. */
  67606. export class PowBlock extends NodeMaterialBlock {
  67607. /**
  67608. * Creates a new PowBlock
  67609. * @param name defines the block name
  67610. */
  67611. constructor(name: string);
  67612. /**
  67613. * Gets the current class name
  67614. * @returns the class name
  67615. */
  67616. getClassName(): string;
  67617. /**
  67618. * Gets the value operand input component
  67619. */
  67620. get value(): NodeMaterialConnectionPoint;
  67621. /**
  67622. * Gets the power operand input component
  67623. */
  67624. get power(): NodeMaterialConnectionPoint;
  67625. /**
  67626. * Gets the output component
  67627. */
  67628. get output(): NodeMaterialConnectionPoint;
  67629. protected _buildBlock(state: NodeMaterialBuildState): this;
  67630. }
  67631. }
  67632. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67634. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67635. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67636. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67637. /**
  67638. * Block used to get a random number
  67639. */
  67640. export class RandomNumberBlock extends NodeMaterialBlock {
  67641. /**
  67642. * Creates a new RandomNumberBlock
  67643. * @param name defines the block name
  67644. */
  67645. constructor(name: string);
  67646. /**
  67647. * Gets the current class name
  67648. * @returns the class name
  67649. */
  67650. getClassName(): string;
  67651. /**
  67652. * Gets the seed input component
  67653. */
  67654. get seed(): NodeMaterialConnectionPoint;
  67655. /**
  67656. * Gets the output component
  67657. */
  67658. get output(): NodeMaterialConnectionPoint;
  67659. protected _buildBlock(state: NodeMaterialBuildState): this;
  67660. }
  67661. }
  67662. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67663. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67666. /**
  67667. * Block used to compute arc tangent of 2 values
  67668. */
  67669. export class ArcTan2Block extends NodeMaterialBlock {
  67670. /**
  67671. * Creates a new ArcTan2Block
  67672. * @param name defines the block name
  67673. */
  67674. constructor(name: string);
  67675. /**
  67676. * Gets the current class name
  67677. * @returns the class name
  67678. */
  67679. getClassName(): string;
  67680. /**
  67681. * Gets the x operand input component
  67682. */
  67683. get x(): NodeMaterialConnectionPoint;
  67684. /**
  67685. * Gets the y operand input component
  67686. */
  67687. get y(): NodeMaterialConnectionPoint;
  67688. /**
  67689. * Gets the output component
  67690. */
  67691. get output(): NodeMaterialConnectionPoint;
  67692. protected _buildBlock(state: NodeMaterialBuildState): this;
  67693. }
  67694. }
  67695. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67697. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67698. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67699. /**
  67700. * Block used to smooth step a value
  67701. */
  67702. export class SmoothStepBlock extends NodeMaterialBlock {
  67703. /**
  67704. * Creates a new SmoothStepBlock
  67705. * @param name defines the block name
  67706. */
  67707. constructor(name: string);
  67708. /**
  67709. * Gets the current class name
  67710. * @returns the class name
  67711. */
  67712. getClassName(): string;
  67713. /**
  67714. * Gets the value operand input component
  67715. */
  67716. get value(): NodeMaterialConnectionPoint;
  67717. /**
  67718. * Gets the first edge operand input component
  67719. */
  67720. get edge0(): NodeMaterialConnectionPoint;
  67721. /**
  67722. * Gets the second edge operand input component
  67723. */
  67724. get edge1(): NodeMaterialConnectionPoint;
  67725. /**
  67726. * Gets the output component
  67727. */
  67728. get output(): NodeMaterialConnectionPoint;
  67729. protected _buildBlock(state: NodeMaterialBuildState): this;
  67730. }
  67731. }
  67732. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67733. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67734. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67735. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67736. /**
  67737. * Block used to get the reciprocal (1 / x) of a value
  67738. */
  67739. export class ReciprocalBlock extends NodeMaterialBlock {
  67740. /**
  67741. * Creates a new ReciprocalBlock
  67742. * @param name defines the block name
  67743. */
  67744. constructor(name: string);
  67745. /**
  67746. * Gets the current class name
  67747. * @returns the class name
  67748. */
  67749. getClassName(): string;
  67750. /**
  67751. * Gets the input component
  67752. */
  67753. get input(): NodeMaterialConnectionPoint;
  67754. /**
  67755. * Gets the output component
  67756. */
  67757. get output(): NodeMaterialConnectionPoint;
  67758. protected _buildBlock(state: NodeMaterialBuildState): this;
  67759. }
  67760. }
  67761. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67762. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67763. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67765. /**
  67766. * Block used to replace a color by another one
  67767. */
  67768. export class ReplaceColorBlock extends NodeMaterialBlock {
  67769. /**
  67770. * Creates a new ReplaceColorBlock
  67771. * @param name defines the block name
  67772. */
  67773. constructor(name: string);
  67774. /**
  67775. * Gets the current class name
  67776. * @returns the class name
  67777. */
  67778. getClassName(): string;
  67779. /**
  67780. * Gets the value input component
  67781. */
  67782. get value(): NodeMaterialConnectionPoint;
  67783. /**
  67784. * Gets the reference input component
  67785. */
  67786. get reference(): NodeMaterialConnectionPoint;
  67787. /**
  67788. * Gets the distance input component
  67789. */
  67790. get distance(): NodeMaterialConnectionPoint;
  67791. /**
  67792. * Gets the replacement input component
  67793. */
  67794. get replacement(): NodeMaterialConnectionPoint;
  67795. /**
  67796. * Gets the output component
  67797. */
  67798. get output(): NodeMaterialConnectionPoint;
  67799. protected _buildBlock(state: NodeMaterialBuildState): this;
  67800. }
  67801. }
  67802. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67803. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67804. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67805. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67806. /**
  67807. * Block used to posterize a value
  67808. * @see https://en.wikipedia.org/wiki/Posterization
  67809. */
  67810. export class PosterizeBlock extends NodeMaterialBlock {
  67811. /**
  67812. * Creates a new PosterizeBlock
  67813. * @param name defines the block name
  67814. */
  67815. constructor(name: string);
  67816. /**
  67817. * Gets the current class name
  67818. * @returns the class name
  67819. */
  67820. getClassName(): string;
  67821. /**
  67822. * Gets the value input component
  67823. */
  67824. get value(): NodeMaterialConnectionPoint;
  67825. /**
  67826. * Gets the steps input component
  67827. */
  67828. get steps(): NodeMaterialConnectionPoint;
  67829. /**
  67830. * Gets the output component
  67831. */
  67832. get output(): NodeMaterialConnectionPoint;
  67833. protected _buildBlock(state: NodeMaterialBuildState): this;
  67834. }
  67835. }
  67836. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67840. import { Scene } from "babylonjs/scene";
  67841. /**
  67842. * Operations supported by the Wave block
  67843. */
  67844. export enum WaveBlockKind {
  67845. /** SawTooth */
  67846. SawTooth = 0,
  67847. /** Square */
  67848. Square = 1,
  67849. /** Triangle */
  67850. Triangle = 2
  67851. }
  67852. /**
  67853. * Block used to apply wave operation to floats
  67854. */
  67855. export class WaveBlock extends NodeMaterialBlock {
  67856. /**
  67857. * Gets or sets the kibnd of wave to be applied by the block
  67858. */
  67859. kind: WaveBlockKind;
  67860. /**
  67861. * Creates a new WaveBlock
  67862. * @param name defines the block name
  67863. */
  67864. constructor(name: string);
  67865. /**
  67866. * Gets the current class name
  67867. * @returns the class name
  67868. */
  67869. getClassName(): string;
  67870. /**
  67871. * Gets the input component
  67872. */
  67873. get input(): NodeMaterialConnectionPoint;
  67874. /**
  67875. * Gets the output component
  67876. */
  67877. get output(): NodeMaterialConnectionPoint;
  67878. protected _buildBlock(state: NodeMaterialBuildState): this;
  67879. serialize(): any;
  67880. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67881. }
  67882. }
  67883. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67887. import { Color3 } from "babylonjs/Maths/math.color";
  67888. import { Scene } from "babylonjs/scene";
  67889. import { Observable } from "babylonjs/Misc/observable";
  67890. /**
  67891. * Class used to store a color step for the GradientBlock
  67892. */
  67893. export class GradientBlockColorStep {
  67894. private _step;
  67895. /**
  67896. * Gets value indicating which step this color is associated with (between 0 and 1)
  67897. */
  67898. get step(): number;
  67899. /**
  67900. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67901. */
  67902. set step(val: number);
  67903. private _color;
  67904. /**
  67905. * Gets the color associated with this step
  67906. */
  67907. get color(): Color3;
  67908. /**
  67909. * Sets the color associated with this step
  67910. */
  67911. set color(val: Color3);
  67912. /**
  67913. * Creates a new GradientBlockColorStep
  67914. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67915. * @param color defines the color associated with this step
  67916. */
  67917. constructor(step: number, color: Color3);
  67918. }
  67919. /**
  67920. * Block used to return a color from a gradient based on an input value between 0 and 1
  67921. */
  67922. export class GradientBlock extends NodeMaterialBlock {
  67923. /**
  67924. * Gets or sets the list of color steps
  67925. */
  67926. colorSteps: GradientBlockColorStep[];
  67927. /** Gets an observable raised when the value is changed */
  67928. onValueChangedObservable: Observable<GradientBlock>;
  67929. /** calls observable when the value is changed*/
  67930. colorStepsUpdated(): void;
  67931. /**
  67932. * Creates a new GradientBlock
  67933. * @param name defines the block name
  67934. */
  67935. constructor(name: string);
  67936. /**
  67937. * Gets the current class name
  67938. * @returns the class name
  67939. */
  67940. getClassName(): string;
  67941. /**
  67942. * Gets the gradient input component
  67943. */
  67944. get gradient(): NodeMaterialConnectionPoint;
  67945. /**
  67946. * Gets the output component
  67947. */
  67948. get output(): NodeMaterialConnectionPoint;
  67949. private _writeColorConstant;
  67950. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67951. serialize(): any;
  67952. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67953. protected _dumpPropertiesCode(): string;
  67954. }
  67955. }
  67956. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67960. /**
  67961. * Block used to normalize lerp between 2 values
  67962. */
  67963. export class NLerpBlock extends NodeMaterialBlock {
  67964. /**
  67965. * Creates a new NLerpBlock
  67966. * @param name defines the block name
  67967. */
  67968. constructor(name: string);
  67969. /**
  67970. * Gets the current class name
  67971. * @returns the class name
  67972. */
  67973. getClassName(): string;
  67974. /**
  67975. * Gets the left operand input component
  67976. */
  67977. get left(): NodeMaterialConnectionPoint;
  67978. /**
  67979. * Gets the right operand input component
  67980. */
  67981. get right(): NodeMaterialConnectionPoint;
  67982. /**
  67983. * Gets the gradient operand input component
  67984. */
  67985. get gradient(): NodeMaterialConnectionPoint;
  67986. /**
  67987. * Gets the output component
  67988. */
  67989. get output(): NodeMaterialConnectionPoint;
  67990. protected _buildBlock(state: NodeMaterialBuildState): this;
  67991. }
  67992. }
  67993. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67997. import { Scene } from "babylonjs/scene";
  67998. /**
  67999. * block used to Generate a Worley Noise 3D Noise Pattern
  68000. */
  68001. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68002. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68003. manhattanDistance: boolean;
  68004. /**
  68005. * Creates a new WorleyNoise3DBlock
  68006. * @param name defines the block name
  68007. */
  68008. constructor(name: string);
  68009. /**
  68010. * Gets the current class name
  68011. * @returns the class name
  68012. */
  68013. getClassName(): string;
  68014. /**
  68015. * Gets the seed input component
  68016. */
  68017. get seed(): NodeMaterialConnectionPoint;
  68018. /**
  68019. * Gets the jitter input component
  68020. */
  68021. get jitter(): NodeMaterialConnectionPoint;
  68022. /**
  68023. * Gets the output component
  68024. */
  68025. get output(): NodeMaterialConnectionPoint;
  68026. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68027. /**
  68028. * Exposes the properties to the UI?
  68029. */
  68030. protected _dumpPropertiesCode(): string;
  68031. /**
  68032. * Exposes the properties to the Seralize?
  68033. */
  68034. serialize(): any;
  68035. /**
  68036. * Exposes the properties to the deseralize?
  68037. */
  68038. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68039. }
  68040. }
  68041. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68042. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68043. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68044. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68045. /**
  68046. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68047. */
  68048. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68049. /**
  68050. * Creates a new SimplexPerlin3DBlock
  68051. * @param name defines the block name
  68052. */
  68053. constructor(name: string);
  68054. /**
  68055. * Gets the current class name
  68056. * @returns the class name
  68057. */
  68058. getClassName(): string;
  68059. /**
  68060. * Gets the seed operand input component
  68061. */
  68062. get seed(): NodeMaterialConnectionPoint;
  68063. /**
  68064. * Gets the output component
  68065. */
  68066. get output(): NodeMaterialConnectionPoint;
  68067. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68068. }
  68069. }
  68070. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68071. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68072. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68073. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68074. /**
  68075. * Block used to blend normals
  68076. */
  68077. export class NormalBlendBlock extends NodeMaterialBlock {
  68078. /**
  68079. * Creates a new NormalBlendBlock
  68080. * @param name defines the block name
  68081. */
  68082. constructor(name: string);
  68083. /**
  68084. * Gets the current class name
  68085. * @returns the class name
  68086. */
  68087. getClassName(): string;
  68088. /**
  68089. * Gets the first input component
  68090. */
  68091. get normalMap0(): NodeMaterialConnectionPoint;
  68092. /**
  68093. * Gets the second input component
  68094. */
  68095. get normalMap1(): NodeMaterialConnectionPoint;
  68096. /**
  68097. * Gets the output component
  68098. */
  68099. get output(): NodeMaterialConnectionPoint;
  68100. protected _buildBlock(state: NodeMaterialBuildState): this;
  68101. }
  68102. }
  68103. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68104. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68105. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68106. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68107. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68108. /**
  68109. * Block used to rotate a 2d vector by a given angle
  68110. */
  68111. export class Rotate2dBlock extends NodeMaterialBlock {
  68112. /**
  68113. * Creates a new Rotate2dBlock
  68114. * @param name defines the block name
  68115. */
  68116. constructor(name: string);
  68117. /**
  68118. * Gets the current class name
  68119. * @returns the class name
  68120. */
  68121. getClassName(): string;
  68122. /**
  68123. * Gets the input vector
  68124. */
  68125. get input(): NodeMaterialConnectionPoint;
  68126. /**
  68127. * Gets the input angle
  68128. */
  68129. get angle(): NodeMaterialConnectionPoint;
  68130. /**
  68131. * Gets the output component
  68132. */
  68133. get output(): NodeMaterialConnectionPoint;
  68134. autoConfigure(material: NodeMaterial): void;
  68135. protected _buildBlock(state: NodeMaterialBuildState): this;
  68136. }
  68137. }
  68138. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68139. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68140. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68141. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68142. /**
  68143. * Block used to get the reflected vector from a direction and a normal
  68144. */
  68145. export class ReflectBlock extends NodeMaterialBlock {
  68146. /**
  68147. * Creates a new ReflectBlock
  68148. * @param name defines the block name
  68149. */
  68150. constructor(name: string);
  68151. /**
  68152. * Gets the current class name
  68153. * @returns the class name
  68154. */
  68155. getClassName(): string;
  68156. /**
  68157. * Gets the incident component
  68158. */
  68159. get incident(): NodeMaterialConnectionPoint;
  68160. /**
  68161. * Gets the normal component
  68162. */
  68163. get normal(): NodeMaterialConnectionPoint;
  68164. /**
  68165. * Gets the output component
  68166. */
  68167. get output(): NodeMaterialConnectionPoint;
  68168. protected _buildBlock(state: NodeMaterialBuildState): this;
  68169. }
  68170. }
  68171. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68172. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68173. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68174. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68175. /**
  68176. * Block used to get the refracted vector from a direction and a normal
  68177. */
  68178. export class RefractBlock extends NodeMaterialBlock {
  68179. /**
  68180. * Creates a new RefractBlock
  68181. * @param name defines the block name
  68182. */
  68183. constructor(name: string);
  68184. /**
  68185. * Gets the current class name
  68186. * @returns the class name
  68187. */
  68188. getClassName(): string;
  68189. /**
  68190. * Gets the incident component
  68191. */
  68192. get incident(): NodeMaterialConnectionPoint;
  68193. /**
  68194. * Gets the normal component
  68195. */
  68196. get normal(): NodeMaterialConnectionPoint;
  68197. /**
  68198. * Gets the index of refraction component
  68199. */
  68200. get ior(): NodeMaterialConnectionPoint;
  68201. /**
  68202. * Gets the output component
  68203. */
  68204. get output(): NodeMaterialConnectionPoint;
  68205. protected _buildBlock(state: NodeMaterialBuildState): this;
  68206. }
  68207. }
  68208. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68210. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68211. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68212. /**
  68213. * Block used to desaturate a color
  68214. */
  68215. export class DesaturateBlock extends NodeMaterialBlock {
  68216. /**
  68217. * Creates a new DesaturateBlock
  68218. * @param name defines the block name
  68219. */
  68220. constructor(name: string);
  68221. /**
  68222. * Gets the current class name
  68223. * @returns the class name
  68224. */
  68225. getClassName(): string;
  68226. /**
  68227. * Gets the color operand input component
  68228. */
  68229. get color(): NodeMaterialConnectionPoint;
  68230. /**
  68231. * Gets the level operand input component
  68232. */
  68233. get level(): NodeMaterialConnectionPoint;
  68234. /**
  68235. * Gets the output component
  68236. */
  68237. get output(): NodeMaterialConnectionPoint;
  68238. protected _buildBlock(state: NodeMaterialBuildState): this;
  68239. }
  68240. }
  68241. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68245. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68246. import { Nullable } from "babylonjs/types";
  68247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68248. import { Scene } from "babylonjs/scene";
  68249. /**
  68250. * Block used to implement the ambient occlusion module of the PBR material
  68251. */
  68252. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68253. /**
  68254. * Create a new AmbientOcclusionBlock
  68255. * @param name defines the block name
  68256. */
  68257. constructor(name: string);
  68258. /**
  68259. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68260. */
  68261. useAmbientInGrayScale: boolean;
  68262. /**
  68263. * Initialize the block and prepare the context for build
  68264. * @param state defines the state that will be used for the build
  68265. */
  68266. initialize(state: NodeMaterialBuildState): void;
  68267. /**
  68268. * Gets the current class name
  68269. * @returns the class name
  68270. */
  68271. getClassName(): string;
  68272. /**
  68273. * Gets the texture input component
  68274. */
  68275. get texture(): NodeMaterialConnectionPoint;
  68276. /**
  68277. * Gets the texture intensity component
  68278. */
  68279. get intensity(): NodeMaterialConnectionPoint;
  68280. /**
  68281. * Gets the direct light intensity input component
  68282. */
  68283. get directLightIntensity(): NodeMaterialConnectionPoint;
  68284. /**
  68285. * Gets the ambient occlusion object output component
  68286. */
  68287. get ambientOcc(): NodeMaterialConnectionPoint;
  68288. /**
  68289. * Gets the main code of the block (fragment side)
  68290. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68291. * @returns the shader code
  68292. */
  68293. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68294. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68295. protected _buildBlock(state: NodeMaterialBuildState): this;
  68296. protected _dumpPropertiesCode(): string;
  68297. serialize(): any;
  68298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68299. }
  68300. }
  68301. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68304. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68305. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68307. import { Nullable } from "babylonjs/types";
  68308. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68309. import { Mesh } from "babylonjs/Meshes/mesh";
  68310. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68311. import { Effect } from "babylonjs/Materials/effect";
  68312. import { Scene } from "babylonjs/scene";
  68313. /**
  68314. * Block used to implement the reflection module of the PBR material
  68315. */
  68316. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68317. /** @hidden */
  68318. _defineLODReflectionAlpha: string;
  68319. /** @hidden */
  68320. _defineLinearSpecularReflection: string;
  68321. private _vEnvironmentIrradianceName;
  68322. /** @hidden */
  68323. _vReflectionMicrosurfaceInfosName: string;
  68324. /** @hidden */
  68325. _vReflectionInfosName: string;
  68326. /** @hidden */
  68327. _vReflectionFilteringInfoName: string;
  68328. private _scene;
  68329. /**
  68330. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68331. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68332. * It's less burden on the user side in the editor part.
  68333. */
  68334. /** @hidden */
  68335. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68336. /** @hidden */
  68337. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68338. /** @hidden */
  68339. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68340. /**
  68341. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68342. * diffuse part of the IBL.
  68343. */
  68344. useSphericalHarmonics: boolean;
  68345. /**
  68346. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68347. */
  68348. forceIrradianceInFragment: boolean;
  68349. /**
  68350. * Create a new ReflectionBlock
  68351. * @param name defines the block name
  68352. */
  68353. constructor(name: string);
  68354. /**
  68355. * Gets the current class name
  68356. * @returns the class name
  68357. */
  68358. getClassName(): string;
  68359. /**
  68360. * Gets the position input component
  68361. */
  68362. get position(): NodeMaterialConnectionPoint;
  68363. /**
  68364. * Gets the world position input component
  68365. */
  68366. get worldPosition(): NodeMaterialConnectionPoint;
  68367. /**
  68368. * Gets the world normal input component
  68369. */
  68370. get worldNormal(): NodeMaterialConnectionPoint;
  68371. /**
  68372. * Gets the world input component
  68373. */
  68374. get world(): NodeMaterialConnectionPoint;
  68375. /**
  68376. * Gets the camera (or eye) position component
  68377. */
  68378. get cameraPosition(): NodeMaterialConnectionPoint;
  68379. /**
  68380. * Gets the view input component
  68381. */
  68382. get view(): NodeMaterialConnectionPoint;
  68383. /**
  68384. * Gets the color input component
  68385. */
  68386. get color(): NodeMaterialConnectionPoint;
  68387. /**
  68388. * Gets the reflection object output component
  68389. */
  68390. get reflection(): NodeMaterialConnectionPoint;
  68391. /**
  68392. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68393. */
  68394. get hasTexture(): boolean;
  68395. /**
  68396. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68397. */
  68398. get reflectionColor(): string;
  68399. protected _getTexture(): Nullable<BaseTexture>;
  68400. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68401. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68402. /**
  68403. * Gets the code to inject in the vertex shader
  68404. * @param state current state of the node material building
  68405. * @returns the shader code
  68406. */
  68407. handleVertexSide(state: NodeMaterialBuildState): string;
  68408. /**
  68409. * Gets the main code of the block (fragment side)
  68410. * @param state current state of the node material building
  68411. * @param normalVarName name of the existing variable corresponding to the normal
  68412. * @returns the shader code
  68413. */
  68414. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68415. protected _buildBlock(state: NodeMaterialBuildState): this;
  68416. protected _dumpPropertiesCode(): string;
  68417. serialize(): any;
  68418. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68419. }
  68420. }
  68421. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68425. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68427. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68428. import { Scene } from "babylonjs/scene";
  68429. import { Nullable } from "babylonjs/types";
  68430. /**
  68431. * Block used to implement the sheen module of the PBR material
  68432. */
  68433. export class SheenBlock extends NodeMaterialBlock {
  68434. /**
  68435. * Create a new SheenBlock
  68436. * @param name defines the block name
  68437. */
  68438. constructor(name: string);
  68439. /**
  68440. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68441. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68442. * making it easier to setup and tweak the effect
  68443. */
  68444. albedoScaling: boolean;
  68445. /**
  68446. * Defines if the sheen is linked to the sheen color.
  68447. */
  68448. linkSheenWithAlbedo: boolean;
  68449. /**
  68450. * Initialize the block and prepare the context for build
  68451. * @param state defines the state that will be used for the build
  68452. */
  68453. initialize(state: NodeMaterialBuildState): void;
  68454. /**
  68455. * Gets the current class name
  68456. * @returns the class name
  68457. */
  68458. getClassName(): string;
  68459. /**
  68460. * Gets the intensity input component
  68461. */
  68462. get intensity(): NodeMaterialConnectionPoint;
  68463. /**
  68464. * Gets the color input component
  68465. */
  68466. get color(): NodeMaterialConnectionPoint;
  68467. /**
  68468. * Gets the roughness input component
  68469. */
  68470. get roughness(): NodeMaterialConnectionPoint;
  68471. /**
  68472. * Gets the sheen object output component
  68473. */
  68474. get sheen(): NodeMaterialConnectionPoint;
  68475. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68476. /**
  68477. * Gets the main code of the block (fragment side)
  68478. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68479. * @returns the shader code
  68480. */
  68481. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68482. protected _buildBlock(state: NodeMaterialBuildState): this;
  68483. protected _dumpPropertiesCode(): string;
  68484. serialize(): any;
  68485. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68486. }
  68487. }
  68488. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68489. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68490. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68494. import { Scene } from "babylonjs/scene";
  68495. import { Nullable } from "babylonjs/types";
  68496. import { Mesh } from "babylonjs/Meshes/mesh";
  68497. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68498. import { Effect } from "babylonjs/Materials/effect";
  68499. /**
  68500. * Block used to implement the reflectivity module of the PBR material
  68501. */
  68502. export class ReflectivityBlock extends NodeMaterialBlock {
  68503. private _metallicReflectanceColor;
  68504. private _metallicF0Factor;
  68505. /** @hidden */
  68506. _vMetallicReflectanceFactorsName: string;
  68507. /**
  68508. * The property below is set by the main PBR block prior to calling methods of this class.
  68509. */
  68510. /** @hidden */
  68511. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68512. /**
  68513. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68514. */
  68515. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68516. /**
  68517. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68518. */
  68519. useMetallnessFromMetallicTextureBlue: boolean;
  68520. /**
  68521. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68522. */
  68523. useRoughnessFromMetallicTextureAlpha: boolean;
  68524. /**
  68525. * Specifies if the metallic texture contains the roughness information in its green channel.
  68526. */
  68527. useRoughnessFromMetallicTextureGreen: boolean;
  68528. /**
  68529. * Create a new ReflectivityBlock
  68530. * @param name defines the block name
  68531. */
  68532. constructor(name: string);
  68533. /**
  68534. * Initialize the block and prepare the context for build
  68535. * @param state defines the state that will be used for the build
  68536. */
  68537. initialize(state: NodeMaterialBuildState): void;
  68538. /**
  68539. * Gets the current class name
  68540. * @returns the class name
  68541. */
  68542. getClassName(): string;
  68543. /**
  68544. * Gets the metallic input component
  68545. */
  68546. get metallic(): NodeMaterialConnectionPoint;
  68547. /**
  68548. * Gets the roughness input component
  68549. */
  68550. get roughness(): NodeMaterialConnectionPoint;
  68551. /**
  68552. * Gets the texture input component
  68553. */
  68554. get texture(): NodeMaterialConnectionPoint;
  68555. /**
  68556. * Gets the reflectivity object output component
  68557. */
  68558. get reflectivity(): NodeMaterialConnectionPoint;
  68559. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68560. /**
  68561. * Gets the main code of the block (fragment side)
  68562. * @param state current state of the node material building
  68563. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68564. * @returns the shader code
  68565. */
  68566. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68567. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68568. protected _buildBlock(state: NodeMaterialBuildState): this;
  68569. protected _dumpPropertiesCode(): string;
  68570. serialize(): any;
  68571. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68572. }
  68573. }
  68574. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68575. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68576. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68577. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68578. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68580. /**
  68581. * Block used to implement the anisotropy module of the PBR material
  68582. */
  68583. export class AnisotropyBlock extends NodeMaterialBlock {
  68584. /**
  68585. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68586. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68587. * It's less burden on the user side in the editor part.
  68588. */
  68589. /** @hidden */
  68590. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68591. /** @hidden */
  68592. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68593. /**
  68594. * Create a new AnisotropyBlock
  68595. * @param name defines the block name
  68596. */
  68597. constructor(name: string);
  68598. /**
  68599. * Initialize the block and prepare the context for build
  68600. * @param state defines the state that will be used for the build
  68601. */
  68602. initialize(state: NodeMaterialBuildState): void;
  68603. /**
  68604. * Gets the current class name
  68605. * @returns the class name
  68606. */
  68607. getClassName(): string;
  68608. /**
  68609. * Gets the intensity input component
  68610. */
  68611. get intensity(): NodeMaterialConnectionPoint;
  68612. /**
  68613. * Gets the direction input component
  68614. */
  68615. get direction(): NodeMaterialConnectionPoint;
  68616. /**
  68617. * Gets the texture input component
  68618. */
  68619. get texture(): NodeMaterialConnectionPoint;
  68620. /**
  68621. * Gets the uv input component
  68622. */
  68623. get uv(): NodeMaterialConnectionPoint;
  68624. /**
  68625. * Gets the worldTangent input component
  68626. */
  68627. get worldTangent(): NodeMaterialConnectionPoint;
  68628. /**
  68629. * Gets the anisotropy object output component
  68630. */
  68631. get anisotropy(): NodeMaterialConnectionPoint;
  68632. private _generateTBNSpace;
  68633. /**
  68634. * Gets the main code of the block (fragment side)
  68635. * @param state current state of the node material building
  68636. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68637. * @returns the shader code
  68638. */
  68639. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68641. protected _buildBlock(state: NodeMaterialBuildState): this;
  68642. }
  68643. }
  68644. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68648. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68650. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68651. import { Nullable } from "babylonjs/types";
  68652. import { Mesh } from "babylonjs/Meshes/mesh";
  68653. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68654. import { Effect } from "babylonjs/Materials/effect";
  68655. /**
  68656. * Block used to implement the clear coat module of the PBR material
  68657. */
  68658. export class ClearCoatBlock extends NodeMaterialBlock {
  68659. private _scene;
  68660. /**
  68661. * Create a new ClearCoatBlock
  68662. * @param name defines the block name
  68663. */
  68664. constructor(name: string);
  68665. /**
  68666. * Initialize the block and prepare the context for build
  68667. * @param state defines the state that will be used for the build
  68668. */
  68669. initialize(state: NodeMaterialBuildState): void;
  68670. /**
  68671. * Gets the current class name
  68672. * @returns the class name
  68673. */
  68674. getClassName(): string;
  68675. /**
  68676. * Gets the intensity input component
  68677. */
  68678. get intensity(): NodeMaterialConnectionPoint;
  68679. /**
  68680. * Gets the roughness input component
  68681. */
  68682. get roughness(): NodeMaterialConnectionPoint;
  68683. /**
  68684. * Gets the ior input component
  68685. */
  68686. get ior(): NodeMaterialConnectionPoint;
  68687. /**
  68688. * Gets the texture input component
  68689. */
  68690. get texture(): NodeMaterialConnectionPoint;
  68691. /**
  68692. * Gets the bump texture input component
  68693. */
  68694. get bumpTexture(): NodeMaterialConnectionPoint;
  68695. /**
  68696. * Gets the uv input component
  68697. */
  68698. get uv(): NodeMaterialConnectionPoint;
  68699. /**
  68700. * Gets the tint color input component
  68701. */
  68702. get tintColor(): NodeMaterialConnectionPoint;
  68703. /**
  68704. * Gets the tint "at distance" input component
  68705. */
  68706. get tintAtDistance(): NodeMaterialConnectionPoint;
  68707. /**
  68708. * Gets the tint thickness input component
  68709. */
  68710. get tintThickness(): NodeMaterialConnectionPoint;
  68711. /**
  68712. * Gets the world tangent input component
  68713. */
  68714. get worldTangent(): NodeMaterialConnectionPoint;
  68715. /**
  68716. * Gets the clear coat object output component
  68717. */
  68718. get clearcoat(): NodeMaterialConnectionPoint;
  68719. autoConfigure(material: NodeMaterial): void;
  68720. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68721. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68722. private _generateTBNSpace;
  68723. /**
  68724. * Gets the main code of the block (fragment side)
  68725. * @param state current state of the node material building
  68726. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68727. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68728. * @param worldPosVarName name of the variable holding the world position
  68729. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68730. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68731. * @param worldNormalVarName name of the variable holding the world normal
  68732. * @returns the shader code
  68733. */
  68734. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68735. protected _buildBlock(state: NodeMaterialBuildState): this;
  68736. }
  68737. }
  68738. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68740. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68741. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68742. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68744. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68745. import { Nullable } from "babylonjs/types";
  68746. /**
  68747. * Block used to implement the sub surface module of the PBR material
  68748. */
  68749. export class SubSurfaceBlock extends NodeMaterialBlock {
  68750. /**
  68751. * Create a new SubSurfaceBlock
  68752. * @param name defines the block name
  68753. */
  68754. constructor(name: string);
  68755. /**
  68756. * Stores the intensity of the different subsurface effects in the thickness texture.
  68757. * * the green channel is the translucency intensity.
  68758. * * the blue channel is the scattering intensity.
  68759. * * the alpha channel is the refraction intensity.
  68760. */
  68761. useMaskFromThicknessTexture: boolean;
  68762. /**
  68763. * Initialize the block and prepare the context for build
  68764. * @param state defines the state that will be used for the build
  68765. */
  68766. initialize(state: NodeMaterialBuildState): void;
  68767. /**
  68768. * Gets the current class name
  68769. * @returns the class name
  68770. */
  68771. getClassName(): string;
  68772. /**
  68773. * Gets the min thickness input component
  68774. */
  68775. get minThickness(): NodeMaterialConnectionPoint;
  68776. /**
  68777. * Gets the max thickness input component
  68778. */
  68779. get maxThickness(): NodeMaterialConnectionPoint;
  68780. /**
  68781. * Gets the thickness texture component
  68782. */
  68783. get thicknessTexture(): NodeMaterialConnectionPoint;
  68784. /**
  68785. * Gets the tint color input component
  68786. */
  68787. get tintColor(): NodeMaterialConnectionPoint;
  68788. /**
  68789. * Gets the translucency intensity input component
  68790. */
  68791. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68792. /**
  68793. * Gets the translucency diffusion distance input component
  68794. */
  68795. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68796. /**
  68797. * Gets the refraction object parameters
  68798. */
  68799. get refraction(): NodeMaterialConnectionPoint;
  68800. /**
  68801. * Gets the sub surface object output component
  68802. */
  68803. get subsurface(): NodeMaterialConnectionPoint;
  68804. autoConfigure(material: NodeMaterial): void;
  68805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68806. /**
  68807. * Gets the main code of the block (fragment side)
  68808. * @param state current state of the node material building
  68809. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68810. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68811. * @param worldPosVarName name of the variable holding the world position
  68812. * @returns the shader code
  68813. */
  68814. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68815. protected _buildBlock(state: NodeMaterialBuildState): this;
  68816. }
  68817. }
  68818. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68819. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68820. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68821. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68822. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68823. import { Light } from "babylonjs/Lights/light";
  68824. import { Nullable } from "babylonjs/types";
  68825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68826. import { Effect } from "babylonjs/Materials/effect";
  68827. import { Mesh } from "babylonjs/Meshes/mesh";
  68828. import { Scene } from "babylonjs/scene";
  68829. /**
  68830. * Block used to implement the PBR metallic/roughness model
  68831. */
  68832. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68833. /**
  68834. * Gets or sets the light associated with this block
  68835. */
  68836. light: Nullable<Light>;
  68837. private _lightId;
  68838. private _scene;
  68839. private _environmentBRDFTexture;
  68840. private _environmentBrdfSamplerName;
  68841. private _vNormalWName;
  68842. private _invertNormalName;
  68843. /**
  68844. * Create a new ReflectionBlock
  68845. * @param name defines the block name
  68846. */
  68847. constructor(name: string);
  68848. /**
  68849. * Intensity of the direct lights e.g. the four lights available in your scene.
  68850. * This impacts both the direct diffuse and specular highlights.
  68851. */
  68852. directIntensity: number;
  68853. /**
  68854. * Intensity of the environment e.g. how much the environment will light the object
  68855. * either through harmonics for rough material or through the refelction for shiny ones.
  68856. */
  68857. environmentIntensity: number;
  68858. /**
  68859. * This is a special control allowing the reduction of the specular highlights coming from the
  68860. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68861. */
  68862. specularIntensity: number;
  68863. /**
  68864. * Defines the falloff type used in this material.
  68865. * It by default is Physical.
  68866. */
  68867. lightFalloff: number;
  68868. /**
  68869. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68870. */
  68871. useAlphaFromAlbedoTexture: boolean;
  68872. /**
  68873. * Specifies that alpha test should be used
  68874. */
  68875. useAlphaTest: boolean;
  68876. /**
  68877. * Defines the alpha limits in alpha test mode.
  68878. */
  68879. alphaTestCutoff: number;
  68880. /**
  68881. * Specifies that alpha blending should be used
  68882. */
  68883. useAlphaBlending: boolean;
  68884. /**
  68885. * Defines if the alpha value should be determined via the rgb values.
  68886. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68887. */
  68888. opacityRGB: boolean;
  68889. /**
  68890. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68891. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68892. */
  68893. useRadianceOverAlpha: boolean;
  68894. /**
  68895. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68896. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68897. */
  68898. useSpecularOverAlpha: boolean;
  68899. /**
  68900. * Enables specular anti aliasing in the PBR shader.
  68901. * It will both interacts on the Geometry for analytical and IBL lighting.
  68902. * It also prefilter the roughness map based on the bump values.
  68903. */
  68904. enableSpecularAntiAliasing: boolean;
  68905. /**
  68906. * Enables realtime filtering on the texture.
  68907. */
  68908. realTimeFiltering: boolean;
  68909. /**
  68910. * Quality switch for realtime filtering
  68911. */
  68912. realTimeFilteringQuality: number;
  68913. /**
  68914. * Defines if the material uses energy conservation.
  68915. */
  68916. useEnergyConservation: boolean;
  68917. /**
  68918. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68919. * too much the area relying on ambient texture to define their ambient occlusion.
  68920. */
  68921. useRadianceOcclusion: boolean;
  68922. /**
  68923. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68924. * makes the reflect vector face the model (under horizon).
  68925. */
  68926. useHorizonOcclusion: boolean;
  68927. /**
  68928. * If set to true, no lighting calculations will be applied.
  68929. */
  68930. unlit: boolean;
  68931. /**
  68932. * Force normal to face away from face.
  68933. */
  68934. forceNormalForward: boolean;
  68935. /**
  68936. * Defines the material debug mode.
  68937. * It helps seeing only some components of the material while troubleshooting.
  68938. */
  68939. debugMode: number;
  68940. /**
  68941. * Specify from where on screen the debug mode should start.
  68942. * The value goes from -1 (full screen) to 1 (not visible)
  68943. * It helps with side by side comparison against the final render
  68944. * This defaults to 0
  68945. */
  68946. debugLimit: number;
  68947. /**
  68948. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68949. * You can use the factor to better multiply the final value.
  68950. */
  68951. debugFactor: number;
  68952. /**
  68953. * Initialize the block and prepare the context for build
  68954. * @param state defines the state that will be used for the build
  68955. */
  68956. initialize(state: NodeMaterialBuildState): void;
  68957. /**
  68958. * Gets the current class name
  68959. * @returns the class name
  68960. */
  68961. getClassName(): string;
  68962. /**
  68963. * Gets the world position input component
  68964. */
  68965. get worldPosition(): NodeMaterialConnectionPoint;
  68966. /**
  68967. * Gets the world normal input component
  68968. */
  68969. get worldNormal(): NodeMaterialConnectionPoint;
  68970. /**
  68971. * Gets the perturbed normal input component
  68972. */
  68973. get perturbedNormal(): NodeMaterialConnectionPoint;
  68974. /**
  68975. * Gets the camera position input component
  68976. */
  68977. get cameraPosition(): NodeMaterialConnectionPoint;
  68978. /**
  68979. * Gets the base color input component
  68980. */
  68981. get baseColor(): NodeMaterialConnectionPoint;
  68982. /**
  68983. * Gets the opacity texture input component
  68984. */
  68985. get opacityTexture(): NodeMaterialConnectionPoint;
  68986. /**
  68987. * Gets the ambient color input component
  68988. */
  68989. get ambientColor(): NodeMaterialConnectionPoint;
  68990. /**
  68991. * Gets the reflectivity object parameters
  68992. */
  68993. get reflectivity(): NodeMaterialConnectionPoint;
  68994. /**
  68995. * Gets the ambient occlusion object parameters
  68996. */
  68997. get ambientOcc(): NodeMaterialConnectionPoint;
  68998. /**
  68999. * Gets the reflection object parameters
  69000. */
  69001. get reflection(): NodeMaterialConnectionPoint;
  69002. /**
  69003. * Gets the sheen object parameters
  69004. */
  69005. get sheen(): NodeMaterialConnectionPoint;
  69006. /**
  69007. * Gets the clear coat object parameters
  69008. */
  69009. get clearcoat(): NodeMaterialConnectionPoint;
  69010. /**
  69011. * Gets the sub surface object parameters
  69012. */
  69013. get subsurface(): NodeMaterialConnectionPoint;
  69014. /**
  69015. * Gets the anisotropy object parameters
  69016. */
  69017. get anisotropy(): NodeMaterialConnectionPoint;
  69018. /**
  69019. * Gets the ambient output component
  69020. */
  69021. get ambient(): NodeMaterialConnectionPoint;
  69022. /**
  69023. * Gets the diffuse output component
  69024. */
  69025. get diffuse(): NodeMaterialConnectionPoint;
  69026. /**
  69027. * Gets the specular output component
  69028. */
  69029. get specular(): NodeMaterialConnectionPoint;
  69030. /**
  69031. * Gets the sheen output component
  69032. */
  69033. get sheenDir(): NodeMaterialConnectionPoint;
  69034. /**
  69035. * Gets the clear coat output component
  69036. */
  69037. get clearcoatDir(): NodeMaterialConnectionPoint;
  69038. /**
  69039. * Gets the indirect diffuse output component
  69040. */
  69041. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69042. /**
  69043. * Gets the indirect specular output component
  69044. */
  69045. get specularIndirect(): NodeMaterialConnectionPoint;
  69046. /**
  69047. * Gets the indirect sheen output component
  69048. */
  69049. get sheenIndirect(): NodeMaterialConnectionPoint;
  69050. /**
  69051. * Gets the indirect clear coat output component
  69052. */
  69053. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69054. /**
  69055. * Gets the refraction output component
  69056. */
  69057. get refraction(): NodeMaterialConnectionPoint;
  69058. /**
  69059. * Gets the global lighting output component
  69060. */
  69061. get lighting(): NodeMaterialConnectionPoint;
  69062. /**
  69063. * Gets the shadow output component
  69064. */
  69065. get shadow(): NodeMaterialConnectionPoint;
  69066. /**
  69067. * Gets the alpha output component
  69068. */
  69069. get alpha(): NodeMaterialConnectionPoint;
  69070. autoConfigure(material: NodeMaterial): void;
  69071. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69072. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69073. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69074. private _injectVertexCode;
  69075. /**
  69076. * Gets the code corresponding to the albedo/opacity module
  69077. * @returns the shader code
  69078. */
  69079. getAlbedoOpacityCode(): string;
  69080. protected _buildBlock(state: NodeMaterialBuildState): this;
  69081. protected _dumpPropertiesCode(): string;
  69082. serialize(): any;
  69083. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69084. }
  69085. }
  69086. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69087. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69088. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69089. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  69090. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  69091. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69092. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69093. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69094. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69095. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69096. }
  69097. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69098. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69099. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69100. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69101. }
  69102. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69103. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69104. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69105. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69106. /**
  69107. * Block used to compute value of one parameter modulo another
  69108. */
  69109. export class ModBlock extends NodeMaterialBlock {
  69110. /**
  69111. * Creates a new ModBlock
  69112. * @param name defines the block name
  69113. */
  69114. constructor(name: string);
  69115. /**
  69116. * Gets the current class name
  69117. * @returns the class name
  69118. */
  69119. getClassName(): string;
  69120. /**
  69121. * Gets the left operand input component
  69122. */
  69123. get left(): NodeMaterialConnectionPoint;
  69124. /**
  69125. * Gets the right operand input component
  69126. */
  69127. get right(): NodeMaterialConnectionPoint;
  69128. /**
  69129. * Gets the output component
  69130. */
  69131. get output(): NodeMaterialConnectionPoint;
  69132. protected _buildBlock(state: NodeMaterialBuildState): this;
  69133. }
  69134. }
  69135. declare module "babylonjs/Materials/Node/Blocks/index" {
  69136. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69137. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69138. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69139. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69140. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69141. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69142. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69143. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69144. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69145. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69146. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69147. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69148. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69149. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69150. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69151. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69152. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69153. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69154. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69155. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69156. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69157. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69158. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69159. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69160. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69161. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69162. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69163. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69164. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69165. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69166. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69167. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69168. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69169. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69170. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69171. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69172. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69173. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69174. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69175. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69176. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69177. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69178. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69179. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69180. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69181. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69182. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69183. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69184. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69185. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69186. }
  69187. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69188. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69189. }
  69190. declare module "babylonjs/Materials/Node/index" {
  69191. export * from "babylonjs/Materials/Node/Enums/index";
  69192. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69193. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69194. export * from "babylonjs/Materials/Node/nodeMaterial";
  69195. export * from "babylonjs/Materials/Node/Blocks/index";
  69196. export * from "babylonjs/Materials/Node/Optimizers/index";
  69197. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69198. }
  69199. declare module "babylonjs/Materials/index" {
  69200. export * from "babylonjs/Materials/Background/index";
  69201. export * from "babylonjs/Materials/colorCurves";
  69202. export * from "babylonjs/Materials/iEffectFallbacks";
  69203. export * from "babylonjs/Materials/effectFallbacks";
  69204. export * from "babylonjs/Materials/effect";
  69205. export * from "babylonjs/Materials/fresnelParameters";
  69206. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69207. export * from "babylonjs/Materials/material";
  69208. export * from "babylonjs/Materials/materialDefines";
  69209. export * from "babylonjs/Materials/thinMaterialHelper";
  69210. export * from "babylonjs/Materials/materialHelper";
  69211. export * from "babylonjs/Materials/multiMaterial";
  69212. export * from "babylonjs/Materials/PBR/index";
  69213. export * from "babylonjs/Materials/pushMaterial";
  69214. export * from "babylonjs/Materials/shaderMaterial";
  69215. export * from "babylonjs/Materials/standardMaterial";
  69216. export * from "babylonjs/Materials/Textures/index";
  69217. export * from "babylonjs/Materials/uniformBuffer";
  69218. export * from "babylonjs/Materials/materialFlags";
  69219. export * from "babylonjs/Materials/Node/index";
  69220. export * from "babylonjs/Materials/effectRenderer";
  69221. export * from "babylonjs/Materials/shadowDepthWrapper";
  69222. }
  69223. declare module "babylonjs/Maths/index" {
  69224. export * from "babylonjs/Maths/math.scalar";
  69225. export * from "babylonjs/Maths/math";
  69226. export * from "babylonjs/Maths/sphericalPolynomial";
  69227. }
  69228. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69229. import { IDisposable } from "babylonjs/scene";
  69230. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69231. /**
  69232. * Configuration for Draco compression
  69233. */
  69234. export interface IDracoCompressionConfiguration {
  69235. /**
  69236. * Configuration for the decoder.
  69237. */
  69238. decoder: {
  69239. /**
  69240. * The url to the WebAssembly module.
  69241. */
  69242. wasmUrl?: string;
  69243. /**
  69244. * The url to the WebAssembly binary.
  69245. */
  69246. wasmBinaryUrl?: string;
  69247. /**
  69248. * The url to the fallback JavaScript module.
  69249. */
  69250. fallbackUrl?: string;
  69251. };
  69252. }
  69253. /**
  69254. * Draco compression (https://google.github.io/draco/)
  69255. *
  69256. * This class wraps the Draco module.
  69257. *
  69258. * **Encoder**
  69259. *
  69260. * The encoder is not currently implemented.
  69261. *
  69262. * **Decoder**
  69263. *
  69264. * 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.
  69265. *
  69266. * To update the configuration, use the following code:
  69267. * ```javascript
  69268. * DracoCompression.Configuration = {
  69269. * decoder: {
  69270. * wasmUrl: "<url to the WebAssembly library>",
  69271. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69272. * fallbackUrl: "<url to the fallback JavaScript library>",
  69273. * }
  69274. * };
  69275. * ```
  69276. *
  69277. * 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.
  69278. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69279. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69280. *
  69281. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69282. * ```javascript
  69283. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69284. * ```
  69285. *
  69286. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69287. */
  69288. export class DracoCompression implements IDisposable {
  69289. private _workerPoolPromise?;
  69290. private _decoderModulePromise?;
  69291. /**
  69292. * The configuration. Defaults to the following urls:
  69293. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69294. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69295. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69296. */
  69297. static Configuration: IDracoCompressionConfiguration;
  69298. /**
  69299. * Returns true if the decoder configuration is available.
  69300. */
  69301. static get DecoderAvailable(): boolean;
  69302. /**
  69303. * Default number of workers to create when creating the draco compression object.
  69304. */
  69305. static DefaultNumWorkers: number;
  69306. private static GetDefaultNumWorkers;
  69307. private static _Default;
  69308. /**
  69309. * Default instance for the draco compression object.
  69310. */
  69311. static get Default(): DracoCompression;
  69312. /**
  69313. * Constructor
  69314. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69315. */
  69316. constructor(numWorkers?: number);
  69317. /**
  69318. * Stop all async operations and release resources.
  69319. */
  69320. dispose(): void;
  69321. /**
  69322. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69323. * @returns a promise that resolves when ready
  69324. */
  69325. whenReadyAsync(): Promise<void>;
  69326. /**
  69327. * Decode Draco compressed mesh data to vertex data.
  69328. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69329. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69330. * @returns A promise that resolves with the decoded vertex data
  69331. */
  69332. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69333. [kind: string]: number;
  69334. }): Promise<VertexData>;
  69335. }
  69336. }
  69337. declare module "babylonjs/Meshes/Compression/index" {
  69338. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69339. }
  69340. declare module "babylonjs/Meshes/csg" {
  69341. import { Nullable } from "babylonjs/types";
  69342. import { Scene } from "babylonjs/scene";
  69343. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69344. import { Mesh } from "babylonjs/Meshes/mesh";
  69345. import { Material } from "babylonjs/Materials/material";
  69346. /**
  69347. * Class for building Constructive Solid Geometry
  69348. */
  69349. export class CSG {
  69350. private polygons;
  69351. /**
  69352. * The world matrix
  69353. */
  69354. matrix: Matrix;
  69355. /**
  69356. * Stores the position
  69357. */
  69358. position: Vector3;
  69359. /**
  69360. * Stores the rotation
  69361. */
  69362. rotation: Vector3;
  69363. /**
  69364. * Stores the rotation quaternion
  69365. */
  69366. rotationQuaternion: Nullable<Quaternion>;
  69367. /**
  69368. * Stores the scaling vector
  69369. */
  69370. scaling: Vector3;
  69371. /**
  69372. * Convert the Mesh to CSG
  69373. * @param mesh The Mesh to convert to CSG
  69374. * @returns A new CSG from the Mesh
  69375. */
  69376. static FromMesh(mesh: Mesh): CSG;
  69377. /**
  69378. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69379. * @param polygons Polygons used to construct a CSG solid
  69380. */
  69381. private static FromPolygons;
  69382. /**
  69383. * Clones, or makes a deep copy, of the CSG
  69384. * @returns A new CSG
  69385. */
  69386. clone(): CSG;
  69387. /**
  69388. * Unions this CSG with another CSG
  69389. * @param csg The CSG to union against this CSG
  69390. * @returns The unioned CSG
  69391. */
  69392. union(csg: CSG): CSG;
  69393. /**
  69394. * Unions this CSG with another CSG in place
  69395. * @param csg The CSG to union against this CSG
  69396. */
  69397. unionInPlace(csg: CSG): void;
  69398. /**
  69399. * Subtracts this CSG with another CSG
  69400. * @param csg The CSG to subtract against this CSG
  69401. * @returns A new CSG
  69402. */
  69403. subtract(csg: CSG): CSG;
  69404. /**
  69405. * Subtracts this CSG with another CSG in place
  69406. * @param csg The CSG to subtact against this CSG
  69407. */
  69408. subtractInPlace(csg: CSG): void;
  69409. /**
  69410. * Intersect this CSG with another CSG
  69411. * @param csg The CSG to intersect against this CSG
  69412. * @returns A new CSG
  69413. */
  69414. intersect(csg: CSG): CSG;
  69415. /**
  69416. * Intersects this CSG with another CSG in place
  69417. * @param csg The CSG to intersect against this CSG
  69418. */
  69419. intersectInPlace(csg: CSG): void;
  69420. /**
  69421. * Return a new CSG solid with solid and empty space switched. This solid is
  69422. * not modified.
  69423. * @returns A new CSG solid with solid and empty space switched
  69424. */
  69425. inverse(): CSG;
  69426. /**
  69427. * Inverses the CSG in place
  69428. */
  69429. inverseInPlace(): void;
  69430. /**
  69431. * This is used to keep meshes transformations so they can be restored
  69432. * when we build back a Babylon Mesh
  69433. * NB : All CSG operations are performed in world coordinates
  69434. * @param csg The CSG to copy the transform attributes from
  69435. * @returns This CSG
  69436. */
  69437. copyTransformAttributes(csg: CSG): CSG;
  69438. /**
  69439. * Build Raw mesh from CSG
  69440. * Coordinates here are in world space
  69441. * @param name The name of the mesh geometry
  69442. * @param scene The Scene
  69443. * @param keepSubMeshes Specifies if the submeshes should be kept
  69444. * @returns A new Mesh
  69445. */
  69446. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69447. /**
  69448. * Build Mesh from CSG taking material and transforms into account
  69449. * @param name The name of the Mesh
  69450. * @param material The material of the Mesh
  69451. * @param scene The Scene
  69452. * @param keepSubMeshes Specifies if submeshes should be kept
  69453. * @returns The new Mesh
  69454. */
  69455. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69456. }
  69457. }
  69458. declare module "babylonjs/Meshes/trailMesh" {
  69459. import { Mesh } from "babylonjs/Meshes/mesh";
  69460. import { Scene } from "babylonjs/scene";
  69461. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69462. /**
  69463. * Class used to create a trail following a mesh
  69464. */
  69465. export class TrailMesh extends Mesh {
  69466. private _generator;
  69467. private _autoStart;
  69468. private _running;
  69469. private _diameter;
  69470. private _length;
  69471. private _sectionPolygonPointsCount;
  69472. private _sectionVectors;
  69473. private _sectionNormalVectors;
  69474. private _beforeRenderObserver;
  69475. /**
  69476. * @constructor
  69477. * @param name The value used by scene.getMeshByName() to do a lookup.
  69478. * @param generator The mesh or transform node to generate a trail.
  69479. * @param scene The scene to add this mesh to.
  69480. * @param diameter Diameter of trailing mesh. Default is 1.
  69481. * @param length Length of trailing mesh. Default is 60.
  69482. * @param autoStart Automatically start trailing mesh. Default true.
  69483. */
  69484. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69485. /**
  69486. * "TrailMesh"
  69487. * @returns "TrailMesh"
  69488. */
  69489. getClassName(): string;
  69490. private _createMesh;
  69491. /**
  69492. * Start trailing mesh.
  69493. */
  69494. start(): void;
  69495. /**
  69496. * Stop trailing mesh.
  69497. */
  69498. stop(): void;
  69499. /**
  69500. * Update trailing mesh geometry.
  69501. */
  69502. update(): void;
  69503. /**
  69504. * Returns a new TrailMesh object.
  69505. * @param name is a string, the name given to the new mesh
  69506. * @param newGenerator use new generator object for cloned trail mesh
  69507. * @returns a new mesh
  69508. */
  69509. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69510. /**
  69511. * Serializes this trail mesh
  69512. * @param serializationObject object to write serialization to
  69513. */
  69514. serialize(serializationObject: any): void;
  69515. /**
  69516. * Parses a serialized trail mesh
  69517. * @param parsedMesh the serialized mesh
  69518. * @param scene the scene to create the trail mesh in
  69519. * @returns the created trail mesh
  69520. */
  69521. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69522. }
  69523. }
  69524. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69525. import { Nullable } from "babylonjs/types";
  69526. import { Scene } from "babylonjs/scene";
  69527. import { Vector4 } from "babylonjs/Maths/math.vector";
  69528. import { Color4 } from "babylonjs/Maths/math.color";
  69529. import { Mesh } from "babylonjs/Meshes/mesh";
  69530. /**
  69531. * Class containing static functions to help procedurally build meshes
  69532. */
  69533. export class TiledBoxBuilder {
  69534. /**
  69535. * Creates a box mesh
  69536. * 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)
  69537. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69541. * @param name defines the name of the mesh
  69542. * @param options defines the options used to create the mesh
  69543. * @param scene defines the hosting scene
  69544. * @returns the box mesh
  69545. */
  69546. static CreateTiledBox(name: string, options: {
  69547. pattern?: number;
  69548. width?: number;
  69549. height?: number;
  69550. depth?: number;
  69551. tileSize?: number;
  69552. tileWidth?: number;
  69553. tileHeight?: number;
  69554. alignHorizontal?: number;
  69555. alignVertical?: number;
  69556. faceUV?: Vector4[];
  69557. faceColors?: Color4[];
  69558. sideOrientation?: number;
  69559. updatable?: boolean;
  69560. }, scene?: Nullable<Scene>): Mesh;
  69561. }
  69562. }
  69563. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69564. import { Vector4 } from "babylonjs/Maths/math.vector";
  69565. import { Mesh } from "babylonjs/Meshes/mesh";
  69566. /**
  69567. * Class containing static functions to help procedurally build meshes
  69568. */
  69569. export class TorusKnotBuilder {
  69570. /**
  69571. * Creates a torus knot mesh
  69572. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69573. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69574. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69575. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69579. * @param name defines the name of the mesh
  69580. * @param options defines the options used to create the mesh
  69581. * @param scene defines the hosting scene
  69582. * @returns the torus knot mesh
  69583. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69584. */
  69585. static CreateTorusKnot(name: string, options: {
  69586. radius?: number;
  69587. tube?: number;
  69588. radialSegments?: number;
  69589. tubularSegments?: number;
  69590. p?: number;
  69591. q?: number;
  69592. updatable?: boolean;
  69593. sideOrientation?: number;
  69594. frontUVs?: Vector4;
  69595. backUVs?: Vector4;
  69596. }, scene: any): Mesh;
  69597. }
  69598. }
  69599. declare module "babylonjs/Meshes/polygonMesh" {
  69600. import { Scene } from "babylonjs/scene";
  69601. import { Vector2 } from "babylonjs/Maths/math.vector";
  69602. import { Mesh } from "babylonjs/Meshes/mesh";
  69603. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69604. import { Path2 } from "babylonjs/Maths/math.path";
  69605. /**
  69606. * Polygon
  69607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69608. */
  69609. export class Polygon {
  69610. /**
  69611. * Creates a rectangle
  69612. * @param xmin bottom X coord
  69613. * @param ymin bottom Y coord
  69614. * @param xmax top X coord
  69615. * @param ymax top Y coord
  69616. * @returns points that make the resulting rectation
  69617. */
  69618. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69619. /**
  69620. * Creates a circle
  69621. * @param radius radius of circle
  69622. * @param cx scale in x
  69623. * @param cy scale in y
  69624. * @param numberOfSides number of sides that make up the circle
  69625. * @returns points that make the resulting circle
  69626. */
  69627. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69628. /**
  69629. * Creates a polygon from input string
  69630. * @param input Input polygon data
  69631. * @returns the parsed points
  69632. */
  69633. static Parse(input: string): Vector2[];
  69634. /**
  69635. * Starts building a polygon from x and y coordinates
  69636. * @param x x coordinate
  69637. * @param y y coordinate
  69638. * @returns the started path2
  69639. */
  69640. static StartingAt(x: number, y: number): Path2;
  69641. }
  69642. /**
  69643. * Builds a polygon
  69644. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69645. */
  69646. export class PolygonMeshBuilder {
  69647. private _points;
  69648. private _outlinepoints;
  69649. private _holes;
  69650. private _name;
  69651. private _scene;
  69652. private _epoints;
  69653. private _eholes;
  69654. private _addToepoint;
  69655. /**
  69656. * Babylon reference to the earcut plugin.
  69657. */
  69658. bjsEarcut: any;
  69659. /**
  69660. * Creates a PolygonMeshBuilder
  69661. * @param name name of the builder
  69662. * @param contours Path of the polygon
  69663. * @param scene scene to add to when creating the mesh
  69664. * @param earcutInjection can be used to inject your own earcut reference
  69665. */
  69666. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69667. /**
  69668. * Adds a whole within the polygon
  69669. * @param hole Array of points defining the hole
  69670. * @returns this
  69671. */
  69672. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69673. /**
  69674. * Creates the polygon
  69675. * @param updatable If the mesh should be updatable
  69676. * @param depth The depth of the mesh created
  69677. * @returns the created mesh
  69678. */
  69679. build(updatable?: boolean, depth?: number): Mesh;
  69680. /**
  69681. * Creates the polygon
  69682. * @param depth The depth of the mesh created
  69683. * @returns the created VertexData
  69684. */
  69685. buildVertexData(depth?: number): VertexData;
  69686. /**
  69687. * Adds a side to the polygon
  69688. * @param positions points that make the polygon
  69689. * @param normals normals of the polygon
  69690. * @param uvs uvs of the polygon
  69691. * @param indices indices of the polygon
  69692. * @param bounds bounds of the polygon
  69693. * @param points points of the polygon
  69694. * @param depth depth of the polygon
  69695. * @param flip flip of the polygon
  69696. */
  69697. private addSide;
  69698. }
  69699. }
  69700. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69701. import { Scene } from "babylonjs/scene";
  69702. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69703. import { Color4 } from "babylonjs/Maths/math.color";
  69704. import { Mesh } from "babylonjs/Meshes/mesh";
  69705. import { Nullable } from "babylonjs/types";
  69706. /**
  69707. * Class containing static functions to help procedurally build meshes
  69708. */
  69709. export class PolygonBuilder {
  69710. /**
  69711. * Creates a polygon mesh
  69712. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69713. * * 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
  69714. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69717. * * Remember you can only change the shape positions, not their number when updating a polygon
  69718. * @param name defines the name of the mesh
  69719. * @param options defines the options used to create the mesh
  69720. * @param scene defines the hosting scene
  69721. * @param earcutInjection can be used to inject your own earcut reference
  69722. * @returns the polygon mesh
  69723. */
  69724. static CreatePolygon(name: string, options: {
  69725. shape: Vector3[];
  69726. holes?: Vector3[][];
  69727. depth?: number;
  69728. faceUV?: Vector4[];
  69729. faceColors?: Color4[];
  69730. updatable?: boolean;
  69731. sideOrientation?: number;
  69732. frontUVs?: Vector4;
  69733. backUVs?: Vector4;
  69734. wrap?: boolean;
  69735. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69736. /**
  69737. * Creates an extruded polygon mesh, with depth in the Y direction.
  69738. * * 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)
  69739. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69740. * @param name defines the name of the mesh
  69741. * @param options defines the options used to create the mesh
  69742. * @param scene defines the hosting scene
  69743. * @param earcutInjection can be used to inject your own earcut reference
  69744. * @returns the polygon mesh
  69745. */
  69746. static ExtrudePolygon(name: string, options: {
  69747. shape: Vector3[];
  69748. holes?: Vector3[][];
  69749. depth?: number;
  69750. faceUV?: Vector4[];
  69751. faceColors?: Color4[];
  69752. updatable?: boolean;
  69753. sideOrientation?: number;
  69754. frontUVs?: Vector4;
  69755. backUVs?: Vector4;
  69756. wrap?: boolean;
  69757. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69758. }
  69759. }
  69760. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69761. import { Scene } from "babylonjs/scene";
  69762. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69763. import { Mesh } from "babylonjs/Meshes/mesh";
  69764. import { Nullable } from "babylonjs/types";
  69765. /**
  69766. * Class containing static functions to help procedurally build meshes
  69767. */
  69768. export class LatheBuilder {
  69769. /**
  69770. * Creates lathe mesh.
  69771. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69772. * * 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
  69773. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69774. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69775. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69776. * * 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
  69777. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69778. * * 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
  69779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69781. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69783. * @param name defines the name of the mesh
  69784. * @param options defines the options used to create the mesh
  69785. * @param scene defines the hosting scene
  69786. * @returns the lathe mesh
  69787. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69788. */
  69789. static CreateLathe(name: string, options: {
  69790. shape: Vector3[];
  69791. radius?: number;
  69792. tessellation?: number;
  69793. clip?: number;
  69794. arc?: number;
  69795. closed?: boolean;
  69796. updatable?: boolean;
  69797. sideOrientation?: number;
  69798. frontUVs?: Vector4;
  69799. backUVs?: Vector4;
  69800. cap?: number;
  69801. invertUV?: boolean;
  69802. }, scene?: Nullable<Scene>): Mesh;
  69803. }
  69804. }
  69805. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69806. import { Nullable } from "babylonjs/types";
  69807. import { Scene } from "babylonjs/scene";
  69808. import { Vector4 } from "babylonjs/Maths/math.vector";
  69809. import { Mesh } from "babylonjs/Meshes/mesh";
  69810. /**
  69811. * Class containing static functions to help procedurally build meshes
  69812. */
  69813. export class TiledPlaneBuilder {
  69814. /**
  69815. * Creates a tiled plane mesh
  69816. * * The parameter `pattern` will, depending on value, do nothing or
  69817. * * * flip (reflect about central vertical) alternate tiles across and up
  69818. * * * flip every tile on alternate rows
  69819. * * * rotate (180 degs) alternate tiles across and up
  69820. * * * rotate every tile on alternate rows
  69821. * * * flip and rotate alternate tiles across and up
  69822. * * * flip and rotate every tile on alternate rows
  69823. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69824. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69827. * * 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)
  69828. * * 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)
  69829. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69830. * @param name defines the name of the mesh
  69831. * @param options defines the options used to create the mesh
  69832. * @param scene defines the hosting scene
  69833. * @returns the box mesh
  69834. */
  69835. static CreateTiledPlane(name: string, options: {
  69836. pattern?: number;
  69837. tileSize?: number;
  69838. tileWidth?: number;
  69839. tileHeight?: number;
  69840. size?: number;
  69841. width?: number;
  69842. height?: number;
  69843. alignHorizontal?: number;
  69844. alignVertical?: number;
  69845. sideOrientation?: number;
  69846. frontUVs?: Vector4;
  69847. backUVs?: Vector4;
  69848. updatable?: boolean;
  69849. }, scene?: Nullable<Scene>): Mesh;
  69850. }
  69851. }
  69852. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69853. import { Nullable } from "babylonjs/types";
  69854. import { Scene } from "babylonjs/scene";
  69855. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69856. import { Mesh } from "babylonjs/Meshes/mesh";
  69857. /**
  69858. * Class containing static functions to help procedurally build meshes
  69859. */
  69860. export class TubeBuilder {
  69861. /**
  69862. * Creates a tube mesh.
  69863. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69864. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69865. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69866. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69867. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69868. * * 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)
  69869. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69870. * * 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
  69871. * * 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
  69872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69874. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69876. * @param name defines the name of the mesh
  69877. * @param options defines the options used to create the mesh
  69878. * @param scene defines the hosting scene
  69879. * @returns the tube mesh
  69880. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69881. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69882. */
  69883. static CreateTube(name: string, options: {
  69884. path: Vector3[];
  69885. radius?: number;
  69886. tessellation?: number;
  69887. radiusFunction?: {
  69888. (i: number, distance: number): number;
  69889. };
  69890. cap?: number;
  69891. arc?: number;
  69892. updatable?: boolean;
  69893. sideOrientation?: number;
  69894. frontUVs?: Vector4;
  69895. backUVs?: Vector4;
  69896. instance?: Mesh;
  69897. invertUV?: boolean;
  69898. }, scene?: Nullable<Scene>): Mesh;
  69899. }
  69900. }
  69901. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69902. import { Scene } from "babylonjs/scene";
  69903. import { Vector4 } from "babylonjs/Maths/math.vector";
  69904. import { Mesh } from "babylonjs/Meshes/mesh";
  69905. import { Nullable } from "babylonjs/types";
  69906. /**
  69907. * Class containing static functions to help procedurally build meshes
  69908. */
  69909. export class IcoSphereBuilder {
  69910. /**
  69911. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69912. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69913. * * 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`)
  69914. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69915. * * 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
  69916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69919. * @param name defines the name of the mesh
  69920. * @param options defines the options used to create the mesh
  69921. * @param scene defines the hosting scene
  69922. * @returns the icosahedron mesh
  69923. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69924. */
  69925. static CreateIcoSphere(name: string, options: {
  69926. radius?: number;
  69927. radiusX?: number;
  69928. radiusY?: number;
  69929. radiusZ?: number;
  69930. flat?: boolean;
  69931. subdivisions?: number;
  69932. sideOrientation?: number;
  69933. frontUVs?: Vector4;
  69934. backUVs?: Vector4;
  69935. updatable?: boolean;
  69936. }, scene?: Nullable<Scene>): Mesh;
  69937. }
  69938. }
  69939. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69940. import { Vector3 } from "babylonjs/Maths/math.vector";
  69941. import { Mesh } from "babylonjs/Meshes/mesh";
  69942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69943. /**
  69944. * Class containing static functions to help procedurally build meshes
  69945. */
  69946. export class DecalBuilder {
  69947. /**
  69948. * Creates a decal mesh.
  69949. * 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
  69950. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69951. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69952. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69953. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69954. * @param name defines the name of the mesh
  69955. * @param sourceMesh defines the mesh where the decal must be applied
  69956. * @param options defines the options used to create the mesh
  69957. * @param scene defines the hosting scene
  69958. * @returns the decal mesh
  69959. * @see https://doc.babylonjs.com/how_to/decals
  69960. */
  69961. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69962. position?: Vector3;
  69963. normal?: Vector3;
  69964. size?: Vector3;
  69965. angle?: number;
  69966. }): Mesh;
  69967. }
  69968. }
  69969. declare module "babylonjs/Meshes/meshBuilder" {
  69970. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69971. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69972. import { Nullable } from "babylonjs/types";
  69973. import { Scene } from "babylonjs/scene";
  69974. import { Mesh } from "babylonjs/Meshes/mesh";
  69975. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69976. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69978. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69979. import { Plane } from "babylonjs/Maths/math.plane";
  69980. /**
  69981. * Class containing static functions to help procedurally build meshes
  69982. */
  69983. export class MeshBuilder {
  69984. /**
  69985. * Creates a box mesh
  69986. * * The parameter `size` sets the size (float) of each box side (default 1)
  69987. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69988. * * 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)
  69989. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69993. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69994. * @param name defines the name of the mesh
  69995. * @param options defines the options used to create the mesh
  69996. * @param scene defines the hosting scene
  69997. * @returns the box mesh
  69998. */
  69999. static CreateBox(name: string, options: {
  70000. size?: number;
  70001. width?: number;
  70002. height?: number;
  70003. depth?: number;
  70004. faceUV?: Vector4[];
  70005. faceColors?: Color4[];
  70006. sideOrientation?: number;
  70007. frontUVs?: Vector4;
  70008. backUVs?: Vector4;
  70009. wrap?: boolean;
  70010. topBaseAt?: number;
  70011. bottomBaseAt?: number;
  70012. updatable?: boolean;
  70013. }, scene?: Nullable<Scene>): Mesh;
  70014. /**
  70015. * Creates a tiled box mesh
  70016. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70018. * @param name defines the name of the mesh
  70019. * @param options defines the options used to create the mesh
  70020. * @param scene defines the hosting scene
  70021. * @returns the tiled box mesh
  70022. */
  70023. static CreateTiledBox(name: string, options: {
  70024. pattern?: number;
  70025. size?: number;
  70026. width?: number;
  70027. height?: number;
  70028. depth: number;
  70029. tileSize?: number;
  70030. tileWidth?: number;
  70031. tileHeight?: number;
  70032. faceUV?: Vector4[];
  70033. faceColors?: Color4[];
  70034. alignHorizontal?: number;
  70035. alignVertical?: number;
  70036. sideOrientation?: number;
  70037. updatable?: boolean;
  70038. }, scene?: Nullable<Scene>): Mesh;
  70039. /**
  70040. * Creates a sphere mesh
  70041. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70042. * * 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`)
  70043. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70044. * * 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
  70045. * * 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)
  70046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70049. * @param name defines the name of the mesh
  70050. * @param options defines the options used to create the mesh
  70051. * @param scene defines the hosting scene
  70052. * @returns the sphere mesh
  70053. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70054. */
  70055. static CreateSphere(name: string, options: {
  70056. segments?: number;
  70057. diameter?: number;
  70058. diameterX?: number;
  70059. diameterY?: number;
  70060. diameterZ?: number;
  70061. arc?: number;
  70062. slice?: number;
  70063. sideOrientation?: number;
  70064. frontUVs?: Vector4;
  70065. backUVs?: Vector4;
  70066. updatable?: boolean;
  70067. }, scene?: Nullable<Scene>): Mesh;
  70068. /**
  70069. * Creates a plane polygonal mesh. By default, this is a disc
  70070. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70071. * * 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
  70072. * * 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
  70073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70076. * @param name defines the name of the mesh
  70077. * @param options defines the options used to create the mesh
  70078. * @param scene defines the hosting scene
  70079. * @returns the plane polygonal mesh
  70080. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70081. */
  70082. static CreateDisc(name: string, options: {
  70083. radius?: number;
  70084. tessellation?: number;
  70085. arc?: number;
  70086. updatable?: boolean;
  70087. sideOrientation?: number;
  70088. frontUVs?: Vector4;
  70089. backUVs?: Vector4;
  70090. }, scene?: Nullable<Scene>): Mesh;
  70091. /**
  70092. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70093. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70094. * * 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`)
  70095. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70096. * * 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
  70097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70100. * @param name defines the name of the mesh
  70101. * @param options defines the options used to create the mesh
  70102. * @param scene defines the hosting scene
  70103. * @returns the icosahedron mesh
  70104. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70105. */
  70106. static CreateIcoSphere(name: string, options: {
  70107. radius?: number;
  70108. radiusX?: number;
  70109. radiusY?: number;
  70110. radiusZ?: number;
  70111. flat?: boolean;
  70112. subdivisions?: number;
  70113. sideOrientation?: number;
  70114. frontUVs?: Vector4;
  70115. backUVs?: Vector4;
  70116. updatable?: boolean;
  70117. }, scene?: Nullable<Scene>): Mesh;
  70118. /**
  70119. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70120. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70121. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70122. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70123. * * 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
  70124. * * 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
  70125. * * 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
  70126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70128. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70129. * * 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
  70130. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70131. * * 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
  70132. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70134. * @param name defines the name of the mesh
  70135. * @param options defines the options used to create the mesh
  70136. * @param scene defines the hosting scene
  70137. * @returns the ribbon mesh
  70138. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70139. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70140. */
  70141. static CreateRibbon(name: string, options: {
  70142. pathArray: Vector3[][];
  70143. closeArray?: boolean;
  70144. closePath?: boolean;
  70145. offset?: number;
  70146. updatable?: boolean;
  70147. sideOrientation?: number;
  70148. frontUVs?: Vector4;
  70149. backUVs?: Vector4;
  70150. instance?: Mesh;
  70151. invertUV?: boolean;
  70152. uvs?: Vector2[];
  70153. colors?: Color4[];
  70154. }, scene?: Nullable<Scene>): Mesh;
  70155. /**
  70156. * Creates a cylinder or a cone mesh
  70157. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70158. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70159. * * 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.
  70160. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70161. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70162. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70163. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70164. * * 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).
  70165. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70166. * * 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).
  70167. * * 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
  70168. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70169. * * 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
  70170. * * 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.
  70171. * * If `enclose` is false, a ring surface is one element.
  70172. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70173. * * 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
  70174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70177. * @param name defines the name of the mesh
  70178. * @param options defines the options used to create the mesh
  70179. * @param scene defines the hosting scene
  70180. * @returns the cylinder mesh
  70181. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70182. */
  70183. static CreateCylinder(name: string, options: {
  70184. height?: number;
  70185. diameterTop?: number;
  70186. diameterBottom?: number;
  70187. diameter?: number;
  70188. tessellation?: number;
  70189. subdivisions?: number;
  70190. arc?: number;
  70191. faceColors?: Color4[];
  70192. faceUV?: Vector4[];
  70193. updatable?: boolean;
  70194. hasRings?: boolean;
  70195. enclose?: boolean;
  70196. cap?: number;
  70197. sideOrientation?: number;
  70198. frontUVs?: Vector4;
  70199. backUVs?: Vector4;
  70200. }, scene?: Nullable<Scene>): Mesh;
  70201. /**
  70202. * Creates a torus mesh
  70203. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70204. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70205. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70209. * @param name defines the name of the mesh
  70210. * @param options defines the options used to create the mesh
  70211. * @param scene defines the hosting scene
  70212. * @returns the torus mesh
  70213. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70214. */
  70215. static CreateTorus(name: string, options: {
  70216. diameter?: number;
  70217. thickness?: number;
  70218. tessellation?: number;
  70219. updatable?: boolean;
  70220. sideOrientation?: number;
  70221. frontUVs?: Vector4;
  70222. backUVs?: Vector4;
  70223. }, scene?: Nullable<Scene>): Mesh;
  70224. /**
  70225. * Creates a torus knot mesh
  70226. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70227. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70228. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70229. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70233. * @param name defines the name of the mesh
  70234. * @param options defines the options used to create the mesh
  70235. * @param scene defines the hosting scene
  70236. * @returns the torus knot mesh
  70237. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70238. */
  70239. static CreateTorusKnot(name: string, options: {
  70240. radius?: number;
  70241. tube?: number;
  70242. radialSegments?: number;
  70243. tubularSegments?: number;
  70244. p?: number;
  70245. q?: number;
  70246. updatable?: boolean;
  70247. sideOrientation?: number;
  70248. frontUVs?: Vector4;
  70249. backUVs?: Vector4;
  70250. }, scene?: Nullable<Scene>): Mesh;
  70251. /**
  70252. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70253. * * 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
  70254. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70255. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70256. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70257. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70258. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70259. * * 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
  70260. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70263. * @param name defines the name of the new line system
  70264. * @param options defines the options used to create the line system
  70265. * @param scene defines the hosting scene
  70266. * @returns a new line system mesh
  70267. */
  70268. static CreateLineSystem(name: string, options: {
  70269. lines: Vector3[][];
  70270. updatable?: boolean;
  70271. instance?: Nullable<LinesMesh>;
  70272. colors?: Nullable<Color4[][]>;
  70273. useVertexAlpha?: boolean;
  70274. }, scene: Nullable<Scene>): LinesMesh;
  70275. /**
  70276. * Creates a line mesh
  70277. * 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
  70278. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70279. * * The parameter `points` is an array successive Vector3
  70280. * * 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
  70281. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70282. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70283. * * When updating an instance, remember that only point positions can change, not the number of points
  70284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70286. * @param name defines the name of the new line system
  70287. * @param options defines the options used to create the line system
  70288. * @param scene defines the hosting scene
  70289. * @returns a new line mesh
  70290. */
  70291. static CreateLines(name: string, options: {
  70292. points: Vector3[];
  70293. updatable?: boolean;
  70294. instance?: Nullable<LinesMesh>;
  70295. colors?: Color4[];
  70296. useVertexAlpha?: boolean;
  70297. }, scene?: Nullable<Scene>): LinesMesh;
  70298. /**
  70299. * Creates a dashed line mesh
  70300. * * 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
  70301. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70302. * * The parameter `points` is an array successive Vector3
  70303. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70304. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70305. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70306. * * 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
  70307. * * When updating an instance, remember that only point positions can change, not the number of points
  70308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70309. * @param name defines the name of the mesh
  70310. * @param options defines the options used to create the mesh
  70311. * @param scene defines the hosting scene
  70312. * @returns the dashed line mesh
  70313. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70314. */
  70315. static CreateDashedLines(name: string, options: {
  70316. points: Vector3[];
  70317. dashSize?: number;
  70318. gapSize?: number;
  70319. dashNb?: number;
  70320. updatable?: boolean;
  70321. instance?: LinesMesh;
  70322. }, scene?: Nullable<Scene>): LinesMesh;
  70323. /**
  70324. * 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.
  70325. * * 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.
  70326. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70327. * * 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.
  70328. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70329. * * 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
  70330. * * 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
  70331. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70336. * @param name defines the name of the mesh
  70337. * @param options defines the options used to create the mesh
  70338. * @param scene defines the hosting scene
  70339. * @returns the extruded shape mesh
  70340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70342. */
  70343. static ExtrudeShape(name: string, options: {
  70344. shape: Vector3[];
  70345. path: Vector3[];
  70346. scale?: number;
  70347. rotation?: number;
  70348. cap?: number;
  70349. updatable?: boolean;
  70350. sideOrientation?: number;
  70351. frontUVs?: Vector4;
  70352. backUVs?: Vector4;
  70353. instance?: Mesh;
  70354. invertUV?: boolean;
  70355. }, scene?: Nullable<Scene>): Mesh;
  70356. /**
  70357. * Creates an custom extruded shape mesh.
  70358. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70359. * * 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.
  70360. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70361. * * 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
  70362. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70363. * * 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
  70364. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70365. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70366. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70367. * * 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
  70368. * * 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
  70369. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70374. * @param name defines the name of the mesh
  70375. * @param options defines the options used to create the mesh
  70376. * @param scene defines the hosting scene
  70377. * @returns the custom extruded shape mesh
  70378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70379. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70380. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70381. */
  70382. static ExtrudeShapeCustom(name: string, options: {
  70383. shape: Vector3[];
  70384. path: Vector3[];
  70385. scaleFunction?: any;
  70386. rotationFunction?: any;
  70387. ribbonCloseArray?: boolean;
  70388. ribbonClosePath?: boolean;
  70389. cap?: number;
  70390. updatable?: boolean;
  70391. sideOrientation?: number;
  70392. frontUVs?: Vector4;
  70393. backUVs?: Vector4;
  70394. instance?: Mesh;
  70395. invertUV?: boolean;
  70396. }, scene?: Nullable<Scene>): Mesh;
  70397. /**
  70398. * Creates lathe mesh.
  70399. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70400. * * 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
  70401. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70402. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70403. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70404. * * 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
  70405. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70406. * * 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
  70407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70409. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70411. * @param name defines the name of the mesh
  70412. * @param options defines the options used to create the mesh
  70413. * @param scene defines the hosting scene
  70414. * @returns the lathe mesh
  70415. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70416. */
  70417. static CreateLathe(name: string, options: {
  70418. shape: Vector3[];
  70419. radius?: number;
  70420. tessellation?: number;
  70421. clip?: number;
  70422. arc?: number;
  70423. closed?: boolean;
  70424. updatable?: boolean;
  70425. sideOrientation?: number;
  70426. frontUVs?: Vector4;
  70427. backUVs?: Vector4;
  70428. cap?: number;
  70429. invertUV?: boolean;
  70430. }, scene?: Nullable<Scene>): Mesh;
  70431. /**
  70432. * Creates a tiled plane mesh
  70433. * * You can set a limited pattern arrangement with the tiles
  70434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70437. * @param name defines the name of the mesh
  70438. * @param options defines the options used to create the mesh
  70439. * @param scene defines the hosting scene
  70440. * @returns the plane mesh
  70441. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70442. */
  70443. static CreateTiledPlane(name: string, options: {
  70444. pattern?: number;
  70445. tileSize?: number;
  70446. tileWidth?: number;
  70447. tileHeight?: number;
  70448. size?: number;
  70449. width?: number;
  70450. height?: number;
  70451. alignHorizontal?: number;
  70452. alignVertical?: number;
  70453. sideOrientation?: number;
  70454. frontUVs?: Vector4;
  70455. backUVs?: Vector4;
  70456. updatable?: boolean;
  70457. }, scene?: Nullable<Scene>): Mesh;
  70458. /**
  70459. * Creates a plane mesh
  70460. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70461. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70462. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70466. * @param name defines the name of the mesh
  70467. * @param options defines the options used to create the mesh
  70468. * @param scene defines the hosting scene
  70469. * @returns the plane mesh
  70470. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70471. */
  70472. static CreatePlane(name: string, options: {
  70473. size?: number;
  70474. width?: number;
  70475. height?: number;
  70476. sideOrientation?: number;
  70477. frontUVs?: Vector4;
  70478. backUVs?: Vector4;
  70479. updatable?: boolean;
  70480. sourcePlane?: Plane;
  70481. }, scene?: Nullable<Scene>): Mesh;
  70482. /**
  70483. * Creates a ground mesh
  70484. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70485. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70487. * @param name defines the name of the mesh
  70488. * @param options defines the options used to create the mesh
  70489. * @param scene defines the hosting scene
  70490. * @returns the ground mesh
  70491. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70492. */
  70493. static CreateGround(name: string, options: {
  70494. width?: number;
  70495. height?: number;
  70496. subdivisions?: number;
  70497. subdivisionsX?: number;
  70498. subdivisionsY?: number;
  70499. updatable?: boolean;
  70500. }, scene?: Nullable<Scene>): Mesh;
  70501. /**
  70502. * Creates a tiled ground mesh
  70503. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70504. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70505. * * 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
  70506. * * 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
  70507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70508. * @param name defines the name of the mesh
  70509. * @param options defines the options used to create the mesh
  70510. * @param scene defines the hosting scene
  70511. * @returns the tiled ground mesh
  70512. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70513. */
  70514. static CreateTiledGround(name: string, options: {
  70515. xmin: number;
  70516. zmin: number;
  70517. xmax: number;
  70518. zmax: number;
  70519. subdivisions?: {
  70520. w: number;
  70521. h: number;
  70522. };
  70523. precision?: {
  70524. w: number;
  70525. h: number;
  70526. };
  70527. updatable?: boolean;
  70528. }, scene?: Nullable<Scene>): Mesh;
  70529. /**
  70530. * Creates a ground mesh from a height map
  70531. * * The parameter `url` sets the URL of the height map image resource.
  70532. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70533. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70534. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70535. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70536. * * 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.
  70537. * * 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).
  70538. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70540. * @param name defines the name of the mesh
  70541. * @param url defines the url to the height map
  70542. * @param options defines the options used to create the mesh
  70543. * @param scene defines the hosting scene
  70544. * @returns the ground mesh
  70545. * @see https://doc.babylonjs.com/babylon101/height_map
  70546. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70547. */
  70548. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70549. width?: number;
  70550. height?: number;
  70551. subdivisions?: number;
  70552. minHeight?: number;
  70553. maxHeight?: number;
  70554. colorFilter?: Color3;
  70555. alphaFilter?: number;
  70556. updatable?: boolean;
  70557. onReady?: (mesh: GroundMesh) => void;
  70558. }, scene?: Nullable<Scene>): GroundMesh;
  70559. /**
  70560. * Creates a polygon mesh
  70561. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70562. * * 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
  70563. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70566. * * Remember you can only change the shape positions, not their number when updating a polygon
  70567. * @param name defines the name of the mesh
  70568. * @param options defines the options used to create the mesh
  70569. * @param scene defines the hosting scene
  70570. * @param earcutInjection can be used to inject your own earcut reference
  70571. * @returns the polygon mesh
  70572. */
  70573. static CreatePolygon(name: string, options: {
  70574. shape: Vector3[];
  70575. holes?: Vector3[][];
  70576. depth?: number;
  70577. faceUV?: Vector4[];
  70578. faceColors?: Color4[];
  70579. updatable?: boolean;
  70580. sideOrientation?: number;
  70581. frontUVs?: Vector4;
  70582. backUVs?: Vector4;
  70583. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70584. /**
  70585. * Creates an extruded polygon mesh, with depth in the Y direction.
  70586. * * 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)
  70587. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70588. * @param name defines the name of the mesh
  70589. * @param options defines the options used to create the mesh
  70590. * @param scene defines the hosting scene
  70591. * @param earcutInjection can be used to inject your own earcut reference
  70592. * @returns the polygon mesh
  70593. */
  70594. static ExtrudePolygon(name: string, options: {
  70595. shape: Vector3[];
  70596. holes?: Vector3[][];
  70597. depth?: number;
  70598. faceUV?: Vector4[];
  70599. faceColors?: Color4[];
  70600. updatable?: boolean;
  70601. sideOrientation?: number;
  70602. frontUVs?: Vector4;
  70603. backUVs?: Vector4;
  70604. wrap?: boolean;
  70605. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70606. /**
  70607. * Creates a tube mesh.
  70608. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70609. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70610. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70611. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70612. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70613. * * 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)
  70614. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70615. * * 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
  70616. * * 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
  70617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70619. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70621. * @param name defines the name of the mesh
  70622. * @param options defines the options used to create the mesh
  70623. * @param scene defines the hosting scene
  70624. * @returns the tube mesh
  70625. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70626. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70627. */
  70628. static CreateTube(name: string, options: {
  70629. path: Vector3[];
  70630. radius?: number;
  70631. tessellation?: number;
  70632. radiusFunction?: {
  70633. (i: number, distance: number): number;
  70634. };
  70635. cap?: number;
  70636. arc?: number;
  70637. updatable?: boolean;
  70638. sideOrientation?: number;
  70639. frontUVs?: Vector4;
  70640. backUVs?: Vector4;
  70641. instance?: Mesh;
  70642. invertUV?: boolean;
  70643. }, scene?: Nullable<Scene>): Mesh;
  70644. /**
  70645. * Creates a polyhedron mesh
  70646. * * 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
  70647. * * The parameter `size` (positive float, default 1) sets the polygon size
  70648. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70649. * * 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`
  70650. * * 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
  70651. * * 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)`)
  70652. * * 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
  70653. * * 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
  70654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70657. * @param name defines the name of the mesh
  70658. * @param options defines the options used to create the mesh
  70659. * @param scene defines the hosting scene
  70660. * @returns the polyhedron mesh
  70661. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70662. */
  70663. static CreatePolyhedron(name: string, options: {
  70664. type?: number;
  70665. size?: number;
  70666. sizeX?: number;
  70667. sizeY?: number;
  70668. sizeZ?: number;
  70669. custom?: any;
  70670. faceUV?: Vector4[];
  70671. faceColors?: Color4[];
  70672. flat?: boolean;
  70673. updatable?: boolean;
  70674. sideOrientation?: number;
  70675. frontUVs?: Vector4;
  70676. backUVs?: Vector4;
  70677. }, scene?: Nullable<Scene>): Mesh;
  70678. /**
  70679. * Creates a decal mesh.
  70680. * 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
  70681. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70682. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70683. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70684. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70685. * @param name defines the name of the mesh
  70686. * @param sourceMesh defines the mesh where the decal must be applied
  70687. * @param options defines the options used to create the mesh
  70688. * @param scene defines the hosting scene
  70689. * @returns the decal mesh
  70690. * @see https://doc.babylonjs.com/how_to/decals
  70691. */
  70692. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70693. position?: Vector3;
  70694. normal?: Vector3;
  70695. size?: Vector3;
  70696. angle?: number;
  70697. }): Mesh;
  70698. /**
  70699. * Creates a Capsule Mesh
  70700. * @param name defines the name of the mesh.
  70701. * @param options the constructors options used to shape the mesh.
  70702. * @param scene defines the scene the mesh is scoped to.
  70703. * @returns the capsule mesh
  70704. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70705. */
  70706. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70707. }
  70708. }
  70709. declare module "babylonjs/Meshes/meshSimplification" {
  70710. import { Mesh } from "babylonjs/Meshes/mesh";
  70711. /**
  70712. * A simplifier interface for future simplification implementations
  70713. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70714. */
  70715. export interface ISimplifier {
  70716. /**
  70717. * Simplification of a given mesh according to the given settings.
  70718. * Since this requires computation, it is assumed that the function runs async.
  70719. * @param settings The settings of the simplification, including quality and distance
  70720. * @param successCallback A callback that will be called after the mesh was simplified.
  70721. * @param errorCallback in case of an error, this callback will be called. optional.
  70722. */
  70723. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70724. }
  70725. /**
  70726. * Expected simplification settings.
  70727. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70728. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70729. */
  70730. export interface ISimplificationSettings {
  70731. /**
  70732. * Gets or sets the expected quality
  70733. */
  70734. quality: number;
  70735. /**
  70736. * Gets or sets the distance when this optimized version should be used
  70737. */
  70738. distance: number;
  70739. /**
  70740. * Gets an already optimized mesh
  70741. */
  70742. optimizeMesh?: boolean;
  70743. }
  70744. /**
  70745. * Class used to specify simplification options
  70746. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70747. */
  70748. export class SimplificationSettings implements ISimplificationSettings {
  70749. /** expected quality */
  70750. quality: number;
  70751. /** distance when this optimized version should be used */
  70752. distance: number;
  70753. /** already optimized mesh */
  70754. optimizeMesh?: boolean | undefined;
  70755. /**
  70756. * Creates a SimplificationSettings
  70757. * @param quality expected quality
  70758. * @param distance distance when this optimized version should be used
  70759. * @param optimizeMesh already optimized mesh
  70760. */
  70761. constructor(
  70762. /** expected quality */
  70763. quality: number,
  70764. /** distance when this optimized version should be used */
  70765. distance: number,
  70766. /** already optimized mesh */
  70767. optimizeMesh?: boolean | undefined);
  70768. }
  70769. /**
  70770. * Interface used to define a simplification task
  70771. */
  70772. export interface ISimplificationTask {
  70773. /**
  70774. * Array of settings
  70775. */
  70776. settings: Array<ISimplificationSettings>;
  70777. /**
  70778. * Simplification type
  70779. */
  70780. simplificationType: SimplificationType;
  70781. /**
  70782. * Mesh to simplify
  70783. */
  70784. mesh: Mesh;
  70785. /**
  70786. * Callback called on success
  70787. */
  70788. successCallback?: () => void;
  70789. /**
  70790. * Defines if parallel processing can be used
  70791. */
  70792. parallelProcessing: boolean;
  70793. }
  70794. /**
  70795. * Queue used to order the simplification tasks
  70796. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70797. */
  70798. export class SimplificationQueue {
  70799. private _simplificationArray;
  70800. /**
  70801. * Gets a boolean indicating that the process is still running
  70802. */
  70803. running: boolean;
  70804. /**
  70805. * Creates a new queue
  70806. */
  70807. constructor();
  70808. /**
  70809. * Adds a new simplification task
  70810. * @param task defines a task to add
  70811. */
  70812. addTask(task: ISimplificationTask): void;
  70813. /**
  70814. * Execute next task
  70815. */
  70816. executeNext(): void;
  70817. /**
  70818. * Execute a simplification task
  70819. * @param task defines the task to run
  70820. */
  70821. runSimplification(task: ISimplificationTask): void;
  70822. private getSimplifier;
  70823. }
  70824. /**
  70825. * The implemented types of simplification
  70826. * At the moment only Quadratic Error Decimation is implemented
  70827. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70828. */
  70829. export enum SimplificationType {
  70830. /** Quadratic error decimation */
  70831. QUADRATIC = 0
  70832. }
  70833. /**
  70834. * An implementation of the Quadratic Error simplification algorithm.
  70835. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70836. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70837. * @author RaananW
  70838. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70839. */
  70840. export class QuadraticErrorSimplification implements ISimplifier {
  70841. private _mesh;
  70842. private triangles;
  70843. private vertices;
  70844. private references;
  70845. private _reconstructedMesh;
  70846. /** Gets or sets the number pf sync interations */
  70847. syncIterations: number;
  70848. /** Gets or sets the aggressiveness of the simplifier */
  70849. aggressiveness: number;
  70850. /** Gets or sets the number of allowed iterations for decimation */
  70851. decimationIterations: number;
  70852. /** Gets or sets the espilon to use for bounding box computation */
  70853. boundingBoxEpsilon: number;
  70854. /**
  70855. * Creates a new QuadraticErrorSimplification
  70856. * @param _mesh defines the target mesh
  70857. */
  70858. constructor(_mesh: Mesh);
  70859. /**
  70860. * Simplification of a given mesh according to the given settings.
  70861. * Since this requires computation, it is assumed that the function runs async.
  70862. * @param settings The settings of the simplification, including quality and distance
  70863. * @param successCallback A callback that will be called after the mesh was simplified.
  70864. */
  70865. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70866. private runDecimation;
  70867. private initWithMesh;
  70868. private init;
  70869. private reconstructMesh;
  70870. private initDecimatedMesh;
  70871. private isFlipped;
  70872. private updateTriangles;
  70873. private identifyBorder;
  70874. private updateMesh;
  70875. private vertexError;
  70876. private calculateError;
  70877. }
  70878. }
  70879. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70880. import { Scene } from "babylonjs/scene";
  70881. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70882. import { ISceneComponent } from "babylonjs/sceneComponent";
  70883. module "babylonjs/scene" {
  70884. interface Scene {
  70885. /** @hidden (Backing field) */
  70886. _simplificationQueue: SimplificationQueue;
  70887. /**
  70888. * Gets or sets the simplification queue attached to the scene
  70889. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70890. */
  70891. simplificationQueue: SimplificationQueue;
  70892. }
  70893. }
  70894. module "babylonjs/Meshes/mesh" {
  70895. interface Mesh {
  70896. /**
  70897. * Simplify the mesh according to the given array of settings.
  70898. * Function will return immediately and will simplify async
  70899. * @param settings a collection of simplification settings
  70900. * @param parallelProcessing should all levels calculate parallel or one after the other
  70901. * @param simplificationType the type of simplification to run
  70902. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70903. * @returns the current mesh
  70904. */
  70905. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70906. }
  70907. }
  70908. /**
  70909. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70910. * created in a scene
  70911. */
  70912. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70913. /**
  70914. * The component name helpfull to identify the component in the list of scene components.
  70915. */
  70916. readonly name: string;
  70917. /**
  70918. * The scene the component belongs to.
  70919. */
  70920. scene: Scene;
  70921. /**
  70922. * Creates a new instance of the component for the given scene
  70923. * @param scene Defines the scene to register the component in
  70924. */
  70925. constructor(scene: Scene);
  70926. /**
  70927. * Registers the component in a given scene
  70928. */
  70929. register(): void;
  70930. /**
  70931. * Rebuilds the elements related to this component in case of
  70932. * context lost for instance.
  70933. */
  70934. rebuild(): void;
  70935. /**
  70936. * Disposes the component and the associated ressources
  70937. */
  70938. dispose(): void;
  70939. private _beforeCameraUpdate;
  70940. }
  70941. }
  70942. declare module "babylonjs/Meshes/Builders/index" {
  70943. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70944. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70945. export * from "babylonjs/Meshes/Builders/discBuilder";
  70946. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70947. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70948. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70949. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70950. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70951. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70952. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70953. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70954. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70955. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70956. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70957. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70958. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70959. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70960. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70961. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70962. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70963. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70964. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70965. }
  70966. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70967. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70968. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70969. import { Matrix } from "babylonjs/Maths/math.vector";
  70970. module "babylonjs/Meshes/mesh" {
  70971. interface Mesh {
  70972. /**
  70973. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70974. */
  70975. thinInstanceEnablePicking: boolean;
  70976. /**
  70977. * Creates a new thin instance
  70978. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70979. * @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
  70980. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70981. */
  70982. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70983. /**
  70984. * Adds the transformation (matrix) of the current mesh as a thin instance
  70985. * @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
  70986. * @returns the thin instance index number
  70987. */
  70988. thinInstanceAddSelf(refresh: boolean): number;
  70989. /**
  70990. * Registers a custom attribute to be used with thin instances
  70991. * @param kind name of the attribute
  70992. * @param stride size in floats of the attribute
  70993. */
  70994. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70995. /**
  70996. * Sets the matrix of a thin instance
  70997. * @param index index of the thin instance
  70998. * @param matrix matrix to set
  70999. * @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
  71000. */
  71001. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71002. /**
  71003. * Sets the value of a custom attribute for a thin instance
  71004. * @param kind name of the attribute
  71005. * @param index index of the thin instance
  71006. * @param value value to set
  71007. * @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
  71008. */
  71009. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71010. /**
  71011. * 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.
  71012. */
  71013. thinInstanceCount: number;
  71014. /**
  71015. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71016. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71017. * @param buffer buffer to set
  71018. * @param stride size in floats of each value of the buffer
  71019. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71020. */
  71021. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71022. /**
  71023. * Gets the list of world matrices
  71024. * @return an array containing all the world matrices from the thin instances
  71025. */
  71026. thinInstanceGetWorldMatrices(): Matrix[];
  71027. /**
  71028. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71029. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71030. */
  71031. thinInstanceBufferUpdated(kind: string): void;
  71032. /**
  71033. * Applies a partial update to a buffer directly on the GPU
  71034. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  71035. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71036. * @param data the data to set in the GPU buffer
  71037. * @param offset the offset in the GPU buffer where to update the data
  71038. */
  71039. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71040. /**
  71041. * Refreshes the bounding info, taking into account all the thin instances defined
  71042. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71043. */
  71044. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71045. /** @hidden */
  71046. _thinInstanceInitializeUserStorage(): void;
  71047. /** @hidden */
  71048. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71049. /** @hidden */
  71050. _userThinInstanceBuffersStorage: {
  71051. data: {
  71052. [key: string]: Float32Array;
  71053. };
  71054. sizes: {
  71055. [key: string]: number;
  71056. };
  71057. vertexBuffers: {
  71058. [key: string]: Nullable<VertexBuffer>;
  71059. };
  71060. strides: {
  71061. [key: string]: number;
  71062. };
  71063. };
  71064. }
  71065. }
  71066. }
  71067. declare module "babylonjs/Meshes/index" {
  71068. export * from "babylonjs/Meshes/abstractMesh";
  71069. export * from "babylonjs/Meshes/buffer";
  71070. export * from "babylonjs/Meshes/Compression/index";
  71071. export * from "babylonjs/Meshes/csg";
  71072. export * from "babylonjs/Meshes/geometry";
  71073. export * from "babylonjs/Meshes/groundMesh";
  71074. export * from "babylonjs/Meshes/trailMesh";
  71075. export * from "babylonjs/Meshes/instancedMesh";
  71076. export * from "babylonjs/Meshes/linesMesh";
  71077. export * from "babylonjs/Meshes/mesh";
  71078. export * from "babylonjs/Meshes/mesh.vertexData";
  71079. export * from "babylonjs/Meshes/meshBuilder";
  71080. export * from "babylonjs/Meshes/meshSimplification";
  71081. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71082. export * from "babylonjs/Meshes/polygonMesh";
  71083. export * from "babylonjs/Meshes/subMesh";
  71084. export * from "babylonjs/Meshes/meshLODLevel";
  71085. export * from "babylonjs/Meshes/transformNode";
  71086. export * from "babylonjs/Meshes/Builders/index";
  71087. export * from "babylonjs/Meshes/dataBuffer";
  71088. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71089. import "babylonjs/Meshes/thinInstanceMesh";
  71090. export * from "babylonjs/Meshes/thinInstanceMesh";
  71091. }
  71092. declare module "babylonjs/Morph/index" {
  71093. export * from "babylonjs/Morph/morphTarget";
  71094. export * from "babylonjs/Morph/morphTargetManager";
  71095. }
  71096. declare module "babylonjs/Navigation/INavigationEngine" {
  71097. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71098. import { Vector3 } from "babylonjs/Maths/math";
  71099. import { Mesh } from "babylonjs/Meshes/mesh";
  71100. import { Scene } from "babylonjs/scene";
  71101. /**
  71102. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71103. */
  71104. export interface INavigationEnginePlugin {
  71105. /**
  71106. * plugin name
  71107. */
  71108. name: string;
  71109. /**
  71110. * Creates a navigation mesh
  71111. * @param meshes array of all the geometry used to compute the navigatio mesh
  71112. * @param parameters bunch of parameters used to filter geometry
  71113. */
  71114. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71115. /**
  71116. * Create a navigation mesh debug mesh
  71117. * @param scene is where the mesh will be added
  71118. * @returns debug display mesh
  71119. */
  71120. createDebugNavMesh(scene: Scene): Mesh;
  71121. /**
  71122. * Get a navigation mesh constrained position, closest to the parameter position
  71123. * @param position world position
  71124. * @returns the closest point to position constrained by the navigation mesh
  71125. */
  71126. getClosestPoint(position: Vector3): Vector3;
  71127. /**
  71128. * Get a navigation mesh constrained position, closest to the parameter position
  71129. * @param position world position
  71130. * @param result output the closest point to position constrained by the navigation mesh
  71131. */
  71132. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71133. /**
  71134. * Get a navigation mesh constrained position, within a particular radius
  71135. * @param position world position
  71136. * @param maxRadius the maximum distance to the constrained world position
  71137. * @returns the closest point to position constrained by the navigation mesh
  71138. */
  71139. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71140. /**
  71141. * Get a navigation mesh constrained position, within a particular radius
  71142. * @param position world position
  71143. * @param maxRadius the maximum distance to the constrained world position
  71144. * @param result output the closest point to position constrained by the navigation mesh
  71145. */
  71146. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71147. /**
  71148. * Compute the final position from a segment made of destination-position
  71149. * @param position world position
  71150. * @param destination world position
  71151. * @returns the resulting point along the navmesh
  71152. */
  71153. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71154. /**
  71155. * Compute the final position from a segment made of destination-position
  71156. * @param position world position
  71157. * @param destination world position
  71158. * @param result output the resulting point along the navmesh
  71159. */
  71160. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71161. /**
  71162. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71163. * @param start world position
  71164. * @param end world position
  71165. * @returns array containing world position composing the path
  71166. */
  71167. computePath(start: Vector3, end: Vector3): Vector3[];
  71168. /**
  71169. * If this plugin is supported
  71170. * @returns true if plugin is supported
  71171. */
  71172. isSupported(): boolean;
  71173. /**
  71174. * Create a new Crowd so you can add agents
  71175. * @param maxAgents the maximum agent count in the crowd
  71176. * @param maxAgentRadius the maximum radius an agent can have
  71177. * @param scene to attach the crowd to
  71178. * @returns the crowd you can add agents to
  71179. */
  71180. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71181. /**
  71182. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71183. * The queries will try to find a solution within those bounds
  71184. * default is (1,1,1)
  71185. * @param extent x,y,z value that define the extent around the queries point of reference
  71186. */
  71187. setDefaultQueryExtent(extent: Vector3): void;
  71188. /**
  71189. * Get the Bounding box extent specified by setDefaultQueryExtent
  71190. * @returns the box extent values
  71191. */
  71192. getDefaultQueryExtent(): Vector3;
  71193. /**
  71194. * build the navmesh from a previously saved state using getNavmeshData
  71195. * @param data the Uint8Array returned by getNavmeshData
  71196. */
  71197. buildFromNavmeshData(data: Uint8Array): void;
  71198. /**
  71199. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71200. * @returns data the Uint8Array that can be saved and reused
  71201. */
  71202. getNavmeshData(): Uint8Array;
  71203. /**
  71204. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71205. * @param result output the box extent values
  71206. */
  71207. getDefaultQueryExtentToRef(result: Vector3): void;
  71208. /**
  71209. * Release all resources
  71210. */
  71211. dispose(): void;
  71212. }
  71213. /**
  71214. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71215. */
  71216. export interface ICrowd {
  71217. /**
  71218. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71219. * You can attach anything to that node. The node position is updated in the scene update tick.
  71220. * @param pos world position that will be constrained by the navigation mesh
  71221. * @param parameters agent parameters
  71222. * @param transform hooked to the agent that will be update by the scene
  71223. * @returns agent index
  71224. */
  71225. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71226. /**
  71227. * Returns the agent position in world space
  71228. * @param index agent index returned by addAgent
  71229. * @returns world space position
  71230. */
  71231. getAgentPosition(index: number): Vector3;
  71232. /**
  71233. * Gets the agent position result in world space
  71234. * @param index agent index returned by addAgent
  71235. * @param result output world space position
  71236. */
  71237. getAgentPositionToRef(index: number, result: Vector3): void;
  71238. /**
  71239. * Gets the agent velocity in world space
  71240. * @param index agent index returned by addAgent
  71241. * @returns world space velocity
  71242. */
  71243. getAgentVelocity(index: number): Vector3;
  71244. /**
  71245. * Gets the agent velocity result in world space
  71246. * @param index agent index returned by addAgent
  71247. * @param result output world space velocity
  71248. */
  71249. getAgentVelocityToRef(index: number, result: Vector3): void;
  71250. /**
  71251. * remove a particular agent previously created
  71252. * @param index agent index returned by addAgent
  71253. */
  71254. removeAgent(index: number): void;
  71255. /**
  71256. * get the list of all agents attached to this crowd
  71257. * @returns list of agent indices
  71258. */
  71259. getAgents(): number[];
  71260. /**
  71261. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71262. * @param deltaTime in seconds
  71263. */
  71264. update(deltaTime: number): void;
  71265. /**
  71266. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71267. * @param index agent index returned by addAgent
  71268. * @param destination targeted world position
  71269. */
  71270. agentGoto(index: number, destination: Vector3): void;
  71271. /**
  71272. * Teleport the agent to a new position
  71273. * @param index agent index returned by addAgent
  71274. * @param destination targeted world position
  71275. */
  71276. agentTeleport(index: number, destination: Vector3): void;
  71277. /**
  71278. * Update agent parameters
  71279. * @param index agent index returned by addAgent
  71280. * @param parameters agent parameters
  71281. */
  71282. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71283. /**
  71284. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71285. * The queries will try to find a solution within those bounds
  71286. * default is (1,1,1)
  71287. * @param extent x,y,z value that define the extent around the queries point of reference
  71288. */
  71289. setDefaultQueryExtent(extent: Vector3): void;
  71290. /**
  71291. * Get the Bounding box extent specified by setDefaultQueryExtent
  71292. * @returns the box extent values
  71293. */
  71294. getDefaultQueryExtent(): Vector3;
  71295. /**
  71296. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71297. * @param result output the box extent values
  71298. */
  71299. getDefaultQueryExtentToRef(result: Vector3): void;
  71300. /**
  71301. * Release all resources
  71302. */
  71303. dispose(): void;
  71304. }
  71305. /**
  71306. * Configures an agent
  71307. */
  71308. export interface IAgentParameters {
  71309. /**
  71310. * Agent radius. [Limit: >= 0]
  71311. */
  71312. radius: number;
  71313. /**
  71314. * Agent height. [Limit: > 0]
  71315. */
  71316. height: number;
  71317. /**
  71318. * Maximum allowed acceleration. [Limit: >= 0]
  71319. */
  71320. maxAcceleration: number;
  71321. /**
  71322. * Maximum allowed speed. [Limit: >= 0]
  71323. */
  71324. maxSpeed: number;
  71325. /**
  71326. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71327. */
  71328. collisionQueryRange: number;
  71329. /**
  71330. * The path visibility optimization range. [Limit: > 0]
  71331. */
  71332. pathOptimizationRange: number;
  71333. /**
  71334. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71335. */
  71336. separationWeight: number;
  71337. }
  71338. /**
  71339. * Configures the navigation mesh creation
  71340. */
  71341. export interface INavMeshParameters {
  71342. /**
  71343. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71344. */
  71345. cs: number;
  71346. /**
  71347. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71348. */
  71349. ch: number;
  71350. /**
  71351. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71352. */
  71353. walkableSlopeAngle: number;
  71354. /**
  71355. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71356. * be considered walkable. [Limit: >= 3] [Units: vx]
  71357. */
  71358. walkableHeight: number;
  71359. /**
  71360. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71361. */
  71362. walkableClimb: number;
  71363. /**
  71364. * The distance to erode/shrink the walkable area of the heightfield away from
  71365. * obstructions. [Limit: >=0] [Units: vx]
  71366. */
  71367. walkableRadius: number;
  71368. /**
  71369. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71370. */
  71371. maxEdgeLen: number;
  71372. /**
  71373. * The maximum distance a simplfied contour's border edges should deviate
  71374. * the original raw contour. [Limit: >=0] [Units: vx]
  71375. */
  71376. maxSimplificationError: number;
  71377. /**
  71378. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71379. */
  71380. minRegionArea: number;
  71381. /**
  71382. * Any regions with a span count smaller than this value will, if possible,
  71383. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71384. */
  71385. mergeRegionArea: number;
  71386. /**
  71387. * The maximum number of vertices allowed for polygons generated during the
  71388. * contour to polygon conversion process. [Limit: >= 3]
  71389. */
  71390. maxVertsPerPoly: number;
  71391. /**
  71392. * Sets the sampling distance to use when generating the detail mesh.
  71393. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71394. */
  71395. detailSampleDist: number;
  71396. /**
  71397. * The maximum distance the detail mesh surface should deviate from heightfield
  71398. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71399. */
  71400. detailSampleMaxError: number;
  71401. }
  71402. }
  71403. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71404. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71405. import { Mesh } from "babylonjs/Meshes/mesh";
  71406. import { Scene } from "babylonjs/scene";
  71407. import { Vector3 } from "babylonjs/Maths/math";
  71408. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71409. /**
  71410. * RecastJS navigation plugin
  71411. */
  71412. export class RecastJSPlugin implements INavigationEnginePlugin {
  71413. /**
  71414. * Reference to the Recast library
  71415. */
  71416. bjsRECAST: any;
  71417. /**
  71418. * plugin name
  71419. */
  71420. name: string;
  71421. /**
  71422. * the first navmesh created. We might extend this to support multiple navmeshes
  71423. */
  71424. navMesh: any;
  71425. /**
  71426. * Initializes the recastJS plugin
  71427. * @param recastInjection can be used to inject your own recast reference
  71428. */
  71429. constructor(recastInjection?: any);
  71430. /**
  71431. * Creates a navigation mesh
  71432. * @param meshes array of all the geometry used to compute the navigatio mesh
  71433. * @param parameters bunch of parameters used to filter geometry
  71434. */
  71435. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71436. /**
  71437. * Create a navigation mesh debug mesh
  71438. * @param scene is where the mesh will be added
  71439. * @returns debug display mesh
  71440. */
  71441. createDebugNavMesh(scene: Scene): Mesh;
  71442. /**
  71443. * Get a navigation mesh constrained position, closest to the parameter position
  71444. * @param position world position
  71445. * @returns the closest point to position constrained by the navigation mesh
  71446. */
  71447. getClosestPoint(position: Vector3): Vector3;
  71448. /**
  71449. * Get a navigation mesh constrained position, closest to the parameter position
  71450. * @param position world position
  71451. * @param result output the closest point to position constrained by the navigation mesh
  71452. */
  71453. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71454. /**
  71455. * Get a navigation mesh constrained position, within a particular radius
  71456. * @param position world position
  71457. * @param maxRadius the maximum distance to the constrained world position
  71458. * @returns the closest point to position constrained by the navigation mesh
  71459. */
  71460. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71461. /**
  71462. * Get a navigation mesh constrained position, within a particular radius
  71463. * @param position world position
  71464. * @param maxRadius the maximum distance to the constrained world position
  71465. * @param result output the closest point to position constrained by the navigation mesh
  71466. */
  71467. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71468. /**
  71469. * Compute the final position from a segment made of destination-position
  71470. * @param position world position
  71471. * @param destination world position
  71472. * @returns the resulting point along the navmesh
  71473. */
  71474. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71475. /**
  71476. * Compute the final position from a segment made of destination-position
  71477. * @param position world position
  71478. * @param destination world position
  71479. * @param result output the resulting point along the navmesh
  71480. */
  71481. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71482. /**
  71483. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71484. * @param start world position
  71485. * @param end world position
  71486. * @returns array containing world position composing the path
  71487. */
  71488. computePath(start: Vector3, end: Vector3): Vector3[];
  71489. /**
  71490. * Create a new Crowd so you can add agents
  71491. * @param maxAgents the maximum agent count in the crowd
  71492. * @param maxAgentRadius the maximum radius an agent can have
  71493. * @param scene to attach the crowd to
  71494. * @returns the crowd you can add agents to
  71495. */
  71496. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71497. /**
  71498. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71499. * The queries will try to find a solution within those bounds
  71500. * default is (1,1,1)
  71501. * @param extent x,y,z value that define the extent around the queries point of reference
  71502. */
  71503. setDefaultQueryExtent(extent: Vector3): void;
  71504. /**
  71505. * Get the Bounding box extent specified by setDefaultQueryExtent
  71506. * @returns the box extent values
  71507. */
  71508. getDefaultQueryExtent(): Vector3;
  71509. /**
  71510. * build the navmesh from a previously saved state using getNavmeshData
  71511. * @param data the Uint8Array returned by getNavmeshData
  71512. */
  71513. buildFromNavmeshData(data: Uint8Array): void;
  71514. /**
  71515. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71516. * @returns data the Uint8Array that can be saved and reused
  71517. */
  71518. getNavmeshData(): Uint8Array;
  71519. /**
  71520. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71521. * @param result output the box extent values
  71522. */
  71523. getDefaultQueryExtentToRef(result: Vector3): void;
  71524. /**
  71525. * Disposes
  71526. */
  71527. dispose(): void;
  71528. /**
  71529. * If this plugin is supported
  71530. * @returns true if plugin is supported
  71531. */
  71532. isSupported(): boolean;
  71533. }
  71534. /**
  71535. * Recast detour crowd implementation
  71536. */
  71537. export class RecastJSCrowd implements ICrowd {
  71538. /**
  71539. * Recast/detour plugin
  71540. */
  71541. bjsRECASTPlugin: RecastJSPlugin;
  71542. /**
  71543. * Link to the detour crowd
  71544. */
  71545. recastCrowd: any;
  71546. /**
  71547. * One transform per agent
  71548. */
  71549. transforms: TransformNode[];
  71550. /**
  71551. * All agents created
  71552. */
  71553. agents: number[];
  71554. /**
  71555. * Link to the scene is kept to unregister the crowd from the scene
  71556. */
  71557. private _scene;
  71558. /**
  71559. * Observer for crowd updates
  71560. */
  71561. private _onBeforeAnimationsObserver;
  71562. /**
  71563. * Constructor
  71564. * @param plugin recastJS plugin
  71565. * @param maxAgents the maximum agent count in the crowd
  71566. * @param maxAgentRadius the maximum radius an agent can have
  71567. * @param scene to attach the crowd to
  71568. * @returns the crowd you can add agents to
  71569. */
  71570. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71571. /**
  71572. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71573. * You can attach anything to that node. The node position is updated in the scene update tick.
  71574. * @param pos world position that will be constrained by the navigation mesh
  71575. * @param parameters agent parameters
  71576. * @param transform hooked to the agent that will be update by the scene
  71577. * @returns agent index
  71578. */
  71579. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71580. /**
  71581. * Returns the agent position in world space
  71582. * @param index agent index returned by addAgent
  71583. * @returns world space position
  71584. */
  71585. getAgentPosition(index: number): Vector3;
  71586. /**
  71587. * Returns the agent position result in world space
  71588. * @param index agent index returned by addAgent
  71589. * @param result output world space position
  71590. */
  71591. getAgentPositionToRef(index: number, result: Vector3): void;
  71592. /**
  71593. * Returns the agent velocity in world space
  71594. * @param index agent index returned by addAgent
  71595. * @returns world space velocity
  71596. */
  71597. getAgentVelocity(index: number): Vector3;
  71598. /**
  71599. * Returns the agent velocity result in world space
  71600. * @param index agent index returned by addAgent
  71601. * @param result output world space velocity
  71602. */
  71603. getAgentVelocityToRef(index: number, result: Vector3): void;
  71604. /**
  71605. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71606. * @param index agent index returned by addAgent
  71607. * @param destination targeted world position
  71608. */
  71609. agentGoto(index: number, destination: Vector3): void;
  71610. /**
  71611. * Teleport the agent to a new position
  71612. * @param index agent index returned by addAgent
  71613. * @param destination targeted world position
  71614. */
  71615. agentTeleport(index: number, destination: Vector3): void;
  71616. /**
  71617. * Update agent parameters
  71618. * @param index agent index returned by addAgent
  71619. * @param parameters agent parameters
  71620. */
  71621. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71622. /**
  71623. * remove a particular agent previously created
  71624. * @param index agent index returned by addAgent
  71625. */
  71626. removeAgent(index: number): void;
  71627. /**
  71628. * get the list of all agents attached to this crowd
  71629. * @returns list of agent indices
  71630. */
  71631. getAgents(): number[];
  71632. /**
  71633. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71634. * @param deltaTime in seconds
  71635. */
  71636. update(deltaTime: number): void;
  71637. /**
  71638. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71639. * The queries will try to find a solution within those bounds
  71640. * default is (1,1,1)
  71641. * @param extent x,y,z value that define the extent around the queries point of reference
  71642. */
  71643. setDefaultQueryExtent(extent: Vector3): void;
  71644. /**
  71645. * Get the Bounding box extent specified by setDefaultQueryExtent
  71646. * @returns the box extent values
  71647. */
  71648. getDefaultQueryExtent(): Vector3;
  71649. /**
  71650. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71651. * @param result output the box extent values
  71652. */
  71653. getDefaultQueryExtentToRef(result: Vector3): void;
  71654. /**
  71655. * Release all resources
  71656. */
  71657. dispose(): void;
  71658. }
  71659. }
  71660. declare module "babylonjs/Navigation/Plugins/index" {
  71661. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71662. }
  71663. declare module "babylonjs/Navigation/index" {
  71664. export * from "babylonjs/Navigation/INavigationEngine";
  71665. export * from "babylonjs/Navigation/Plugins/index";
  71666. }
  71667. declare module "babylonjs/Offline/database" {
  71668. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71669. /**
  71670. * Class used to enable access to IndexedDB
  71671. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71672. */
  71673. export class Database implements IOfflineProvider {
  71674. private _callbackManifestChecked;
  71675. private _currentSceneUrl;
  71676. private _db;
  71677. private _enableSceneOffline;
  71678. private _enableTexturesOffline;
  71679. private _manifestVersionFound;
  71680. private _mustUpdateRessources;
  71681. private _hasReachedQuota;
  71682. private _isSupported;
  71683. private _idbFactory;
  71684. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71685. private static IsUASupportingBlobStorage;
  71686. /**
  71687. * Gets a boolean indicating if Database storate is enabled (off by default)
  71688. */
  71689. static IDBStorageEnabled: boolean;
  71690. /**
  71691. * Gets a boolean indicating if scene must be saved in the database
  71692. */
  71693. get enableSceneOffline(): boolean;
  71694. /**
  71695. * Gets a boolean indicating if textures must be saved in the database
  71696. */
  71697. get enableTexturesOffline(): boolean;
  71698. /**
  71699. * Creates a new Database
  71700. * @param urlToScene defines the url to load the scene
  71701. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71702. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71703. */
  71704. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71705. private static _ParseURL;
  71706. private static _ReturnFullUrlLocation;
  71707. private _checkManifestFile;
  71708. /**
  71709. * Open the database and make it available
  71710. * @param successCallback defines the callback to call on success
  71711. * @param errorCallback defines the callback to call on error
  71712. */
  71713. open(successCallback: () => void, errorCallback: () => void): void;
  71714. /**
  71715. * Loads an image from the database
  71716. * @param url defines the url to load from
  71717. * @param image defines the target DOM image
  71718. */
  71719. loadImage(url: string, image: HTMLImageElement): void;
  71720. private _loadImageFromDBAsync;
  71721. private _saveImageIntoDBAsync;
  71722. private _checkVersionFromDB;
  71723. private _loadVersionFromDBAsync;
  71724. private _saveVersionIntoDBAsync;
  71725. /**
  71726. * Loads a file from database
  71727. * @param url defines the URL to load from
  71728. * @param sceneLoaded defines a callback to call on success
  71729. * @param progressCallBack defines a callback to call when progress changed
  71730. * @param errorCallback defines a callback to call on error
  71731. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71732. */
  71733. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71734. private _loadFileAsync;
  71735. private _saveFileAsync;
  71736. /**
  71737. * Validates if xhr data is correct
  71738. * @param xhr defines the request to validate
  71739. * @param dataType defines the expected data type
  71740. * @returns true if data is correct
  71741. */
  71742. private static _ValidateXHRData;
  71743. }
  71744. }
  71745. declare module "babylonjs/Offline/index" {
  71746. export * from "babylonjs/Offline/database";
  71747. export * from "babylonjs/Offline/IOfflineProvider";
  71748. }
  71749. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71750. /** @hidden */
  71751. export var gpuUpdateParticlesPixelShader: {
  71752. name: string;
  71753. shader: string;
  71754. };
  71755. }
  71756. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71757. /** @hidden */
  71758. export var gpuUpdateParticlesVertexShader: {
  71759. name: string;
  71760. shader: string;
  71761. };
  71762. }
  71763. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71764. /** @hidden */
  71765. export var clipPlaneFragmentDeclaration2: {
  71766. name: string;
  71767. shader: string;
  71768. };
  71769. }
  71770. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71771. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71772. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71773. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71774. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71775. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71776. /** @hidden */
  71777. export var gpuRenderParticlesPixelShader: {
  71778. name: string;
  71779. shader: string;
  71780. };
  71781. }
  71782. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71783. /** @hidden */
  71784. export var clipPlaneVertexDeclaration2: {
  71785. name: string;
  71786. shader: string;
  71787. };
  71788. }
  71789. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71790. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71791. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71792. /** @hidden */
  71793. export var gpuRenderParticlesVertexShader: {
  71794. name: string;
  71795. shader: string;
  71796. };
  71797. }
  71798. declare module "babylonjs/Particles/gpuParticleSystem" {
  71799. import { Nullable } from "babylonjs/types";
  71800. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71801. import { Observable } from "babylonjs/Misc/observable";
  71802. import { Matrix } from "babylonjs/Maths/math.vector";
  71803. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71804. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71805. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71806. import { IDisposable } from "babylonjs/scene";
  71807. import { Effect } from "babylonjs/Materials/effect";
  71808. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71809. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71810. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71811. import { Scene } from "babylonjs/scene";
  71812. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71813. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71814. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71815. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71816. /**
  71817. * This represents a GPU particle system in Babylon
  71818. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71819. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71820. */
  71821. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71822. /**
  71823. * The layer mask we are rendering the particles through.
  71824. */
  71825. layerMask: number;
  71826. private _capacity;
  71827. private _activeCount;
  71828. private _currentActiveCount;
  71829. private _accumulatedCount;
  71830. private _renderEffect;
  71831. private _updateEffect;
  71832. private _buffer0;
  71833. private _buffer1;
  71834. private _spriteBuffer;
  71835. private _updateVAO;
  71836. private _renderVAO;
  71837. private _targetIndex;
  71838. private _sourceBuffer;
  71839. private _targetBuffer;
  71840. private _currentRenderId;
  71841. private _started;
  71842. private _stopped;
  71843. private _timeDelta;
  71844. private _randomTexture;
  71845. private _randomTexture2;
  71846. private _attributesStrideSize;
  71847. private _updateEffectOptions;
  71848. private _randomTextureSize;
  71849. private _actualFrame;
  71850. private _customEffect;
  71851. private readonly _rawTextureWidth;
  71852. /**
  71853. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71854. */
  71855. static get IsSupported(): boolean;
  71856. /**
  71857. * An event triggered when the system is disposed.
  71858. */
  71859. onDisposeObservable: Observable<IParticleSystem>;
  71860. /**
  71861. * An event triggered when the system is stopped
  71862. */
  71863. onStoppedObservable: Observable<IParticleSystem>;
  71864. /**
  71865. * Gets the maximum number of particles active at the same time.
  71866. * @returns The max number of active particles.
  71867. */
  71868. getCapacity(): number;
  71869. /**
  71870. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71871. * to override the particles.
  71872. */
  71873. forceDepthWrite: boolean;
  71874. /**
  71875. * Gets or set the number of active particles
  71876. */
  71877. get activeParticleCount(): number;
  71878. set activeParticleCount(value: number);
  71879. private _preWarmDone;
  71880. /**
  71881. * Specifies if the particles are updated in emitter local space or world space.
  71882. */
  71883. isLocal: boolean;
  71884. /** Gets or sets a matrix to use to compute projection */
  71885. defaultProjectionMatrix: Matrix;
  71886. /**
  71887. * Is this system ready to be used/rendered
  71888. * @return true if the system is ready
  71889. */
  71890. isReady(): boolean;
  71891. /**
  71892. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71893. * @returns True if it has been started, otherwise false.
  71894. */
  71895. isStarted(): boolean;
  71896. /**
  71897. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71898. * @returns True if it has been stopped, otherwise false.
  71899. */
  71900. isStopped(): boolean;
  71901. /**
  71902. * Gets a boolean indicating that the system is stopping
  71903. * @returns true if the system is currently stopping
  71904. */
  71905. isStopping(): boolean;
  71906. /**
  71907. * Gets the number of particles active at the same time.
  71908. * @returns The number of active particles.
  71909. */
  71910. getActiveCount(): number;
  71911. /**
  71912. * Starts the particle system and begins to emit
  71913. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71914. */
  71915. start(delay?: number): void;
  71916. /**
  71917. * Stops the particle system.
  71918. */
  71919. stop(): void;
  71920. /**
  71921. * Remove all active particles
  71922. */
  71923. reset(): void;
  71924. /**
  71925. * Returns the string "GPUParticleSystem"
  71926. * @returns a string containing the class name
  71927. */
  71928. getClassName(): string;
  71929. /**
  71930. * Gets the custom effect used to render the particles
  71931. * @param blendMode Blend mode for which the effect should be retrieved
  71932. * @returns The effect
  71933. */
  71934. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71935. /**
  71936. * Sets the custom effect used to render the particles
  71937. * @param effect The effect to set
  71938. * @param blendMode Blend mode for which the effect should be set
  71939. */
  71940. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71941. /** @hidden */
  71942. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71943. /**
  71944. * Observable that will be called just before the particles are drawn
  71945. */
  71946. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71947. /**
  71948. * Gets the name of the particle vertex shader
  71949. */
  71950. get vertexShaderName(): string;
  71951. private _colorGradientsTexture;
  71952. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71953. /**
  71954. * Adds a new color gradient
  71955. * @param gradient defines the gradient to use (between 0 and 1)
  71956. * @param color1 defines the color to affect to the specified gradient
  71957. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71958. * @returns the current particle system
  71959. */
  71960. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71961. private _refreshColorGradient;
  71962. /** Force the system to rebuild all gradients that need to be resync */
  71963. forceRefreshGradients(): void;
  71964. /**
  71965. * Remove a specific color gradient
  71966. * @param gradient defines the gradient to remove
  71967. * @returns the current particle system
  71968. */
  71969. removeColorGradient(gradient: number): GPUParticleSystem;
  71970. private _angularSpeedGradientsTexture;
  71971. private _sizeGradientsTexture;
  71972. private _velocityGradientsTexture;
  71973. private _limitVelocityGradientsTexture;
  71974. private _dragGradientsTexture;
  71975. private _addFactorGradient;
  71976. /**
  71977. * Adds a new size gradient
  71978. * @param gradient defines the gradient to use (between 0 and 1)
  71979. * @param factor defines the size factor to affect to the specified gradient
  71980. * @returns the current particle system
  71981. */
  71982. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71983. /**
  71984. * Remove a specific size gradient
  71985. * @param gradient defines the gradient to remove
  71986. * @returns the current particle system
  71987. */
  71988. removeSizeGradient(gradient: number): GPUParticleSystem;
  71989. private _refreshFactorGradient;
  71990. /**
  71991. * Adds a new angular speed gradient
  71992. * @param gradient defines the gradient to use (between 0 and 1)
  71993. * @param factor defines the angular speed to affect to the specified gradient
  71994. * @returns the current particle system
  71995. */
  71996. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71997. /**
  71998. * Remove a specific angular speed gradient
  71999. * @param gradient defines the gradient to remove
  72000. * @returns the current particle system
  72001. */
  72002. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72003. /**
  72004. * Adds a new velocity gradient
  72005. * @param gradient defines the gradient to use (between 0 and 1)
  72006. * @param factor defines the velocity to affect to the specified gradient
  72007. * @returns the current particle system
  72008. */
  72009. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72010. /**
  72011. * Remove a specific velocity gradient
  72012. * @param gradient defines the gradient to remove
  72013. * @returns the current particle system
  72014. */
  72015. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72016. /**
  72017. * Adds a new limit velocity gradient
  72018. * @param gradient defines the gradient to use (between 0 and 1)
  72019. * @param factor defines the limit velocity value to affect to the specified gradient
  72020. * @returns the current particle system
  72021. */
  72022. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72023. /**
  72024. * Remove a specific limit velocity gradient
  72025. * @param gradient defines the gradient to remove
  72026. * @returns the current particle system
  72027. */
  72028. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72029. /**
  72030. * Adds a new drag gradient
  72031. * @param gradient defines the gradient to use (between 0 and 1)
  72032. * @param factor defines the drag value to affect to the specified gradient
  72033. * @returns the current particle system
  72034. */
  72035. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72036. /**
  72037. * Remove a specific drag gradient
  72038. * @param gradient defines the gradient to remove
  72039. * @returns the current particle system
  72040. */
  72041. removeDragGradient(gradient: number): GPUParticleSystem;
  72042. /**
  72043. * Not supported by GPUParticleSystem
  72044. * @param gradient defines the gradient to use (between 0 and 1)
  72045. * @param factor defines the emit rate value to affect to the specified gradient
  72046. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72047. * @returns the current particle system
  72048. */
  72049. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72050. /**
  72051. * Not supported by GPUParticleSystem
  72052. * @param gradient defines the gradient to remove
  72053. * @returns the current particle system
  72054. */
  72055. removeEmitRateGradient(gradient: number): IParticleSystem;
  72056. /**
  72057. * Not supported by GPUParticleSystem
  72058. * @param gradient defines the gradient to use (between 0 and 1)
  72059. * @param factor defines the start size value to affect to the specified gradient
  72060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72061. * @returns the current particle system
  72062. */
  72063. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72064. /**
  72065. * Not supported by GPUParticleSystem
  72066. * @param gradient defines the gradient to remove
  72067. * @returns the current particle system
  72068. */
  72069. removeStartSizeGradient(gradient: number): IParticleSystem;
  72070. /**
  72071. * Not supported by GPUParticleSystem
  72072. * @param gradient defines the gradient to use (between 0 and 1)
  72073. * @param min defines the color remap minimal range
  72074. * @param max defines the color remap maximal range
  72075. * @returns the current particle system
  72076. */
  72077. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72078. /**
  72079. * Not supported by GPUParticleSystem
  72080. * @param gradient defines the gradient to remove
  72081. * @returns the current particle system
  72082. */
  72083. removeColorRemapGradient(): IParticleSystem;
  72084. /**
  72085. * Not supported by GPUParticleSystem
  72086. * @param gradient defines the gradient to use (between 0 and 1)
  72087. * @param min defines the alpha remap minimal range
  72088. * @param max defines the alpha remap maximal range
  72089. * @returns the current particle system
  72090. */
  72091. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72092. /**
  72093. * Not supported by GPUParticleSystem
  72094. * @param gradient defines the gradient to remove
  72095. * @returns the current particle system
  72096. */
  72097. removeAlphaRemapGradient(): IParticleSystem;
  72098. /**
  72099. * Not supported by GPUParticleSystem
  72100. * @param gradient defines the gradient to use (between 0 and 1)
  72101. * @param color defines the color to affect to the specified gradient
  72102. * @returns the current particle system
  72103. */
  72104. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72105. /**
  72106. * Not supported by GPUParticleSystem
  72107. * @param gradient defines the gradient to remove
  72108. * @returns the current particle system
  72109. */
  72110. removeRampGradient(): IParticleSystem;
  72111. /**
  72112. * Not supported by GPUParticleSystem
  72113. * @returns the list of ramp gradients
  72114. */
  72115. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72116. /**
  72117. * Not supported by GPUParticleSystem
  72118. * Gets or sets a boolean indicating that ramp gradients must be used
  72119. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72120. */
  72121. get useRampGradients(): boolean;
  72122. set useRampGradients(value: boolean);
  72123. /**
  72124. * Not supported by GPUParticleSystem
  72125. * @param gradient defines the gradient to use (between 0 and 1)
  72126. * @param factor defines the life time factor to affect to the specified gradient
  72127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72128. * @returns the current particle system
  72129. */
  72130. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72131. /**
  72132. * Not supported by GPUParticleSystem
  72133. * @param gradient defines the gradient to remove
  72134. * @returns the current particle system
  72135. */
  72136. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72137. /**
  72138. * Instantiates a GPU particle system.
  72139. * 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.
  72140. * @param name The name of the particle system
  72141. * @param options The options used to create the system
  72142. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72143. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72144. * @param customEffect a custom effect used to change the way particles are rendered by default
  72145. */
  72146. constructor(name: string, options: Partial<{
  72147. capacity: number;
  72148. randomTextureSize: number;
  72149. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72150. protected _reset(): void;
  72151. private _createUpdateVAO;
  72152. private _createRenderVAO;
  72153. private _initialize;
  72154. /** @hidden */
  72155. _recreateUpdateEffect(): void;
  72156. private _getEffect;
  72157. /**
  72158. * Fill the defines array according to the current settings of the particle system
  72159. * @param defines Array to be updated
  72160. * @param blendMode blend mode to take into account when updating the array
  72161. */
  72162. fillDefines(defines: Array<string>, blendMode?: number): void;
  72163. /**
  72164. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72165. * @param uniforms Uniforms array to fill
  72166. * @param attributes Attributes array to fill
  72167. * @param samplers Samplers array to fill
  72168. */
  72169. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72170. /** @hidden */
  72171. _recreateRenderEffect(): Effect;
  72172. /**
  72173. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72174. * @param preWarm defines if we are in the pre-warmimg phase
  72175. */
  72176. animate(preWarm?: boolean): void;
  72177. private _createFactorGradientTexture;
  72178. private _createSizeGradientTexture;
  72179. private _createAngularSpeedGradientTexture;
  72180. private _createVelocityGradientTexture;
  72181. private _createLimitVelocityGradientTexture;
  72182. private _createDragGradientTexture;
  72183. private _createColorGradientTexture;
  72184. /**
  72185. * Renders the particle system in its current state
  72186. * @param preWarm defines if the system should only update the particles but not render them
  72187. * @returns the current number of particles
  72188. */
  72189. render(preWarm?: boolean): number;
  72190. /**
  72191. * Rebuilds the particle system
  72192. */
  72193. rebuild(): void;
  72194. private _releaseBuffers;
  72195. private _releaseVAOs;
  72196. /**
  72197. * Disposes the particle system and free the associated resources
  72198. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72199. */
  72200. dispose(disposeTexture?: boolean): void;
  72201. /**
  72202. * Clones the particle system.
  72203. * @param name The name of the cloned object
  72204. * @param newEmitter The new emitter to use
  72205. * @returns the cloned particle system
  72206. */
  72207. clone(name: string, newEmitter: any): GPUParticleSystem;
  72208. /**
  72209. * Serializes the particle system to a JSON object
  72210. * @param serializeTexture defines if the texture must be serialized as well
  72211. * @returns the JSON object
  72212. */
  72213. serialize(serializeTexture?: boolean): any;
  72214. /**
  72215. * Parses a JSON object to create a GPU particle system.
  72216. * @param parsedParticleSystem The JSON object to parse
  72217. * @param sceneOrEngine The scene or the engine to create the particle system in
  72218. * @param rootUrl The root url to use to load external dependencies like texture
  72219. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72220. * @returns the parsed GPU particle system
  72221. */
  72222. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72223. }
  72224. }
  72225. declare module "babylonjs/Particles/particleSystemSet" {
  72226. import { Nullable } from "babylonjs/types";
  72227. import { Color3 } from "babylonjs/Maths/math.color";
  72228. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72230. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72231. import { Scene, IDisposable } from "babylonjs/scene";
  72232. /**
  72233. * Represents a set of particle systems working together to create a specific effect
  72234. */
  72235. export class ParticleSystemSet implements IDisposable {
  72236. /**
  72237. * Gets or sets base Assets URL
  72238. */
  72239. static BaseAssetsUrl: string;
  72240. private _emitterCreationOptions;
  72241. private _emitterNode;
  72242. /**
  72243. * Gets the particle system list
  72244. */
  72245. systems: IParticleSystem[];
  72246. /**
  72247. * Gets the emitter node used with this set
  72248. */
  72249. get emitterNode(): Nullable<TransformNode>;
  72250. /**
  72251. * Creates a new emitter mesh as a sphere
  72252. * @param options defines the options used to create the sphere
  72253. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72254. * @param scene defines the hosting scene
  72255. */
  72256. setEmitterAsSphere(options: {
  72257. diameter: number;
  72258. segments: number;
  72259. color: Color3;
  72260. }, renderingGroupId: number, scene: Scene): void;
  72261. /**
  72262. * Starts all particle systems of the set
  72263. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72264. */
  72265. start(emitter?: AbstractMesh): void;
  72266. /**
  72267. * Release all associated resources
  72268. */
  72269. dispose(): void;
  72270. /**
  72271. * Serialize the set into a JSON compatible object
  72272. * @param serializeTexture defines if the texture must be serialized as well
  72273. * @returns a JSON compatible representation of the set
  72274. */
  72275. serialize(serializeTexture?: boolean): any;
  72276. /**
  72277. * Parse a new ParticleSystemSet from a serialized source
  72278. * @param data defines a JSON compatible representation of the set
  72279. * @param scene defines the hosting scene
  72280. * @param gpu defines if we want GPU particles or CPU particles
  72281. * @returns a new ParticleSystemSet
  72282. */
  72283. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72284. }
  72285. }
  72286. declare module "babylonjs/Particles/particleHelper" {
  72287. import { Nullable } from "babylonjs/types";
  72288. import { Scene } from "babylonjs/scene";
  72289. import { Vector3 } from "babylonjs/Maths/math.vector";
  72290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72291. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72292. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72293. /**
  72294. * This class is made for on one-liner static method to help creating particle system set.
  72295. */
  72296. export class ParticleHelper {
  72297. /**
  72298. * Gets or sets base Assets URL
  72299. */
  72300. static BaseAssetsUrl: string;
  72301. /** Define the Url to load snippets */
  72302. static SnippetUrl: string;
  72303. /**
  72304. * Create a default particle system that you can tweak
  72305. * @param emitter defines the emitter to use
  72306. * @param capacity defines the system capacity (default is 500 particles)
  72307. * @param scene defines the hosting scene
  72308. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72309. * @returns the new Particle system
  72310. */
  72311. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72312. /**
  72313. * This is the main static method (one-liner) of this helper to create different particle systems
  72314. * @param type This string represents the type to the particle system to create
  72315. * @param scene The scene where the particle system should live
  72316. * @param gpu If the system will use gpu
  72317. * @returns the ParticleSystemSet created
  72318. */
  72319. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72320. /**
  72321. * Static function used to export a particle system to a ParticleSystemSet variable.
  72322. * Please note that the emitter shape is not exported
  72323. * @param systems defines the particle systems to export
  72324. * @returns the created particle system set
  72325. */
  72326. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72327. /**
  72328. * Creates a particle system from a snippet saved in a remote file
  72329. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72330. * @param url defines the url to load from
  72331. * @param scene defines the hosting scene
  72332. * @param gpu If the system will use gpu
  72333. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72334. * @returns a promise that will resolve to the new particle system
  72335. */
  72336. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72337. /**
  72338. * Creates a particle system from a snippet saved by the particle system editor
  72339. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72340. * @param scene defines the hosting scene
  72341. * @param gpu If the system will use gpu
  72342. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72343. * @returns a promise that will resolve to the new particle system
  72344. */
  72345. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72346. }
  72347. }
  72348. declare module "babylonjs/Particles/particleSystemComponent" {
  72349. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72350. import { Effect } from "babylonjs/Materials/effect";
  72351. import "babylonjs/Shaders/particles.vertex";
  72352. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72353. module "babylonjs/Engines/engine" {
  72354. interface Engine {
  72355. /**
  72356. * Create an effect to use with particle systems.
  72357. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72358. * the particle system for which you want to create a custom effect in the last parameter
  72359. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72360. * @param uniformsNames defines a list of attribute names
  72361. * @param samplers defines an array of string used to represent textures
  72362. * @param defines defines the string containing the defines to use to compile the shaders
  72363. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72364. * @param onCompiled defines a function to call when the effect creation is successful
  72365. * @param onError defines a function to call when the effect creation has failed
  72366. * @param particleSystem the particle system you want to create the effect for
  72367. * @returns the new Effect
  72368. */
  72369. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72370. }
  72371. }
  72372. module "babylonjs/Meshes/mesh" {
  72373. interface Mesh {
  72374. /**
  72375. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72376. * @returns an array of IParticleSystem
  72377. */
  72378. getEmittedParticleSystems(): IParticleSystem[];
  72379. /**
  72380. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72381. * @returns an array of IParticleSystem
  72382. */
  72383. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72384. }
  72385. }
  72386. }
  72387. declare module "babylonjs/Particles/pointsCloudSystem" {
  72388. import { Color4 } from "babylonjs/Maths/math";
  72389. import { Mesh } from "babylonjs/Meshes/mesh";
  72390. import { Scene, IDisposable } from "babylonjs/scene";
  72391. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72392. /** Defines the 4 color options */
  72393. export enum PointColor {
  72394. /** color value */
  72395. Color = 2,
  72396. /** uv value */
  72397. UV = 1,
  72398. /** random value */
  72399. Random = 0,
  72400. /** stated value */
  72401. Stated = 3
  72402. }
  72403. /**
  72404. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72405. * 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.
  72406. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72407. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72408. *
  72409. * Full documentation here : TO BE ENTERED
  72410. */
  72411. export class PointsCloudSystem implements IDisposable {
  72412. /**
  72413. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72414. * Example : var p = SPS.particles[i];
  72415. */
  72416. particles: CloudPoint[];
  72417. /**
  72418. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72419. */
  72420. nbParticles: number;
  72421. /**
  72422. * This a counter for your own usage. It's not set by any SPS functions.
  72423. */
  72424. counter: number;
  72425. /**
  72426. * The PCS name. This name is also given to the underlying mesh.
  72427. */
  72428. name: string;
  72429. /**
  72430. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72431. */
  72432. mesh: Mesh;
  72433. /**
  72434. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72435. * Please read :
  72436. */
  72437. vars: any;
  72438. /**
  72439. * @hidden
  72440. */
  72441. _size: number;
  72442. private _scene;
  72443. private _promises;
  72444. private _positions;
  72445. private _indices;
  72446. private _normals;
  72447. private _colors;
  72448. private _uvs;
  72449. private _indices32;
  72450. private _positions32;
  72451. private _colors32;
  72452. private _uvs32;
  72453. private _updatable;
  72454. private _isVisibilityBoxLocked;
  72455. private _alwaysVisible;
  72456. private _groups;
  72457. private _groupCounter;
  72458. private _computeParticleColor;
  72459. private _computeParticleTexture;
  72460. private _computeParticleRotation;
  72461. private _computeBoundingBox;
  72462. private _isReady;
  72463. /**
  72464. * Creates a PCS (Points Cloud System) object
  72465. * @param name (String) is the PCS name, this will be the underlying mesh name
  72466. * @param pointSize (number) is the size for each point
  72467. * @param scene (Scene) is the scene in which the PCS is added
  72468. * @param options defines the options of the PCS e.g.
  72469. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72470. */
  72471. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72472. updatable?: boolean;
  72473. });
  72474. /**
  72475. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72476. * If no points were added to the PCS, the returned mesh is just a single point.
  72477. * @returns a promise for the created mesh
  72478. */
  72479. buildMeshAsync(): Promise<Mesh>;
  72480. /**
  72481. * @hidden
  72482. */
  72483. private _buildMesh;
  72484. private _addParticle;
  72485. private _randomUnitVector;
  72486. private _getColorIndicesForCoord;
  72487. private _setPointsColorOrUV;
  72488. private _colorFromTexture;
  72489. private _calculateDensity;
  72490. /**
  72491. * Adds points to the PCS in random positions within a unit sphere
  72492. * @param nb (positive integer) the number of particles to be created from this model
  72493. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72494. * @returns the number of groups in the system
  72495. */
  72496. addPoints(nb: number, pointFunction?: any): number;
  72497. /**
  72498. * Adds points to the PCS from the surface of the model shape
  72499. * @param mesh is any Mesh object that will be used as a surface model for the points
  72500. * @param nb (positive integer) the number of particles to be created from this model
  72501. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72502. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72503. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72504. * @returns the number of groups in the system
  72505. */
  72506. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72507. /**
  72508. * Adds points to the PCS inside the model shape
  72509. * @param mesh is any Mesh object that will be used as a surface model for the points
  72510. * @param nb (positive integer) the number of particles to be created from this model
  72511. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72512. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72513. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72514. * @returns the number of groups in the system
  72515. */
  72516. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72517. /**
  72518. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72519. * This method calls `updateParticle()` for each particle of the SPS.
  72520. * For an animated SPS, it is usually called within the render loop.
  72521. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72522. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72523. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72524. * @returns the PCS.
  72525. */
  72526. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72527. /**
  72528. * Disposes the PCS.
  72529. */
  72530. dispose(): void;
  72531. /**
  72532. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72533. * doc :
  72534. * @returns the PCS.
  72535. */
  72536. refreshVisibleSize(): PointsCloudSystem;
  72537. /**
  72538. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72539. * @param size the size (float) of the visibility box
  72540. * note : this doesn't lock the PCS mesh bounding box.
  72541. * doc :
  72542. */
  72543. setVisibilityBox(size: number): void;
  72544. /**
  72545. * Gets whether the PCS is always visible or not
  72546. * doc :
  72547. */
  72548. get isAlwaysVisible(): boolean;
  72549. /**
  72550. * Sets the PCS as always visible or not
  72551. * doc :
  72552. */
  72553. set isAlwaysVisible(val: boolean);
  72554. /**
  72555. * Tells to `setParticles()` to compute the particle rotations or not
  72556. * Default value : false. The PCS is faster when it's set to false
  72557. * Note : particle rotations are only applied to parent particles
  72558. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72559. */
  72560. set computeParticleRotation(val: boolean);
  72561. /**
  72562. * Tells to `setParticles()` to compute the particle colors or not.
  72563. * Default value : true. The PCS is faster when it's set to false.
  72564. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72565. */
  72566. set computeParticleColor(val: boolean);
  72567. set computeParticleTexture(val: boolean);
  72568. /**
  72569. * Gets if `setParticles()` computes the particle colors or not.
  72570. * Default value : false. The PCS is faster when it's set to false.
  72571. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72572. */
  72573. get computeParticleColor(): boolean;
  72574. /**
  72575. * Gets if `setParticles()` computes the particle textures or not.
  72576. * Default value : false. The PCS is faster when it's set to false.
  72577. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72578. */
  72579. get computeParticleTexture(): boolean;
  72580. /**
  72581. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72582. */
  72583. set computeBoundingBox(val: boolean);
  72584. /**
  72585. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72586. */
  72587. get computeBoundingBox(): boolean;
  72588. /**
  72589. * This function does nothing. It may be overwritten to set all the particle first values.
  72590. * The PCS doesn't call this function, you may have to call it by your own.
  72591. * doc :
  72592. */
  72593. initParticles(): void;
  72594. /**
  72595. * This function does nothing. It may be overwritten to recycle a particle
  72596. * The PCS doesn't call this function, you can to call it
  72597. * doc :
  72598. * @param particle The particle to recycle
  72599. * @returns the recycled particle
  72600. */
  72601. recycleParticle(particle: CloudPoint): CloudPoint;
  72602. /**
  72603. * Updates a particle : this function should be overwritten by the user.
  72604. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72605. * doc :
  72606. * @example : just set a particle position or velocity and recycle conditions
  72607. * @param particle The particle to update
  72608. * @returns the updated particle
  72609. */
  72610. updateParticle(particle: CloudPoint): CloudPoint;
  72611. /**
  72612. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72613. * This does nothing and may be overwritten by the user.
  72614. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72615. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72616. * @param update the boolean update value actually passed to setParticles()
  72617. */
  72618. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72619. /**
  72620. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72621. * This will be passed three parameters.
  72622. * This does nothing and may be overwritten by the user.
  72623. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72624. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72625. * @param update the boolean update value actually passed to setParticles()
  72626. */
  72627. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72628. }
  72629. }
  72630. declare module "babylonjs/Particles/cloudPoint" {
  72631. import { Nullable } from "babylonjs/types";
  72632. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72633. import { Mesh } from "babylonjs/Meshes/mesh";
  72634. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72635. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72636. /**
  72637. * Represents one particle of a points cloud system.
  72638. */
  72639. export class CloudPoint {
  72640. /**
  72641. * particle global index
  72642. */
  72643. idx: number;
  72644. /**
  72645. * The color of the particle
  72646. */
  72647. color: Nullable<Color4>;
  72648. /**
  72649. * The world space position of the particle.
  72650. */
  72651. position: Vector3;
  72652. /**
  72653. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72654. */
  72655. rotation: Vector3;
  72656. /**
  72657. * The world space rotation quaternion of the particle.
  72658. */
  72659. rotationQuaternion: Nullable<Quaternion>;
  72660. /**
  72661. * The uv of the particle.
  72662. */
  72663. uv: Nullable<Vector2>;
  72664. /**
  72665. * The current speed of the particle.
  72666. */
  72667. velocity: Vector3;
  72668. /**
  72669. * The pivot point in the particle local space.
  72670. */
  72671. pivot: Vector3;
  72672. /**
  72673. * Must the particle be translated from its pivot point in its local space ?
  72674. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72675. * Default : false
  72676. */
  72677. translateFromPivot: boolean;
  72678. /**
  72679. * Index of this particle in the global "positions" array (Internal use)
  72680. * @hidden
  72681. */
  72682. _pos: number;
  72683. /**
  72684. * @hidden Index of this particle in the global "indices" array (Internal use)
  72685. */
  72686. _ind: number;
  72687. /**
  72688. * Group this particle belongs to
  72689. */
  72690. _group: PointsGroup;
  72691. /**
  72692. * Group id of this particle
  72693. */
  72694. groupId: number;
  72695. /**
  72696. * Index of the particle in its group id (Internal use)
  72697. */
  72698. idxInGroup: number;
  72699. /**
  72700. * @hidden Particle BoundingInfo object (Internal use)
  72701. */
  72702. _boundingInfo: BoundingInfo;
  72703. /**
  72704. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72705. */
  72706. _pcs: PointsCloudSystem;
  72707. /**
  72708. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72709. */
  72710. _stillInvisible: boolean;
  72711. /**
  72712. * @hidden Last computed particle rotation matrix
  72713. */
  72714. _rotationMatrix: number[];
  72715. /**
  72716. * Parent particle Id, if any.
  72717. * Default null.
  72718. */
  72719. parentId: Nullable<number>;
  72720. /**
  72721. * @hidden Internal global position in the PCS.
  72722. */
  72723. _globalPosition: Vector3;
  72724. /**
  72725. * Creates a Point Cloud object.
  72726. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72727. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72728. * @param group (PointsGroup) is the group the particle belongs to
  72729. * @param groupId (integer) is the group identifier in the PCS.
  72730. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72731. * @param pcs defines the PCS it is associated to
  72732. */
  72733. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72734. /**
  72735. * get point size
  72736. */
  72737. get size(): Vector3;
  72738. /**
  72739. * Set point size
  72740. */
  72741. set size(scale: Vector3);
  72742. /**
  72743. * Legacy support, changed quaternion to rotationQuaternion
  72744. */
  72745. get quaternion(): Nullable<Quaternion>;
  72746. /**
  72747. * Legacy support, changed quaternion to rotationQuaternion
  72748. */
  72749. set quaternion(q: Nullable<Quaternion>);
  72750. /**
  72751. * Returns a boolean. True if the particle intersects a mesh, else false
  72752. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72753. * @param target is the object (point or mesh) what the intersection is computed against
  72754. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72755. * @returns true if it intersects
  72756. */
  72757. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72758. /**
  72759. * get the rotation matrix of the particle
  72760. * @hidden
  72761. */
  72762. getRotationMatrix(m: Matrix): void;
  72763. }
  72764. /**
  72765. * Represents a group of points in a points cloud system
  72766. * * PCS internal tool, don't use it manually.
  72767. */
  72768. export class PointsGroup {
  72769. /**
  72770. * The group id
  72771. * @hidden
  72772. */
  72773. groupID: number;
  72774. /**
  72775. * image data for group (internal use)
  72776. * @hidden
  72777. */
  72778. _groupImageData: Nullable<ArrayBufferView>;
  72779. /**
  72780. * Image Width (internal use)
  72781. * @hidden
  72782. */
  72783. _groupImgWidth: number;
  72784. /**
  72785. * Image Height (internal use)
  72786. * @hidden
  72787. */
  72788. _groupImgHeight: number;
  72789. /**
  72790. * Custom position function (internal use)
  72791. * @hidden
  72792. */
  72793. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72794. /**
  72795. * density per facet for surface points
  72796. * @hidden
  72797. */
  72798. _groupDensity: number[];
  72799. /**
  72800. * Only when points are colored by texture carries pointer to texture list array
  72801. * @hidden
  72802. */
  72803. _textureNb: number;
  72804. /**
  72805. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72806. * PCS internal tool, don't use it manually.
  72807. * @hidden
  72808. */
  72809. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72810. }
  72811. }
  72812. declare module "babylonjs/Particles/index" {
  72813. export * from "babylonjs/Particles/baseParticleSystem";
  72814. export * from "babylonjs/Particles/EmitterTypes/index";
  72815. export * from "babylonjs/Particles/gpuParticleSystem";
  72816. export * from "babylonjs/Particles/IParticleSystem";
  72817. export * from "babylonjs/Particles/particle";
  72818. export * from "babylonjs/Particles/particleHelper";
  72819. export * from "babylonjs/Particles/particleSystem";
  72820. import "babylonjs/Particles/particleSystemComponent";
  72821. export * from "babylonjs/Particles/particleSystemComponent";
  72822. export * from "babylonjs/Particles/particleSystemSet";
  72823. export * from "babylonjs/Particles/solidParticle";
  72824. export * from "babylonjs/Particles/solidParticleSystem";
  72825. export * from "babylonjs/Particles/cloudPoint";
  72826. export * from "babylonjs/Particles/pointsCloudSystem";
  72827. export * from "babylonjs/Particles/subEmitter";
  72828. }
  72829. declare module "babylonjs/Physics/physicsEngineComponent" {
  72830. import { Nullable } from "babylonjs/types";
  72831. import { Observable, Observer } from "babylonjs/Misc/observable";
  72832. import { Vector3 } from "babylonjs/Maths/math.vector";
  72833. import { Mesh } from "babylonjs/Meshes/mesh";
  72834. import { ISceneComponent } from "babylonjs/sceneComponent";
  72835. import { Scene } from "babylonjs/scene";
  72836. import { Node } from "babylonjs/node";
  72837. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72838. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72839. module "babylonjs/scene" {
  72840. interface Scene {
  72841. /** @hidden (Backing field) */
  72842. _physicsEngine: Nullable<IPhysicsEngine>;
  72843. /** @hidden */
  72844. _physicsTimeAccumulator: number;
  72845. /**
  72846. * Gets the current physics engine
  72847. * @returns a IPhysicsEngine or null if none attached
  72848. */
  72849. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72850. /**
  72851. * Enables physics to the current scene
  72852. * @param gravity defines the scene's gravity for the physics engine
  72853. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72854. * @return a boolean indicating if the physics engine was initialized
  72855. */
  72856. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72857. /**
  72858. * Disables and disposes the physics engine associated with the scene
  72859. */
  72860. disablePhysicsEngine(): void;
  72861. /**
  72862. * Gets a boolean indicating if there is an active physics engine
  72863. * @returns a boolean indicating if there is an active physics engine
  72864. */
  72865. isPhysicsEnabled(): boolean;
  72866. /**
  72867. * Deletes a physics compound impostor
  72868. * @param compound defines the compound to delete
  72869. */
  72870. deleteCompoundImpostor(compound: any): void;
  72871. /**
  72872. * An event triggered when physic simulation is about to be run
  72873. */
  72874. onBeforePhysicsObservable: Observable<Scene>;
  72875. /**
  72876. * An event triggered when physic simulation has been done
  72877. */
  72878. onAfterPhysicsObservable: Observable<Scene>;
  72879. }
  72880. }
  72881. module "babylonjs/Meshes/abstractMesh" {
  72882. interface AbstractMesh {
  72883. /** @hidden */
  72884. _physicsImpostor: Nullable<PhysicsImpostor>;
  72885. /**
  72886. * Gets or sets impostor used for physic simulation
  72887. * @see https://doc.babylonjs.com/features/physics_engine
  72888. */
  72889. physicsImpostor: Nullable<PhysicsImpostor>;
  72890. /**
  72891. * Gets the current physics impostor
  72892. * @see https://doc.babylonjs.com/features/physics_engine
  72893. * @returns a physics impostor or null
  72894. */
  72895. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72896. /** Apply a physic impulse to the mesh
  72897. * @param force defines the force to apply
  72898. * @param contactPoint defines where to apply the force
  72899. * @returns the current mesh
  72900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72901. */
  72902. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72903. /**
  72904. * Creates a physic joint between two meshes
  72905. * @param otherMesh defines the other mesh to use
  72906. * @param pivot1 defines the pivot to use on this mesh
  72907. * @param pivot2 defines the pivot to use on the other mesh
  72908. * @param options defines additional options (can be plugin dependent)
  72909. * @returns the current mesh
  72910. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72911. */
  72912. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72913. /** @hidden */
  72914. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72915. }
  72916. }
  72917. /**
  72918. * Defines the physics engine scene component responsible to manage a physics engine
  72919. */
  72920. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72921. /**
  72922. * The component name helpful to identify the component in the list of scene components.
  72923. */
  72924. readonly name: string;
  72925. /**
  72926. * The scene the component belongs to.
  72927. */
  72928. scene: Scene;
  72929. /**
  72930. * Creates a new instance of the component for the given scene
  72931. * @param scene Defines the scene to register the component in
  72932. */
  72933. constructor(scene: Scene);
  72934. /**
  72935. * Registers the component in a given scene
  72936. */
  72937. register(): void;
  72938. /**
  72939. * Rebuilds the elements related to this component in case of
  72940. * context lost for instance.
  72941. */
  72942. rebuild(): void;
  72943. /**
  72944. * Disposes the component and the associated ressources
  72945. */
  72946. dispose(): void;
  72947. }
  72948. }
  72949. declare module "babylonjs/Physics/physicsHelper" {
  72950. import { Nullable } from "babylonjs/types";
  72951. import { Vector3 } from "babylonjs/Maths/math.vector";
  72952. import { Mesh } from "babylonjs/Meshes/mesh";
  72953. import { Scene } from "babylonjs/scene";
  72954. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72955. /**
  72956. * A helper for physics simulations
  72957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72958. */
  72959. export class PhysicsHelper {
  72960. private _scene;
  72961. private _physicsEngine;
  72962. /**
  72963. * Initializes the Physics helper
  72964. * @param scene Babylon.js scene
  72965. */
  72966. constructor(scene: Scene);
  72967. /**
  72968. * Applies a radial explosion impulse
  72969. * @param origin the origin of the explosion
  72970. * @param radiusOrEventOptions the radius or the options of radial explosion
  72971. * @param strength the explosion strength
  72972. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72973. * @returns A physics radial explosion event, or null
  72974. */
  72975. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72976. /**
  72977. * Applies a radial explosion force
  72978. * @param origin the origin of the explosion
  72979. * @param radiusOrEventOptions the radius or the options of radial explosion
  72980. * @param strength the explosion strength
  72981. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72982. * @returns A physics radial explosion event, or null
  72983. */
  72984. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72985. /**
  72986. * Creates a gravitational field
  72987. * @param origin the origin of the explosion
  72988. * @param radiusOrEventOptions the radius or the options of radial explosion
  72989. * @param strength the explosion strength
  72990. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72991. * @returns A physics gravitational field event, or null
  72992. */
  72993. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72994. /**
  72995. * Creates a physics updraft event
  72996. * @param origin the origin of the updraft
  72997. * @param radiusOrEventOptions the radius or the options of the updraft
  72998. * @param strength the strength of the updraft
  72999. * @param height the height of the updraft
  73000. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73001. * @returns A physics updraft event, or null
  73002. */
  73003. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73004. /**
  73005. * Creates a physics vortex event
  73006. * @param origin the of the vortex
  73007. * @param radiusOrEventOptions the radius or the options of the vortex
  73008. * @param strength the strength of the vortex
  73009. * @param height the height of the vortex
  73010. * @returns a Physics vortex event, or null
  73011. * A physics vortex event or null
  73012. */
  73013. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73014. }
  73015. /**
  73016. * Represents a physics radial explosion event
  73017. */
  73018. class PhysicsRadialExplosionEvent {
  73019. private _scene;
  73020. private _options;
  73021. private _sphere;
  73022. private _dataFetched;
  73023. /**
  73024. * Initializes a radial explosioin event
  73025. * @param _scene BabylonJS scene
  73026. * @param _options The options for the vortex event
  73027. */
  73028. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73029. /**
  73030. * Returns the data related to the radial explosion event (sphere).
  73031. * @returns The radial explosion event data
  73032. */
  73033. getData(): PhysicsRadialExplosionEventData;
  73034. /**
  73035. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73036. * @param impostor A physics imposter
  73037. * @param origin the origin of the explosion
  73038. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73039. */
  73040. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73041. /**
  73042. * Triggers affecterd impostors callbacks
  73043. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73044. */
  73045. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73046. /**
  73047. * Disposes the sphere.
  73048. * @param force Specifies if the sphere should be disposed by force
  73049. */
  73050. dispose(force?: boolean): void;
  73051. /*** Helpers ***/
  73052. private _prepareSphere;
  73053. private _intersectsWithSphere;
  73054. }
  73055. /**
  73056. * Represents a gravitational field event
  73057. */
  73058. class PhysicsGravitationalFieldEvent {
  73059. private _physicsHelper;
  73060. private _scene;
  73061. private _origin;
  73062. private _options;
  73063. private _tickCallback;
  73064. private _sphere;
  73065. private _dataFetched;
  73066. /**
  73067. * Initializes the physics gravitational field event
  73068. * @param _physicsHelper A physics helper
  73069. * @param _scene BabylonJS scene
  73070. * @param _origin The origin position of the gravitational field event
  73071. * @param _options The options for the vortex event
  73072. */
  73073. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73074. /**
  73075. * Returns the data related to the gravitational field event (sphere).
  73076. * @returns A gravitational field event
  73077. */
  73078. getData(): PhysicsGravitationalFieldEventData;
  73079. /**
  73080. * Enables the gravitational field.
  73081. */
  73082. enable(): void;
  73083. /**
  73084. * Disables the gravitational field.
  73085. */
  73086. disable(): void;
  73087. /**
  73088. * Disposes the sphere.
  73089. * @param force The force to dispose from the gravitational field event
  73090. */
  73091. dispose(force?: boolean): void;
  73092. private _tick;
  73093. }
  73094. /**
  73095. * Represents a physics updraft event
  73096. */
  73097. class PhysicsUpdraftEvent {
  73098. private _scene;
  73099. private _origin;
  73100. private _options;
  73101. private _physicsEngine;
  73102. private _originTop;
  73103. private _originDirection;
  73104. private _tickCallback;
  73105. private _cylinder;
  73106. private _cylinderPosition;
  73107. private _dataFetched;
  73108. /**
  73109. * Initializes the physics updraft event
  73110. * @param _scene BabylonJS scene
  73111. * @param _origin The origin position of the updraft
  73112. * @param _options The options for the updraft event
  73113. */
  73114. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73115. /**
  73116. * Returns the data related to the updraft event (cylinder).
  73117. * @returns A physics updraft event
  73118. */
  73119. getData(): PhysicsUpdraftEventData;
  73120. /**
  73121. * Enables the updraft.
  73122. */
  73123. enable(): void;
  73124. /**
  73125. * Disables the updraft.
  73126. */
  73127. disable(): void;
  73128. /**
  73129. * Disposes the cylinder.
  73130. * @param force Specifies if the updraft should be disposed by force
  73131. */
  73132. dispose(force?: boolean): void;
  73133. private getImpostorHitData;
  73134. private _tick;
  73135. /*** Helpers ***/
  73136. private _prepareCylinder;
  73137. private _intersectsWithCylinder;
  73138. }
  73139. /**
  73140. * Represents a physics vortex event
  73141. */
  73142. class PhysicsVortexEvent {
  73143. private _scene;
  73144. private _origin;
  73145. private _options;
  73146. private _physicsEngine;
  73147. private _originTop;
  73148. private _tickCallback;
  73149. private _cylinder;
  73150. private _cylinderPosition;
  73151. private _dataFetched;
  73152. /**
  73153. * Initializes the physics vortex event
  73154. * @param _scene The BabylonJS scene
  73155. * @param _origin The origin position of the vortex
  73156. * @param _options The options for the vortex event
  73157. */
  73158. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73159. /**
  73160. * Returns the data related to the vortex event (cylinder).
  73161. * @returns The physics vortex event data
  73162. */
  73163. getData(): PhysicsVortexEventData;
  73164. /**
  73165. * Enables the vortex.
  73166. */
  73167. enable(): void;
  73168. /**
  73169. * Disables the cortex.
  73170. */
  73171. disable(): void;
  73172. /**
  73173. * Disposes the sphere.
  73174. * @param force
  73175. */
  73176. dispose(force?: boolean): void;
  73177. private getImpostorHitData;
  73178. private _tick;
  73179. /*** Helpers ***/
  73180. private _prepareCylinder;
  73181. private _intersectsWithCylinder;
  73182. }
  73183. /**
  73184. * Options fot the radial explosion event
  73185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73186. */
  73187. export class PhysicsRadialExplosionEventOptions {
  73188. /**
  73189. * The radius of the sphere for the radial explosion.
  73190. */
  73191. radius: number;
  73192. /**
  73193. * The strenth of the explosion.
  73194. */
  73195. strength: number;
  73196. /**
  73197. * The strenght of the force in correspondence to the distance of the affected object
  73198. */
  73199. falloff: PhysicsRadialImpulseFalloff;
  73200. /**
  73201. * Sphere options for the radial explosion.
  73202. */
  73203. sphere: {
  73204. segments: number;
  73205. diameter: number;
  73206. };
  73207. /**
  73208. * Sphere options for the radial explosion.
  73209. */
  73210. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73211. }
  73212. /**
  73213. * Options fot the updraft event
  73214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73215. */
  73216. export class PhysicsUpdraftEventOptions {
  73217. /**
  73218. * The radius of the cylinder for the vortex
  73219. */
  73220. radius: number;
  73221. /**
  73222. * The strenth of the updraft.
  73223. */
  73224. strength: number;
  73225. /**
  73226. * The height of the cylinder for the updraft.
  73227. */
  73228. height: number;
  73229. /**
  73230. * The mode for the the updraft.
  73231. */
  73232. updraftMode: PhysicsUpdraftMode;
  73233. }
  73234. /**
  73235. * Options fot the vortex event
  73236. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73237. */
  73238. export class PhysicsVortexEventOptions {
  73239. /**
  73240. * The radius of the cylinder for the vortex
  73241. */
  73242. radius: number;
  73243. /**
  73244. * The strenth of the vortex.
  73245. */
  73246. strength: number;
  73247. /**
  73248. * The height of the cylinder for the vortex.
  73249. */
  73250. height: number;
  73251. /**
  73252. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73253. */
  73254. centripetalForceThreshold: number;
  73255. /**
  73256. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73257. */
  73258. centripetalForceMultiplier: number;
  73259. /**
  73260. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73261. */
  73262. centrifugalForceMultiplier: number;
  73263. /**
  73264. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73265. */
  73266. updraftForceMultiplier: number;
  73267. }
  73268. /**
  73269. * The strenght of the force in correspondence to the distance of the affected object
  73270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73271. */
  73272. export enum PhysicsRadialImpulseFalloff {
  73273. /** Defines that impulse is constant in strength across it's whole radius */
  73274. Constant = 0,
  73275. /** Defines that impulse gets weaker if it's further from the origin */
  73276. Linear = 1
  73277. }
  73278. /**
  73279. * The strength of the force in correspondence to the distance of the affected object
  73280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73281. */
  73282. export enum PhysicsUpdraftMode {
  73283. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73284. Center = 0,
  73285. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73286. Perpendicular = 1
  73287. }
  73288. /**
  73289. * Interface for a physics hit data
  73290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73291. */
  73292. export interface PhysicsHitData {
  73293. /**
  73294. * The force applied at the contact point
  73295. */
  73296. force: Vector3;
  73297. /**
  73298. * The contact point
  73299. */
  73300. contactPoint: Vector3;
  73301. /**
  73302. * The distance from the origin to the contact point
  73303. */
  73304. distanceFromOrigin: number;
  73305. }
  73306. /**
  73307. * Interface for radial explosion event data
  73308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73309. */
  73310. export interface PhysicsRadialExplosionEventData {
  73311. /**
  73312. * A sphere used for the radial explosion event
  73313. */
  73314. sphere: Mesh;
  73315. }
  73316. /**
  73317. * Interface for gravitational field event data
  73318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73319. */
  73320. export interface PhysicsGravitationalFieldEventData {
  73321. /**
  73322. * A sphere mesh used for the gravitational field event
  73323. */
  73324. sphere: Mesh;
  73325. }
  73326. /**
  73327. * Interface for updraft event data
  73328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73329. */
  73330. export interface PhysicsUpdraftEventData {
  73331. /**
  73332. * A cylinder used for the updraft event
  73333. */
  73334. cylinder: Mesh;
  73335. }
  73336. /**
  73337. * Interface for vortex event data
  73338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73339. */
  73340. export interface PhysicsVortexEventData {
  73341. /**
  73342. * A cylinder used for the vortex event
  73343. */
  73344. cylinder: Mesh;
  73345. }
  73346. /**
  73347. * Interface for an affected physics impostor
  73348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73349. */
  73350. export interface PhysicsAffectedImpostorWithData {
  73351. /**
  73352. * The impostor affected by the effect
  73353. */
  73354. impostor: PhysicsImpostor;
  73355. /**
  73356. * The data about the hit/horce from the explosion
  73357. */
  73358. hitData: PhysicsHitData;
  73359. }
  73360. }
  73361. declare module "babylonjs/Physics/Plugins/index" {
  73362. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73363. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73364. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73365. }
  73366. declare module "babylonjs/Physics/index" {
  73367. export * from "babylonjs/Physics/IPhysicsEngine";
  73368. export * from "babylonjs/Physics/physicsEngine";
  73369. export * from "babylonjs/Physics/physicsEngineComponent";
  73370. export * from "babylonjs/Physics/physicsHelper";
  73371. export * from "babylonjs/Physics/physicsImpostor";
  73372. export * from "babylonjs/Physics/physicsJoint";
  73373. export * from "babylonjs/Physics/Plugins/index";
  73374. }
  73375. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73376. /** @hidden */
  73377. export var blackAndWhitePixelShader: {
  73378. name: string;
  73379. shader: string;
  73380. };
  73381. }
  73382. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73383. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73384. import { Camera } from "babylonjs/Cameras/camera";
  73385. import { Engine } from "babylonjs/Engines/engine";
  73386. import "babylonjs/Shaders/blackAndWhite.fragment";
  73387. import { Nullable } from "babylonjs/types";
  73388. import { Scene } from "babylonjs/scene";
  73389. /**
  73390. * Post process used to render in black and white
  73391. */
  73392. export class BlackAndWhitePostProcess extends PostProcess {
  73393. /**
  73394. * Linear about to convert he result to black and white (default: 1)
  73395. */
  73396. degree: number;
  73397. /**
  73398. * Gets a string identifying the name of the class
  73399. * @returns "BlackAndWhitePostProcess" string
  73400. */
  73401. getClassName(): string;
  73402. /**
  73403. * Creates a black and white post process
  73404. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73405. * @param name The name of the effect.
  73406. * @param options The required width/height ratio to downsize to before computing the render pass.
  73407. * @param camera The camera to apply the render pass to.
  73408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73409. * @param engine The engine which the post process will be applied. (default: current engine)
  73410. * @param reusable If the post process can be reused on the same frame. (default: false)
  73411. */
  73412. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73413. /** @hidden */
  73414. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73415. }
  73416. }
  73417. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73418. import { Nullable } from "babylonjs/types";
  73419. import { Camera } from "babylonjs/Cameras/camera";
  73420. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73421. import { Engine } from "babylonjs/Engines/engine";
  73422. /**
  73423. * This represents a set of one or more post processes in Babylon.
  73424. * A post process can be used to apply a shader to a texture after it is rendered.
  73425. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73426. */
  73427. export class PostProcessRenderEffect {
  73428. private _postProcesses;
  73429. private _getPostProcesses;
  73430. private _singleInstance;
  73431. private _cameras;
  73432. private _indicesForCamera;
  73433. /**
  73434. * Name of the effect
  73435. * @hidden
  73436. */
  73437. _name: string;
  73438. /**
  73439. * Instantiates a post process render effect.
  73440. * A post process can be used to apply a shader to a texture after it is rendered.
  73441. * @param engine The engine the effect is tied to
  73442. * @param name The name of the effect
  73443. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73444. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73445. */
  73446. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73447. /**
  73448. * Checks if all the post processes in the effect are supported.
  73449. */
  73450. get isSupported(): boolean;
  73451. /**
  73452. * Updates the current state of the effect
  73453. * @hidden
  73454. */
  73455. _update(): void;
  73456. /**
  73457. * Attaches the effect on cameras
  73458. * @param cameras The camera to attach to.
  73459. * @hidden
  73460. */
  73461. _attachCameras(cameras: Camera): void;
  73462. /**
  73463. * Attaches the effect on cameras
  73464. * @param cameras The camera to attach to.
  73465. * @hidden
  73466. */
  73467. _attachCameras(cameras: Camera[]): void;
  73468. /**
  73469. * Detaches the effect on cameras
  73470. * @param cameras The camera to detatch from.
  73471. * @hidden
  73472. */
  73473. _detachCameras(cameras: Camera): void;
  73474. /**
  73475. * Detatches the effect on cameras
  73476. * @param cameras The camera to detatch from.
  73477. * @hidden
  73478. */
  73479. _detachCameras(cameras: Camera[]): void;
  73480. /**
  73481. * Enables the effect on given cameras
  73482. * @param cameras The camera to enable.
  73483. * @hidden
  73484. */
  73485. _enable(cameras: Camera): void;
  73486. /**
  73487. * Enables the effect on given cameras
  73488. * @param cameras The camera to enable.
  73489. * @hidden
  73490. */
  73491. _enable(cameras: Nullable<Camera[]>): void;
  73492. /**
  73493. * Disables the effect on the given cameras
  73494. * @param cameras The camera to disable.
  73495. * @hidden
  73496. */
  73497. _disable(cameras: Camera): void;
  73498. /**
  73499. * Disables the effect on the given cameras
  73500. * @param cameras The camera to disable.
  73501. * @hidden
  73502. */
  73503. _disable(cameras: Nullable<Camera[]>): void;
  73504. /**
  73505. * Gets a list of the post processes contained in the effect.
  73506. * @param camera The camera to get the post processes on.
  73507. * @returns The list of the post processes in the effect.
  73508. */
  73509. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73510. }
  73511. }
  73512. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73513. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73514. /** @hidden */
  73515. export var extractHighlightsPixelShader: {
  73516. name: string;
  73517. shader: string;
  73518. };
  73519. }
  73520. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73521. import { Nullable } from "babylonjs/types";
  73522. import { Camera } from "babylonjs/Cameras/camera";
  73523. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73524. import { Engine } from "babylonjs/Engines/engine";
  73525. import "babylonjs/Shaders/extractHighlights.fragment";
  73526. /**
  73527. * 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.
  73528. */
  73529. export class ExtractHighlightsPostProcess extends PostProcess {
  73530. /**
  73531. * The luminance threshold, pixels below this value will be set to black.
  73532. */
  73533. threshold: number;
  73534. /** @hidden */
  73535. _exposure: number;
  73536. /**
  73537. * Post process which has the input texture to be used when performing highlight extraction
  73538. * @hidden
  73539. */
  73540. _inputPostProcess: Nullable<PostProcess>;
  73541. /**
  73542. * Gets a string identifying the name of the class
  73543. * @returns "ExtractHighlightsPostProcess" string
  73544. */
  73545. getClassName(): string;
  73546. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73547. }
  73548. }
  73549. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73550. /** @hidden */
  73551. export var bloomMergePixelShader: {
  73552. name: string;
  73553. shader: string;
  73554. };
  73555. }
  73556. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73557. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73558. import { Nullable } from "babylonjs/types";
  73559. import { Engine } from "babylonjs/Engines/engine";
  73560. import { Camera } from "babylonjs/Cameras/camera";
  73561. import "babylonjs/Shaders/bloomMerge.fragment";
  73562. /**
  73563. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73564. */
  73565. export class BloomMergePostProcess extends PostProcess {
  73566. /** Weight of the bloom to be added to the original input. */
  73567. weight: number;
  73568. /**
  73569. * Gets a string identifying the name of the class
  73570. * @returns "BloomMergePostProcess" string
  73571. */
  73572. getClassName(): string;
  73573. /**
  73574. * Creates a new instance of @see BloomMergePostProcess
  73575. * @param name The name of the effect.
  73576. * @param originalFromInput Post process which's input will be used for the merge.
  73577. * @param blurred Blurred highlights post process which's output will be used.
  73578. * @param weight Weight of the bloom to be added to the original input.
  73579. * @param options The required width/height ratio to downsize to before computing the render pass.
  73580. * @param camera The camera to apply the render pass to.
  73581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73582. * @param engine The engine which the post process will be applied. (default: current engine)
  73583. * @param reusable If the post process can be reused on the same frame. (default: false)
  73584. * @param textureType Type of textures used when performing the post process. (default: 0)
  73585. * @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)
  73586. */
  73587. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73588. /** Weight of the bloom to be added to the original input. */
  73589. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73590. }
  73591. }
  73592. declare module "babylonjs/PostProcesses/bloomEffect" {
  73593. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73594. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73595. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73596. import { Camera } from "babylonjs/Cameras/camera";
  73597. import { Scene } from "babylonjs/scene";
  73598. /**
  73599. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73600. */
  73601. export class BloomEffect extends PostProcessRenderEffect {
  73602. private bloomScale;
  73603. /**
  73604. * @hidden Internal
  73605. */
  73606. _effects: Array<PostProcess>;
  73607. /**
  73608. * @hidden Internal
  73609. */
  73610. _downscale: ExtractHighlightsPostProcess;
  73611. private _blurX;
  73612. private _blurY;
  73613. private _merge;
  73614. /**
  73615. * The luminance threshold to find bright areas of the image to bloom.
  73616. */
  73617. get threshold(): number;
  73618. set threshold(value: number);
  73619. /**
  73620. * The strength of the bloom.
  73621. */
  73622. get weight(): number;
  73623. set weight(value: number);
  73624. /**
  73625. * Specifies the size of the bloom blur kernel, relative to the final output size
  73626. */
  73627. get kernel(): number;
  73628. set kernel(value: number);
  73629. /**
  73630. * Creates a new instance of @see BloomEffect
  73631. * @param scene The scene the effect belongs to.
  73632. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73633. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73634. * @param bloomWeight The the strength of bloom.
  73635. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73636. * @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)
  73637. */
  73638. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73639. /**
  73640. * Disposes each of the internal effects for a given camera.
  73641. * @param camera The camera to dispose the effect on.
  73642. */
  73643. disposeEffects(camera: Camera): void;
  73644. /**
  73645. * @hidden Internal
  73646. */
  73647. _updateEffects(): void;
  73648. /**
  73649. * Internal
  73650. * @returns if all the contained post processes are ready.
  73651. * @hidden
  73652. */
  73653. _isReady(): boolean;
  73654. }
  73655. }
  73656. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73657. /** @hidden */
  73658. export var chromaticAberrationPixelShader: {
  73659. name: string;
  73660. shader: string;
  73661. };
  73662. }
  73663. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73664. import { Vector2 } from "babylonjs/Maths/math.vector";
  73665. import { Nullable } from "babylonjs/types";
  73666. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73667. import { Camera } from "babylonjs/Cameras/camera";
  73668. import { Engine } from "babylonjs/Engines/engine";
  73669. import "babylonjs/Shaders/chromaticAberration.fragment";
  73670. import { Scene } from "babylonjs/scene";
  73671. /**
  73672. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73673. */
  73674. export class ChromaticAberrationPostProcess extends PostProcess {
  73675. /**
  73676. * The amount of seperation of rgb channels (default: 30)
  73677. */
  73678. aberrationAmount: number;
  73679. /**
  73680. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73681. */
  73682. radialIntensity: number;
  73683. /**
  73684. * 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))
  73685. */
  73686. direction: Vector2;
  73687. /**
  73688. * 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))
  73689. */
  73690. centerPosition: Vector2;
  73691. /** The width of the screen to apply the effect on */
  73692. screenWidth: number;
  73693. /** The height of the screen to apply the effect on */
  73694. screenHeight: number;
  73695. /**
  73696. * Gets a string identifying the name of the class
  73697. * @returns "ChromaticAberrationPostProcess" string
  73698. */
  73699. getClassName(): string;
  73700. /**
  73701. * Creates a new instance ChromaticAberrationPostProcess
  73702. * @param name The name of the effect.
  73703. * @param screenWidth The width of the screen to apply the effect on.
  73704. * @param screenHeight The height of the screen to apply the effect on.
  73705. * @param options The required width/height ratio to downsize to before computing the render pass.
  73706. * @param camera The camera to apply the render pass to.
  73707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73708. * @param engine The engine which the post process will be applied. (default: current engine)
  73709. * @param reusable If the post process can be reused on the same frame. (default: false)
  73710. * @param textureType Type of textures used when performing the post process. (default: 0)
  73711. * @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)
  73712. */
  73713. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73714. /** @hidden */
  73715. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73716. }
  73717. }
  73718. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73719. /** @hidden */
  73720. export var circleOfConfusionPixelShader: {
  73721. name: string;
  73722. shader: string;
  73723. };
  73724. }
  73725. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73726. import { Nullable } from "babylonjs/types";
  73727. import { Engine } from "babylonjs/Engines/engine";
  73728. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73729. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73730. import { Camera } from "babylonjs/Cameras/camera";
  73731. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73732. /**
  73733. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73734. */
  73735. export class CircleOfConfusionPostProcess extends PostProcess {
  73736. /**
  73737. * 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.
  73738. */
  73739. lensSize: number;
  73740. /**
  73741. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73742. */
  73743. fStop: number;
  73744. /**
  73745. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73746. */
  73747. focusDistance: number;
  73748. /**
  73749. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73750. */
  73751. focalLength: number;
  73752. /**
  73753. * Gets a string identifying the name of the class
  73754. * @returns "CircleOfConfusionPostProcess" string
  73755. */
  73756. getClassName(): string;
  73757. private _depthTexture;
  73758. /**
  73759. * Creates a new instance CircleOfConfusionPostProcess
  73760. * @param name The name of the effect.
  73761. * @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.
  73762. * @param options The required width/height ratio to downsize to before computing the render pass.
  73763. * @param camera The camera to apply the render pass to.
  73764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73765. * @param engine The engine which the post process will be applied. (default: current engine)
  73766. * @param reusable If the post process can be reused on the same frame. (default: false)
  73767. * @param textureType Type of textures used when performing the post process. (default: 0)
  73768. * @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)
  73769. */
  73770. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73771. /**
  73772. * 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.
  73773. */
  73774. set depthTexture(value: RenderTargetTexture);
  73775. }
  73776. }
  73777. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73778. /** @hidden */
  73779. export var colorCorrectionPixelShader: {
  73780. name: string;
  73781. shader: string;
  73782. };
  73783. }
  73784. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73785. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73786. import { Engine } from "babylonjs/Engines/engine";
  73787. import { Camera } from "babylonjs/Cameras/camera";
  73788. import "babylonjs/Shaders/colorCorrection.fragment";
  73789. import { Nullable } from "babylonjs/types";
  73790. import { Scene } from "babylonjs/scene";
  73791. /**
  73792. *
  73793. * This post-process allows the modification of rendered colors by using
  73794. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73795. *
  73796. * The object needs to be provided an url to a texture containing the color
  73797. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73798. * Use an image editing software to tweak the LUT to match your needs.
  73799. *
  73800. * For an example of a color LUT, see here:
  73801. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73802. * For explanations on color grading, see here:
  73803. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73804. *
  73805. */
  73806. export class ColorCorrectionPostProcess extends PostProcess {
  73807. private _colorTableTexture;
  73808. /**
  73809. * Gets the color table url used to create the LUT texture
  73810. */
  73811. colorTableUrl: string;
  73812. /**
  73813. * Gets a string identifying the name of the class
  73814. * @returns "ColorCorrectionPostProcess" string
  73815. */
  73816. getClassName(): string;
  73817. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73818. /** @hidden */
  73819. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73820. }
  73821. }
  73822. declare module "babylonjs/Shaders/convolution.fragment" {
  73823. /** @hidden */
  73824. export var convolutionPixelShader: {
  73825. name: string;
  73826. shader: string;
  73827. };
  73828. }
  73829. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73830. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73831. import { Nullable } from "babylonjs/types";
  73832. import { Camera } from "babylonjs/Cameras/camera";
  73833. import { Engine } from "babylonjs/Engines/engine";
  73834. import "babylonjs/Shaders/convolution.fragment";
  73835. import { Scene } from "babylonjs/scene";
  73836. /**
  73837. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73838. * input texture to perform effects such as edge detection or sharpening
  73839. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73840. */
  73841. export class ConvolutionPostProcess extends PostProcess {
  73842. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73843. kernel: number[];
  73844. /**
  73845. * Gets a string identifying the name of the class
  73846. * @returns "ConvolutionPostProcess" string
  73847. */
  73848. getClassName(): string;
  73849. /**
  73850. * Creates a new instance ConvolutionPostProcess
  73851. * @param name The name of the effect.
  73852. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73853. * @param options The required width/height ratio to downsize to before computing the render pass.
  73854. * @param camera The camera to apply the render pass to.
  73855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73856. * @param engine The engine which the post process will be applied. (default: current engine)
  73857. * @param reusable If the post process can be reused on the same frame. (default: false)
  73858. * @param textureType Type of textures used when performing the post process. (default: 0)
  73859. */
  73860. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73861. /** @hidden */
  73862. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73863. /**
  73864. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73865. */
  73866. static EdgeDetect0Kernel: number[];
  73867. /**
  73868. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73869. */
  73870. static EdgeDetect1Kernel: number[];
  73871. /**
  73872. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73873. */
  73874. static EdgeDetect2Kernel: number[];
  73875. /**
  73876. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73877. */
  73878. static SharpenKernel: number[];
  73879. /**
  73880. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73881. */
  73882. static EmbossKernel: number[];
  73883. /**
  73884. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73885. */
  73886. static GaussianKernel: number[];
  73887. }
  73888. }
  73889. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73890. import { Nullable } from "babylonjs/types";
  73891. import { Vector2 } from "babylonjs/Maths/math.vector";
  73892. import { Camera } from "babylonjs/Cameras/camera";
  73893. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73894. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73895. import { Engine } from "babylonjs/Engines/engine";
  73896. import { Scene } from "babylonjs/scene";
  73897. /**
  73898. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73899. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73900. * based on samples that have a large difference in distance than the center pixel.
  73901. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73902. */
  73903. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73904. /**
  73905. * The direction the blur should be applied
  73906. */
  73907. direction: Vector2;
  73908. /**
  73909. * Gets a string identifying the name of the class
  73910. * @returns "DepthOfFieldBlurPostProcess" string
  73911. */
  73912. getClassName(): string;
  73913. /**
  73914. * Creates a new instance CircleOfConfusionPostProcess
  73915. * @param name The name of the effect.
  73916. * @param scene The scene the effect belongs to.
  73917. * @param direction The direction the blur should be applied.
  73918. * @param kernel The size of the kernel used to blur.
  73919. * @param options The required width/height ratio to downsize to before computing the render pass.
  73920. * @param camera The camera to apply the render pass to.
  73921. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73922. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73923. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73924. * @param engine The engine which the post process will be applied. (default: current engine)
  73925. * @param reusable If the post process can be reused on the same frame. (default: false)
  73926. * @param textureType Type of textures used when performing the post process. (default: 0)
  73927. * @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)
  73928. */
  73929. 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);
  73930. }
  73931. }
  73932. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73933. /** @hidden */
  73934. export var depthOfFieldMergePixelShader: {
  73935. name: string;
  73936. shader: string;
  73937. };
  73938. }
  73939. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73940. import { Nullable } from "babylonjs/types";
  73941. import { Camera } from "babylonjs/Cameras/camera";
  73942. import { Effect } from "babylonjs/Materials/effect";
  73943. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73944. import { Engine } from "babylonjs/Engines/engine";
  73945. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73946. /**
  73947. * Options to be set when merging outputs from the default pipeline.
  73948. */
  73949. export class DepthOfFieldMergePostProcessOptions {
  73950. /**
  73951. * The original image to merge on top of
  73952. */
  73953. originalFromInput: PostProcess;
  73954. /**
  73955. * Parameters to perform the merge of the depth of field effect
  73956. */
  73957. depthOfField?: {
  73958. circleOfConfusion: PostProcess;
  73959. blurSteps: Array<PostProcess>;
  73960. };
  73961. /**
  73962. * Parameters to perform the merge of bloom effect
  73963. */
  73964. bloom?: {
  73965. blurred: PostProcess;
  73966. weight: number;
  73967. };
  73968. }
  73969. /**
  73970. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73971. */
  73972. export class DepthOfFieldMergePostProcess extends PostProcess {
  73973. private blurSteps;
  73974. /**
  73975. * Gets a string identifying the name of the class
  73976. * @returns "DepthOfFieldMergePostProcess" string
  73977. */
  73978. getClassName(): string;
  73979. /**
  73980. * Creates a new instance of DepthOfFieldMergePostProcess
  73981. * @param name The name of the effect.
  73982. * @param originalFromInput Post process which's input will be used for the merge.
  73983. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73984. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73985. * @param options The required width/height ratio to downsize to before computing the render pass.
  73986. * @param camera The camera to apply the render pass to.
  73987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73988. * @param engine The engine which the post process will be applied. (default: current engine)
  73989. * @param reusable If the post process can be reused on the same frame. (default: false)
  73990. * @param textureType Type of textures used when performing the post process. (default: 0)
  73991. * @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)
  73992. */
  73993. 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);
  73994. /**
  73995. * Updates the effect with the current post process compile time values and recompiles the shader.
  73996. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73997. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73998. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73999. * @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
  74000. * @param onCompiled Called when the shader has been compiled.
  74001. * @param onError Called if there is an error when compiling a shader.
  74002. */
  74003. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74004. }
  74005. }
  74006. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74007. import { Nullable } from "babylonjs/types";
  74008. import { Camera } from "babylonjs/Cameras/camera";
  74009. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74010. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74011. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74012. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74013. import { Scene } from "babylonjs/scene";
  74014. /**
  74015. * Specifies the level of max blur that should be applied when using the depth of field effect
  74016. */
  74017. export enum DepthOfFieldEffectBlurLevel {
  74018. /**
  74019. * Subtle blur
  74020. */
  74021. Low = 0,
  74022. /**
  74023. * Medium blur
  74024. */
  74025. Medium = 1,
  74026. /**
  74027. * Large blur
  74028. */
  74029. High = 2
  74030. }
  74031. /**
  74032. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74033. */
  74034. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74035. private _circleOfConfusion;
  74036. /**
  74037. * @hidden Internal, blurs from high to low
  74038. */
  74039. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74040. private _depthOfFieldBlurY;
  74041. private _dofMerge;
  74042. /**
  74043. * @hidden Internal post processes in depth of field effect
  74044. */
  74045. _effects: Array<PostProcess>;
  74046. /**
  74047. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74048. */
  74049. set focalLength(value: number);
  74050. get focalLength(): number;
  74051. /**
  74052. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74053. */
  74054. set fStop(value: number);
  74055. get fStop(): number;
  74056. /**
  74057. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74058. */
  74059. set focusDistance(value: number);
  74060. get focusDistance(): number;
  74061. /**
  74062. * 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.
  74063. */
  74064. set lensSize(value: number);
  74065. get lensSize(): number;
  74066. /**
  74067. * Creates a new instance DepthOfFieldEffect
  74068. * @param scene The scene the effect belongs to.
  74069. * @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.
  74070. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74071. * @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)
  74072. */
  74073. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74074. /**
  74075. * Get the current class name of the current effet
  74076. * @returns "DepthOfFieldEffect"
  74077. */
  74078. getClassName(): string;
  74079. /**
  74080. * 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.
  74081. */
  74082. set depthTexture(value: RenderTargetTexture);
  74083. /**
  74084. * Disposes each of the internal effects for a given camera.
  74085. * @param camera The camera to dispose the effect on.
  74086. */
  74087. disposeEffects(camera: Camera): void;
  74088. /**
  74089. * @hidden Internal
  74090. */
  74091. _updateEffects(): void;
  74092. /**
  74093. * Internal
  74094. * @returns if all the contained post processes are ready.
  74095. * @hidden
  74096. */
  74097. _isReady(): boolean;
  74098. }
  74099. }
  74100. declare module "babylonjs/Shaders/displayPass.fragment" {
  74101. /** @hidden */
  74102. export var displayPassPixelShader: {
  74103. name: string;
  74104. shader: string;
  74105. };
  74106. }
  74107. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74108. import { Nullable } from "babylonjs/types";
  74109. import { Camera } from "babylonjs/Cameras/camera";
  74110. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74111. import { Engine } from "babylonjs/Engines/engine";
  74112. import "babylonjs/Shaders/displayPass.fragment";
  74113. import { Scene } from "babylonjs/scene";
  74114. /**
  74115. * DisplayPassPostProcess which produces an output the same as it's input
  74116. */
  74117. export class DisplayPassPostProcess extends PostProcess {
  74118. /**
  74119. * Gets a string identifying the name of the class
  74120. * @returns "DisplayPassPostProcess" string
  74121. */
  74122. getClassName(): string;
  74123. /**
  74124. * Creates the DisplayPassPostProcess
  74125. * @param name The name of the effect.
  74126. * @param options The required width/height ratio to downsize to before computing the render pass.
  74127. * @param camera The camera to apply the render pass to.
  74128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74129. * @param engine The engine which the post process will be applied. (default: current engine)
  74130. * @param reusable If the post process can be reused on the same frame. (default: false)
  74131. */
  74132. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74133. /** @hidden */
  74134. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74135. }
  74136. }
  74137. declare module "babylonjs/Shaders/filter.fragment" {
  74138. /** @hidden */
  74139. export var filterPixelShader: {
  74140. name: string;
  74141. shader: string;
  74142. };
  74143. }
  74144. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74145. import { Nullable } from "babylonjs/types";
  74146. import { Matrix } from "babylonjs/Maths/math.vector";
  74147. import { Camera } from "babylonjs/Cameras/camera";
  74148. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74149. import { Engine } from "babylonjs/Engines/engine";
  74150. import "babylonjs/Shaders/filter.fragment";
  74151. import { Scene } from "babylonjs/scene";
  74152. /**
  74153. * Applies a kernel filter to the image
  74154. */
  74155. export class FilterPostProcess extends PostProcess {
  74156. /** The matrix to be applied to the image */
  74157. kernelMatrix: Matrix;
  74158. /**
  74159. * Gets a string identifying the name of the class
  74160. * @returns "FilterPostProcess" string
  74161. */
  74162. getClassName(): string;
  74163. /**
  74164. *
  74165. * @param name The name of the effect.
  74166. * @param kernelMatrix The matrix to be applied to the image
  74167. * @param options The required width/height ratio to downsize to before computing the render pass.
  74168. * @param camera The camera to apply the render pass to.
  74169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74170. * @param engine The engine which the post process will be applied. (default: current engine)
  74171. * @param reusable If the post process can be reused on the same frame. (default: false)
  74172. */
  74173. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74174. /** @hidden */
  74175. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74176. }
  74177. }
  74178. declare module "babylonjs/Shaders/fxaa.fragment" {
  74179. /** @hidden */
  74180. export var fxaaPixelShader: {
  74181. name: string;
  74182. shader: string;
  74183. };
  74184. }
  74185. declare module "babylonjs/Shaders/fxaa.vertex" {
  74186. /** @hidden */
  74187. export var fxaaVertexShader: {
  74188. name: string;
  74189. shader: string;
  74190. };
  74191. }
  74192. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74193. import { Nullable } from "babylonjs/types";
  74194. import { Camera } from "babylonjs/Cameras/camera";
  74195. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74196. import { Engine } from "babylonjs/Engines/engine";
  74197. import "babylonjs/Shaders/fxaa.fragment";
  74198. import "babylonjs/Shaders/fxaa.vertex";
  74199. import { Scene } from "babylonjs/scene";
  74200. /**
  74201. * Fxaa post process
  74202. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74203. */
  74204. export class FxaaPostProcess extends PostProcess {
  74205. /**
  74206. * Gets a string identifying the name of the class
  74207. * @returns "FxaaPostProcess" string
  74208. */
  74209. getClassName(): string;
  74210. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74211. private _getDefines;
  74212. /** @hidden */
  74213. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74214. }
  74215. }
  74216. declare module "babylonjs/Shaders/grain.fragment" {
  74217. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74218. /** @hidden */
  74219. export var grainPixelShader: {
  74220. name: string;
  74221. shader: string;
  74222. };
  74223. }
  74224. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74225. import { Nullable } from "babylonjs/types";
  74226. import { Camera } from "babylonjs/Cameras/camera";
  74227. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74228. import { Engine } from "babylonjs/Engines/engine";
  74229. import "babylonjs/Shaders/grain.fragment";
  74230. import { Scene } from "babylonjs/scene";
  74231. /**
  74232. * The GrainPostProcess adds noise to the image at mid luminance levels
  74233. */
  74234. export class GrainPostProcess extends PostProcess {
  74235. /**
  74236. * The intensity of the grain added (default: 30)
  74237. */
  74238. intensity: number;
  74239. /**
  74240. * If the grain should be randomized on every frame
  74241. */
  74242. animated: boolean;
  74243. /**
  74244. * Gets a string identifying the name of the class
  74245. * @returns "GrainPostProcess" string
  74246. */
  74247. getClassName(): string;
  74248. /**
  74249. * Creates a new instance of @see GrainPostProcess
  74250. * @param name The name of the effect.
  74251. * @param options The required width/height ratio to downsize to before computing the render pass.
  74252. * @param camera The camera to apply the render pass to.
  74253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74254. * @param engine The engine which the post process will be applied. (default: current engine)
  74255. * @param reusable If the post process can be reused on the same frame. (default: false)
  74256. * @param textureType Type of textures used when performing the post process. (default: 0)
  74257. * @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)
  74258. */
  74259. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74260. /** @hidden */
  74261. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74262. }
  74263. }
  74264. declare module "babylonjs/Shaders/highlights.fragment" {
  74265. /** @hidden */
  74266. export var highlightsPixelShader: {
  74267. name: string;
  74268. shader: string;
  74269. };
  74270. }
  74271. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74272. import { Nullable } from "babylonjs/types";
  74273. import { Camera } from "babylonjs/Cameras/camera";
  74274. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74275. import { Engine } from "babylonjs/Engines/engine";
  74276. import "babylonjs/Shaders/highlights.fragment";
  74277. /**
  74278. * Extracts highlights from the image
  74279. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74280. */
  74281. export class HighlightsPostProcess extends PostProcess {
  74282. /**
  74283. * Gets a string identifying the name of the class
  74284. * @returns "HighlightsPostProcess" string
  74285. */
  74286. getClassName(): string;
  74287. /**
  74288. * Extracts highlights from the image
  74289. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74290. * @param name The name of the effect.
  74291. * @param options The required width/height ratio to downsize to before computing the render pass.
  74292. * @param camera The camera to apply the render pass to.
  74293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74294. * @param engine The engine which the post process will be applied. (default: current engine)
  74295. * @param reusable If the post process can be reused on the same frame. (default: false)
  74296. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74297. */
  74298. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74299. }
  74300. }
  74301. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74302. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74303. /**
  74304. * Contains all parameters needed for the prepass to perform
  74305. * motion blur
  74306. */
  74307. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74308. /**
  74309. * Is motion blur enabled
  74310. */
  74311. enabled: boolean;
  74312. /**
  74313. * Name of the configuration
  74314. */
  74315. name: string;
  74316. /**
  74317. * Textures that should be present in the MRT for this effect to work
  74318. */
  74319. readonly texturesRequired: number[];
  74320. }
  74321. }
  74322. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74323. import { Nullable } from "babylonjs/types";
  74324. import { Scene } from "babylonjs/scene";
  74325. import { ISceneComponent } from "babylonjs/sceneComponent";
  74326. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74327. module "babylonjs/scene" {
  74328. interface Scene {
  74329. /** @hidden (Backing field) */
  74330. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74331. /**
  74332. * Gets or Sets the current geometry buffer associated to the scene.
  74333. */
  74334. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74335. /**
  74336. * Enables a GeometryBufferRender and associates it with the scene
  74337. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74338. * @returns the GeometryBufferRenderer
  74339. */
  74340. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74341. /**
  74342. * Disables the GeometryBufferRender associated with the scene
  74343. */
  74344. disableGeometryBufferRenderer(): void;
  74345. }
  74346. }
  74347. /**
  74348. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74349. * in several rendering techniques.
  74350. */
  74351. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74352. /**
  74353. * The component name helpful to identify the component in the list of scene components.
  74354. */
  74355. readonly name: string;
  74356. /**
  74357. * The scene the component belongs to.
  74358. */
  74359. scene: Scene;
  74360. /**
  74361. * Creates a new instance of the component for the given scene
  74362. * @param scene Defines the scene to register the component in
  74363. */
  74364. constructor(scene: Scene);
  74365. /**
  74366. * Registers the component in a given scene
  74367. */
  74368. register(): void;
  74369. /**
  74370. * Rebuilds the elements related to this component in case of
  74371. * context lost for instance.
  74372. */
  74373. rebuild(): void;
  74374. /**
  74375. * Disposes the component and the associated ressources
  74376. */
  74377. dispose(): void;
  74378. private _gatherRenderTargets;
  74379. }
  74380. }
  74381. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74382. /** @hidden */
  74383. export var motionBlurPixelShader: {
  74384. name: string;
  74385. shader: string;
  74386. };
  74387. }
  74388. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74389. import { Nullable } from "babylonjs/types";
  74390. import { Camera } from "babylonjs/Cameras/camera";
  74391. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74393. import "babylonjs/Animations/animatable";
  74394. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74395. import "babylonjs/Shaders/motionBlur.fragment";
  74396. import { Engine } from "babylonjs/Engines/engine";
  74397. import { Scene } from "babylonjs/scene";
  74398. /**
  74399. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74400. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74401. * As an example, all you have to do is to create the post-process:
  74402. * var mb = new BABYLON.MotionBlurPostProcess(
  74403. * 'mb', // The name of the effect.
  74404. * scene, // The scene containing the objects to blur according to their velocity.
  74405. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74406. * camera // The camera to apply the render pass to.
  74407. * );
  74408. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74409. */
  74410. export class MotionBlurPostProcess extends PostProcess {
  74411. /**
  74412. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74413. */
  74414. motionStrength: number;
  74415. /**
  74416. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74417. */
  74418. get motionBlurSamples(): number;
  74419. /**
  74420. * Sets the number of iterations to be used for motion blur quality
  74421. */
  74422. set motionBlurSamples(samples: number);
  74423. private _motionBlurSamples;
  74424. private _forceGeometryBuffer;
  74425. private _geometryBufferRenderer;
  74426. private _prePassRenderer;
  74427. /**
  74428. * Gets a string identifying the name of the class
  74429. * @returns "MotionBlurPostProcess" string
  74430. */
  74431. getClassName(): string;
  74432. /**
  74433. * Creates a new instance MotionBlurPostProcess
  74434. * @param name The name of the effect.
  74435. * @param scene The scene containing the objects to blur according to their velocity.
  74436. * @param options The required width/height ratio to downsize to before computing the render pass.
  74437. * @param camera The camera to apply the render pass to.
  74438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74439. * @param engine The engine which the post process will be applied. (default: current engine)
  74440. * @param reusable If the post process can be reused on the same frame. (default: false)
  74441. * @param textureType Type of textures used when performing the post process. (default: 0)
  74442. * @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)
  74443. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74444. */
  74445. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74446. /**
  74447. * Excludes the given skinned mesh from computing bones velocities.
  74448. * 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.
  74449. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74450. */
  74451. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74452. /**
  74453. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74454. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74455. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74456. */
  74457. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74458. /**
  74459. * Disposes the post process.
  74460. * @param camera The camera to dispose the post process on.
  74461. */
  74462. dispose(camera?: Camera): void;
  74463. /** @hidden */
  74464. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74465. }
  74466. }
  74467. declare module "babylonjs/Shaders/refraction.fragment" {
  74468. /** @hidden */
  74469. export var refractionPixelShader: {
  74470. name: string;
  74471. shader: string;
  74472. };
  74473. }
  74474. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74475. import { Color3 } from "babylonjs/Maths/math.color";
  74476. import { Camera } from "babylonjs/Cameras/camera";
  74477. import { Texture } from "babylonjs/Materials/Textures/texture";
  74478. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74479. import { Engine } from "babylonjs/Engines/engine";
  74480. import "babylonjs/Shaders/refraction.fragment";
  74481. import { Scene } from "babylonjs/scene";
  74482. /**
  74483. * Post process which applies a refractin texture
  74484. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74485. */
  74486. export class RefractionPostProcess extends PostProcess {
  74487. private _refTexture;
  74488. private _ownRefractionTexture;
  74489. /** the base color of the refraction (used to taint the rendering) */
  74490. color: Color3;
  74491. /** simulated refraction depth */
  74492. depth: number;
  74493. /** the coefficient of the base color (0 to remove base color tainting) */
  74494. colorLevel: number;
  74495. /** Gets the url used to load the refraction texture */
  74496. refractionTextureUrl: string;
  74497. /**
  74498. * Gets or sets the refraction texture
  74499. * Please note that you are responsible for disposing the texture if you set it manually
  74500. */
  74501. get refractionTexture(): Texture;
  74502. set refractionTexture(value: Texture);
  74503. /**
  74504. * Gets a string identifying the name of the class
  74505. * @returns "RefractionPostProcess" string
  74506. */
  74507. getClassName(): string;
  74508. /**
  74509. * Initializes the RefractionPostProcess
  74510. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74511. * @param name The name of the effect.
  74512. * @param refractionTextureUrl Url of the refraction texture to use
  74513. * @param color the base color of the refraction (used to taint the rendering)
  74514. * @param depth simulated refraction depth
  74515. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74516. * @param camera The camera to apply the render pass to.
  74517. * @param options The required width/height ratio to downsize to before computing the render pass.
  74518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74519. * @param engine The engine which the post process will be applied. (default: current engine)
  74520. * @param reusable If the post process can be reused on the same frame. (default: false)
  74521. */
  74522. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74523. /**
  74524. * Disposes of the post process
  74525. * @param camera Camera to dispose post process on
  74526. */
  74527. dispose(camera: Camera): void;
  74528. /** @hidden */
  74529. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74530. }
  74531. }
  74532. declare module "babylonjs/Shaders/sharpen.fragment" {
  74533. /** @hidden */
  74534. export var sharpenPixelShader: {
  74535. name: string;
  74536. shader: string;
  74537. };
  74538. }
  74539. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74540. import { Nullable } from "babylonjs/types";
  74541. import { Camera } from "babylonjs/Cameras/camera";
  74542. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74543. import "babylonjs/Shaders/sharpen.fragment";
  74544. import { Engine } from "babylonjs/Engines/engine";
  74545. import { Scene } from "babylonjs/scene";
  74546. /**
  74547. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74548. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74549. */
  74550. export class SharpenPostProcess extends PostProcess {
  74551. /**
  74552. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74553. */
  74554. colorAmount: number;
  74555. /**
  74556. * How much sharpness should be applied (default: 0.3)
  74557. */
  74558. edgeAmount: number;
  74559. /**
  74560. * Gets a string identifying the name of the class
  74561. * @returns "SharpenPostProcess" string
  74562. */
  74563. getClassName(): string;
  74564. /**
  74565. * Creates a new instance ConvolutionPostProcess
  74566. * @param name The name of the effect.
  74567. * @param options The required width/height ratio to downsize to before computing the render pass.
  74568. * @param camera The camera to apply the render pass to.
  74569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74570. * @param engine The engine which the post process will be applied. (default: current engine)
  74571. * @param reusable If the post process can be reused on the same frame. (default: false)
  74572. * @param textureType Type of textures used when performing the post process. (default: 0)
  74573. * @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)
  74574. */
  74575. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74576. /** @hidden */
  74577. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74578. }
  74579. }
  74580. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74581. import { Nullable } from "babylonjs/types";
  74582. import { Camera } from "babylonjs/Cameras/camera";
  74583. import { Engine } from "babylonjs/Engines/engine";
  74584. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74585. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74586. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74587. /**
  74588. * PostProcessRenderPipeline
  74589. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74590. */
  74591. export class PostProcessRenderPipeline {
  74592. private engine;
  74593. private _renderEffects;
  74594. private _renderEffectsForIsolatedPass;
  74595. /**
  74596. * List of inspectable custom properties (used by the Inspector)
  74597. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74598. */
  74599. inspectableCustomProperties: IInspectable[];
  74600. /**
  74601. * @hidden
  74602. */
  74603. protected _cameras: Camera[];
  74604. /** @hidden */
  74605. _name: string;
  74606. /**
  74607. * Gets pipeline name
  74608. */
  74609. get name(): string;
  74610. /** Gets the list of attached cameras */
  74611. get cameras(): Camera[];
  74612. /**
  74613. * Initializes a PostProcessRenderPipeline
  74614. * @param engine engine to add the pipeline to
  74615. * @param name name of the pipeline
  74616. */
  74617. constructor(engine: Engine, name: string);
  74618. /**
  74619. * Gets the class name
  74620. * @returns "PostProcessRenderPipeline"
  74621. */
  74622. getClassName(): string;
  74623. /**
  74624. * If all the render effects in the pipeline are supported
  74625. */
  74626. get isSupported(): boolean;
  74627. /**
  74628. * Adds an effect to the pipeline
  74629. * @param renderEffect the effect to add
  74630. */
  74631. addEffect(renderEffect: PostProcessRenderEffect): void;
  74632. /** @hidden */
  74633. _rebuild(): void;
  74634. /** @hidden */
  74635. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74636. /** @hidden */
  74637. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74638. /** @hidden */
  74639. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74640. /** @hidden */
  74641. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74642. /** @hidden */
  74643. _attachCameras(cameras: Camera, unique: boolean): void;
  74644. /** @hidden */
  74645. _attachCameras(cameras: Camera[], unique: boolean): void;
  74646. /** @hidden */
  74647. _detachCameras(cameras: Camera): void;
  74648. /** @hidden */
  74649. _detachCameras(cameras: Nullable<Camera[]>): void;
  74650. /** @hidden */
  74651. _update(): void;
  74652. /** @hidden */
  74653. _reset(): void;
  74654. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74655. /**
  74656. * Sets the required values to the prepass renderer.
  74657. * @param prePassRenderer defines the prepass renderer to setup.
  74658. * @returns true if the pre pass is needed.
  74659. */
  74660. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74661. /**
  74662. * Disposes of the pipeline
  74663. */
  74664. dispose(): void;
  74665. }
  74666. }
  74667. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74668. import { Camera } from "babylonjs/Cameras/camera";
  74669. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74670. /**
  74671. * PostProcessRenderPipelineManager class
  74672. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74673. */
  74674. export class PostProcessRenderPipelineManager {
  74675. private _renderPipelines;
  74676. /**
  74677. * Initializes a PostProcessRenderPipelineManager
  74678. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74679. */
  74680. constructor();
  74681. /**
  74682. * Gets the list of supported render pipelines
  74683. */
  74684. get supportedPipelines(): PostProcessRenderPipeline[];
  74685. /**
  74686. * Adds a pipeline to the manager
  74687. * @param renderPipeline The pipeline to add
  74688. */
  74689. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74690. /**
  74691. * Attaches a camera to the pipeline
  74692. * @param renderPipelineName The name of the pipeline to attach to
  74693. * @param cameras the camera to attach
  74694. * @param unique if the camera can be attached multiple times to the pipeline
  74695. */
  74696. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74697. /**
  74698. * Detaches a camera from the pipeline
  74699. * @param renderPipelineName The name of the pipeline to detach from
  74700. * @param cameras the camera to detach
  74701. */
  74702. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74703. /**
  74704. * Enables an effect by name on a pipeline
  74705. * @param renderPipelineName the name of the pipeline to enable the effect in
  74706. * @param renderEffectName the name of the effect to enable
  74707. * @param cameras the cameras that the effect should be enabled on
  74708. */
  74709. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74710. /**
  74711. * Disables an effect by name on a pipeline
  74712. * @param renderPipelineName the name of the pipeline to disable the effect in
  74713. * @param renderEffectName the name of the effect to disable
  74714. * @param cameras the cameras that the effect should be disabled on
  74715. */
  74716. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74717. /**
  74718. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74719. */
  74720. update(): void;
  74721. /** @hidden */
  74722. _rebuild(): void;
  74723. /**
  74724. * Disposes of the manager and pipelines
  74725. */
  74726. dispose(): void;
  74727. }
  74728. }
  74729. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74730. import { ISceneComponent } from "babylonjs/sceneComponent";
  74731. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74732. import { Scene } from "babylonjs/scene";
  74733. module "babylonjs/scene" {
  74734. interface Scene {
  74735. /** @hidden (Backing field) */
  74736. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74737. /**
  74738. * Gets the postprocess render pipeline manager
  74739. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74740. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74741. */
  74742. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74743. }
  74744. }
  74745. /**
  74746. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74747. */
  74748. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74749. /**
  74750. * The component name helpfull to identify the component in the list of scene components.
  74751. */
  74752. readonly name: string;
  74753. /**
  74754. * The scene the component belongs to.
  74755. */
  74756. scene: Scene;
  74757. /**
  74758. * Creates a new instance of the component for the given scene
  74759. * @param scene Defines the scene to register the component in
  74760. */
  74761. constructor(scene: Scene);
  74762. /**
  74763. * Registers the component in a given scene
  74764. */
  74765. register(): void;
  74766. /**
  74767. * Rebuilds the elements related to this component in case of
  74768. * context lost for instance.
  74769. */
  74770. rebuild(): void;
  74771. /**
  74772. * Disposes the component and the associated ressources
  74773. */
  74774. dispose(): void;
  74775. private _gatherRenderTargets;
  74776. }
  74777. }
  74778. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74779. import { Nullable } from "babylonjs/types";
  74780. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74781. import { Camera } from "babylonjs/Cameras/camera";
  74782. import { IDisposable } from "babylonjs/scene";
  74783. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74784. import { Scene } from "babylonjs/scene";
  74785. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74786. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74787. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74788. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74789. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74790. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74791. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74792. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74793. import { Animation } from "babylonjs/Animations/animation";
  74794. /**
  74795. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74796. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74797. */
  74798. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74799. private _scene;
  74800. private _camerasToBeAttached;
  74801. /**
  74802. * ID of the sharpen post process,
  74803. */
  74804. private readonly SharpenPostProcessId;
  74805. /**
  74806. * @ignore
  74807. * ID of the image processing post process;
  74808. */
  74809. readonly ImageProcessingPostProcessId: string;
  74810. /**
  74811. * @ignore
  74812. * ID of the Fast Approximate Anti-Aliasing post process;
  74813. */
  74814. readonly FxaaPostProcessId: string;
  74815. /**
  74816. * ID of the chromatic aberration post process,
  74817. */
  74818. private readonly ChromaticAberrationPostProcessId;
  74819. /**
  74820. * ID of the grain post process
  74821. */
  74822. private readonly GrainPostProcessId;
  74823. /**
  74824. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74825. */
  74826. sharpen: SharpenPostProcess;
  74827. private _sharpenEffect;
  74828. private bloom;
  74829. /**
  74830. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74831. */
  74832. depthOfField: DepthOfFieldEffect;
  74833. /**
  74834. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74835. */
  74836. fxaa: FxaaPostProcess;
  74837. /**
  74838. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74839. */
  74840. imageProcessing: ImageProcessingPostProcess;
  74841. /**
  74842. * Chromatic aberration post process which will shift rgb colors in the image
  74843. */
  74844. chromaticAberration: ChromaticAberrationPostProcess;
  74845. private _chromaticAberrationEffect;
  74846. /**
  74847. * Grain post process which add noise to the image
  74848. */
  74849. grain: GrainPostProcess;
  74850. private _grainEffect;
  74851. /**
  74852. * Glow post process which adds a glow to emissive areas of the image
  74853. */
  74854. private _glowLayer;
  74855. /**
  74856. * Animations which can be used to tweak settings over a period of time
  74857. */
  74858. animations: Animation[];
  74859. private _imageProcessingConfigurationObserver;
  74860. private _sharpenEnabled;
  74861. private _bloomEnabled;
  74862. private _depthOfFieldEnabled;
  74863. private _depthOfFieldBlurLevel;
  74864. private _fxaaEnabled;
  74865. private _imageProcessingEnabled;
  74866. private _defaultPipelineTextureType;
  74867. private _bloomScale;
  74868. private _chromaticAberrationEnabled;
  74869. private _grainEnabled;
  74870. private _buildAllowed;
  74871. /**
  74872. * Gets active scene
  74873. */
  74874. get scene(): Scene;
  74875. /**
  74876. * Enable or disable the sharpen process from the pipeline
  74877. */
  74878. set sharpenEnabled(enabled: boolean);
  74879. get sharpenEnabled(): boolean;
  74880. private _resizeObserver;
  74881. private _hardwareScaleLevel;
  74882. private _bloomKernel;
  74883. /**
  74884. * Specifies the size of the bloom blur kernel, relative to the final output size
  74885. */
  74886. get bloomKernel(): number;
  74887. set bloomKernel(value: number);
  74888. /**
  74889. * Specifies the weight of the bloom in the final rendering
  74890. */
  74891. private _bloomWeight;
  74892. /**
  74893. * Specifies the luma threshold for the area that will be blurred by the bloom
  74894. */
  74895. private _bloomThreshold;
  74896. private _hdr;
  74897. /**
  74898. * The strength of the bloom.
  74899. */
  74900. set bloomWeight(value: number);
  74901. get bloomWeight(): number;
  74902. /**
  74903. * The strength of the bloom.
  74904. */
  74905. set bloomThreshold(value: number);
  74906. get bloomThreshold(): number;
  74907. /**
  74908. * The scale of the bloom, lower value will provide better performance.
  74909. */
  74910. set bloomScale(value: number);
  74911. get bloomScale(): number;
  74912. /**
  74913. * Enable or disable the bloom from the pipeline
  74914. */
  74915. set bloomEnabled(enabled: boolean);
  74916. get bloomEnabled(): boolean;
  74917. private _rebuildBloom;
  74918. /**
  74919. * If the depth of field is enabled.
  74920. */
  74921. get depthOfFieldEnabled(): boolean;
  74922. set depthOfFieldEnabled(enabled: boolean);
  74923. /**
  74924. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74925. */
  74926. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74927. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74928. /**
  74929. * If the anti aliasing is enabled.
  74930. */
  74931. set fxaaEnabled(enabled: boolean);
  74932. get fxaaEnabled(): boolean;
  74933. private _samples;
  74934. /**
  74935. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74936. */
  74937. set samples(sampleCount: number);
  74938. get samples(): number;
  74939. /**
  74940. * If image processing is enabled.
  74941. */
  74942. set imageProcessingEnabled(enabled: boolean);
  74943. get imageProcessingEnabled(): boolean;
  74944. /**
  74945. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74946. */
  74947. set glowLayerEnabled(enabled: boolean);
  74948. get glowLayerEnabled(): boolean;
  74949. /**
  74950. * Gets the glow layer (or null if not defined)
  74951. */
  74952. get glowLayer(): Nullable<GlowLayer>;
  74953. /**
  74954. * Enable or disable the chromaticAberration process from the pipeline
  74955. */
  74956. set chromaticAberrationEnabled(enabled: boolean);
  74957. get chromaticAberrationEnabled(): boolean;
  74958. /**
  74959. * Enable or disable the grain process from the pipeline
  74960. */
  74961. set grainEnabled(enabled: boolean);
  74962. get grainEnabled(): boolean;
  74963. /**
  74964. * @constructor
  74965. * @param name - The rendering pipeline name (default: "")
  74966. * @param hdr - If high dynamic range textures should be used (default: true)
  74967. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74968. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74969. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74970. */
  74971. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74972. /**
  74973. * Get the class name
  74974. * @returns "DefaultRenderingPipeline"
  74975. */
  74976. getClassName(): string;
  74977. /**
  74978. * Force the compilation of the entire pipeline.
  74979. */
  74980. prepare(): void;
  74981. private _hasCleared;
  74982. private _prevPostProcess;
  74983. private _prevPrevPostProcess;
  74984. private _setAutoClearAndTextureSharing;
  74985. private _depthOfFieldSceneObserver;
  74986. private _buildPipeline;
  74987. private _disposePostProcesses;
  74988. /**
  74989. * Adds a camera to the pipeline
  74990. * @param camera the camera to be added
  74991. */
  74992. addCamera(camera: Camera): void;
  74993. /**
  74994. * Removes a camera from the pipeline
  74995. * @param camera the camera to remove
  74996. */
  74997. removeCamera(camera: Camera): void;
  74998. /**
  74999. * Dispose of the pipeline and stop all post processes
  75000. */
  75001. dispose(): void;
  75002. /**
  75003. * Serialize the rendering pipeline (Used when exporting)
  75004. * @returns the serialized object
  75005. */
  75006. serialize(): any;
  75007. /**
  75008. * Parse the serialized pipeline
  75009. * @param source Source pipeline.
  75010. * @param scene The scene to load the pipeline to.
  75011. * @param rootUrl The URL of the serialized pipeline.
  75012. * @returns An instantiated pipeline from the serialized object.
  75013. */
  75014. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75015. }
  75016. }
  75017. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75018. /** @hidden */
  75019. export var lensHighlightsPixelShader: {
  75020. name: string;
  75021. shader: string;
  75022. };
  75023. }
  75024. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75025. /** @hidden */
  75026. export var depthOfFieldPixelShader: {
  75027. name: string;
  75028. shader: string;
  75029. };
  75030. }
  75031. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75032. import { Camera } from "babylonjs/Cameras/camera";
  75033. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75034. import { Scene } from "babylonjs/scene";
  75035. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75036. import "babylonjs/Shaders/chromaticAberration.fragment";
  75037. import "babylonjs/Shaders/lensHighlights.fragment";
  75038. import "babylonjs/Shaders/depthOfField.fragment";
  75039. /**
  75040. * BABYLON.JS Chromatic Aberration GLSL Shader
  75041. * Author: Olivier Guyot
  75042. * Separates very slightly R, G and B colors on the edges of the screen
  75043. * Inspired by Francois Tarlier & Martins Upitis
  75044. */
  75045. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75046. /**
  75047. * @ignore
  75048. * The chromatic aberration PostProcess id in the pipeline
  75049. */
  75050. LensChromaticAberrationEffect: string;
  75051. /**
  75052. * @ignore
  75053. * The highlights enhancing PostProcess id in the pipeline
  75054. */
  75055. HighlightsEnhancingEffect: string;
  75056. /**
  75057. * @ignore
  75058. * The depth-of-field PostProcess id in the pipeline
  75059. */
  75060. LensDepthOfFieldEffect: string;
  75061. private _scene;
  75062. private _depthTexture;
  75063. private _grainTexture;
  75064. private _chromaticAberrationPostProcess;
  75065. private _highlightsPostProcess;
  75066. private _depthOfFieldPostProcess;
  75067. private _edgeBlur;
  75068. private _grainAmount;
  75069. private _chromaticAberration;
  75070. private _distortion;
  75071. private _highlightsGain;
  75072. private _highlightsThreshold;
  75073. private _dofDistance;
  75074. private _dofAperture;
  75075. private _dofDarken;
  75076. private _dofPentagon;
  75077. private _blurNoise;
  75078. /**
  75079. * @constructor
  75080. *
  75081. * Effect parameters are as follow:
  75082. * {
  75083. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75084. * edge_blur: number; // from 0 to x (1 for realism)
  75085. * distortion: number; // from 0 to x (1 for realism)
  75086. * grain_amount: number; // from 0 to 1
  75087. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75088. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75089. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75090. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75091. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75092. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75093. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75094. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75095. * }
  75096. * Note: if an effect parameter is unset, effect is disabled
  75097. *
  75098. * @param name The rendering pipeline name
  75099. * @param parameters - An object containing all parameters (see above)
  75100. * @param scene The scene linked to this pipeline
  75101. * @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)
  75102. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75103. */
  75104. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75105. /**
  75106. * Get the class name
  75107. * @returns "LensRenderingPipeline"
  75108. */
  75109. getClassName(): string;
  75110. /**
  75111. * Gets associated scene
  75112. */
  75113. get scene(): Scene;
  75114. /**
  75115. * Gets or sets the edge blur
  75116. */
  75117. get edgeBlur(): number;
  75118. set edgeBlur(value: number);
  75119. /**
  75120. * Gets or sets the grain amount
  75121. */
  75122. get grainAmount(): number;
  75123. set grainAmount(value: number);
  75124. /**
  75125. * Gets or sets the chromatic aberration amount
  75126. */
  75127. get chromaticAberration(): number;
  75128. set chromaticAberration(value: number);
  75129. /**
  75130. * Gets or sets the depth of field aperture
  75131. */
  75132. get dofAperture(): number;
  75133. set dofAperture(value: number);
  75134. /**
  75135. * Gets or sets the edge distortion
  75136. */
  75137. get edgeDistortion(): number;
  75138. set edgeDistortion(value: number);
  75139. /**
  75140. * Gets or sets the depth of field distortion
  75141. */
  75142. get dofDistortion(): number;
  75143. set dofDistortion(value: number);
  75144. /**
  75145. * Gets or sets the darken out of focus amount
  75146. */
  75147. get darkenOutOfFocus(): number;
  75148. set darkenOutOfFocus(value: number);
  75149. /**
  75150. * Gets or sets a boolean indicating if blur noise is enabled
  75151. */
  75152. get blurNoise(): boolean;
  75153. set blurNoise(value: boolean);
  75154. /**
  75155. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75156. */
  75157. get pentagonBokeh(): boolean;
  75158. set pentagonBokeh(value: boolean);
  75159. /**
  75160. * Gets or sets the highlight grain amount
  75161. */
  75162. get highlightsGain(): number;
  75163. set highlightsGain(value: number);
  75164. /**
  75165. * Gets or sets the highlight threshold
  75166. */
  75167. get highlightsThreshold(): number;
  75168. set highlightsThreshold(value: number);
  75169. /**
  75170. * Sets the amount of blur at the edges
  75171. * @param amount blur amount
  75172. */
  75173. setEdgeBlur(amount: number): void;
  75174. /**
  75175. * Sets edge blur to 0
  75176. */
  75177. disableEdgeBlur(): void;
  75178. /**
  75179. * Sets the amout of grain
  75180. * @param amount Amount of grain
  75181. */
  75182. setGrainAmount(amount: number): void;
  75183. /**
  75184. * Set grain amount to 0
  75185. */
  75186. disableGrain(): void;
  75187. /**
  75188. * Sets the chromatic aberration amount
  75189. * @param amount amount of chromatic aberration
  75190. */
  75191. setChromaticAberration(amount: number): void;
  75192. /**
  75193. * Sets chromatic aberration amount to 0
  75194. */
  75195. disableChromaticAberration(): void;
  75196. /**
  75197. * Sets the EdgeDistortion amount
  75198. * @param amount amount of EdgeDistortion
  75199. */
  75200. setEdgeDistortion(amount: number): void;
  75201. /**
  75202. * Sets edge distortion to 0
  75203. */
  75204. disableEdgeDistortion(): void;
  75205. /**
  75206. * Sets the FocusDistance amount
  75207. * @param amount amount of FocusDistance
  75208. */
  75209. setFocusDistance(amount: number): void;
  75210. /**
  75211. * Disables depth of field
  75212. */
  75213. disableDepthOfField(): void;
  75214. /**
  75215. * Sets the Aperture amount
  75216. * @param amount amount of Aperture
  75217. */
  75218. setAperture(amount: number): void;
  75219. /**
  75220. * Sets the DarkenOutOfFocus amount
  75221. * @param amount amount of DarkenOutOfFocus
  75222. */
  75223. setDarkenOutOfFocus(amount: number): void;
  75224. private _pentagonBokehIsEnabled;
  75225. /**
  75226. * Creates a pentagon bokeh effect
  75227. */
  75228. enablePentagonBokeh(): void;
  75229. /**
  75230. * Disables the pentagon bokeh effect
  75231. */
  75232. disablePentagonBokeh(): void;
  75233. /**
  75234. * Enables noise blur
  75235. */
  75236. enableNoiseBlur(): void;
  75237. /**
  75238. * Disables noise blur
  75239. */
  75240. disableNoiseBlur(): void;
  75241. /**
  75242. * Sets the HighlightsGain amount
  75243. * @param amount amount of HighlightsGain
  75244. */
  75245. setHighlightsGain(amount: number): void;
  75246. /**
  75247. * Sets the HighlightsThreshold amount
  75248. * @param amount amount of HighlightsThreshold
  75249. */
  75250. setHighlightsThreshold(amount: number): void;
  75251. /**
  75252. * Disables highlights
  75253. */
  75254. disableHighlights(): void;
  75255. /**
  75256. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75257. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75258. */
  75259. dispose(disableDepthRender?: boolean): void;
  75260. private _createChromaticAberrationPostProcess;
  75261. private _createHighlightsPostProcess;
  75262. private _createDepthOfFieldPostProcess;
  75263. private _createGrainTexture;
  75264. }
  75265. }
  75266. declare module "babylonjs/Rendering/ssao2Configuration" {
  75267. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75268. /**
  75269. * Contains all parameters needed for the prepass to perform
  75270. * screen space subsurface scattering
  75271. */
  75272. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75273. /**
  75274. * Is subsurface enabled
  75275. */
  75276. enabled: boolean;
  75277. /**
  75278. * Name of the configuration
  75279. */
  75280. name: string;
  75281. /**
  75282. * Textures that should be present in the MRT for this effect to work
  75283. */
  75284. readonly texturesRequired: number[];
  75285. }
  75286. }
  75287. declare module "babylonjs/Shaders/ssao2.fragment" {
  75288. /** @hidden */
  75289. export var ssao2PixelShader: {
  75290. name: string;
  75291. shader: string;
  75292. };
  75293. }
  75294. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75295. /** @hidden */
  75296. export var ssaoCombinePixelShader: {
  75297. name: string;
  75298. shader: string;
  75299. };
  75300. }
  75301. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75302. import { Camera } from "babylonjs/Cameras/camera";
  75303. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75304. import { Scene } from "babylonjs/scene";
  75305. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75306. import "babylonjs/Shaders/ssao2.fragment";
  75307. import "babylonjs/Shaders/ssaoCombine.fragment";
  75308. /**
  75309. * Render pipeline to produce ssao effect
  75310. */
  75311. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75312. /**
  75313. * @ignore
  75314. * The PassPostProcess id in the pipeline that contains the original scene color
  75315. */
  75316. SSAOOriginalSceneColorEffect: string;
  75317. /**
  75318. * @ignore
  75319. * The SSAO PostProcess id in the pipeline
  75320. */
  75321. SSAORenderEffect: string;
  75322. /**
  75323. * @ignore
  75324. * The horizontal blur PostProcess id in the pipeline
  75325. */
  75326. SSAOBlurHRenderEffect: string;
  75327. /**
  75328. * @ignore
  75329. * The vertical blur PostProcess id in the pipeline
  75330. */
  75331. SSAOBlurVRenderEffect: string;
  75332. /**
  75333. * @ignore
  75334. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75335. */
  75336. SSAOCombineRenderEffect: string;
  75337. /**
  75338. * The output strength of the SSAO post-process. Default value is 1.0.
  75339. */
  75340. totalStrength: number;
  75341. /**
  75342. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75343. */
  75344. maxZ: number;
  75345. /**
  75346. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75347. */
  75348. minZAspect: number;
  75349. private _samples;
  75350. /**
  75351. * Number of samples used for the SSAO calculations. Default value is 8
  75352. */
  75353. set samples(n: number);
  75354. get samples(): number;
  75355. private _textureSamples;
  75356. /**
  75357. * Number of samples to use for antialiasing
  75358. */
  75359. set textureSamples(n: number);
  75360. get textureSamples(): number;
  75361. /**
  75362. * Force rendering the geometry through geometry buffer
  75363. */
  75364. private _forceGeometryBuffer;
  75365. /**
  75366. * Ratio object used for SSAO ratio and blur ratio
  75367. */
  75368. private _ratio;
  75369. /**
  75370. * Dynamically generated sphere sampler.
  75371. */
  75372. private _sampleSphere;
  75373. /**
  75374. * Blur filter offsets
  75375. */
  75376. private _samplerOffsets;
  75377. private _expensiveBlur;
  75378. /**
  75379. * If bilateral blur should be used
  75380. */
  75381. set expensiveBlur(b: boolean);
  75382. get expensiveBlur(): boolean;
  75383. /**
  75384. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75385. */
  75386. radius: number;
  75387. /**
  75388. * The base color of the SSAO post-process
  75389. * The final result is "base + ssao" between [0, 1]
  75390. */
  75391. base: number;
  75392. /**
  75393. * Support test.
  75394. */
  75395. static get IsSupported(): boolean;
  75396. private _scene;
  75397. private _randomTexture;
  75398. private _originalColorPostProcess;
  75399. private _ssaoPostProcess;
  75400. private _blurHPostProcess;
  75401. private _blurVPostProcess;
  75402. private _ssaoCombinePostProcess;
  75403. private _prePassRenderer;
  75404. /**
  75405. * Gets active scene
  75406. */
  75407. get scene(): Scene;
  75408. /**
  75409. * @constructor
  75410. * @param name The rendering pipeline name
  75411. * @param scene The scene linked to this pipeline
  75412. * @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 }
  75413. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75414. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75415. */
  75416. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75417. /**
  75418. * Get the class name
  75419. * @returns "SSAO2RenderingPipeline"
  75420. */
  75421. getClassName(): string;
  75422. /**
  75423. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75424. */
  75425. dispose(disableGeometryBufferRenderer?: boolean): void;
  75426. private _createBlurPostProcess;
  75427. /** @hidden */
  75428. _rebuild(): void;
  75429. private _bits;
  75430. private _radicalInverse_VdC;
  75431. private _hammersley;
  75432. private _hemisphereSample_uniform;
  75433. private _generateHemisphere;
  75434. private _getDefinesForSSAO;
  75435. private _createSSAOPostProcess;
  75436. private _createSSAOCombinePostProcess;
  75437. private _createRandomTexture;
  75438. /**
  75439. * Serialize the rendering pipeline (Used when exporting)
  75440. * @returns the serialized object
  75441. */
  75442. serialize(): any;
  75443. /**
  75444. * Parse the serialized pipeline
  75445. * @param source Source pipeline.
  75446. * @param scene The scene to load the pipeline to.
  75447. * @param rootUrl The URL of the serialized pipeline.
  75448. * @returns An instantiated pipeline from the serialized object.
  75449. */
  75450. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75451. }
  75452. }
  75453. declare module "babylonjs/Shaders/ssao.fragment" {
  75454. /** @hidden */
  75455. export var ssaoPixelShader: {
  75456. name: string;
  75457. shader: string;
  75458. };
  75459. }
  75460. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75461. import { Camera } from "babylonjs/Cameras/camera";
  75462. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75463. import { Scene } from "babylonjs/scene";
  75464. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75465. import "babylonjs/Shaders/ssao.fragment";
  75466. import "babylonjs/Shaders/ssaoCombine.fragment";
  75467. /**
  75468. * Render pipeline to produce ssao effect
  75469. */
  75470. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75471. /**
  75472. * @ignore
  75473. * The PassPostProcess id in the pipeline that contains the original scene color
  75474. */
  75475. SSAOOriginalSceneColorEffect: string;
  75476. /**
  75477. * @ignore
  75478. * The SSAO PostProcess id in the pipeline
  75479. */
  75480. SSAORenderEffect: string;
  75481. /**
  75482. * @ignore
  75483. * The horizontal blur PostProcess id in the pipeline
  75484. */
  75485. SSAOBlurHRenderEffect: string;
  75486. /**
  75487. * @ignore
  75488. * The vertical blur PostProcess id in the pipeline
  75489. */
  75490. SSAOBlurVRenderEffect: string;
  75491. /**
  75492. * @ignore
  75493. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75494. */
  75495. SSAOCombineRenderEffect: string;
  75496. /**
  75497. * The output strength of the SSAO post-process. Default value is 1.0.
  75498. */
  75499. totalStrength: number;
  75500. /**
  75501. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75502. */
  75503. radius: number;
  75504. /**
  75505. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75506. * Must not be equal to fallOff and superior to fallOff.
  75507. * Default value is 0.0075
  75508. */
  75509. area: number;
  75510. /**
  75511. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75512. * Must not be equal to area and inferior to area.
  75513. * Default value is 0.000001
  75514. */
  75515. fallOff: number;
  75516. /**
  75517. * The base color of the SSAO post-process
  75518. * The final result is "base + ssao" between [0, 1]
  75519. */
  75520. base: number;
  75521. private _scene;
  75522. private _depthTexture;
  75523. private _randomTexture;
  75524. private _originalColorPostProcess;
  75525. private _ssaoPostProcess;
  75526. private _blurHPostProcess;
  75527. private _blurVPostProcess;
  75528. private _ssaoCombinePostProcess;
  75529. private _firstUpdate;
  75530. /**
  75531. * Gets active scene
  75532. */
  75533. get scene(): Scene;
  75534. /**
  75535. * @constructor
  75536. * @param name - The rendering pipeline name
  75537. * @param scene - The scene linked to this pipeline
  75538. * @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 }
  75539. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75540. */
  75541. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75542. /**
  75543. * Get the class name
  75544. * @returns "SSAORenderingPipeline"
  75545. */
  75546. getClassName(): string;
  75547. /**
  75548. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75549. */
  75550. dispose(disableDepthRender?: boolean): void;
  75551. private _createBlurPostProcess;
  75552. /** @hidden */
  75553. _rebuild(): void;
  75554. private _createSSAOPostProcess;
  75555. private _createSSAOCombinePostProcess;
  75556. private _createRandomTexture;
  75557. }
  75558. }
  75559. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75560. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75561. /**
  75562. * Contains all parameters needed for the prepass to perform
  75563. * screen space reflections
  75564. */
  75565. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75566. /**
  75567. * Is ssr enabled
  75568. */
  75569. enabled: boolean;
  75570. /**
  75571. * Name of the configuration
  75572. */
  75573. name: string;
  75574. /**
  75575. * Textures that should be present in the MRT for this effect to work
  75576. */
  75577. readonly texturesRequired: number[];
  75578. }
  75579. }
  75580. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75581. /** @hidden */
  75582. export var screenSpaceReflectionPixelShader: {
  75583. name: string;
  75584. shader: string;
  75585. };
  75586. }
  75587. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75588. import { Nullable } from "babylonjs/types";
  75589. import { Camera } from "babylonjs/Cameras/camera";
  75590. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75591. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75592. import { Engine } from "babylonjs/Engines/engine";
  75593. import { Scene } from "babylonjs/scene";
  75594. /**
  75595. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75596. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75597. */
  75598. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75599. /**
  75600. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75601. */
  75602. threshold: number;
  75603. /**
  75604. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75605. */
  75606. strength: number;
  75607. /**
  75608. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75609. */
  75610. reflectionSpecularFalloffExponent: number;
  75611. /**
  75612. * 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]
  75613. */
  75614. step: number;
  75615. /**
  75616. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75617. */
  75618. roughnessFactor: number;
  75619. private _forceGeometryBuffer;
  75620. private _geometryBufferRenderer;
  75621. private _prePassRenderer;
  75622. private _enableSmoothReflections;
  75623. private _reflectionSamples;
  75624. private _smoothSteps;
  75625. /**
  75626. * Gets a string identifying the name of the class
  75627. * @returns "ScreenSpaceReflectionPostProcess" string
  75628. */
  75629. getClassName(): string;
  75630. /**
  75631. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75632. * @param name The name of the effect.
  75633. * @param scene The scene containing the objects to calculate reflections.
  75634. * @param options The required width/height ratio to downsize to before computing the render pass.
  75635. * @param camera The camera to apply the render pass to.
  75636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75637. * @param engine The engine which the post process will be applied. (default: current engine)
  75638. * @param reusable If the post process can be reused on the same frame. (default: false)
  75639. * @param textureType Type of textures used when performing the post process. (default: 0)
  75640. * @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)
  75641. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75642. */
  75643. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75644. /**
  75645. * Gets wether or not smoothing reflections is enabled.
  75646. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75647. */
  75648. get enableSmoothReflections(): boolean;
  75649. /**
  75650. * Sets wether or not smoothing reflections is enabled.
  75651. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75652. */
  75653. set enableSmoothReflections(enabled: boolean);
  75654. /**
  75655. * Gets the number of samples taken while computing reflections. More samples count is high,
  75656. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75657. */
  75658. get reflectionSamples(): number;
  75659. /**
  75660. * Sets the number of samples taken while computing reflections. More samples count is high,
  75661. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75662. */
  75663. set reflectionSamples(samples: number);
  75664. /**
  75665. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75666. * more the post-process will require GPU power and can generate a drop in FPS.
  75667. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75668. */
  75669. get smoothSteps(): number;
  75670. set smoothSteps(steps: number);
  75671. private _updateEffectDefines;
  75672. /** @hidden */
  75673. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75674. }
  75675. }
  75676. declare module "babylonjs/Shaders/standard.fragment" {
  75677. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75678. /** @hidden */
  75679. export var standardPixelShader: {
  75680. name: string;
  75681. shader: string;
  75682. };
  75683. }
  75684. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75685. import { Nullable } from "babylonjs/types";
  75686. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75687. import { Camera } from "babylonjs/Cameras/camera";
  75688. import { Texture } from "babylonjs/Materials/Textures/texture";
  75689. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75690. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75691. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75692. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75693. import { IDisposable } from "babylonjs/scene";
  75694. import { SpotLight } from "babylonjs/Lights/spotLight";
  75695. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75696. import { Scene } from "babylonjs/scene";
  75697. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75698. import { Animation } from "babylonjs/Animations/animation";
  75699. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75700. import "babylonjs/Shaders/standard.fragment";
  75701. /**
  75702. * Standard rendering pipeline
  75703. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75704. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75705. */
  75706. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75707. /**
  75708. * Public members
  75709. */
  75710. /**
  75711. * Post-process which contains the original scene color before the pipeline applies all the effects
  75712. */
  75713. originalPostProcess: Nullable<PostProcess>;
  75714. /**
  75715. * Post-process used to down scale an image x4
  75716. */
  75717. downSampleX4PostProcess: Nullable<PostProcess>;
  75718. /**
  75719. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75720. */
  75721. brightPassPostProcess: Nullable<PostProcess>;
  75722. /**
  75723. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75724. */
  75725. blurHPostProcesses: PostProcess[];
  75726. /**
  75727. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75728. */
  75729. blurVPostProcesses: PostProcess[];
  75730. /**
  75731. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75732. */
  75733. textureAdderPostProcess: Nullable<PostProcess>;
  75734. /**
  75735. * Post-process used to create volumetric lighting effect
  75736. */
  75737. volumetricLightPostProcess: Nullable<PostProcess>;
  75738. /**
  75739. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75740. */
  75741. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75742. /**
  75743. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75744. */
  75745. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75746. /**
  75747. * Post-process used to merge the volumetric light effect and the real scene color
  75748. */
  75749. volumetricLightMergePostProces: Nullable<PostProcess>;
  75750. /**
  75751. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75752. */
  75753. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75754. /**
  75755. * Base post-process used to calculate the average luminance of the final image for HDR
  75756. */
  75757. luminancePostProcess: Nullable<PostProcess>;
  75758. /**
  75759. * Post-processes used to create down sample post-processes in order to get
  75760. * the average luminance of the final image for HDR
  75761. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75762. */
  75763. luminanceDownSamplePostProcesses: PostProcess[];
  75764. /**
  75765. * Post-process used to create a HDR effect (light adaptation)
  75766. */
  75767. hdrPostProcess: Nullable<PostProcess>;
  75768. /**
  75769. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75770. */
  75771. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75772. /**
  75773. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75774. */
  75775. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75776. /**
  75777. * Post-process used to merge the final HDR post-process and the real scene color
  75778. */
  75779. hdrFinalPostProcess: Nullable<PostProcess>;
  75780. /**
  75781. * Post-process used to create a lens flare effect
  75782. */
  75783. lensFlarePostProcess: Nullable<PostProcess>;
  75784. /**
  75785. * Post-process that merges the result of the lens flare post-process and the real scene color
  75786. */
  75787. lensFlareComposePostProcess: Nullable<PostProcess>;
  75788. /**
  75789. * Post-process used to create a motion blur effect
  75790. */
  75791. motionBlurPostProcess: Nullable<PostProcess>;
  75792. /**
  75793. * Post-process used to create a depth of field effect
  75794. */
  75795. depthOfFieldPostProcess: Nullable<PostProcess>;
  75796. /**
  75797. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75798. */
  75799. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75800. /**
  75801. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75802. */
  75803. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75804. /**
  75805. * Represents the brightness threshold in order to configure the illuminated surfaces
  75806. */
  75807. brightThreshold: number;
  75808. /**
  75809. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75810. */
  75811. blurWidth: number;
  75812. /**
  75813. * Sets if the blur for highlighted surfaces must be only horizontal
  75814. */
  75815. horizontalBlur: boolean;
  75816. /**
  75817. * Gets the overall exposure used by the pipeline
  75818. */
  75819. get exposure(): number;
  75820. /**
  75821. * Sets the overall exposure used by the pipeline
  75822. */
  75823. set exposure(value: number);
  75824. /**
  75825. * Texture used typically to simulate "dirty" on camera lens
  75826. */
  75827. lensTexture: Nullable<Texture>;
  75828. /**
  75829. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75830. */
  75831. volumetricLightCoefficient: number;
  75832. /**
  75833. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75834. */
  75835. volumetricLightPower: number;
  75836. /**
  75837. * Used the set the blur intensity to smooth the volumetric lights
  75838. */
  75839. volumetricLightBlurScale: number;
  75840. /**
  75841. * Light (spot or directional) used to generate the volumetric lights rays
  75842. * The source light must have a shadow generate so the pipeline can get its
  75843. * depth map
  75844. */
  75845. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75846. /**
  75847. * For eye adaptation, represents the minimum luminance the eye can see
  75848. */
  75849. hdrMinimumLuminance: number;
  75850. /**
  75851. * For eye adaptation, represents the decrease luminance speed
  75852. */
  75853. hdrDecreaseRate: number;
  75854. /**
  75855. * For eye adaptation, represents the increase luminance speed
  75856. */
  75857. hdrIncreaseRate: number;
  75858. /**
  75859. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75860. */
  75861. get hdrAutoExposure(): boolean;
  75862. /**
  75863. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75864. */
  75865. set hdrAutoExposure(value: boolean);
  75866. /**
  75867. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75868. */
  75869. lensColorTexture: Nullable<Texture>;
  75870. /**
  75871. * The overall strengh for the lens flare effect
  75872. */
  75873. lensFlareStrength: number;
  75874. /**
  75875. * Dispersion coefficient for lens flare ghosts
  75876. */
  75877. lensFlareGhostDispersal: number;
  75878. /**
  75879. * Main lens flare halo width
  75880. */
  75881. lensFlareHaloWidth: number;
  75882. /**
  75883. * Based on the lens distortion effect, defines how much the lens flare result
  75884. * is distorted
  75885. */
  75886. lensFlareDistortionStrength: number;
  75887. /**
  75888. * Configures the blur intensity used for for lens flare (halo)
  75889. */
  75890. lensFlareBlurWidth: number;
  75891. /**
  75892. * Lens star texture must be used to simulate rays on the flares and is available
  75893. * in the documentation
  75894. */
  75895. lensStarTexture: Nullable<Texture>;
  75896. /**
  75897. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75898. * flare effect by taking account of the dirt texture
  75899. */
  75900. lensFlareDirtTexture: Nullable<Texture>;
  75901. /**
  75902. * Represents the focal length for the depth of field effect
  75903. */
  75904. depthOfFieldDistance: number;
  75905. /**
  75906. * Represents the blur intensity for the blurred part of the depth of field effect
  75907. */
  75908. depthOfFieldBlurWidth: number;
  75909. /**
  75910. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75911. */
  75912. get motionStrength(): number;
  75913. /**
  75914. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75915. */
  75916. set motionStrength(strength: number);
  75917. /**
  75918. * Gets wether or not the motion blur post-process is object based or screen based.
  75919. */
  75920. get objectBasedMotionBlur(): boolean;
  75921. /**
  75922. * Sets wether or not the motion blur post-process should be object based or screen based
  75923. */
  75924. set objectBasedMotionBlur(value: boolean);
  75925. /**
  75926. * List of animations for the pipeline (IAnimatable implementation)
  75927. */
  75928. animations: Animation[];
  75929. /**
  75930. * Private members
  75931. */
  75932. private _scene;
  75933. private _currentDepthOfFieldSource;
  75934. private _basePostProcess;
  75935. private _fixedExposure;
  75936. private _currentExposure;
  75937. private _hdrAutoExposure;
  75938. private _hdrCurrentLuminance;
  75939. private _motionStrength;
  75940. private _isObjectBasedMotionBlur;
  75941. private _floatTextureType;
  75942. private _camerasToBeAttached;
  75943. private _ratio;
  75944. private _bloomEnabled;
  75945. private _depthOfFieldEnabled;
  75946. private _vlsEnabled;
  75947. private _lensFlareEnabled;
  75948. private _hdrEnabled;
  75949. private _motionBlurEnabled;
  75950. private _fxaaEnabled;
  75951. private _screenSpaceReflectionsEnabled;
  75952. private _motionBlurSamples;
  75953. private _volumetricLightStepsCount;
  75954. private _samples;
  75955. /**
  75956. * @ignore
  75957. * Specifies if the bloom pipeline is enabled
  75958. */
  75959. get BloomEnabled(): boolean;
  75960. set BloomEnabled(enabled: boolean);
  75961. /**
  75962. * @ignore
  75963. * Specifies if the depth of field pipeline is enabed
  75964. */
  75965. get DepthOfFieldEnabled(): boolean;
  75966. set DepthOfFieldEnabled(enabled: boolean);
  75967. /**
  75968. * @ignore
  75969. * Specifies if the lens flare pipeline is enabed
  75970. */
  75971. get LensFlareEnabled(): boolean;
  75972. set LensFlareEnabled(enabled: boolean);
  75973. /**
  75974. * @ignore
  75975. * Specifies if the HDR pipeline is enabled
  75976. */
  75977. get HDREnabled(): boolean;
  75978. set HDREnabled(enabled: boolean);
  75979. /**
  75980. * @ignore
  75981. * Specifies if the volumetric lights scattering effect is enabled
  75982. */
  75983. get VLSEnabled(): boolean;
  75984. set VLSEnabled(enabled: boolean);
  75985. /**
  75986. * @ignore
  75987. * Specifies if the motion blur effect is enabled
  75988. */
  75989. get MotionBlurEnabled(): boolean;
  75990. set MotionBlurEnabled(enabled: boolean);
  75991. /**
  75992. * Specifies if anti-aliasing is enabled
  75993. */
  75994. get fxaaEnabled(): boolean;
  75995. set fxaaEnabled(enabled: boolean);
  75996. /**
  75997. * Specifies if screen space reflections are enabled.
  75998. */
  75999. get screenSpaceReflectionsEnabled(): boolean;
  76000. set screenSpaceReflectionsEnabled(enabled: boolean);
  76001. /**
  76002. * Specifies the number of steps used to calculate the volumetric lights
  76003. * Typically in interval [50, 200]
  76004. */
  76005. get volumetricLightStepsCount(): number;
  76006. set volumetricLightStepsCount(count: number);
  76007. /**
  76008. * Specifies the number of samples used for the motion blur effect
  76009. * Typically in interval [16, 64]
  76010. */
  76011. get motionBlurSamples(): number;
  76012. set motionBlurSamples(samples: number);
  76013. /**
  76014. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76015. */
  76016. get samples(): number;
  76017. set samples(sampleCount: number);
  76018. /**
  76019. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76020. * @constructor
  76021. * @param name The rendering pipeline name
  76022. * @param scene The scene linked to this pipeline
  76023. * @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)
  76024. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76025. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76026. */
  76027. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76028. private _buildPipeline;
  76029. private _createDownSampleX4PostProcess;
  76030. private _createBrightPassPostProcess;
  76031. private _createBlurPostProcesses;
  76032. private _createTextureAdderPostProcess;
  76033. private _createVolumetricLightPostProcess;
  76034. private _createLuminancePostProcesses;
  76035. private _createHdrPostProcess;
  76036. private _createLensFlarePostProcess;
  76037. private _createDepthOfFieldPostProcess;
  76038. private _createMotionBlurPostProcess;
  76039. private _getDepthTexture;
  76040. private _disposePostProcesses;
  76041. /**
  76042. * Dispose of the pipeline and stop all post processes
  76043. */
  76044. dispose(): void;
  76045. /**
  76046. * Serialize the rendering pipeline (Used when exporting)
  76047. * @returns the serialized object
  76048. */
  76049. serialize(): any;
  76050. /**
  76051. * Parse the serialized pipeline
  76052. * @param source Source pipeline.
  76053. * @param scene The scene to load the pipeline to.
  76054. * @param rootUrl The URL of the serialized pipeline.
  76055. * @returns An instantiated pipeline from the serialized object.
  76056. */
  76057. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76058. /**
  76059. * Luminance steps
  76060. */
  76061. static LuminanceSteps: number;
  76062. }
  76063. }
  76064. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76065. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76066. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76067. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76068. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76069. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76070. }
  76071. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76072. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76073. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76074. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76075. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76076. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76077. }
  76078. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76079. /** @hidden */
  76080. export var stereoscopicInterlacePixelShader: {
  76081. name: string;
  76082. shader: string;
  76083. };
  76084. }
  76085. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76086. import { Camera } from "babylonjs/Cameras/camera";
  76087. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76088. import { Engine } from "babylonjs/Engines/engine";
  76089. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76090. /**
  76091. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76092. */
  76093. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76094. private _stepSize;
  76095. private _passedProcess;
  76096. /**
  76097. * Gets a string identifying the name of the class
  76098. * @returns "StereoscopicInterlacePostProcessI" string
  76099. */
  76100. getClassName(): string;
  76101. /**
  76102. * Initializes a StereoscopicInterlacePostProcessI
  76103. * @param name The name of the effect.
  76104. * @param rigCameras The rig cameras to be appled to the post process
  76105. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76106. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76108. * @param engine The engine which the post process will be applied. (default: current engine)
  76109. * @param reusable If the post process can be reused on the same frame. (default: false)
  76110. */
  76111. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76112. }
  76113. /**
  76114. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76115. */
  76116. export class StereoscopicInterlacePostProcess extends PostProcess {
  76117. private _stepSize;
  76118. private _passedProcess;
  76119. /**
  76120. * Gets a string identifying the name of the class
  76121. * @returns "StereoscopicInterlacePostProcess" string
  76122. */
  76123. getClassName(): string;
  76124. /**
  76125. * Initializes a StereoscopicInterlacePostProcess
  76126. * @param name The name of the effect.
  76127. * @param rigCameras The rig cameras to be appled to the post process
  76128. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76130. * @param engine The engine which the post process will be applied. (default: current engine)
  76131. * @param reusable If the post process can be reused on the same frame. (default: false)
  76132. */
  76133. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76134. }
  76135. }
  76136. declare module "babylonjs/Shaders/tonemap.fragment" {
  76137. /** @hidden */
  76138. export var tonemapPixelShader: {
  76139. name: string;
  76140. shader: string;
  76141. };
  76142. }
  76143. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76144. import { Camera } from "babylonjs/Cameras/camera";
  76145. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76146. import "babylonjs/Shaders/tonemap.fragment";
  76147. import { Engine } from "babylonjs/Engines/engine";
  76148. /** Defines operator used for tonemapping */
  76149. export enum TonemappingOperator {
  76150. /** Hable */
  76151. Hable = 0,
  76152. /** Reinhard */
  76153. Reinhard = 1,
  76154. /** HejiDawson */
  76155. HejiDawson = 2,
  76156. /** Photographic */
  76157. Photographic = 3
  76158. }
  76159. /**
  76160. * Defines a post process to apply tone mapping
  76161. */
  76162. export class TonemapPostProcess extends PostProcess {
  76163. private _operator;
  76164. /** Defines the required exposure adjustement */
  76165. exposureAdjustment: number;
  76166. /**
  76167. * Gets a string identifying the name of the class
  76168. * @returns "TonemapPostProcess" string
  76169. */
  76170. getClassName(): string;
  76171. /**
  76172. * Creates a new TonemapPostProcess
  76173. * @param name defines the name of the postprocess
  76174. * @param _operator defines the operator to use
  76175. * @param exposureAdjustment defines the required exposure adjustement
  76176. * @param camera defines the camera to use (can be null)
  76177. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76178. * @param engine defines the hosting engine (can be ignore if camera is set)
  76179. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76180. */
  76181. constructor(name: string, _operator: TonemappingOperator,
  76182. /** Defines the required exposure adjustement */
  76183. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76184. }
  76185. }
  76186. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76187. /** @hidden */
  76188. export var volumetricLightScatteringPixelShader: {
  76189. name: string;
  76190. shader: string;
  76191. };
  76192. }
  76193. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76194. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76195. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76196. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76197. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76198. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76199. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76200. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76201. /** @hidden */
  76202. export var volumetricLightScatteringPassVertexShader: {
  76203. name: string;
  76204. shader: string;
  76205. };
  76206. }
  76207. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76208. /** @hidden */
  76209. export var volumetricLightScatteringPassPixelShader: {
  76210. name: string;
  76211. shader: string;
  76212. };
  76213. }
  76214. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76215. import { Vector3 } from "babylonjs/Maths/math.vector";
  76216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76217. import { Mesh } from "babylonjs/Meshes/mesh";
  76218. import { Camera } from "babylonjs/Cameras/camera";
  76219. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76220. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76221. import { Scene } from "babylonjs/scene";
  76222. import "babylonjs/Meshes/Builders/planeBuilder";
  76223. import "babylonjs/Shaders/depth.vertex";
  76224. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76225. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76226. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76227. import { Engine } from "babylonjs/Engines/engine";
  76228. /**
  76229. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76230. */
  76231. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76232. private _volumetricLightScatteringPass;
  76233. private _volumetricLightScatteringRTT;
  76234. private _viewPort;
  76235. private _screenCoordinates;
  76236. private _cachedDefines;
  76237. /**
  76238. * If not undefined, the mesh position is computed from the attached node position
  76239. */
  76240. attachedNode: {
  76241. position: Vector3;
  76242. };
  76243. /**
  76244. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76245. */
  76246. customMeshPosition: Vector3;
  76247. /**
  76248. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76249. */
  76250. useCustomMeshPosition: boolean;
  76251. /**
  76252. * If the post-process should inverse the light scattering direction
  76253. */
  76254. invert: boolean;
  76255. /**
  76256. * The internal mesh used by the post-process
  76257. */
  76258. mesh: Mesh;
  76259. /**
  76260. * @hidden
  76261. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76262. */
  76263. get useDiffuseColor(): boolean;
  76264. set useDiffuseColor(useDiffuseColor: boolean);
  76265. /**
  76266. * Array containing the excluded meshes not rendered in the internal pass
  76267. */
  76268. excludedMeshes: AbstractMesh[];
  76269. /**
  76270. * Controls the overall intensity of the post-process
  76271. */
  76272. exposure: number;
  76273. /**
  76274. * Dissipates each sample's contribution in range [0, 1]
  76275. */
  76276. decay: number;
  76277. /**
  76278. * Controls the overall intensity of each sample
  76279. */
  76280. weight: number;
  76281. /**
  76282. * Controls the density of each sample
  76283. */
  76284. density: number;
  76285. /**
  76286. * @constructor
  76287. * @param name The post-process name
  76288. * @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)
  76289. * @param camera The camera that the post-process will be attached to
  76290. * @param mesh The mesh used to create the light scattering
  76291. * @param samples The post-process quality, default 100
  76292. * @param samplingModeThe post-process filtering mode
  76293. * @param engine The babylon engine
  76294. * @param reusable If the post-process is reusable
  76295. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76296. */
  76297. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76298. /**
  76299. * Returns the string "VolumetricLightScatteringPostProcess"
  76300. * @returns "VolumetricLightScatteringPostProcess"
  76301. */
  76302. getClassName(): string;
  76303. private _isReady;
  76304. /**
  76305. * Sets the new light position for light scattering effect
  76306. * @param position The new custom light position
  76307. */
  76308. setCustomMeshPosition(position: Vector3): void;
  76309. /**
  76310. * Returns the light position for light scattering effect
  76311. * @return Vector3 The custom light position
  76312. */
  76313. getCustomMeshPosition(): Vector3;
  76314. /**
  76315. * Disposes the internal assets and detaches the post-process from the camera
  76316. */
  76317. dispose(camera: Camera): void;
  76318. /**
  76319. * Returns the render target texture used by the post-process
  76320. * @return the render target texture used by the post-process
  76321. */
  76322. getPass(): RenderTargetTexture;
  76323. private _meshExcluded;
  76324. private _createPass;
  76325. private _updateMeshScreenCoordinates;
  76326. /**
  76327. * Creates a default mesh for the Volumeric Light Scattering post-process
  76328. * @param name The mesh name
  76329. * @param scene The scene where to create the mesh
  76330. * @return the default mesh
  76331. */
  76332. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76333. }
  76334. }
  76335. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76336. /** @hidden */
  76337. export var screenSpaceCurvaturePixelShader: {
  76338. name: string;
  76339. shader: string;
  76340. };
  76341. }
  76342. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76343. import { Nullable } from "babylonjs/types";
  76344. import { Camera } from "babylonjs/Cameras/camera";
  76345. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76346. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76347. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76348. import { Engine } from "babylonjs/Engines/engine";
  76349. import { Scene } from "babylonjs/scene";
  76350. /**
  76351. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76352. */
  76353. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76354. /**
  76355. * Defines how much ridge the curvature effect displays.
  76356. */
  76357. ridge: number;
  76358. /**
  76359. * Defines how much valley the curvature effect displays.
  76360. */
  76361. valley: number;
  76362. private _geometryBufferRenderer;
  76363. /**
  76364. * Gets a string identifying the name of the class
  76365. * @returns "ScreenSpaceCurvaturePostProcess" string
  76366. */
  76367. getClassName(): string;
  76368. /**
  76369. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76370. * @param name The name of the effect.
  76371. * @param scene The scene containing the objects to blur according to their velocity.
  76372. * @param options The required width/height ratio to downsize to before computing the render pass.
  76373. * @param camera The camera to apply the render pass to.
  76374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76375. * @param engine The engine which the post process will be applied. (default: current engine)
  76376. * @param reusable If the post process can be reused on the same frame. (default: false)
  76377. * @param textureType Type of textures used when performing the post process. (default: 0)
  76378. * @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)
  76379. */
  76380. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76381. /**
  76382. * Support test.
  76383. */
  76384. static get IsSupported(): boolean;
  76385. /** @hidden */
  76386. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76387. }
  76388. }
  76389. declare module "babylonjs/PostProcesses/index" {
  76390. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76391. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76392. export * from "babylonjs/PostProcesses/bloomEffect";
  76393. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76394. export * from "babylonjs/PostProcesses/blurPostProcess";
  76395. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76396. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76397. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76398. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76399. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76400. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76401. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76402. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76403. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76404. export * from "babylonjs/PostProcesses/filterPostProcess";
  76405. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76406. export * from "babylonjs/PostProcesses/grainPostProcess";
  76407. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76408. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76409. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76410. export * from "babylonjs/PostProcesses/passPostProcess";
  76411. export * from "babylonjs/PostProcesses/postProcess";
  76412. export * from "babylonjs/PostProcesses/postProcessManager";
  76413. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76414. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76415. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76416. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76417. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76418. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76419. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76420. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76421. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76422. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76423. }
  76424. declare module "babylonjs/Probes/index" {
  76425. export * from "babylonjs/Probes/reflectionProbe";
  76426. }
  76427. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76428. import { Scene } from "babylonjs/scene";
  76429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76430. import { SmartArray } from "babylonjs/Misc/smartArray";
  76431. import { ISceneComponent } from "babylonjs/sceneComponent";
  76432. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76433. import "babylonjs/Meshes/Builders/boxBuilder";
  76434. import "babylonjs/Shaders/color.fragment";
  76435. import "babylonjs/Shaders/color.vertex";
  76436. import { Color3 } from "babylonjs/Maths/math.color";
  76437. import { Observable } from "babylonjs/Misc/observable";
  76438. module "babylonjs/scene" {
  76439. interface Scene {
  76440. /** @hidden (Backing field) */
  76441. _boundingBoxRenderer: BoundingBoxRenderer;
  76442. /** @hidden (Backing field) */
  76443. _forceShowBoundingBoxes: boolean;
  76444. /**
  76445. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76446. */
  76447. forceShowBoundingBoxes: boolean;
  76448. /**
  76449. * Gets the bounding box renderer associated with the scene
  76450. * @returns a BoundingBoxRenderer
  76451. */
  76452. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76453. }
  76454. }
  76455. module "babylonjs/Meshes/abstractMesh" {
  76456. interface AbstractMesh {
  76457. /** @hidden (Backing field) */
  76458. _showBoundingBox: boolean;
  76459. /**
  76460. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76461. */
  76462. showBoundingBox: boolean;
  76463. }
  76464. }
  76465. /**
  76466. * Component responsible of rendering the bounding box of the meshes in a scene.
  76467. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76468. */
  76469. export class BoundingBoxRenderer implements ISceneComponent {
  76470. /**
  76471. * The component name helpfull to identify the component in the list of scene components.
  76472. */
  76473. readonly name: string;
  76474. /**
  76475. * The scene the component belongs to.
  76476. */
  76477. scene: Scene;
  76478. /**
  76479. * Color of the bounding box lines placed in front of an object
  76480. */
  76481. frontColor: Color3;
  76482. /**
  76483. * Color of the bounding box lines placed behind an object
  76484. */
  76485. backColor: Color3;
  76486. /**
  76487. * Defines if the renderer should show the back lines or not
  76488. */
  76489. showBackLines: boolean;
  76490. /**
  76491. * Observable raised before rendering a bounding box
  76492. */
  76493. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76494. /**
  76495. * Observable raised after rendering a bounding box
  76496. */
  76497. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76498. /**
  76499. * @hidden
  76500. */
  76501. renderList: SmartArray<BoundingBox>;
  76502. private _colorShader;
  76503. private _vertexBuffers;
  76504. private _indexBuffer;
  76505. private _fillIndexBuffer;
  76506. private _fillIndexData;
  76507. /**
  76508. * Instantiates a new bounding box renderer in a scene.
  76509. * @param scene the scene the renderer renders in
  76510. */
  76511. constructor(scene: Scene);
  76512. /**
  76513. * Registers the component in a given scene
  76514. */
  76515. register(): void;
  76516. private _evaluateSubMesh;
  76517. private _activeMesh;
  76518. private _prepareRessources;
  76519. private _createIndexBuffer;
  76520. /**
  76521. * Rebuilds the elements related to this component in case of
  76522. * context lost for instance.
  76523. */
  76524. rebuild(): void;
  76525. /**
  76526. * @hidden
  76527. */
  76528. reset(): void;
  76529. /**
  76530. * Render the bounding boxes of a specific rendering group
  76531. * @param renderingGroupId defines the rendering group to render
  76532. */
  76533. render(renderingGroupId: number): void;
  76534. /**
  76535. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76536. * @param mesh Define the mesh to render the occlusion bounding box for
  76537. */
  76538. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76539. /**
  76540. * Dispose and release the resources attached to this renderer.
  76541. */
  76542. dispose(): void;
  76543. }
  76544. }
  76545. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76546. import { Nullable } from "babylonjs/types";
  76547. import { Scene } from "babylonjs/scene";
  76548. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76549. import { Camera } from "babylonjs/Cameras/camera";
  76550. import { ISceneComponent } from "babylonjs/sceneComponent";
  76551. module "babylonjs/scene" {
  76552. interface Scene {
  76553. /** @hidden (Backing field) */
  76554. _depthRenderer: {
  76555. [id: string]: DepthRenderer;
  76556. };
  76557. /**
  76558. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76559. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76560. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76561. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76562. * @returns the created depth renderer
  76563. */
  76564. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76565. /**
  76566. * Disables a depth renderer for a given camera
  76567. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76568. */
  76569. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76570. }
  76571. }
  76572. /**
  76573. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76574. * in several rendering techniques.
  76575. */
  76576. export class DepthRendererSceneComponent implements ISceneComponent {
  76577. /**
  76578. * The component name helpfull to identify the component in the list of scene components.
  76579. */
  76580. readonly name: string;
  76581. /**
  76582. * The scene the component belongs to.
  76583. */
  76584. scene: Scene;
  76585. /**
  76586. * Creates a new instance of the component for the given scene
  76587. * @param scene Defines the scene to register the component in
  76588. */
  76589. constructor(scene: Scene);
  76590. /**
  76591. * Registers the component in a given scene
  76592. */
  76593. register(): void;
  76594. /**
  76595. * Rebuilds the elements related to this component in case of
  76596. * context lost for instance.
  76597. */
  76598. rebuild(): void;
  76599. /**
  76600. * Disposes the component and the associated ressources
  76601. */
  76602. dispose(): void;
  76603. private _gatherRenderTargets;
  76604. private _gatherActiveCameraRenderTargets;
  76605. }
  76606. }
  76607. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76608. import { Nullable } from "babylonjs/types";
  76609. import { Scene } from "babylonjs/scene";
  76610. import { ISceneComponent } from "babylonjs/sceneComponent";
  76611. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76612. module "babylonjs/abstractScene" {
  76613. interface AbstractScene {
  76614. /** @hidden (Backing field) */
  76615. _prePassRenderer: Nullable<PrePassRenderer>;
  76616. /**
  76617. * Gets or Sets the current prepass renderer associated to the scene.
  76618. */
  76619. prePassRenderer: Nullable<PrePassRenderer>;
  76620. /**
  76621. * Enables the prepass and associates it with the scene
  76622. * @returns the PrePassRenderer
  76623. */
  76624. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76625. /**
  76626. * Disables the prepass associated with the scene
  76627. */
  76628. disablePrePassRenderer(): void;
  76629. }
  76630. }
  76631. /**
  76632. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76633. * in several rendering techniques.
  76634. */
  76635. export class PrePassRendererSceneComponent implements ISceneComponent {
  76636. /**
  76637. * The component name helpful to identify the component in the list of scene components.
  76638. */
  76639. readonly name: string;
  76640. /**
  76641. * The scene the component belongs to.
  76642. */
  76643. scene: Scene;
  76644. /**
  76645. * Creates a new instance of the component for the given scene
  76646. * @param scene Defines the scene to register the component in
  76647. */
  76648. constructor(scene: Scene);
  76649. /**
  76650. * Registers the component in a given scene
  76651. */
  76652. register(): void;
  76653. private _beforeCameraDraw;
  76654. private _afterCameraDraw;
  76655. private _beforeClearStage;
  76656. /**
  76657. * Rebuilds the elements related to this component in case of
  76658. * context lost for instance.
  76659. */
  76660. rebuild(): void;
  76661. /**
  76662. * Disposes the component and the associated ressources
  76663. */
  76664. dispose(): void;
  76665. }
  76666. }
  76667. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76668. /** @hidden */
  76669. export var fibonacci: {
  76670. name: string;
  76671. shader: string;
  76672. };
  76673. }
  76674. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76675. /** @hidden */
  76676. export var diffusionProfile: {
  76677. name: string;
  76678. shader: string;
  76679. };
  76680. }
  76681. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76682. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76683. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76684. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76685. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76686. /** @hidden */
  76687. export var subSurfaceScatteringPixelShader: {
  76688. name: string;
  76689. shader: string;
  76690. };
  76691. }
  76692. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76693. import { Nullable } from "babylonjs/types";
  76694. import { Camera } from "babylonjs/Cameras/camera";
  76695. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76696. import { Engine } from "babylonjs/Engines/engine";
  76697. import { Scene } from "babylonjs/scene";
  76698. import "babylonjs/Shaders/imageProcessing.fragment";
  76699. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76700. import "babylonjs/Shaders/postprocess.vertex";
  76701. /**
  76702. * Sub surface scattering post process
  76703. */
  76704. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76705. /**
  76706. * Gets a string identifying the name of the class
  76707. * @returns "SubSurfaceScatteringPostProcess" string
  76708. */
  76709. getClassName(): string;
  76710. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76711. }
  76712. }
  76713. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76714. import { Scene } from "babylonjs/scene";
  76715. import { Color3 } from "babylonjs/Maths/math.color";
  76716. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76717. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76718. /**
  76719. * Contains all parameters needed for the prepass to perform
  76720. * screen space subsurface scattering
  76721. */
  76722. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76723. /** @hidden */
  76724. static _SceneComponentInitialization: (scene: Scene) => void;
  76725. private _ssDiffusionS;
  76726. private _ssFilterRadii;
  76727. private _ssDiffusionD;
  76728. /**
  76729. * Post process to attach for screen space subsurface scattering
  76730. */
  76731. postProcess: SubSurfaceScatteringPostProcess;
  76732. /**
  76733. * Diffusion profile color for subsurface scattering
  76734. */
  76735. get ssDiffusionS(): number[];
  76736. /**
  76737. * Diffusion profile max color channel value for subsurface scattering
  76738. */
  76739. get ssDiffusionD(): number[];
  76740. /**
  76741. * Diffusion profile filter radius for subsurface scattering
  76742. */
  76743. get ssFilterRadii(): number[];
  76744. /**
  76745. * Is subsurface enabled
  76746. */
  76747. enabled: boolean;
  76748. /**
  76749. * Name of the configuration
  76750. */
  76751. name: string;
  76752. /**
  76753. * Diffusion profile colors for subsurface scattering
  76754. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76755. * See ...
  76756. * Note that you can only store up to 5 of them
  76757. */
  76758. ssDiffusionProfileColors: Color3[];
  76759. /**
  76760. * Defines the ratio real world => scene units.
  76761. * Used for subsurface scattering
  76762. */
  76763. metersPerUnit: number;
  76764. /**
  76765. * Textures that should be present in the MRT for this effect to work
  76766. */
  76767. readonly texturesRequired: number[];
  76768. private _scene;
  76769. /**
  76770. * Builds a subsurface configuration object
  76771. * @param scene The scene
  76772. */
  76773. constructor(scene: Scene);
  76774. /**
  76775. * Adds a new diffusion profile.
  76776. * Useful for more realistic subsurface scattering on diverse materials.
  76777. * @param color The color of the diffusion profile. Should be the average color of the material.
  76778. * @return The index of the diffusion profile for the material subsurface configuration
  76779. */
  76780. addDiffusionProfile(color: Color3): number;
  76781. /**
  76782. * Creates the sss post process
  76783. * @return The created post process
  76784. */
  76785. createPostProcess(): SubSurfaceScatteringPostProcess;
  76786. /**
  76787. * Deletes all diffusion profiles.
  76788. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76789. */
  76790. clearAllDiffusionProfiles(): void;
  76791. /**
  76792. * Disposes this object
  76793. */
  76794. dispose(): void;
  76795. /**
  76796. * @hidden
  76797. * https://zero-radiance.github.io/post/sampling-diffusion/
  76798. *
  76799. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76800. * ------------------------------------------------------------------------------------
  76801. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76802. * PDF[r, phi, s] = r * R[r, phi, s]
  76803. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76804. * ------------------------------------------------------------------------------------
  76805. * We importance sample the color channel with the widest scattering distance.
  76806. */
  76807. getDiffusionProfileParameters(color: Color3): number;
  76808. /**
  76809. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76810. * 'u' is the random number (the value of the CDF): [0, 1).
  76811. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76812. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76813. */
  76814. private _sampleBurleyDiffusionProfile;
  76815. }
  76816. }
  76817. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76818. import { Nullable } from "babylonjs/types";
  76819. import { Scene } from "babylonjs/scene";
  76820. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76821. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76822. import { AbstractScene } from "babylonjs/abstractScene";
  76823. module "babylonjs/abstractScene" {
  76824. interface AbstractScene {
  76825. /** @hidden (Backing field) */
  76826. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76827. /**
  76828. * Gets or Sets the current prepass renderer associated to the scene.
  76829. */
  76830. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76831. /**
  76832. * Enables the subsurface effect for prepass
  76833. * @returns the SubSurfaceConfiguration
  76834. */
  76835. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76836. /**
  76837. * Disables the subsurface effect for prepass
  76838. */
  76839. disableSubSurfaceForPrePass(): void;
  76840. }
  76841. }
  76842. /**
  76843. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76844. * in several rendering techniques.
  76845. */
  76846. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76847. /**
  76848. * The component name helpful to identify the component in the list of scene components.
  76849. */
  76850. readonly name: string;
  76851. /**
  76852. * The scene the component belongs to.
  76853. */
  76854. scene: Scene;
  76855. /**
  76856. * Creates a new instance of the component for the given scene
  76857. * @param scene Defines the scene to register the component in
  76858. */
  76859. constructor(scene: Scene);
  76860. /**
  76861. * Registers the component in a given scene
  76862. */
  76863. register(): void;
  76864. /**
  76865. * Serializes the component data to the specified json object
  76866. * @param serializationObject The object to serialize to
  76867. */
  76868. serialize(serializationObject: any): void;
  76869. /**
  76870. * Adds all the elements from the container to the scene
  76871. * @param container the container holding the elements
  76872. */
  76873. addFromContainer(container: AbstractScene): void;
  76874. /**
  76875. * Removes all the elements in the container from the scene
  76876. * @param container contains the elements to remove
  76877. * @param dispose if the removed element should be disposed (default: false)
  76878. */
  76879. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76880. /**
  76881. * Rebuilds the elements related to this component in case of
  76882. * context lost for instance.
  76883. */
  76884. rebuild(): void;
  76885. /**
  76886. * Disposes the component and the associated ressources
  76887. */
  76888. dispose(): void;
  76889. }
  76890. }
  76891. declare module "babylonjs/Shaders/outline.fragment" {
  76892. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76893. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76894. /** @hidden */
  76895. export var outlinePixelShader: {
  76896. name: string;
  76897. shader: string;
  76898. };
  76899. }
  76900. declare module "babylonjs/Shaders/outline.vertex" {
  76901. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76902. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76903. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76904. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76905. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76907. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76908. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76909. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76910. /** @hidden */
  76911. export var outlineVertexShader: {
  76912. name: string;
  76913. shader: string;
  76914. };
  76915. }
  76916. declare module "babylonjs/Rendering/outlineRenderer" {
  76917. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76918. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76919. import { Scene } from "babylonjs/scene";
  76920. import { ISceneComponent } from "babylonjs/sceneComponent";
  76921. import "babylonjs/Shaders/outline.fragment";
  76922. import "babylonjs/Shaders/outline.vertex";
  76923. module "babylonjs/scene" {
  76924. interface Scene {
  76925. /** @hidden */
  76926. _outlineRenderer: OutlineRenderer;
  76927. /**
  76928. * Gets the outline renderer associated with the scene
  76929. * @returns a OutlineRenderer
  76930. */
  76931. getOutlineRenderer(): OutlineRenderer;
  76932. }
  76933. }
  76934. module "babylonjs/Meshes/abstractMesh" {
  76935. interface AbstractMesh {
  76936. /** @hidden (Backing field) */
  76937. _renderOutline: boolean;
  76938. /**
  76939. * Gets or sets a boolean indicating if the outline must be rendered as well
  76940. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76941. */
  76942. renderOutline: boolean;
  76943. /** @hidden (Backing field) */
  76944. _renderOverlay: boolean;
  76945. /**
  76946. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76947. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76948. */
  76949. renderOverlay: boolean;
  76950. }
  76951. }
  76952. /**
  76953. * This class is responsible to draw bothe outline/overlay of meshes.
  76954. * It should not be used directly but through the available method on mesh.
  76955. */
  76956. export class OutlineRenderer implements ISceneComponent {
  76957. /**
  76958. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76959. */
  76960. private static _StencilReference;
  76961. /**
  76962. * The name of the component. Each component must have a unique name.
  76963. */
  76964. name: string;
  76965. /**
  76966. * The scene the component belongs to.
  76967. */
  76968. scene: Scene;
  76969. /**
  76970. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76971. */
  76972. zOffset: number;
  76973. private _engine;
  76974. private _effect;
  76975. private _cachedDefines;
  76976. private _savedDepthWrite;
  76977. /**
  76978. * Instantiates a new outline renderer. (There could be only one per scene).
  76979. * @param scene Defines the scene it belongs to
  76980. */
  76981. constructor(scene: Scene);
  76982. /**
  76983. * Register the component to one instance of a scene.
  76984. */
  76985. register(): void;
  76986. /**
  76987. * Rebuilds the elements related to this component in case of
  76988. * context lost for instance.
  76989. */
  76990. rebuild(): void;
  76991. /**
  76992. * Disposes the component and the associated ressources.
  76993. */
  76994. dispose(): void;
  76995. /**
  76996. * Renders the outline in the canvas.
  76997. * @param subMesh Defines the sumesh to render
  76998. * @param batch Defines the batch of meshes in case of instances
  76999. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77000. */
  77001. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77002. /**
  77003. * Returns whether or not the outline renderer is ready for a given submesh.
  77004. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77005. * @param subMesh Defines the submesh to check readyness for
  77006. * @param useInstances Defines wheter wee are trying to render instances or not
  77007. * @returns true if ready otherwise false
  77008. */
  77009. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77010. private _beforeRenderingMesh;
  77011. private _afterRenderingMesh;
  77012. }
  77013. }
  77014. declare module "babylonjs/Rendering/index" {
  77015. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77016. export * from "babylonjs/Rendering/depthRenderer";
  77017. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77018. export * from "babylonjs/Rendering/edgesRenderer";
  77019. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77020. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77021. export * from "babylonjs/Rendering/prePassRenderer";
  77022. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77023. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77024. export * from "babylonjs/Rendering/outlineRenderer";
  77025. export * from "babylonjs/Rendering/renderingGroup";
  77026. export * from "babylonjs/Rendering/renderingManager";
  77027. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77028. }
  77029. declare module "babylonjs/Sprites/ISprites" {
  77030. /**
  77031. * Defines the basic options interface of a Sprite Frame Source Size.
  77032. */
  77033. export interface ISpriteJSONSpriteSourceSize {
  77034. /**
  77035. * number of the original width of the Frame
  77036. */
  77037. w: number;
  77038. /**
  77039. * number of the original height of the Frame
  77040. */
  77041. h: number;
  77042. }
  77043. /**
  77044. * Defines the basic options interface of a Sprite Frame Data.
  77045. */
  77046. export interface ISpriteJSONSpriteFrameData {
  77047. /**
  77048. * number of the x offset of the Frame
  77049. */
  77050. x: number;
  77051. /**
  77052. * number of the y offset of the Frame
  77053. */
  77054. y: number;
  77055. /**
  77056. * number of the width of the Frame
  77057. */
  77058. w: number;
  77059. /**
  77060. * number of the height of the Frame
  77061. */
  77062. h: number;
  77063. }
  77064. /**
  77065. * Defines the basic options interface of a JSON Sprite.
  77066. */
  77067. export interface ISpriteJSONSprite {
  77068. /**
  77069. * string name of the Frame
  77070. */
  77071. filename: string;
  77072. /**
  77073. * ISpriteJSONSpriteFrame basic object of the frame data
  77074. */
  77075. frame: ISpriteJSONSpriteFrameData;
  77076. /**
  77077. * boolean to flag is the frame was rotated.
  77078. */
  77079. rotated: boolean;
  77080. /**
  77081. * boolean to flag is the frame was trimmed.
  77082. */
  77083. trimmed: boolean;
  77084. /**
  77085. * ISpriteJSONSpriteFrame basic object of the source data
  77086. */
  77087. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77088. /**
  77089. * ISpriteJSONSpriteFrame basic object of the source data
  77090. */
  77091. sourceSize: ISpriteJSONSpriteSourceSize;
  77092. }
  77093. /**
  77094. * Defines the basic options interface of a JSON atlas.
  77095. */
  77096. export interface ISpriteJSONAtlas {
  77097. /**
  77098. * Array of objects that contain the frame data.
  77099. */
  77100. frames: Array<ISpriteJSONSprite>;
  77101. /**
  77102. * object basic object containing the sprite meta data.
  77103. */
  77104. meta?: object;
  77105. }
  77106. }
  77107. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77108. /** @hidden */
  77109. export var spriteMapPixelShader: {
  77110. name: string;
  77111. shader: string;
  77112. };
  77113. }
  77114. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77115. /** @hidden */
  77116. export var spriteMapVertexShader: {
  77117. name: string;
  77118. shader: string;
  77119. };
  77120. }
  77121. declare module "babylonjs/Sprites/spriteMap" {
  77122. import { IDisposable, Scene } from "babylonjs/scene";
  77123. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77124. import { Texture } from "babylonjs/Materials/Textures/texture";
  77125. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77126. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77127. import "babylonjs/Meshes/Builders/planeBuilder";
  77128. import "babylonjs/Shaders/spriteMap.fragment";
  77129. import "babylonjs/Shaders/spriteMap.vertex";
  77130. /**
  77131. * Defines the basic options interface of a SpriteMap
  77132. */
  77133. export interface ISpriteMapOptions {
  77134. /**
  77135. * Vector2 of the number of cells in the grid.
  77136. */
  77137. stageSize?: Vector2;
  77138. /**
  77139. * Vector2 of the size of the output plane in World Units.
  77140. */
  77141. outputSize?: Vector2;
  77142. /**
  77143. * Vector3 of the position of the output plane in World Units.
  77144. */
  77145. outputPosition?: Vector3;
  77146. /**
  77147. * Vector3 of the rotation of the output plane.
  77148. */
  77149. outputRotation?: Vector3;
  77150. /**
  77151. * number of layers that the system will reserve in resources.
  77152. */
  77153. layerCount?: number;
  77154. /**
  77155. * number of max animation frames a single cell will reserve in resources.
  77156. */
  77157. maxAnimationFrames?: number;
  77158. /**
  77159. * number cell index of the base tile when the system compiles.
  77160. */
  77161. baseTile?: number;
  77162. /**
  77163. * boolean flip the sprite after its been repositioned by the framing data.
  77164. */
  77165. flipU?: boolean;
  77166. /**
  77167. * Vector3 scalar of the global RGB values of the SpriteMap.
  77168. */
  77169. colorMultiply?: Vector3;
  77170. }
  77171. /**
  77172. * Defines the IDisposable interface in order to be cleanable from resources.
  77173. */
  77174. export interface ISpriteMap extends IDisposable {
  77175. /**
  77176. * String name of the SpriteMap.
  77177. */
  77178. name: string;
  77179. /**
  77180. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77181. */
  77182. atlasJSON: ISpriteJSONAtlas;
  77183. /**
  77184. * Texture of the SpriteMap.
  77185. */
  77186. spriteSheet: Texture;
  77187. /**
  77188. * The parameters to initialize the SpriteMap with.
  77189. */
  77190. options: ISpriteMapOptions;
  77191. }
  77192. /**
  77193. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77194. */
  77195. export class SpriteMap implements ISpriteMap {
  77196. /** The Name of the spriteMap */
  77197. name: string;
  77198. /** The JSON file with the frame and meta data */
  77199. atlasJSON: ISpriteJSONAtlas;
  77200. /** The systems Sprite Sheet Texture */
  77201. spriteSheet: Texture;
  77202. /** Arguments passed with the Constructor */
  77203. options: ISpriteMapOptions;
  77204. /** Public Sprite Storage array, parsed from atlasJSON */
  77205. sprites: Array<ISpriteJSONSprite>;
  77206. /** Returns the Number of Sprites in the System */
  77207. get spriteCount(): number;
  77208. /** Returns the Position of Output Plane*/
  77209. get position(): Vector3;
  77210. /** Returns the Position of Output Plane*/
  77211. set position(v: Vector3);
  77212. /** Returns the Rotation of Output Plane*/
  77213. get rotation(): Vector3;
  77214. /** Returns the Rotation of Output Plane*/
  77215. set rotation(v: Vector3);
  77216. /** Sets the AnimationMap*/
  77217. get animationMap(): RawTexture;
  77218. /** Sets the AnimationMap*/
  77219. set animationMap(v: RawTexture);
  77220. /** Scene that the SpriteMap was created in */
  77221. private _scene;
  77222. /** Texture Buffer of Float32 that holds tile frame data*/
  77223. private _frameMap;
  77224. /** Texture Buffers of Float32 that holds tileMap data*/
  77225. private _tileMaps;
  77226. /** Texture Buffer of Float32 that holds Animation Data*/
  77227. private _animationMap;
  77228. /** Custom ShaderMaterial Central to the System*/
  77229. private _material;
  77230. /** Custom ShaderMaterial Central to the System*/
  77231. private _output;
  77232. /** Systems Time Ticker*/
  77233. private _time;
  77234. /**
  77235. * Creates a new SpriteMap
  77236. * @param name defines the SpriteMaps Name
  77237. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77238. * @param spriteSheet is the Texture that the Sprites are on.
  77239. * @param options a basic deployment configuration
  77240. * @param scene The Scene that the map is deployed on
  77241. */
  77242. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77243. /**
  77244. * Returns tileID location
  77245. * @returns Vector2 the cell position ID
  77246. */
  77247. getTileID(): Vector2;
  77248. /**
  77249. * Gets the UV location of the mouse over the SpriteMap.
  77250. * @returns Vector2 the UV position of the mouse interaction
  77251. */
  77252. getMousePosition(): Vector2;
  77253. /**
  77254. * Creates the "frame" texture Buffer
  77255. * -------------------------------------
  77256. * Structure of frames
  77257. * "filename": "Falling-Water-2.png",
  77258. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77259. * "rotated": true,
  77260. * "trimmed": true,
  77261. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77262. * "sourceSize": {"w":32,"h":32}
  77263. * @returns RawTexture of the frameMap
  77264. */
  77265. private _createFrameBuffer;
  77266. /**
  77267. * Creates the tileMap texture Buffer
  77268. * @param buffer normally and array of numbers, or a false to generate from scratch
  77269. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77270. * @returns RawTexture of the tileMap
  77271. */
  77272. private _createTileBuffer;
  77273. /**
  77274. * Modifies the data of the tileMaps
  77275. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77276. * @param pos is the iVector2 Coordinates of the Tile
  77277. * @param tile The SpriteIndex of the new Tile
  77278. */
  77279. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77280. /**
  77281. * Creates the animationMap texture Buffer
  77282. * @param buffer normally and array of numbers, or a false to generate from scratch
  77283. * @returns RawTexture of the animationMap
  77284. */
  77285. private _createTileAnimationBuffer;
  77286. /**
  77287. * Modifies the data of the animationMap
  77288. * @param cellID is the Index of the Sprite
  77289. * @param _frame is the target Animation frame
  77290. * @param toCell is the Target Index of the next frame of the animation
  77291. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77292. * @param speed is a global scalar of the time variable on the map.
  77293. */
  77294. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77295. /**
  77296. * Exports the .tilemaps file
  77297. */
  77298. saveTileMaps(): void;
  77299. /**
  77300. * Imports the .tilemaps file
  77301. * @param url of the .tilemaps file
  77302. */
  77303. loadTileMaps(url: string): void;
  77304. /**
  77305. * Release associated resources
  77306. */
  77307. dispose(): void;
  77308. }
  77309. }
  77310. declare module "babylonjs/Sprites/spritePackedManager" {
  77311. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77312. import { Scene } from "babylonjs/scene";
  77313. /**
  77314. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77315. * @see https://doc.babylonjs.com/babylon101/sprites
  77316. */
  77317. export class SpritePackedManager extends SpriteManager {
  77318. /** defines the packed manager's name */
  77319. name: string;
  77320. /**
  77321. * Creates a new sprite manager from a packed sprite sheet
  77322. * @param name defines the manager's name
  77323. * @param imgUrl defines the sprite sheet url
  77324. * @param capacity defines the maximum allowed number of sprites
  77325. * @param scene defines the hosting scene
  77326. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77327. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77328. * @param samplingMode defines the smapling mode to use with spritesheet
  77329. * @param fromPacked set to true; do not alter
  77330. */
  77331. constructor(
  77332. /** defines the packed manager's name */
  77333. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77334. }
  77335. }
  77336. declare module "babylonjs/Sprites/index" {
  77337. export * from "babylonjs/Sprites/sprite";
  77338. export * from "babylonjs/Sprites/ISprites";
  77339. export * from "babylonjs/Sprites/spriteManager";
  77340. export * from "babylonjs/Sprites/spriteMap";
  77341. export * from "babylonjs/Sprites/spritePackedManager";
  77342. export * from "babylonjs/Sprites/spriteSceneComponent";
  77343. }
  77344. declare module "babylonjs/States/index" {
  77345. export * from "babylonjs/States/alphaCullingState";
  77346. export * from "babylonjs/States/depthCullingState";
  77347. export * from "babylonjs/States/stencilState";
  77348. }
  77349. declare module "babylonjs/Misc/assetsManager" {
  77350. import { Scene } from "babylonjs/scene";
  77351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77352. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77353. import { Skeleton } from "babylonjs/Bones/skeleton";
  77354. import { Observable } from "babylonjs/Misc/observable";
  77355. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77356. import { Texture } from "babylonjs/Materials/Textures/texture";
  77357. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77358. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77359. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77360. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77361. import { AssetContainer } from "babylonjs/assetContainer";
  77362. /**
  77363. * Defines the list of states available for a task inside a AssetsManager
  77364. */
  77365. export enum AssetTaskState {
  77366. /**
  77367. * Initialization
  77368. */
  77369. INIT = 0,
  77370. /**
  77371. * Running
  77372. */
  77373. RUNNING = 1,
  77374. /**
  77375. * Done
  77376. */
  77377. DONE = 2,
  77378. /**
  77379. * Error
  77380. */
  77381. ERROR = 3
  77382. }
  77383. /**
  77384. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77385. */
  77386. export abstract class AbstractAssetTask {
  77387. /**
  77388. * Task name
  77389. */ name: string;
  77390. /**
  77391. * Callback called when the task is successful
  77392. */
  77393. onSuccess: (task: any) => void;
  77394. /**
  77395. * Callback called when the task is not successful
  77396. */
  77397. onError: (task: any, message?: string, exception?: any) => void;
  77398. /**
  77399. * Creates a new AssetsManager
  77400. * @param name defines the name of the task
  77401. */
  77402. constructor(
  77403. /**
  77404. * Task name
  77405. */ name: string);
  77406. private _isCompleted;
  77407. private _taskState;
  77408. private _errorObject;
  77409. /**
  77410. * Get if the task is completed
  77411. */
  77412. get isCompleted(): boolean;
  77413. /**
  77414. * Gets the current state of the task
  77415. */
  77416. get taskState(): AssetTaskState;
  77417. /**
  77418. * Gets the current error object (if task is in error)
  77419. */
  77420. get errorObject(): {
  77421. message?: string;
  77422. exception?: any;
  77423. };
  77424. /**
  77425. * Internal only
  77426. * @hidden
  77427. */
  77428. _setErrorObject(message?: string, exception?: any): void;
  77429. /**
  77430. * Execute the current task
  77431. * @param scene defines the scene where you want your assets to be loaded
  77432. * @param onSuccess is a callback called when the task is successfully executed
  77433. * @param onError is a callback called if an error occurs
  77434. */
  77435. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77436. /**
  77437. * Execute the current task
  77438. * @param scene defines the scene where you want your assets to be loaded
  77439. * @param onSuccess is a callback called when the task is successfully executed
  77440. * @param onError is a callback called if an error occurs
  77441. */
  77442. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77443. /**
  77444. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77445. * This can be used with failed tasks that have the reason for failure fixed.
  77446. */
  77447. reset(): void;
  77448. private onErrorCallback;
  77449. private onDoneCallback;
  77450. }
  77451. /**
  77452. * Define the interface used by progress events raised during assets loading
  77453. */
  77454. export interface IAssetsProgressEvent {
  77455. /**
  77456. * Defines the number of remaining tasks to process
  77457. */
  77458. remainingCount: number;
  77459. /**
  77460. * Defines the total number of tasks
  77461. */
  77462. totalCount: number;
  77463. /**
  77464. * Defines the task that was just processed
  77465. */
  77466. task: AbstractAssetTask;
  77467. }
  77468. /**
  77469. * Class used to share progress information about assets loading
  77470. */
  77471. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77472. /**
  77473. * Defines the number of remaining tasks to process
  77474. */
  77475. remainingCount: number;
  77476. /**
  77477. * Defines the total number of tasks
  77478. */
  77479. totalCount: number;
  77480. /**
  77481. * Defines the task that was just processed
  77482. */
  77483. task: AbstractAssetTask;
  77484. /**
  77485. * Creates a AssetsProgressEvent
  77486. * @param remainingCount defines the number of remaining tasks to process
  77487. * @param totalCount defines the total number of tasks
  77488. * @param task defines the task that was just processed
  77489. */
  77490. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77491. }
  77492. /**
  77493. * Define a task used by AssetsManager to load assets into a container
  77494. */
  77495. export class ContainerAssetTask extends AbstractAssetTask {
  77496. /**
  77497. * Defines the name of the task
  77498. */
  77499. name: string;
  77500. /**
  77501. * Defines the list of mesh's names you want to load
  77502. */
  77503. meshesNames: any;
  77504. /**
  77505. * Defines the root url to use as a base to load your meshes and associated resources
  77506. */
  77507. rootUrl: string;
  77508. /**
  77509. * Defines the filename or File of the scene to load from
  77510. */
  77511. sceneFilename: string | File;
  77512. /**
  77513. * Get the loaded asset container
  77514. */
  77515. loadedContainer: AssetContainer;
  77516. /**
  77517. * Gets the list of loaded meshes
  77518. */
  77519. loadedMeshes: Array<AbstractMesh>;
  77520. /**
  77521. * Gets the list of loaded particle systems
  77522. */
  77523. loadedParticleSystems: Array<IParticleSystem>;
  77524. /**
  77525. * Gets the list of loaded skeletons
  77526. */
  77527. loadedSkeletons: Array<Skeleton>;
  77528. /**
  77529. * Gets the list of loaded animation groups
  77530. */
  77531. loadedAnimationGroups: Array<AnimationGroup>;
  77532. /**
  77533. * Callback called when the task is successful
  77534. */
  77535. onSuccess: (task: ContainerAssetTask) => void;
  77536. /**
  77537. * Callback called when the task is successful
  77538. */
  77539. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77540. /**
  77541. * Creates a new ContainerAssetTask
  77542. * @param name defines the name of the task
  77543. * @param meshesNames defines the list of mesh's names you want to load
  77544. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77545. * @param sceneFilename defines the filename or File of the scene to load from
  77546. */
  77547. constructor(
  77548. /**
  77549. * Defines the name of the task
  77550. */
  77551. name: string,
  77552. /**
  77553. * Defines the list of mesh's names you want to load
  77554. */
  77555. meshesNames: any,
  77556. /**
  77557. * Defines the root url to use as a base to load your meshes and associated resources
  77558. */
  77559. rootUrl: string,
  77560. /**
  77561. * Defines the filename or File of the scene to load from
  77562. */
  77563. sceneFilename: string | File);
  77564. /**
  77565. * Execute the current task
  77566. * @param scene defines the scene where you want your assets to be loaded
  77567. * @param onSuccess is a callback called when the task is successfully executed
  77568. * @param onError is a callback called if an error occurs
  77569. */
  77570. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77571. }
  77572. /**
  77573. * Define a task used by AssetsManager to load meshes
  77574. */
  77575. export class MeshAssetTask extends AbstractAssetTask {
  77576. /**
  77577. * Defines the name of the task
  77578. */
  77579. name: string;
  77580. /**
  77581. * Defines the list of mesh's names you want to load
  77582. */
  77583. meshesNames: any;
  77584. /**
  77585. * Defines the root url to use as a base to load your meshes and associated resources
  77586. */
  77587. rootUrl: string;
  77588. /**
  77589. * Defines the filename or File of the scene to load from
  77590. */
  77591. sceneFilename: string | File;
  77592. /**
  77593. * Gets the list of loaded meshes
  77594. */
  77595. loadedMeshes: Array<AbstractMesh>;
  77596. /**
  77597. * Gets the list of loaded particle systems
  77598. */
  77599. loadedParticleSystems: Array<IParticleSystem>;
  77600. /**
  77601. * Gets the list of loaded skeletons
  77602. */
  77603. loadedSkeletons: Array<Skeleton>;
  77604. /**
  77605. * Gets the list of loaded animation groups
  77606. */
  77607. loadedAnimationGroups: Array<AnimationGroup>;
  77608. /**
  77609. * Callback called when the task is successful
  77610. */
  77611. onSuccess: (task: MeshAssetTask) => void;
  77612. /**
  77613. * Callback called when the task is successful
  77614. */
  77615. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77616. /**
  77617. * Creates a new MeshAssetTask
  77618. * @param name defines the name of the task
  77619. * @param meshesNames defines the list of mesh's names you want to load
  77620. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77621. * @param sceneFilename defines the filename or File of the scene to load from
  77622. */
  77623. constructor(
  77624. /**
  77625. * Defines the name of the task
  77626. */
  77627. name: string,
  77628. /**
  77629. * Defines the list of mesh's names you want to load
  77630. */
  77631. meshesNames: any,
  77632. /**
  77633. * Defines the root url to use as a base to load your meshes and associated resources
  77634. */
  77635. rootUrl: string,
  77636. /**
  77637. * Defines the filename or File of the scene to load from
  77638. */
  77639. sceneFilename: string | File);
  77640. /**
  77641. * Execute the current task
  77642. * @param scene defines the scene where you want your assets to be loaded
  77643. * @param onSuccess is a callback called when the task is successfully executed
  77644. * @param onError is a callback called if an error occurs
  77645. */
  77646. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77647. }
  77648. /**
  77649. * Define a task used by AssetsManager to load text content
  77650. */
  77651. export class TextFileAssetTask extends AbstractAssetTask {
  77652. /**
  77653. * Defines the name of the task
  77654. */
  77655. name: string;
  77656. /**
  77657. * Defines the location of the file to load
  77658. */
  77659. url: string;
  77660. /**
  77661. * Gets the loaded text string
  77662. */
  77663. text: string;
  77664. /**
  77665. * Callback called when the task is successful
  77666. */
  77667. onSuccess: (task: TextFileAssetTask) => void;
  77668. /**
  77669. * Callback called when the task is successful
  77670. */
  77671. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77672. /**
  77673. * Creates a new TextFileAssetTask object
  77674. * @param name defines the name of the task
  77675. * @param url defines the location of the file to load
  77676. */
  77677. constructor(
  77678. /**
  77679. * Defines the name of the task
  77680. */
  77681. name: string,
  77682. /**
  77683. * Defines the location of the file to load
  77684. */
  77685. url: string);
  77686. /**
  77687. * Execute the current task
  77688. * @param scene defines the scene where you want your assets to be loaded
  77689. * @param onSuccess is a callback called when the task is successfully executed
  77690. * @param onError is a callback called if an error occurs
  77691. */
  77692. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77693. }
  77694. /**
  77695. * Define a task used by AssetsManager to load binary data
  77696. */
  77697. export class BinaryFileAssetTask extends AbstractAssetTask {
  77698. /**
  77699. * Defines the name of the task
  77700. */
  77701. name: string;
  77702. /**
  77703. * Defines the location of the file to load
  77704. */
  77705. url: string;
  77706. /**
  77707. * Gets the lodaded data (as an array buffer)
  77708. */
  77709. data: ArrayBuffer;
  77710. /**
  77711. * Callback called when the task is successful
  77712. */
  77713. onSuccess: (task: BinaryFileAssetTask) => void;
  77714. /**
  77715. * Callback called when the task is successful
  77716. */
  77717. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77718. /**
  77719. * Creates a new BinaryFileAssetTask object
  77720. * @param name defines the name of the new task
  77721. * @param url defines the location of the file to load
  77722. */
  77723. constructor(
  77724. /**
  77725. * Defines the name of the task
  77726. */
  77727. name: string,
  77728. /**
  77729. * Defines the location of the file to load
  77730. */
  77731. url: string);
  77732. /**
  77733. * Execute the current task
  77734. * @param scene defines the scene where you want your assets to be loaded
  77735. * @param onSuccess is a callback called when the task is successfully executed
  77736. * @param onError is a callback called if an error occurs
  77737. */
  77738. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77739. }
  77740. /**
  77741. * Define a task used by AssetsManager to load images
  77742. */
  77743. export class ImageAssetTask extends AbstractAssetTask {
  77744. /**
  77745. * Defines the name of the task
  77746. */
  77747. name: string;
  77748. /**
  77749. * Defines the location of the image to load
  77750. */
  77751. url: string;
  77752. /**
  77753. * Gets the loaded images
  77754. */
  77755. image: HTMLImageElement;
  77756. /**
  77757. * Callback called when the task is successful
  77758. */
  77759. onSuccess: (task: ImageAssetTask) => void;
  77760. /**
  77761. * Callback called when the task is successful
  77762. */
  77763. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77764. /**
  77765. * Creates a new ImageAssetTask
  77766. * @param name defines the name of the task
  77767. * @param url defines the location of the image to load
  77768. */
  77769. constructor(
  77770. /**
  77771. * Defines the name of the task
  77772. */
  77773. name: string,
  77774. /**
  77775. * Defines the location of the image to load
  77776. */
  77777. url: string);
  77778. /**
  77779. * Execute the current task
  77780. * @param scene defines the scene where you want your assets to be loaded
  77781. * @param onSuccess is a callback called when the task is successfully executed
  77782. * @param onError is a callback called if an error occurs
  77783. */
  77784. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77785. }
  77786. /**
  77787. * Defines the interface used by texture loading tasks
  77788. */
  77789. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77790. /**
  77791. * Gets the loaded texture
  77792. */
  77793. texture: TEX;
  77794. }
  77795. /**
  77796. * Define a task used by AssetsManager to load 2D textures
  77797. */
  77798. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77799. /**
  77800. * Defines the name of the task
  77801. */
  77802. name: string;
  77803. /**
  77804. * Defines the location of the file to load
  77805. */
  77806. url: string;
  77807. /**
  77808. * Defines if mipmap should not be generated (default is false)
  77809. */
  77810. noMipmap?: boolean | undefined;
  77811. /**
  77812. * Defines if texture must be inverted on Y axis (default is true)
  77813. */
  77814. invertY: boolean;
  77815. /**
  77816. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77817. */
  77818. samplingMode: number;
  77819. /**
  77820. * Gets the loaded texture
  77821. */
  77822. texture: Texture;
  77823. /**
  77824. * Callback called when the task is successful
  77825. */
  77826. onSuccess: (task: TextureAssetTask) => void;
  77827. /**
  77828. * Callback called when the task is successful
  77829. */
  77830. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77831. /**
  77832. * Creates a new TextureAssetTask object
  77833. * @param name defines the name of the task
  77834. * @param url defines the location of the file to load
  77835. * @param noMipmap defines if mipmap should not be generated (default is false)
  77836. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77837. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77838. */
  77839. constructor(
  77840. /**
  77841. * Defines the name of the task
  77842. */
  77843. name: string,
  77844. /**
  77845. * Defines the location of the file to load
  77846. */
  77847. url: string,
  77848. /**
  77849. * Defines if mipmap should not be generated (default is false)
  77850. */
  77851. noMipmap?: boolean | undefined,
  77852. /**
  77853. * Defines if texture must be inverted on Y axis (default is true)
  77854. */
  77855. invertY?: boolean,
  77856. /**
  77857. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77858. */
  77859. samplingMode?: number);
  77860. /**
  77861. * Execute the current task
  77862. * @param scene defines the scene where you want your assets to be loaded
  77863. * @param onSuccess is a callback called when the task is successfully executed
  77864. * @param onError is a callback called if an error occurs
  77865. */
  77866. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77867. }
  77868. /**
  77869. * Define a task used by AssetsManager to load cube textures
  77870. */
  77871. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77872. /**
  77873. * Defines the name of the task
  77874. */
  77875. name: string;
  77876. /**
  77877. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77878. */
  77879. url: string;
  77880. /**
  77881. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77882. */
  77883. extensions?: string[] | undefined;
  77884. /**
  77885. * Defines if mipmaps should not be generated (default is false)
  77886. */
  77887. noMipmap?: boolean | undefined;
  77888. /**
  77889. * Defines the explicit list of files (undefined by default)
  77890. */
  77891. files?: string[] | undefined;
  77892. /**
  77893. * Gets the loaded texture
  77894. */
  77895. texture: CubeTexture;
  77896. /**
  77897. * Callback called when the task is successful
  77898. */
  77899. onSuccess: (task: CubeTextureAssetTask) => void;
  77900. /**
  77901. * Callback called when the task is successful
  77902. */
  77903. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77904. /**
  77905. * Creates a new CubeTextureAssetTask
  77906. * @param name defines the name of the task
  77907. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77908. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77909. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77910. * @param files defines the explicit list of files (undefined by default)
  77911. */
  77912. constructor(
  77913. /**
  77914. * Defines the name of the task
  77915. */
  77916. name: string,
  77917. /**
  77918. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77919. */
  77920. url: string,
  77921. /**
  77922. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77923. */
  77924. extensions?: string[] | undefined,
  77925. /**
  77926. * Defines if mipmaps should not be generated (default is false)
  77927. */
  77928. noMipmap?: boolean | undefined,
  77929. /**
  77930. * Defines the explicit list of files (undefined by default)
  77931. */
  77932. files?: string[] | undefined);
  77933. /**
  77934. * Execute the current task
  77935. * @param scene defines the scene where you want your assets to be loaded
  77936. * @param onSuccess is a callback called when the task is successfully executed
  77937. * @param onError is a callback called if an error occurs
  77938. */
  77939. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77940. }
  77941. /**
  77942. * Define a task used by AssetsManager to load HDR cube textures
  77943. */
  77944. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77945. /**
  77946. * Defines the name of the task
  77947. */
  77948. name: string;
  77949. /**
  77950. * Defines the location of the file to load
  77951. */
  77952. url: string;
  77953. /**
  77954. * Defines the desired size (the more it increases the longer the generation will be)
  77955. */
  77956. size: number;
  77957. /**
  77958. * Defines if mipmaps should not be generated (default is false)
  77959. */
  77960. noMipmap: boolean;
  77961. /**
  77962. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77963. */
  77964. generateHarmonics: boolean;
  77965. /**
  77966. * 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)
  77967. */
  77968. gammaSpace: boolean;
  77969. /**
  77970. * Internal Use Only
  77971. */
  77972. reserved: boolean;
  77973. /**
  77974. * Gets the loaded texture
  77975. */
  77976. texture: HDRCubeTexture;
  77977. /**
  77978. * Callback called when the task is successful
  77979. */
  77980. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77981. /**
  77982. * Callback called when the task is successful
  77983. */
  77984. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77985. /**
  77986. * Creates a new HDRCubeTextureAssetTask object
  77987. * @param name defines the name of the task
  77988. * @param url defines the location of the file to load
  77989. * @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.
  77990. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77991. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77992. * @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)
  77993. * @param reserved Internal use only
  77994. */
  77995. constructor(
  77996. /**
  77997. * Defines the name of the task
  77998. */
  77999. name: string,
  78000. /**
  78001. * Defines the location of the file to load
  78002. */
  78003. url: string,
  78004. /**
  78005. * Defines the desired size (the more it increases the longer the generation will be)
  78006. */
  78007. size: number,
  78008. /**
  78009. * Defines if mipmaps should not be generated (default is false)
  78010. */
  78011. noMipmap?: boolean,
  78012. /**
  78013. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78014. */
  78015. generateHarmonics?: boolean,
  78016. /**
  78017. * 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)
  78018. */
  78019. gammaSpace?: boolean,
  78020. /**
  78021. * Internal Use Only
  78022. */
  78023. reserved?: boolean);
  78024. /**
  78025. * Execute the current task
  78026. * @param scene defines the scene where you want your assets to be loaded
  78027. * @param onSuccess is a callback called when the task is successfully executed
  78028. * @param onError is a callback called if an error occurs
  78029. */
  78030. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78031. }
  78032. /**
  78033. * Define a task used by AssetsManager to load Equirectangular cube textures
  78034. */
  78035. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78036. /**
  78037. * Defines the name of the task
  78038. */
  78039. name: string;
  78040. /**
  78041. * Defines the location of the file to load
  78042. */
  78043. url: string;
  78044. /**
  78045. * Defines the desired size (the more it increases the longer the generation will be)
  78046. */
  78047. size: number;
  78048. /**
  78049. * Defines if mipmaps should not be generated (default is false)
  78050. */
  78051. noMipmap: boolean;
  78052. /**
  78053. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78054. * but the standard material would require them in Gamma space) (default is true)
  78055. */
  78056. gammaSpace: boolean;
  78057. /**
  78058. * Gets the loaded texture
  78059. */
  78060. texture: EquiRectangularCubeTexture;
  78061. /**
  78062. * Callback called when the task is successful
  78063. */
  78064. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78065. /**
  78066. * Callback called when the task is successful
  78067. */
  78068. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78069. /**
  78070. * Creates a new EquiRectangularCubeTextureAssetTask object
  78071. * @param name defines the name of the task
  78072. * @param url defines the location of the file to load
  78073. * @param size defines the desired size (the more it increases the longer the generation will be)
  78074. * If the size is omitted this implies you are using a preprocessed cubemap.
  78075. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78076. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78077. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78078. * (default is true)
  78079. */
  78080. constructor(
  78081. /**
  78082. * Defines the name of the task
  78083. */
  78084. name: string,
  78085. /**
  78086. * Defines the location of the file to load
  78087. */
  78088. url: string,
  78089. /**
  78090. * Defines the desired size (the more it increases the longer the generation will be)
  78091. */
  78092. size: number,
  78093. /**
  78094. * Defines if mipmaps should not be generated (default is false)
  78095. */
  78096. noMipmap?: boolean,
  78097. /**
  78098. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78099. * but the standard material would require them in Gamma space) (default is true)
  78100. */
  78101. gammaSpace?: boolean);
  78102. /**
  78103. * Execute the current task
  78104. * @param scene defines the scene where you want your assets to be loaded
  78105. * @param onSuccess is a callback called when the task is successfully executed
  78106. * @param onError is a callback called if an error occurs
  78107. */
  78108. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78109. }
  78110. /**
  78111. * This class can be used to easily import assets into a scene
  78112. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78113. */
  78114. export class AssetsManager {
  78115. private _scene;
  78116. private _isLoading;
  78117. protected _tasks: AbstractAssetTask[];
  78118. protected _waitingTasksCount: number;
  78119. protected _totalTasksCount: number;
  78120. /**
  78121. * Callback called when all tasks are processed
  78122. */
  78123. onFinish: (tasks: AbstractAssetTask[]) => void;
  78124. /**
  78125. * Callback called when a task is successful
  78126. */
  78127. onTaskSuccess: (task: AbstractAssetTask) => void;
  78128. /**
  78129. * Callback called when a task had an error
  78130. */
  78131. onTaskError: (task: AbstractAssetTask) => void;
  78132. /**
  78133. * Callback called when a task is done (whatever the result is)
  78134. */
  78135. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78136. /**
  78137. * Observable called when all tasks are processed
  78138. */
  78139. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78140. /**
  78141. * Observable called when a task had an error
  78142. */
  78143. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78144. /**
  78145. * Observable called when all tasks were executed
  78146. */
  78147. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78148. /**
  78149. * Observable called when a task is done (whatever the result is)
  78150. */
  78151. onProgressObservable: Observable<IAssetsProgressEvent>;
  78152. /**
  78153. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78154. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78155. */
  78156. useDefaultLoadingScreen: boolean;
  78157. /**
  78158. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78159. * when all assets have been downloaded.
  78160. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78161. */
  78162. autoHideLoadingUI: boolean;
  78163. /**
  78164. * Creates a new AssetsManager
  78165. * @param scene defines the scene to work on
  78166. */
  78167. constructor(scene: Scene);
  78168. /**
  78169. * Add a ContainerAssetTask to the list of active tasks
  78170. * @param taskName defines the name of the new task
  78171. * @param meshesNames defines the name of meshes to load
  78172. * @param rootUrl defines the root url to use to locate files
  78173. * @param sceneFilename defines the filename of the scene file
  78174. * @returns a new ContainerAssetTask object
  78175. */
  78176. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78177. /**
  78178. * Add a MeshAssetTask to the list of active tasks
  78179. * @param taskName defines the name of the new task
  78180. * @param meshesNames defines the name of meshes to load
  78181. * @param rootUrl defines the root url to use to locate files
  78182. * @param sceneFilename defines the filename of the scene file
  78183. * @returns a new MeshAssetTask object
  78184. */
  78185. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78186. /**
  78187. * Add a TextFileAssetTask to the list of active tasks
  78188. * @param taskName defines the name of the new task
  78189. * @param url defines the url of the file to load
  78190. * @returns a new TextFileAssetTask object
  78191. */
  78192. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78193. /**
  78194. * Add a BinaryFileAssetTask to the list of active tasks
  78195. * @param taskName defines the name of the new task
  78196. * @param url defines the url of the file to load
  78197. * @returns a new BinaryFileAssetTask object
  78198. */
  78199. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78200. /**
  78201. * Add a ImageAssetTask to the list of active tasks
  78202. * @param taskName defines the name of the new task
  78203. * @param url defines the url of the file to load
  78204. * @returns a new ImageAssetTask object
  78205. */
  78206. addImageTask(taskName: string, url: string): ImageAssetTask;
  78207. /**
  78208. * Add a TextureAssetTask to the list of active tasks
  78209. * @param taskName defines the name of the new task
  78210. * @param url defines the url of the file to load
  78211. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78212. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78213. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78214. * @returns a new TextureAssetTask object
  78215. */
  78216. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78217. /**
  78218. * Add a CubeTextureAssetTask to the list of active tasks
  78219. * @param taskName defines the name of the new task
  78220. * @param url defines the url of the file to load
  78221. * @param extensions defines the extension to use to load the cube map (can be null)
  78222. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78223. * @param files defines the list of files to load (can be null)
  78224. * @returns a new CubeTextureAssetTask object
  78225. */
  78226. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78227. /**
  78228. *
  78229. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78230. * @param taskName defines the name of the new task
  78231. * @param url defines the url of the file to load
  78232. * @param size defines the size you want for the cubemap (can be null)
  78233. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78234. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78235. * @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)
  78236. * @param reserved Internal use only
  78237. * @returns a new HDRCubeTextureAssetTask object
  78238. */
  78239. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78240. /**
  78241. *
  78242. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78243. * @param taskName defines the name of the new task
  78244. * @param url defines the url of the file to load
  78245. * @param size defines the size you want for the cubemap (can be null)
  78246. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78247. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78248. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78249. * @returns a new EquiRectangularCubeTextureAssetTask object
  78250. */
  78251. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78252. /**
  78253. * Remove a task from the assets manager.
  78254. * @param task the task to remove
  78255. */
  78256. removeTask(task: AbstractAssetTask): void;
  78257. private _decreaseWaitingTasksCount;
  78258. private _runTask;
  78259. /**
  78260. * Reset the AssetsManager and remove all tasks
  78261. * @return the current instance of the AssetsManager
  78262. */
  78263. reset(): AssetsManager;
  78264. /**
  78265. * Start the loading process
  78266. * @return the current instance of the AssetsManager
  78267. */
  78268. load(): AssetsManager;
  78269. /**
  78270. * Start the loading process as an async operation
  78271. * @return a promise returning the list of failed tasks
  78272. */
  78273. loadAsync(): Promise<void>;
  78274. }
  78275. }
  78276. declare module "babylonjs/Misc/deferred" {
  78277. /**
  78278. * Wrapper class for promise with external resolve and reject.
  78279. */
  78280. export class Deferred<T> {
  78281. /**
  78282. * The promise associated with this deferred object.
  78283. */
  78284. readonly promise: Promise<T>;
  78285. private _resolve;
  78286. private _reject;
  78287. /**
  78288. * The resolve method of the promise associated with this deferred object.
  78289. */
  78290. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78291. /**
  78292. * The reject method of the promise associated with this deferred object.
  78293. */
  78294. get reject(): (reason?: any) => void;
  78295. /**
  78296. * Constructor for this deferred object.
  78297. */
  78298. constructor();
  78299. }
  78300. }
  78301. declare module "babylonjs/Misc/meshExploder" {
  78302. import { Mesh } from "babylonjs/Meshes/mesh";
  78303. /**
  78304. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78305. */
  78306. export class MeshExploder {
  78307. private _centerMesh;
  78308. private _meshes;
  78309. private _meshesOrigins;
  78310. private _toCenterVectors;
  78311. private _scaledDirection;
  78312. private _newPosition;
  78313. private _centerPosition;
  78314. /**
  78315. * Explodes meshes from a center mesh.
  78316. * @param meshes The meshes to explode.
  78317. * @param centerMesh The mesh to be center of explosion.
  78318. */
  78319. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78320. private _setCenterMesh;
  78321. /**
  78322. * Get class name
  78323. * @returns "MeshExploder"
  78324. */
  78325. getClassName(): string;
  78326. /**
  78327. * "Exploded meshes"
  78328. * @returns Array of meshes with the centerMesh at index 0.
  78329. */
  78330. getMeshes(): Array<Mesh>;
  78331. /**
  78332. * Explodes meshes giving a specific direction
  78333. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78334. */
  78335. explode(direction?: number): void;
  78336. }
  78337. }
  78338. declare module "babylonjs/Misc/filesInput" {
  78339. import { Engine } from "babylonjs/Engines/engine";
  78340. import { Scene } from "babylonjs/scene";
  78341. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78342. import { Nullable } from "babylonjs/types";
  78343. /**
  78344. * Class used to help managing file picking and drag'n'drop
  78345. */
  78346. export class FilesInput {
  78347. /**
  78348. * List of files ready to be loaded
  78349. */
  78350. static get FilesToLoad(): {
  78351. [key: string]: File;
  78352. };
  78353. /**
  78354. * Callback called when a file is processed
  78355. */
  78356. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78357. private _engine;
  78358. private _currentScene;
  78359. private _sceneLoadedCallback;
  78360. private _progressCallback;
  78361. private _additionalRenderLoopLogicCallback;
  78362. private _textureLoadingCallback;
  78363. private _startingProcessingFilesCallback;
  78364. private _onReloadCallback;
  78365. private _errorCallback;
  78366. private _elementToMonitor;
  78367. private _sceneFileToLoad;
  78368. private _filesToLoad;
  78369. /**
  78370. * Creates a new FilesInput
  78371. * @param engine defines the rendering engine
  78372. * @param scene defines the hosting scene
  78373. * @param sceneLoadedCallback callback called when scene is loaded
  78374. * @param progressCallback callback called to track progress
  78375. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78376. * @param textureLoadingCallback callback called when a texture is loading
  78377. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78378. * @param onReloadCallback callback called when a reload is requested
  78379. * @param errorCallback callback call if an error occurs
  78380. */
  78381. 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>);
  78382. private _dragEnterHandler;
  78383. private _dragOverHandler;
  78384. private _dropHandler;
  78385. /**
  78386. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78387. * @param elementToMonitor defines the DOM element to track
  78388. */
  78389. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78390. /** Gets the current list of files to load */
  78391. get filesToLoad(): File[];
  78392. /**
  78393. * Release all associated resources
  78394. */
  78395. dispose(): void;
  78396. private renderFunction;
  78397. private drag;
  78398. private drop;
  78399. private _traverseFolder;
  78400. private _processFiles;
  78401. /**
  78402. * Load files from a drop event
  78403. * @param event defines the drop event to use as source
  78404. */
  78405. loadFiles(event: any): void;
  78406. private _processReload;
  78407. /**
  78408. * Reload the current scene from the loaded files
  78409. */
  78410. reload(): void;
  78411. }
  78412. }
  78413. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78414. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78415. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78416. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78417. }
  78418. declare module "babylonjs/Misc/sceneOptimizer" {
  78419. import { Scene, IDisposable } from "babylonjs/scene";
  78420. import { Observable } from "babylonjs/Misc/observable";
  78421. /**
  78422. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78423. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78424. */
  78425. export class SceneOptimization {
  78426. /**
  78427. * Defines the priority of this optimization (0 by default which means first in the list)
  78428. */
  78429. priority: number;
  78430. /**
  78431. * Gets a string describing the action executed by the current optimization
  78432. * @returns description string
  78433. */
  78434. getDescription(): string;
  78435. /**
  78436. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78437. * @param scene defines the current scene where to apply this optimization
  78438. * @param optimizer defines the current optimizer
  78439. * @returns true if everything that can be done was applied
  78440. */
  78441. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78442. /**
  78443. * Creates the SceneOptimization object
  78444. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78445. * @param desc defines the description associated with the optimization
  78446. */
  78447. constructor(
  78448. /**
  78449. * Defines the priority of this optimization (0 by default which means first in the list)
  78450. */
  78451. priority?: number);
  78452. }
  78453. /**
  78454. * Defines an optimization used to reduce the size of render target textures
  78455. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78456. */
  78457. export class TextureOptimization extends SceneOptimization {
  78458. /**
  78459. * Defines the priority of this optimization (0 by default which means first in the list)
  78460. */
  78461. priority: number;
  78462. /**
  78463. * 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
  78464. */
  78465. maximumSize: number;
  78466. /**
  78467. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78468. */
  78469. step: number;
  78470. /**
  78471. * Gets a string describing the action executed by the current optimization
  78472. * @returns description string
  78473. */
  78474. getDescription(): string;
  78475. /**
  78476. * Creates the TextureOptimization object
  78477. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78478. * @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
  78479. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78480. */
  78481. constructor(
  78482. /**
  78483. * Defines the priority of this optimization (0 by default which means first in the list)
  78484. */
  78485. priority?: number,
  78486. /**
  78487. * 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
  78488. */
  78489. maximumSize?: number,
  78490. /**
  78491. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78492. */
  78493. step?: number);
  78494. /**
  78495. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78496. * @param scene defines the current scene where to apply this optimization
  78497. * @param optimizer defines the current optimizer
  78498. * @returns true if everything that can be done was applied
  78499. */
  78500. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78501. }
  78502. /**
  78503. * Defines an optimization used to increase or decrease the rendering resolution
  78504. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78505. */
  78506. export class HardwareScalingOptimization extends SceneOptimization {
  78507. /**
  78508. * Defines the priority of this optimization (0 by default which means first in the list)
  78509. */
  78510. priority: number;
  78511. /**
  78512. * Defines the maximum scale to use (2 by default)
  78513. */
  78514. maximumScale: number;
  78515. /**
  78516. * Defines the step to use between two passes (0.5 by default)
  78517. */
  78518. step: number;
  78519. private _currentScale;
  78520. private _directionOffset;
  78521. /**
  78522. * Gets a string describing the action executed by the current optimization
  78523. * @return description string
  78524. */
  78525. getDescription(): string;
  78526. /**
  78527. * Creates the HardwareScalingOptimization object
  78528. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78529. * @param maximumScale defines the maximum scale to use (2 by default)
  78530. * @param step defines the step to use between two passes (0.5 by default)
  78531. */
  78532. constructor(
  78533. /**
  78534. * Defines the priority of this optimization (0 by default which means first in the list)
  78535. */
  78536. priority?: number,
  78537. /**
  78538. * Defines the maximum scale to use (2 by default)
  78539. */
  78540. maximumScale?: number,
  78541. /**
  78542. * Defines the step to use between two passes (0.5 by default)
  78543. */
  78544. step?: number);
  78545. /**
  78546. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78547. * @param scene defines the current scene where to apply this optimization
  78548. * @param optimizer defines the current optimizer
  78549. * @returns true if everything that can be done was applied
  78550. */
  78551. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78552. }
  78553. /**
  78554. * Defines an optimization used to remove shadows
  78555. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78556. */
  78557. export class ShadowsOptimization extends SceneOptimization {
  78558. /**
  78559. * Gets a string describing the action executed by the current optimization
  78560. * @return description string
  78561. */
  78562. getDescription(): string;
  78563. /**
  78564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78565. * @param scene defines the current scene where to apply this optimization
  78566. * @param optimizer defines the current optimizer
  78567. * @returns true if everything that can be done was applied
  78568. */
  78569. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78570. }
  78571. /**
  78572. * Defines an optimization used to turn post-processes off
  78573. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78574. */
  78575. export class PostProcessesOptimization extends SceneOptimization {
  78576. /**
  78577. * Gets a string describing the action executed by the current optimization
  78578. * @return description string
  78579. */
  78580. getDescription(): string;
  78581. /**
  78582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78583. * @param scene defines the current scene where to apply this optimization
  78584. * @param optimizer defines the current optimizer
  78585. * @returns true if everything that can be done was applied
  78586. */
  78587. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78588. }
  78589. /**
  78590. * Defines an optimization used to turn lens flares off
  78591. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78592. */
  78593. export class LensFlaresOptimization extends SceneOptimization {
  78594. /**
  78595. * Gets a string describing the action executed by the current optimization
  78596. * @return description string
  78597. */
  78598. getDescription(): string;
  78599. /**
  78600. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78601. * @param scene defines the current scene where to apply this optimization
  78602. * @param optimizer defines the current optimizer
  78603. * @returns true if everything that can be done was applied
  78604. */
  78605. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78606. }
  78607. /**
  78608. * Defines an optimization based on user defined callback.
  78609. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78610. */
  78611. export class CustomOptimization extends SceneOptimization {
  78612. /**
  78613. * Callback called to apply the custom optimization.
  78614. */
  78615. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78616. /**
  78617. * Callback called to get custom description
  78618. */
  78619. onGetDescription: () => string;
  78620. /**
  78621. * Gets a string describing the action executed by the current optimization
  78622. * @returns description string
  78623. */
  78624. getDescription(): string;
  78625. /**
  78626. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78627. * @param scene defines the current scene where to apply this optimization
  78628. * @param optimizer defines the current optimizer
  78629. * @returns true if everything that can be done was applied
  78630. */
  78631. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78632. }
  78633. /**
  78634. * Defines an optimization used to turn particles off
  78635. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78636. */
  78637. export class ParticlesOptimization extends SceneOptimization {
  78638. /**
  78639. * Gets a string describing the action executed by the current optimization
  78640. * @return description string
  78641. */
  78642. getDescription(): string;
  78643. /**
  78644. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78645. * @param scene defines the current scene where to apply this optimization
  78646. * @param optimizer defines the current optimizer
  78647. * @returns true if everything that can be done was applied
  78648. */
  78649. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78650. }
  78651. /**
  78652. * Defines an optimization used to turn render targets off
  78653. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78654. */
  78655. export class RenderTargetsOptimization extends SceneOptimization {
  78656. /**
  78657. * Gets a string describing the action executed by the current optimization
  78658. * @return description string
  78659. */
  78660. getDescription(): string;
  78661. /**
  78662. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78663. * @param scene defines the current scene where to apply this optimization
  78664. * @param optimizer defines the current optimizer
  78665. * @returns true if everything that can be done was applied
  78666. */
  78667. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78668. }
  78669. /**
  78670. * Defines an optimization used to merge meshes with compatible materials
  78671. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78672. */
  78673. export class MergeMeshesOptimization extends SceneOptimization {
  78674. private static _UpdateSelectionTree;
  78675. /**
  78676. * Gets or sets a boolean which defines if optimization octree has to be updated
  78677. */
  78678. static get UpdateSelectionTree(): boolean;
  78679. /**
  78680. * Gets or sets a boolean which defines if optimization octree has to be updated
  78681. */
  78682. static set UpdateSelectionTree(value: boolean);
  78683. /**
  78684. * Gets a string describing the action executed by the current optimization
  78685. * @return description string
  78686. */
  78687. getDescription(): string;
  78688. private _canBeMerged;
  78689. /**
  78690. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78691. * @param scene defines the current scene where to apply this optimization
  78692. * @param optimizer defines the current optimizer
  78693. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78694. * @returns true if everything that can be done was applied
  78695. */
  78696. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78697. }
  78698. /**
  78699. * Defines a list of options used by SceneOptimizer
  78700. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78701. */
  78702. export class SceneOptimizerOptions {
  78703. /**
  78704. * Defines the target frame rate to reach (60 by default)
  78705. */
  78706. targetFrameRate: number;
  78707. /**
  78708. * Defines the interval between two checkes (2000ms by default)
  78709. */
  78710. trackerDuration: number;
  78711. /**
  78712. * Gets the list of optimizations to apply
  78713. */
  78714. optimizations: SceneOptimization[];
  78715. /**
  78716. * Creates a new list of options used by SceneOptimizer
  78717. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78718. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78719. */
  78720. constructor(
  78721. /**
  78722. * Defines the target frame rate to reach (60 by default)
  78723. */
  78724. targetFrameRate?: number,
  78725. /**
  78726. * Defines the interval between two checkes (2000ms by default)
  78727. */
  78728. trackerDuration?: number);
  78729. /**
  78730. * Add a new optimization
  78731. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78732. * @returns the current SceneOptimizerOptions
  78733. */
  78734. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78735. /**
  78736. * Add a new custom optimization
  78737. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78738. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78739. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78740. * @returns the current SceneOptimizerOptions
  78741. */
  78742. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78743. /**
  78744. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78745. * @param targetFrameRate defines the target frame rate (60 by default)
  78746. * @returns a SceneOptimizerOptions object
  78747. */
  78748. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78749. /**
  78750. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78751. * @param targetFrameRate defines the target frame rate (60 by default)
  78752. * @returns a SceneOptimizerOptions object
  78753. */
  78754. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78755. /**
  78756. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78757. * @param targetFrameRate defines the target frame rate (60 by default)
  78758. * @returns a SceneOptimizerOptions object
  78759. */
  78760. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78761. }
  78762. /**
  78763. * Class used to run optimizations in order to reach a target frame rate
  78764. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78765. */
  78766. export class SceneOptimizer implements IDisposable {
  78767. private _isRunning;
  78768. private _options;
  78769. private _scene;
  78770. private _currentPriorityLevel;
  78771. private _targetFrameRate;
  78772. private _trackerDuration;
  78773. private _currentFrameRate;
  78774. private _sceneDisposeObserver;
  78775. private _improvementMode;
  78776. /**
  78777. * Defines an observable called when the optimizer reaches the target frame rate
  78778. */
  78779. onSuccessObservable: Observable<SceneOptimizer>;
  78780. /**
  78781. * Defines an observable called when the optimizer enables an optimization
  78782. */
  78783. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78784. /**
  78785. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78786. */
  78787. onFailureObservable: Observable<SceneOptimizer>;
  78788. /**
  78789. * Gets a boolean indicating if the optimizer is in improvement mode
  78790. */
  78791. get isInImprovementMode(): boolean;
  78792. /**
  78793. * Gets the current priority level (0 at start)
  78794. */
  78795. get currentPriorityLevel(): number;
  78796. /**
  78797. * Gets the current frame rate checked by the SceneOptimizer
  78798. */
  78799. get currentFrameRate(): number;
  78800. /**
  78801. * Gets or sets the current target frame rate (60 by default)
  78802. */
  78803. get targetFrameRate(): number;
  78804. /**
  78805. * Gets or sets the current target frame rate (60 by default)
  78806. */
  78807. set targetFrameRate(value: number);
  78808. /**
  78809. * Gets or sets the current interval between two checks (every 2000ms by default)
  78810. */
  78811. get trackerDuration(): number;
  78812. /**
  78813. * Gets or sets the current interval between two checks (every 2000ms by default)
  78814. */
  78815. set trackerDuration(value: number);
  78816. /**
  78817. * Gets the list of active optimizations
  78818. */
  78819. get optimizations(): SceneOptimization[];
  78820. /**
  78821. * Creates a new SceneOptimizer
  78822. * @param scene defines the scene to work on
  78823. * @param options defines the options to use with the SceneOptimizer
  78824. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78825. * @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)
  78826. */
  78827. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78828. /**
  78829. * Stops the current optimizer
  78830. */
  78831. stop(): void;
  78832. /**
  78833. * Reset the optimizer to initial step (current priority level = 0)
  78834. */
  78835. reset(): void;
  78836. /**
  78837. * Start the optimizer. By default it will try to reach a specific framerate
  78838. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78839. */
  78840. start(): void;
  78841. private _checkCurrentState;
  78842. /**
  78843. * Release all resources
  78844. */
  78845. dispose(): void;
  78846. /**
  78847. * Helper function to create a SceneOptimizer with one single line of code
  78848. * @param scene defines the scene to work on
  78849. * @param options defines the options to use with the SceneOptimizer
  78850. * @param onSuccess defines a callback to call on success
  78851. * @param onFailure defines a callback to call on failure
  78852. * @returns the new SceneOptimizer object
  78853. */
  78854. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78855. }
  78856. }
  78857. declare module "babylonjs/Misc/sceneSerializer" {
  78858. import { Scene } from "babylonjs/scene";
  78859. /**
  78860. * Class used to serialize a scene into a string
  78861. */
  78862. export class SceneSerializer {
  78863. /**
  78864. * Clear cache used by a previous serialization
  78865. */
  78866. static ClearCache(): void;
  78867. /**
  78868. * Serialize a scene into a JSON compatible object
  78869. * @param scene defines the scene to serialize
  78870. * @returns a JSON compatible object
  78871. */
  78872. static Serialize(scene: Scene): any;
  78873. /**
  78874. * Serialize a mesh into a JSON compatible object
  78875. * @param toSerialize defines the mesh to serialize
  78876. * @param withParents defines if parents must be serialized as well
  78877. * @param withChildren defines if children must be serialized as well
  78878. * @returns a JSON compatible object
  78879. */
  78880. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78881. }
  78882. }
  78883. declare module "babylonjs/Misc/textureTools" {
  78884. import { Texture } from "babylonjs/Materials/Textures/texture";
  78885. /**
  78886. * Class used to host texture specific utilities
  78887. */
  78888. export class TextureTools {
  78889. /**
  78890. * Uses the GPU to create a copy texture rescaled at a given size
  78891. * @param texture Texture to copy from
  78892. * @param width defines the desired width
  78893. * @param height defines the desired height
  78894. * @param useBilinearMode defines if bilinear mode has to be used
  78895. * @return the generated texture
  78896. */
  78897. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78898. }
  78899. }
  78900. declare module "babylonjs/Misc/videoRecorder" {
  78901. import { Nullable } from "babylonjs/types";
  78902. import { Engine } from "babylonjs/Engines/engine";
  78903. /**
  78904. * This represents the different options available for the video capture.
  78905. */
  78906. export interface VideoRecorderOptions {
  78907. /** Defines the mime type of the video. */
  78908. mimeType: string;
  78909. /** Defines the FPS the video should be recorded at. */
  78910. fps: number;
  78911. /** Defines the chunk size for the recording data. */
  78912. recordChunckSize: number;
  78913. /** The audio tracks to attach to the recording. */
  78914. audioTracks?: MediaStreamTrack[];
  78915. }
  78916. /**
  78917. * This can help with recording videos from BabylonJS.
  78918. * This is based on the available WebRTC functionalities of the browser.
  78919. *
  78920. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78921. */
  78922. export class VideoRecorder {
  78923. private static readonly _defaultOptions;
  78924. /**
  78925. * Returns whether or not the VideoRecorder is available in your browser.
  78926. * @param engine Defines the Babylon Engine.
  78927. * @returns true if supported otherwise false.
  78928. */
  78929. static IsSupported(engine: Engine): boolean;
  78930. private readonly _options;
  78931. private _canvas;
  78932. private _mediaRecorder;
  78933. private _recordedChunks;
  78934. private _fileName;
  78935. private _resolve;
  78936. private _reject;
  78937. /**
  78938. * True when a recording is already in progress.
  78939. */
  78940. get isRecording(): boolean;
  78941. /**
  78942. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78943. * @param engine Defines the BabylonJS Engine you wish to record.
  78944. * @param options Defines options that can be used to customize the capture.
  78945. */
  78946. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78947. /**
  78948. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78949. */
  78950. stopRecording(): void;
  78951. /**
  78952. * Starts recording the canvas for a max duration specified in parameters.
  78953. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78954. * If null no automatic download will start and you can rely on the promise to get the data back.
  78955. * @param maxDuration Defines the maximum recording time in seconds.
  78956. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78957. * @return A promise callback at the end of the recording with the video data in Blob.
  78958. */
  78959. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78960. /**
  78961. * Releases internal resources used during the recording.
  78962. */
  78963. dispose(): void;
  78964. private _handleDataAvailable;
  78965. private _handleError;
  78966. private _handleStop;
  78967. }
  78968. }
  78969. declare module "babylonjs/Misc/screenshotTools" {
  78970. import { Camera } from "babylonjs/Cameras/camera";
  78971. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78972. import { Engine } from "babylonjs/Engines/engine";
  78973. /**
  78974. * Class containing a set of static utilities functions for screenshots
  78975. */
  78976. export class ScreenshotTools {
  78977. /**
  78978. * Captures a screenshot of the current rendering
  78979. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78980. * @param engine defines the rendering engine
  78981. * @param camera defines the source camera
  78982. * @param size This parameter can be set to a single number or to an object with the
  78983. * following (optional) properties: precision, width, height. If a single number is passed,
  78984. * it will be used for both width and height. If an object is passed, the screenshot size
  78985. * will be derived from the parameters. The precision property is a multiplier allowing
  78986. * rendering at a higher or lower resolution
  78987. * @param successCallback defines the callback receives a single parameter which contains the
  78988. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78989. * src parameter of an <img> to display it
  78990. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78991. * Check your browser for supported MIME types
  78992. */
  78993. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78994. /**
  78995. * Captures a screenshot of the current rendering
  78996. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78997. * @param engine defines the rendering engine
  78998. * @param camera defines the source camera
  78999. * @param size This parameter can be set to a single number or to an object with the
  79000. * following (optional) properties: precision, width, height. If a single number is passed,
  79001. * it will be used for both width and height. If an object is passed, the screenshot size
  79002. * will be derived from the parameters. The precision property is a multiplier allowing
  79003. * rendering at a higher or lower resolution
  79004. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79005. * Check your browser for supported MIME types
  79006. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79007. * to the src parameter of an <img> to display it
  79008. */
  79009. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79010. /**
  79011. * Generates an image screenshot from the specified camera.
  79012. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79013. * @param engine The engine to use for rendering
  79014. * @param camera The camera to use for rendering
  79015. * @param size This parameter can be set to a single number or to an object with the
  79016. * following (optional) properties: precision, width, height. If a single number is passed,
  79017. * it will be used for both width and height. If an object is passed, the screenshot size
  79018. * will be derived from the parameters. The precision property is a multiplier allowing
  79019. * rendering at a higher or lower resolution
  79020. * @param successCallback The callback receives a single parameter which contains the
  79021. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79022. * src parameter of an <img> to display it
  79023. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79024. * Check your browser for supported MIME types
  79025. * @param samples Texture samples (default: 1)
  79026. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79027. * @param fileName A name for for the downloaded file.
  79028. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79029. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79030. */
  79031. 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;
  79032. /**
  79033. * Generates an image screenshot from the specified camera.
  79034. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79035. * @param engine The engine to use for rendering
  79036. * @param camera The camera to use for rendering
  79037. * @param size This parameter can be set to a single number or to an object with the
  79038. * following (optional) properties: precision, width, height. If a single number is passed,
  79039. * it will be used for both width and height. If an object is passed, the screenshot size
  79040. * will be derived from the parameters. The precision property is a multiplier allowing
  79041. * rendering at a higher or lower resolution
  79042. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79043. * Check your browser for supported MIME types
  79044. * @param samples Texture samples (default: 1)
  79045. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79046. * @param fileName A name for for the downloaded file.
  79047. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79048. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79049. * to the src parameter of an <img> to display it
  79050. */
  79051. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79052. /**
  79053. * Gets height and width for screenshot size
  79054. * @private
  79055. */
  79056. private static _getScreenshotSize;
  79057. }
  79058. }
  79059. declare module "babylonjs/Misc/dataReader" {
  79060. /**
  79061. * Interface for a data buffer
  79062. */
  79063. export interface IDataBuffer {
  79064. /**
  79065. * Reads bytes from the data buffer.
  79066. * @param byteOffset The byte offset to read
  79067. * @param byteLength The byte length to read
  79068. * @returns A promise that resolves when the bytes are read
  79069. */
  79070. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79071. /**
  79072. * The byte length of the buffer.
  79073. */
  79074. readonly byteLength: number;
  79075. }
  79076. /**
  79077. * Utility class for reading from a data buffer
  79078. */
  79079. export class DataReader {
  79080. /**
  79081. * The data buffer associated with this data reader.
  79082. */
  79083. readonly buffer: IDataBuffer;
  79084. /**
  79085. * The current byte offset from the beginning of the data buffer.
  79086. */
  79087. byteOffset: number;
  79088. private _dataView;
  79089. private _dataByteOffset;
  79090. /**
  79091. * Constructor
  79092. * @param buffer The buffer to read
  79093. */
  79094. constructor(buffer: IDataBuffer);
  79095. /**
  79096. * Loads the given byte length.
  79097. * @param byteLength The byte length to load
  79098. * @returns A promise that resolves when the load is complete
  79099. */
  79100. loadAsync(byteLength: number): Promise<void>;
  79101. /**
  79102. * Read a unsigned 32-bit integer from the currently loaded data range.
  79103. * @returns The 32-bit integer read
  79104. */
  79105. readUint32(): number;
  79106. /**
  79107. * Read a byte array from the currently loaded data range.
  79108. * @param byteLength The byte length to read
  79109. * @returns The byte array read
  79110. */
  79111. readUint8Array(byteLength: number): Uint8Array;
  79112. /**
  79113. * Read a string from the currently loaded data range.
  79114. * @param byteLength The byte length to read
  79115. * @returns The string read
  79116. */
  79117. readString(byteLength: number): string;
  79118. /**
  79119. * Skips the given byte length the currently loaded data range.
  79120. * @param byteLength The byte length to skip
  79121. */
  79122. skipBytes(byteLength: number): void;
  79123. }
  79124. }
  79125. declare module "babylonjs/Misc/dataStorage" {
  79126. /**
  79127. * Class for storing data to local storage if available or in-memory storage otherwise
  79128. */
  79129. export class DataStorage {
  79130. private static _Storage;
  79131. private static _GetStorage;
  79132. /**
  79133. * Reads a string from the data storage
  79134. * @param key The key to read
  79135. * @param defaultValue The value if the key doesn't exist
  79136. * @returns The string value
  79137. */
  79138. static ReadString(key: string, defaultValue: string): string;
  79139. /**
  79140. * Writes a string to the data storage
  79141. * @param key The key to write
  79142. * @param value The value to write
  79143. */
  79144. static WriteString(key: string, value: string): void;
  79145. /**
  79146. * Reads a boolean from the data storage
  79147. * @param key The key to read
  79148. * @param defaultValue The value if the key doesn't exist
  79149. * @returns The boolean value
  79150. */
  79151. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79152. /**
  79153. * Writes a boolean to the data storage
  79154. * @param key The key to write
  79155. * @param value The value to write
  79156. */
  79157. static WriteBoolean(key: string, value: boolean): void;
  79158. /**
  79159. * Reads a number from the data storage
  79160. * @param key The key to read
  79161. * @param defaultValue The value if the key doesn't exist
  79162. * @returns The number value
  79163. */
  79164. static ReadNumber(key: string, defaultValue: number): number;
  79165. /**
  79166. * Writes a number to the data storage
  79167. * @param key The key to write
  79168. * @param value The value to write
  79169. */
  79170. static WriteNumber(key: string, value: number): void;
  79171. }
  79172. }
  79173. declare module "babylonjs/Misc/sceneRecorder" {
  79174. import { Scene } from "babylonjs/scene";
  79175. /**
  79176. * Class used to record delta files between 2 scene states
  79177. */
  79178. export class SceneRecorder {
  79179. private _trackedScene;
  79180. private _savedJSON;
  79181. /**
  79182. * Track a given scene. This means the current scene state will be considered the original state
  79183. * @param scene defines the scene to track
  79184. */
  79185. track(scene: Scene): void;
  79186. /**
  79187. * Get the delta between current state and original state
  79188. * @returns a string containing the delta
  79189. */
  79190. getDelta(): any;
  79191. private _compareArray;
  79192. private _compareObjects;
  79193. private _compareCollections;
  79194. private static GetShadowGeneratorById;
  79195. /**
  79196. * Apply a given delta to a given scene
  79197. * @param deltaJSON defines the JSON containing the delta
  79198. * @param scene defines the scene to apply the delta to
  79199. */
  79200. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79201. private static _ApplyPropertiesToEntity;
  79202. private static _ApplyDeltaForEntity;
  79203. }
  79204. }
  79205. declare module "babylonjs/Misc/trajectoryClassifier" {
  79206. import { DeepImmutable, Nullable } from "babylonjs/types";
  79207. import { Vector3 } from "babylonjs/Maths/math.vector";
  79208. /**
  79209. * A 3D trajectory consisting of an order list of vectors describing a
  79210. * path of motion through 3D space.
  79211. */
  79212. export class Trajectory {
  79213. private _points;
  79214. private readonly _segmentLength;
  79215. /**
  79216. * Serialize to JSON.
  79217. * @returns serialized JSON string
  79218. */
  79219. serialize(): string;
  79220. /**
  79221. * Deserialize from JSON.
  79222. * @param json serialized JSON string
  79223. * @returns deserialized Trajectory
  79224. */
  79225. static Deserialize(json: string): Trajectory;
  79226. /**
  79227. * Create a new empty Trajectory.
  79228. * @param segmentLength radius of discretization for Trajectory points
  79229. */
  79230. constructor(segmentLength?: number);
  79231. /**
  79232. * Get the length of the Trajectory.
  79233. * @returns length of the Trajectory
  79234. */
  79235. getLength(): number;
  79236. /**
  79237. * Append a new point to the Trajectory.
  79238. * NOTE: This implementation has many allocations.
  79239. * @param point point to append to the Trajectory
  79240. */
  79241. add(point: DeepImmutable<Vector3>): void;
  79242. /**
  79243. * Create a new Trajectory with a segment length chosen to make it
  79244. * probable that the new Trajectory will have a specified number of
  79245. * segments. This operation is imprecise.
  79246. * @param targetResolution number of segments desired
  79247. * @returns new Trajectory with approximately the requested number of segments
  79248. */
  79249. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79250. /**
  79251. * Convert Trajectory segments into tokenized representation. This
  79252. * representation is an array of numbers where each nth number is the
  79253. * index of the token which is most similar to the nth segment of the
  79254. * Trajectory.
  79255. * @param tokens list of vectors which serve as discrete tokens
  79256. * @returns list of indices of most similar token per segment
  79257. */
  79258. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79259. private static _forwardDir;
  79260. private static _inverseFromVec;
  79261. private static _upDir;
  79262. private static _fromToVec;
  79263. private static _lookMatrix;
  79264. /**
  79265. * Transform the rotation (i.e., direction) of a segment to isolate
  79266. * the relative transformation represented by the segment. This operation
  79267. * may or may not succeed due to singularities in the equations that define
  79268. * motion relativity in this context.
  79269. * @param priorVec the origin of the prior segment
  79270. * @param fromVec the origin of the current segment
  79271. * @param toVec the destination of the current segment
  79272. * @param result reference to output variable
  79273. * @returns whether or not transformation was successful
  79274. */
  79275. private static _transformSegmentDirToRef;
  79276. private static _bestMatch;
  79277. private static _score;
  79278. private static _bestScore;
  79279. /**
  79280. * Determine which token vector is most similar to the
  79281. * segment vector.
  79282. * @param segment segment vector
  79283. * @param tokens token vector list
  79284. * @returns index of the most similar token to the segment
  79285. */
  79286. private static _tokenizeSegment;
  79287. }
  79288. /**
  79289. * Class representing a set of known, named trajectories to which Trajectories can be
  79290. * added and using which Trajectories can be recognized.
  79291. */
  79292. export class TrajectoryClassifier {
  79293. private _maximumAllowableMatchCost;
  79294. private _vector3Alphabet;
  79295. private _levenshteinAlphabet;
  79296. private _nameToDescribedTrajectory;
  79297. /**
  79298. * Serialize to JSON.
  79299. * @returns JSON serialization
  79300. */
  79301. serialize(): string;
  79302. /**
  79303. * Deserialize from JSON.
  79304. * @param json JSON serialization
  79305. * @returns deserialized TrajectorySet
  79306. */
  79307. static Deserialize(json: string): TrajectoryClassifier;
  79308. /**
  79309. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79310. * VERY naive, need to be generating these things from known
  79311. * sets. Better version later, probably eliminating this one.
  79312. * @returns auto-generated TrajectorySet
  79313. */
  79314. static Generate(): TrajectoryClassifier;
  79315. private constructor();
  79316. /**
  79317. * Add a new Trajectory to the set with a given name.
  79318. * @param trajectory new Trajectory to be added
  79319. * @param classification name to which to add the Trajectory
  79320. */
  79321. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79322. /**
  79323. * Remove a known named trajectory and all Trajectories associated with it.
  79324. * @param classification name to remove
  79325. * @returns whether anything was removed
  79326. */
  79327. deleteClassification(classification: string): boolean;
  79328. /**
  79329. * Attempt to recognize a Trajectory from among all the classifications
  79330. * already known to the classifier.
  79331. * @param trajectory Trajectory to be recognized
  79332. * @returns classification of Trajectory if recognized, null otherwise
  79333. */
  79334. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79335. }
  79336. }
  79337. declare module "babylonjs/Misc/index" {
  79338. export * from "babylonjs/Misc/andOrNotEvaluator";
  79339. export * from "babylonjs/Misc/assetsManager";
  79340. export * from "babylonjs/Misc/basis";
  79341. export * from "babylonjs/Misc/dds";
  79342. export * from "babylonjs/Misc/decorators";
  79343. export * from "babylonjs/Misc/deferred";
  79344. export * from "babylonjs/Misc/environmentTextureTools";
  79345. export * from "babylonjs/Misc/meshExploder";
  79346. export * from "babylonjs/Misc/filesInput";
  79347. export * from "babylonjs/Misc/HighDynamicRange/index";
  79348. export * from "babylonjs/Misc/khronosTextureContainer";
  79349. export * from "babylonjs/Misc/observable";
  79350. export * from "babylonjs/Misc/performanceMonitor";
  79351. export * from "babylonjs/Misc/promise";
  79352. export * from "babylonjs/Misc/sceneOptimizer";
  79353. export * from "babylonjs/Misc/sceneSerializer";
  79354. export * from "babylonjs/Misc/smartArray";
  79355. export * from "babylonjs/Misc/stringDictionary";
  79356. export * from "babylonjs/Misc/tags";
  79357. export * from "babylonjs/Misc/textureTools";
  79358. export * from "babylonjs/Misc/tga";
  79359. export * from "babylonjs/Misc/tools";
  79360. export * from "babylonjs/Misc/videoRecorder";
  79361. export * from "babylonjs/Misc/virtualJoystick";
  79362. export * from "babylonjs/Misc/workerPool";
  79363. export * from "babylonjs/Misc/logger";
  79364. export * from "babylonjs/Misc/typeStore";
  79365. export * from "babylonjs/Misc/filesInputStore";
  79366. export * from "babylonjs/Misc/deepCopier";
  79367. export * from "babylonjs/Misc/pivotTools";
  79368. export * from "babylonjs/Misc/precisionDate";
  79369. export * from "babylonjs/Misc/screenshotTools";
  79370. export * from "babylonjs/Misc/typeStore";
  79371. export * from "babylonjs/Misc/webRequest";
  79372. export * from "babylonjs/Misc/iInspectable";
  79373. export * from "babylonjs/Misc/brdfTextureTools";
  79374. export * from "babylonjs/Misc/rgbdTextureTools";
  79375. export * from "babylonjs/Misc/gradients";
  79376. export * from "babylonjs/Misc/perfCounter";
  79377. export * from "babylonjs/Misc/fileRequest";
  79378. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79379. export * from "babylonjs/Misc/retryStrategy";
  79380. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79381. export * from "babylonjs/Misc/canvasGenerator";
  79382. export * from "babylonjs/Misc/fileTools";
  79383. export * from "babylonjs/Misc/stringTools";
  79384. export * from "babylonjs/Misc/dataReader";
  79385. export * from "babylonjs/Misc/minMaxReducer";
  79386. export * from "babylonjs/Misc/depthReducer";
  79387. export * from "babylonjs/Misc/dataStorage";
  79388. export * from "babylonjs/Misc/sceneRecorder";
  79389. export * from "babylonjs/Misc/khronosTextureContainer2";
  79390. export * from "babylonjs/Misc/trajectoryClassifier";
  79391. export * from "babylonjs/Misc/timer";
  79392. }
  79393. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79394. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79395. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79396. import { Observable } from "babylonjs/Misc/observable";
  79397. import { Matrix } from "babylonjs/Maths/math.vector";
  79398. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79399. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79400. /**
  79401. * An interface for all Hit test features
  79402. */
  79403. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79404. /**
  79405. * Triggered when new babylon (transformed) hit test results are available
  79406. */
  79407. onHitTestResultObservable: Observable<T[]>;
  79408. }
  79409. /**
  79410. * Options used for hit testing
  79411. */
  79412. export interface IWebXRLegacyHitTestOptions {
  79413. /**
  79414. * Only test when user interacted with the scene. Default - hit test every frame
  79415. */
  79416. testOnPointerDownOnly?: boolean;
  79417. /**
  79418. * The node to use to transform the local results to world coordinates
  79419. */
  79420. worldParentNode?: TransformNode;
  79421. }
  79422. /**
  79423. * Interface defining the babylon result of raycasting/hit-test
  79424. */
  79425. export interface IWebXRLegacyHitResult {
  79426. /**
  79427. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79428. */
  79429. transformationMatrix: Matrix;
  79430. /**
  79431. * The native hit test result
  79432. */
  79433. xrHitResult: XRHitResult | XRHitTestResult;
  79434. }
  79435. /**
  79436. * The currently-working hit-test module.
  79437. * Hit test (or Ray-casting) is used to interact with the real world.
  79438. * For further information read here - https://github.com/immersive-web/hit-test
  79439. */
  79440. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79441. /**
  79442. * options to use when constructing this feature
  79443. */
  79444. readonly options: IWebXRLegacyHitTestOptions;
  79445. private _direction;
  79446. private _mat;
  79447. private _onSelectEnabled;
  79448. private _origin;
  79449. /**
  79450. * The module's name
  79451. */
  79452. static readonly Name: string;
  79453. /**
  79454. * The (Babylon) version of this module.
  79455. * This is an integer representing the implementation version.
  79456. * This number does not correspond to the WebXR specs version
  79457. */
  79458. static readonly Version: number;
  79459. /**
  79460. * Populated with the last native XR Hit Results
  79461. */
  79462. lastNativeXRHitResults: XRHitResult[];
  79463. /**
  79464. * Triggered when new babylon (transformed) hit test results are available
  79465. */
  79466. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79467. /**
  79468. * Creates a new instance of the (legacy version) hit test feature
  79469. * @param _xrSessionManager an instance of WebXRSessionManager
  79470. * @param options options to use when constructing this feature
  79471. */
  79472. constructor(_xrSessionManager: WebXRSessionManager,
  79473. /**
  79474. * options to use when constructing this feature
  79475. */
  79476. options?: IWebXRLegacyHitTestOptions);
  79477. /**
  79478. * execute a hit test with an XR Ray
  79479. *
  79480. * @param xrSession a native xrSession that will execute this hit test
  79481. * @param xrRay the ray (position and direction) to use for ray-casting
  79482. * @param referenceSpace native XR reference space to use for the hit-test
  79483. * @param filter filter function that will filter the results
  79484. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79485. */
  79486. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79487. /**
  79488. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79489. * @param event the (select) event to use to select with
  79490. * @param referenceSpace the reference space to use for this hit test
  79491. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79492. */
  79493. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79494. /**
  79495. * attach this feature
  79496. * Will usually be called by the features manager
  79497. *
  79498. * @returns true if successful.
  79499. */
  79500. attach(): boolean;
  79501. /**
  79502. * detach this feature.
  79503. * Will usually be called by the features manager
  79504. *
  79505. * @returns true if successful.
  79506. */
  79507. detach(): boolean;
  79508. /**
  79509. * Dispose this feature and all of the resources attached
  79510. */
  79511. dispose(): void;
  79512. protected _onXRFrame(frame: XRFrame): void;
  79513. private _onHitTestResults;
  79514. private _onSelect;
  79515. }
  79516. }
  79517. declare module "babylonjs/XR/features/WebXRHitTest" {
  79518. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79519. import { Observable } from "babylonjs/Misc/observable";
  79520. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79521. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79522. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79523. /**
  79524. * Options used for hit testing (version 2)
  79525. */
  79526. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79527. /**
  79528. * Do not create a permanent hit test. Will usually be used when only
  79529. * transient inputs are needed.
  79530. */
  79531. disablePermanentHitTest?: boolean;
  79532. /**
  79533. * Enable transient (for example touch-based) hit test inspections
  79534. */
  79535. enableTransientHitTest?: boolean;
  79536. /**
  79537. * Offset ray for the permanent hit test
  79538. */
  79539. offsetRay?: Vector3;
  79540. /**
  79541. * Offset ray for the transient hit test
  79542. */
  79543. transientOffsetRay?: Vector3;
  79544. /**
  79545. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79546. */
  79547. useReferenceSpace?: boolean;
  79548. /**
  79549. * Override the default entity type(s) of the hit-test result
  79550. */
  79551. entityTypes?: XRHitTestTrackableType[];
  79552. }
  79553. /**
  79554. * Interface defining the babylon result of hit-test
  79555. */
  79556. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79557. /**
  79558. * The input source that generated this hit test (if transient)
  79559. */
  79560. inputSource?: XRInputSource;
  79561. /**
  79562. * Is this a transient hit test
  79563. */
  79564. isTransient?: boolean;
  79565. /**
  79566. * Position of the hit test result
  79567. */
  79568. position: Vector3;
  79569. /**
  79570. * Rotation of the hit test result
  79571. */
  79572. rotationQuaternion: Quaternion;
  79573. /**
  79574. * The native hit test result
  79575. */
  79576. xrHitResult: XRHitTestResult;
  79577. }
  79578. /**
  79579. * The currently-working hit-test module.
  79580. * Hit test (or Ray-casting) is used to interact with the real world.
  79581. * For further information read here - https://github.com/immersive-web/hit-test
  79582. *
  79583. * Tested on chrome (mobile) 80.
  79584. */
  79585. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79586. /**
  79587. * options to use when constructing this feature
  79588. */
  79589. readonly options: IWebXRHitTestOptions;
  79590. private _tmpMat;
  79591. private _tmpPos;
  79592. private _tmpQuat;
  79593. private _transientXrHitTestSource;
  79594. private _xrHitTestSource;
  79595. private initHitTestSource;
  79596. /**
  79597. * The module's name
  79598. */
  79599. static readonly Name: string;
  79600. /**
  79601. * The (Babylon) version of this module.
  79602. * This is an integer representing the implementation version.
  79603. * This number does not correspond to the WebXR specs version
  79604. */
  79605. static readonly Version: number;
  79606. /**
  79607. * When set to true, each hit test will have its own position/rotation objects
  79608. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79609. * the developers will clone them or copy them as they see fit.
  79610. */
  79611. autoCloneTransformation: boolean;
  79612. /**
  79613. * Triggered when new babylon (transformed) hit test results are available
  79614. * Note - this will be called when results come back from the device. It can be an empty array!!
  79615. */
  79616. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79617. /**
  79618. * Use this to temporarily pause hit test checks.
  79619. */
  79620. paused: boolean;
  79621. /**
  79622. * Creates a new instance of the hit test feature
  79623. * @param _xrSessionManager an instance of WebXRSessionManager
  79624. * @param options options to use when constructing this feature
  79625. */
  79626. constructor(_xrSessionManager: WebXRSessionManager,
  79627. /**
  79628. * options to use when constructing this feature
  79629. */
  79630. options?: IWebXRHitTestOptions);
  79631. /**
  79632. * attach this feature
  79633. * Will usually be called by the features manager
  79634. *
  79635. * @returns true if successful.
  79636. */
  79637. attach(): boolean;
  79638. /**
  79639. * detach this feature.
  79640. * Will usually be called by the features manager
  79641. *
  79642. * @returns true if successful.
  79643. */
  79644. detach(): boolean;
  79645. /**
  79646. * Dispose this feature and all of the resources attached
  79647. */
  79648. dispose(): void;
  79649. protected _onXRFrame(frame: XRFrame): void;
  79650. private _processWebXRHitTestResult;
  79651. }
  79652. }
  79653. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79654. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79655. import { Observable } from "babylonjs/Misc/observable";
  79656. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79657. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79658. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79659. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79660. /**
  79661. * Configuration options of the anchor system
  79662. */
  79663. export interface IWebXRAnchorSystemOptions {
  79664. /**
  79665. * a node that will be used to convert local to world coordinates
  79666. */
  79667. worldParentNode?: TransformNode;
  79668. /**
  79669. * If set to true a reference of the created anchors will be kept until the next session starts
  79670. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79671. */
  79672. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79673. }
  79674. /**
  79675. * A babylon container for an XR Anchor
  79676. */
  79677. export interface IWebXRAnchor {
  79678. /**
  79679. * A babylon-assigned ID for this anchor
  79680. */
  79681. id: number;
  79682. /**
  79683. * Transformation matrix to apply to an object attached to this anchor
  79684. */
  79685. transformationMatrix: Matrix;
  79686. /**
  79687. * The native anchor object
  79688. */
  79689. xrAnchor: XRAnchor;
  79690. /**
  79691. * if defined, this object will be constantly updated by the anchor's position and rotation
  79692. */
  79693. attachedNode?: TransformNode;
  79694. }
  79695. /**
  79696. * An implementation of the anchor system for WebXR.
  79697. * For further information see https://github.com/immersive-web/anchors/
  79698. */
  79699. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79700. private _options;
  79701. private _lastFrameDetected;
  79702. private _trackedAnchors;
  79703. private _referenceSpaceForFrameAnchors;
  79704. private _futureAnchors;
  79705. /**
  79706. * The module's name
  79707. */
  79708. static readonly Name: string;
  79709. /**
  79710. * The (Babylon) version of this module.
  79711. * This is an integer representing the implementation version.
  79712. * This number does not correspond to the WebXR specs version
  79713. */
  79714. static readonly Version: number;
  79715. /**
  79716. * Observers registered here will be executed when a new anchor was added to the session
  79717. */
  79718. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79719. /**
  79720. * Observers registered here will be executed when an anchor was removed from the session
  79721. */
  79722. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79723. /**
  79724. * Observers registered here will be executed when an existing anchor updates
  79725. * This can execute N times every frame
  79726. */
  79727. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79728. /**
  79729. * Set the reference space to use for anchor creation, when not using a hit test.
  79730. * Will default to the session's reference space if not defined
  79731. */
  79732. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79733. /**
  79734. * constructs a new anchor system
  79735. * @param _xrSessionManager an instance of WebXRSessionManager
  79736. * @param _options configuration object for this feature
  79737. */
  79738. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79739. private _tmpVector;
  79740. private _tmpQuaternion;
  79741. private _populateTmpTransformation;
  79742. /**
  79743. * Create a new anchor point using a hit test result at a specific point in the scene
  79744. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79745. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79746. *
  79747. * @param hitTestResult The hit test result to use for this anchor creation
  79748. * @param position an optional position offset for this anchor
  79749. * @param rotationQuaternion an optional rotation offset for this anchor
  79750. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79751. */
  79752. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79753. /**
  79754. * Add a new anchor at a specific position and rotation
  79755. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79756. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79757. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79758. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79759. *
  79760. * @param position the position in which to add an anchor
  79761. * @param rotationQuaternion an optional rotation for the anchor transformation
  79762. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79763. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79764. */
  79765. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79766. /**
  79767. * detach this feature.
  79768. * Will usually be called by the features manager
  79769. *
  79770. * @returns true if successful.
  79771. */
  79772. detach(): boolean;
  79773. /**
  79774. * Dispose this feature and all of the resources attached
  79775. */
  79776. dispose(): void;
  79777. protected _onXRFrame(frame: XRFrame): void;
  79778. /**
  79779. * avoiding using Array.find for global support.
  79780. * @param xrAnchor the plane to find in the array
  79781. */
  79782. private _findIndexInAnchorArray;
  79783. private _updateAnchorWithXRFrame;
  79784. private _createAnchorAtTransformation;
  79785. }
  79786. }
  79787. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79788. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79789. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79790. import { Observable } from "babylonjs/Misc/observable";
  79791. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79792. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79793. /**
  79794. * Options used in the plane detector module
  79795. */
  79796. export interface IWebXRPlaneDetectorOptions {
  79797. /**
  79798. * The node to use to transform the local results to world coordinates
  79799. */
  79800. worldParentNode?: TransformNode;
  79801. /**
  79802. * If set to true a reference of the created planes will be kept until the next session starts
  79803. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79804. */
  79805. doNotRemovePlanesOnSessionEnded?: boolean;
  79806. }
  79807. /**
  79808. * A babylon interface for a WebXR plane.
  79809. * A Plane is actually a polygon, built from N points in space
  79810. *
  79811. * Supported in chrome 79, not supported in canary 81 ATM
  79812. */
  79813. export interface IWebXRPlane {
  79814. /**
  79815. * a babylon-assigned ID for this polygon
  79816. */
  79817. id: number;
  79818. /**
  79819. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79820. */
  79821. polygonDefinition: Array<Vector3>;
  79822. /**
  79823. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79824. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79825. */
  79826. transformationMatrix: Matrix;
  79827. /**
  79828. * the native xr-plane object
  79829. */
  79830. xrPlane: XRPlane;
  79831. }
  79832. /**
  79833. * The plane detector is used to detect planes in the real world when in AR
  79834. * For more information see https://github.com/immersive-web/real-world-geometry/
  79835. */
  79836. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79837. private _options;
  79838. private _detectedPlanes;
  79839. private _enabled;
  79840. private _lastFrameDetected;
  79841. /**
  79842. * The module's name
  79843. */
  79844. static readonly Name: string;
  79845. /**
  79846. * The (Babylon) version of this module.
  79847. * This is an integer representing the implementation version.
  79848. * This number does not correspond to the WebXR specs version
  79849. */
  79850. static readonly Version: number;
  79851. /**
  79852. * Observers registered here will be executed when a new plane was added to the session
  79853. */
  79854. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79855. /**
  79856. * Observers registered here will be executed when a plane is no longer detected in the session
  79857. */
  79858. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79859. /**
  79860. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79861. * This can execute N times every frame
  79862. */
  79863. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79864. /**
  79865. * construct a new Plane Detector
  79866. * @param _xrSessionManager an instance of xr Session manager
  79867. * @param _options configuration to use when constructing this feature
  79868. */
  79869. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79870. /**
  79871. * detach this feature.
  79872. * Will usually be called by the features manager
  79873. *
  79874. * @returns true if successful.
  79875. */
  79876. detach(): boolean;
  79877. /**
  79878. * Dispose this feature and all of the resources attached
  79879. */
  79880. dispose(): void;
  79881. protected _onXRFrame(frame: XRFrame): void;
  79882. private _init;
  79883. private _updatePlaneWithXRPlane;
  79884. /**
  79885. * avoiding using Array.find for global support.
  79886. * @param xrPlane the plane to find in the array
  79887. */
  79888. private findIndexInPlaneArray;
  79889. }
  79890. }
  79891. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79892. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79894. import { Observable } from "babylonjs/Misc/observable";
  79895. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79896. /**
  79897. * Options interface for the background remover plugin
  79898. */
  79899. export interface IWebXRBackgroundRemoverOptions {
  79900. /**
  79901. * Further background meshes to disable when entering AR
  79902. */
  79903. backgroundMeshes?: AbstractMesh[];
  79904. /**
  79905. * flags to configure the removal of the environment helper.
  79906. * If not set, the entire background will be removed. If set, flags should be set as well.
  79907. */
  79908. environmentHelperRemovalFlags?: {
  79909. /**
  79910. * Should the skybox be removed (default false)
  79911. */
  79912. skyBox?: boolean;
  79913. /**
  79914. * Should the ground be removed (default false)
  79915. */
  79916. ground?: boolean;
  79917. };
  79918. /**
  79919. * don't disable the environment helper
  79920. */
  79921. ignoreEnvironmentHelper?: boolean;
  79922. }
  79923. /**
  79924. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79925. */
  79926. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79927. /**
  79928. * read-only options to be used in this module
  79929. */
  79930. readonly options: IWebXRBackgroundRemoverOptions;
  79931. /**
  79932. * The module's name
  79933. */
  79934. static readonly Name: string;
  79935. /**
  79936. * The (Babylon) version of this module.
  79937. * This is an integer representing the implementation version.
  79938. * This number does not correspond to the WebXR specs version
  79939. */
  79940. static readonly Version: number;
  79941. /**
  79942. * registered observers will be triggered when the background state changes
  79943. */
  79944. onBackgroundStateChangedObservable: Observable<boolean>;
  79945. /**
  79946. * constructs a new background remover module
  79947. * @param _xrSessionManager the session manager for this module
  79948. * @param options read-only options to be used in this module
  79949. */
  79950. constructor(_xrSessionManager: WebXRSessionManager,
  79951. /**
  79952. * read-only options to be used in this module
  79953. */
  79954. options?: IWebXRBackgroundRemoverOptions);
  79955. /**
  79956. * attach this feature
  79957. * Will usually be called by the features manager
  79958. *
  79959. * @returns true if successful.
  79960. */
  79961. attach(): boolean;
  79962. /**
  79963. * detach this feature.
  79964. * Will usually be called by the features manager
  79965. *
  79966. * @returns true if successful.
  79967. */
  79968. detach(): boolean;
  79969. /**
  79970. * Dispose this feature and all of the resources attached
  79971. */
  79972. dispose(): void;
  79973. protected _onXRFrame(_xrFrame: XRFrame): void;
  79974. private _setBackgroundState;
  79975. }
  79976. }
  79977. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79978. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79979. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79980. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79981. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79982. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79983. import { Nullable } from "babylonjs/types";
  79984. /**
  79985. * Options for the controller physics feature
  79986. */
  79987. export class IWebXRControllerPhysicsOptions {
  79988. /**
  79989. * Should the headset get its own impostor
  79990. */
  79991. enableHeadsetImpostor?: boolean;
  79992. /**
  79993. * Optional parameters for the headset impostor
  79994. */
  79995. headsetImpostorParams?: {
  79996. /**
  79997. * The type of impostor to create. Default is sphere
  79998. */
  79999. impostorType: number;
  80000. /**
  80001. * the size of the impostor. Defaults to 10cm
  80002. */
  80003. impostorSize?: number | {
  80004. width: number;
  80005. height: number;
  80006. depth: number;
  80007. };
  80008. /**
  80009. * Friction definitions
  80010. */
  80011. friction?: number;
  80012. /**
  80013. * Restitution
  80014. */
  80015. restitution?: number;
  80016. };
  80017. /**
  80018. * The physics properties of the future impostors
  80019. */
  80020. physicsProperties?: {
  80021. /**
  80022. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80023. * Note that this requires a physics engine that supports mesh impostors!
  80024. */
  80025. useControllerMesh?: boolean;
  80026. /**
  80027. * The type of impostor to create. Default is sphere
  80028. */
  80029. impostorType?: number;
  80030. /**
  80031. * the size of the impostor. Defaults to 10cm
  80032. */
  80033. impostorSize?: number | {
  80034. width: number;
  80035. height: number;
  80036. depth: number;
  80037. };
  80038. /**
  80039. * Friction definitions
  80040. */
  80041. friction?: number;
  80042. /**
  80043. * Restitution
  80044. */
  80045. restitution?: number;
  80046. };
  80047. /**
  80048. * the xr input to use with this pointer selection
  80049. */
  80050. xrInput: WebXRInput;
  80051. }
  80052. /**
  80053. * Add physics impostor to your webxr controllers,
  80054. * including naive calculation of their linear and angular velocity
  80055. */
  80056. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80057. private readonly _options;
  80058. private _attachController;
  80059. private _controllers;
  80060. private _debugMode;
  80061. private _delta;
  80062. private _headsetImpostor?;
  80063. private _headsetMesh?;
  80064. private _lastTimestamp;
  80065. private _tmpQuaternion;
  80066. private _tmpVector;
  80067. /**
  80068. * The module's name
  80069. */
  80070. static readonly Name: string;
  80071. /**
  80072. * The (Babylon) version of this module.
  80073. * This is an integer representing the implementation version.
  80074. * This number does not correspond to the webxr specs version
  80075. */
  80076. static readonly Version: number;
  80077. /**
  80078. * Construct a new Controller Physics Feature
  80079. * @param _xrSessionManager the corresponding xr session manager
  80080. * @param _options options to create this feature with
  80081. */
  80082. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80083. /**
  80084. * @hidden
  80085. * enable debugging - will show console outputs and the impostor mesh
  80086. */
  80087. _enablePhysicsDebug(): void;
  80088. /**
  80089. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80090. * @param xrController the controller to add
  80091. */
  80092. addController(xrController: WebXRInputSource): void;
  80093. /**
  80094. * attach this feature
  80095. * Will usually be called by the features manager
  80096. *
  80097. * @returns true if successful.
  80098. */
  80099. attach(): boolean;
  80100. /**
  80101. * detach this feature.
  80102. * Will usually be called by the features manager
  80103. *
  80104. * @returns true if successful.
  80105. */
  80106. detach(): boolean;
  80107. /**
  80108. * Get the headset impostor, if enabled
  80109. * @returns the impostor
  80110. */
  80111. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80112. /**
  80113. * Get the physics impostor of a specific controller.
  80114. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80115. * @param controller the controller or the controller id of which to get the impostor
  80116. * @returns the impostor or null
  80117. */
  80118. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80119. /**
  80120. * Update the physics properties provided in the constructor
  80121. * @param newProperties the new properties object
  80122. */
  80123. setPhysicsProperties(newProperties: {
  80124. impostorType?: number;
  80125. impostorSize?: number | {
  80126. width: number;
  80127. height: number;
  80128. depth: number;
  80129. };
  80130. friction?: number;
  80131. restitution?: number;
  80132. }): void;
  80133. protected _onXRFrame(_xrFrame: any): void;
  80134. private _detachController;
  80135. }
  80136. }
  80137. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80138. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80139. import { Observable } from "babylonjs/Misc/observable";
  80140. import { Vector3 } from "babylonjs/Maths/math.vector";
  80141. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80142. /**
  80143. * A babylon interface for a "WebXR" feature point.
  80144. * Represents the position and confidence value of a given feature point.
  80145. */
  80146. export interface IWebXRFeaturePoint {
  80147. /**
  80148. * Represents the position of the feature point in world space.
  80149. */
  80150. position: Vector3;
  80151. /**
  80152. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80153. */
  80154. confidenceValue: number;
  80155. }
  80156. /**
  80157. * The feature point system is used to detect feature points from real world geometry.
  80158. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80159. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80160. */
  80161. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80162. private _enabled;
  80163. private _featurePointCloud;
  80164. /**
  80165. * The module's name
  80166. */
  80167. static readonly Name: string;
  80168. /**
  80169. * The (Babylon) version of this module.
  80170. * This is an integer representing the implementation version.
  80171. * This number does not correspond to the WebXR specs version
  80172. */
  80173. static readonly Version: number;
  80174. /**
  80175. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80176. * Will notify the observers about which feature points have been added.
  80177. */
  80178. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80179. /**
  80180. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80181. * Will notify the observers about which feature points have been updated.
  80182. */
  80183. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80184. /**
  80185. * The current feature point cloud maintained across frames.
  80186. */
  80187. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80188. /**
  80189. * construct the feature point system
  80190. * @param _xrSessionManager an instance of xr Session manager
  80191. */
  80192. constructor(_xrSessionManager: WebXRSessionManager);
  80193. /**
  80194. * Detach this feature.
  80195. * Will usually be called by the features manager
  80196. *
  80197. * @returns true if successful.
  80198. */
  80199. detach(): boolean;
  80200. /**
  80201. * Dispose this feature and all of the resources attached
  80202. */
  80203. dispose(): void;
  80204. /**
  80205. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80206. */
  80207. protected _onXRFrame(frame: XRFrame): void;
  80208. /**
  80209. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80210. */
  80211. private _init;
  80212. }
  80213. }
  80214. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80215. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80216. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80218. import { Mesh } from "babylonjs/Meshes/mesh";
  80219. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80220. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80221. import { Nullable } from "babylonjs/types";
  80222. import { IDisposable } from "babylonjs/scene";
  80223. import { Observable } from "babylonjs/Misc/observable";
  80224. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80225. /**
  80226. * Configuration interface for the hand tracking feature
  80227. */
  80228. export interface IWebXRHandTrackingOptions {
  80229. /**
  80230. * The xrInput that will be used as source for new hands
  80231. */
  80232. xrInput: WebXRInput;
  80233. /**
  80234. * Configuration object for the joint meshes
  80235. */
  80236. jointMeshes?: {
  80237. /**
  80238. * Should the meshes created be invisible (defaults to false)
  80239. */
  80240. invisible?: boolean;
  80241. /**
  80242. * A source mesh to be used to create instances. Defaults to a sphere.
  80243. * This mesh will be the source for all other (25) meshes.
  80244. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80245. */
  80246. sourceMesh?: Mesh;
  80247. /**
  80248. * This function will be called after a mesh was created for a specific joint.
  80249. * Using this function you can either manipulate the instance or return a new mesh.
  80250. * When returning a new mesh the instance created before will be disposed
  80251. */
  80252. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80253. /**
  80254. * Should the source mesh stay visible. Defaults to false
  80255. */
  80256. keepOriginalVisible?: boolean;
  80257. /**
  80258. * Scale factor for all instances (defaults to 2)
  80259. */
  80260. scaleFactor?: number;
  80261. /**
  80262. * Should each instance have its own physics impostor
  80263. */
  80264. enablePhysics?: boolean;
  80265. /**
  80266. * If enabled, override default physics properties
  80267. */
  80268. physicsProps?: {
  80269. friction?: number;
  80270. restitution?: number;
  80271. impostorType?: number;
  80272. };
  80273. /**
  80274. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80275. */
  80276. handMesh?: AbstractMesh;
  80277. };
  80278. }
  80279. /**
  80280. * Parts of the hands divided to writs and finger names
  80281. */
  80282. export const enum HandPart {
  80283. /**
  80284. * HandPart - Wrist
  80285. */
  80286. WRIST = "wrist",
  80287. /**
  80288. * HandPart - The THumb
  80289. */
  80290. THUMB = "thumb",
  80291. /**
  80292. * HandPart - Index finger
  80293. */
  80294. INDEX = "index",
  80295. /**
  80296. * HandPart - Middle finger
  80297. */
  80298. MIDDLE = "middle",
  80299. /**
  80300. * HandPart - Ring finger
  80301. */
  80302. RING = "ring",
  80303. /**
  80304. * HandPart - Little finger
  80305. */
  80306. LITTLE = "little"
  80307. }
  80308. /**
  80309. * Representing a single hand (with its corresponding native XRHand object)
  80310. */
  80311. export class WebXRHand implements IDisposable {
  80312. /** the controller to which the hand correlates */
  80313. readonly xrController: WebXRInputSource;
  80314. /** the meshes to be used to track the hand joints */
  80315. readonly trackedMeshes: AbstractMesh[];
  80316. /**
  80317. * Hand-parts definition (key is HandPart)
  80318. */
  80319. handPartsDefinition: {
  80320. [key: string]: number[];
  80321. };
  80322. /**
  80323. * Populate the HandPartsDefinition object.
  80324. * This is called as a side effect since certain browsers don't have XRHand defined.
  80325. */
  80326. private generateHandPartsDefinition;
  80327. /**
  80328. * Construct a new hand object
  80329. * @param xrController the controller to which the hand correlates
  80330. * @param trackedMeshes the meshes to be used to track the hand joints
  80331. */
  80332. constructor(
  80333. /** the controller to which the hand correlates */
  80334. xrController: WebXRInputSource,
  80335. /** the meshes to be used to track the hand joints */
  80336. trackedMeshes: AbstractMesh[]);
  80337. /**
  80338. * Update this hand from the latest xr frame
  80339. * @param xrFrame xrFrame to update from
  80340. * @param referenceSpace The current viewer reference space
  80341. * @param scaleFactor optional scale factor for the meshes
  80342. */
  80343. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80344. /**
  80345. * Get meshes of part of the hand
  80346. * @param part the part of hand to get
  80347. * @returns An array of meshes that correlate to the hand part requested
  80348. */
  80349. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80350. /**
  80351. * Dispose this Hand object
  80352. */
  80353. dispose(): void;
  80354. }
  80355. /**
  80356. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80357. */
  80358. export class WebXRHandTracking extends WebXRAbstractFeature {
  80359. /**
  80360. * options to use when constructing this feature
  80361. */
  80362. readonly options: IWebXRHandTrackingOptions;
  80363. private static _idCounter;
  80364. /**
  80365. * The module's name
  80366. */
  80367. static readonly Name: string;
  80368. /**
  80369. * The (Babylon) version of this module.
  80370. * This is an integer representing the implementation version.
  80371. * This number does not correspond to the WebXR specs version
  80372. */
  80373. static readonly Version: number;
  80374. /**
  80375. * This observable will notify registered observers when a new hand object was added and initialized
  80376. */
  80377. onHandAddedObservable: Observable<WebXRHand>;
  80378. /**
  80379. * This observable will notify its observers right before the hand object is disposed
  80380. */
  80381. onHandRemovedObservable: Observable<WebXRHand>;
  80382. private _hands;
  80383. /**
  80384. * Creates a new instance of the hit test feature
  80385. * @param _xrSessionManager an instance of WebXRSessionManager
  80386. * @param options options to use when constructing this feature
  80387. */
  80388. constructor(_xrSessionManager: WebXRSessionManager,
  80389. /**
  80390. * options to use when constructing this feature
  80391. */
  80392. options: IWebXRHandTrackingOptions);
  80393. /**
  80394. * Check if the needed objects are defined.
  80395. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80396. */
  80397. isCompatible(): boolean;
  80398. /**
  80399. * attach this feature
  80400. * Will usually be called by the features manager
  80401. *
  80402. * @returns true if successful.
  80403. */
  80404. attach(): boolean;
  80405. /**
  80406. * detach this feature.
  80407. * Will usually be called by the features manager
  80408. *
  80409. * @returns true if successful.
  80410. */
  80411. detach(): boolean;
  80412. /**
  80413. * Dispose this feature and all of the resources attached
  80414. */
  80415. dispose(): void;
  80416. /**
  80417. * Get the hand object according to the controller id
  80418. * @param controllerId the controller id to which we want to get the hand
  80419. * @returns null if not found or the WebXRHand object if found
  80420. */
  80421. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80422. /**
  80423. * Get a hand object according to the requested handedness
  80424. * @param handedness the handedness to request
  80425. * @returns null if not found or the WebXRHand object if found
  80426. */
  80427. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80428. protected _onXRFrame(_xrFrame: XRFrame): void;
  80429. private _attachHand;
  80430. private _detachHand;
  80431. }
  80432. }
  80433. declare module "babylonjs/XR/features/index" {
  80434. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80435. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80436. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80437. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80438. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80439. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80440. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80441. export * from "babylonjs/XR/features/WebXRHitTest";
  80442. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80443. export * from "babylonjs/XR/features/WebXRHandTracking";
  80444. }
  80445. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80446. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80448. import { Scene } from "babylonjs/scene";
  80449. /**
  80450. * The motion controller class for all microsoft mixed reality controllers
  80451. */
  80452. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80453. protected readonly _mapping: {
  80454. defaultButton: {
  80455. valueNodeName: string;
  80456. unpressedNodeName: string;
  80457. pressedNodeName: string;
  80458. };
  80459. defaultAxis: {
  80460. valueNodeName: string;
  80461. minNodeName: string;
  80462. maxNodeName: string;
  80463. };
  80464. buttons: {
  80465. "xr-standard-trigger": {
  80466. rootNodeName: string;
  80467. componentProperty: string;
  80468. states: string[];
  80469. };
  80470. "xr-standard-squeeze": {
  80471. rootNodeName: string;
  80472. componentProperty: string;
  80473. states: string[];
  80474. };
  80475. "xr-standard-touchpad": {
  80476. rootNodeName: string;
  80477. labelAnchorNodeName: string;
  80478. touchPointNodeName: string;
  80479. };
  80480. "xr-standard-thumbstick": {
  80481. rootNodeName: string;
  80482. componentProperty: string;
  80483. states: string[];
  80484. };
  80485. };
  80486. axes: {
  80487. "xr-standard-touchpad": {
  80488. "x-axis": {
  80489. rootNodeName: string;
  80490. };
  80491. "y-axis": {
  80492. rootNodeName: string;
  80493. };
  80494. };
  80495. "xr-standard-thumbstick": {
  80496. "x-axis": {
  80497. rootNodeName: string;
  80498. };
  80499. "y-axis": {
  80500. rootNodeName: string;
  80501. };
  80502. };
  80503. };
  80504. };
  80505. /**
  80506. * The base url used to load the left and right controller models
  80507. */
  80508. static MODEL_BASE_URL: string;
  80509. /**
  80510. * The name of the left controller model file
  80511. */
  80512. static MODEL_LEFT_FILENAME: string;
  80513. /**
  80514. * The name of the right controller model file
  80515. */
  80516. static MODEL_RIGHT_FILENAME: string;
  80517. profileId: string;
  80518. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80519. protected _getFilenameAndPath(): {
  80520. filename: string;
  80521. path: string;
  80522. };
  80523. protected _getModelLoadingConstraints(): boolean;
  80524. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80525. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80526. protected _updateModel(): void;
  80527. }
  80528. }
  80529. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80530. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80532. import { Scene } from "babylonjs/scene";
  80533. /**
  80534. * The motion controller class for oculus touch (quest, rift).
  80535. * This class supports legacy mapping as well the standard xr mapping
  80536. */
  80537. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80538. private _forceLegacyControllers;
  80539. private _modelRootNode;
  80540. /**
  80541. * The base url used to load the left and right controller models
  80542. */
  80543. static MODEL_BASE_URL: string;
  80544. /**
  80545. * The name of the left controller model file
  80546. */
  80547. static MODEL_LEFT_FILENAME: string;
  80548. /**
  80549. * The name of the right controller model file
  80550. */
  80551. static MODEL_RIGHT_FILENAME: string;
  80552. /**
  80553. * Base Url for the Quest controller model.
  80554. */
  80555. static QUEST_MODEL_BASE_URL: string;
  80556. profileId: string;
  80557. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80558. protected _getFilenameAndPath(): {
  80559. filename: string;
  80560. path: string;
  80561. };
  80562. protected _getModelLoadingConstraints(): boolean;
  80563. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80564. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80565. protected _updateModel(): void;
  80566. /**
  80567. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80568. * between the touch and touch 2.
  80569. */
  80570. private _isQuest;
  80571. }
  80572. }
  80573. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80574. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80575. import { Scene } from "babylonjs/scene";
  80576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80577. /**
  80578. * The motion controller class for the standard HTC-Vive controllers
  80579. */
  80580. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80581. private _modelRootNode;
  80582. /**
  80583. * The base url used to load the left and right controller models
  80584. */
  80585. static MODEL_BASE_URL: string;
  80586. /**
  80587. * File name for the controller model.
  80588. */
  80589. static MODEL_FILENAME: string;
  80590. profileId: string;
  80591. /**
  80592. * Create a new Vive motion controller object
  80593. * @param scene the scene to use to create this controller
  80594. * @param gamepadObject the corresponding gamepad object
  80595. * @param handedness the handedness of the controller
  80596. */
  80597. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80598. protected _getFilenameAndPath(): {
  80599. filename: string;
  80600. path: string;
  80601. };
  80602. protected _getModelLoadingConstraints(): boolean;
  80603. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80604. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80605. protected _updateModel(): void;
  80606. }
  80607. }
  80608. declare module "babylonjs/XR/motionController/index" {
  80609. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80610. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80611. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80612. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80613. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80614. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80615. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80616. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80617. }
  80618. declare module "babylonjs/XR/index" {
  80619. export * from "babylonjs/XR/webXRCamera";
  80620. export * from "babylonjs/XR/webXREnterExitUI";
  80621. export * from "babylonjs/XR/webXRExperienceHelper";
  80622. export * from "babylonjs/XR/webXRInput";
  80623. export * from "babylonjs/XR/webXRInputSource";
  80624. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80625. export * from "babylonjs/XR/webXRTypes";
  80626. export * from "babylonjs/XR/webXRSessionManager";
  80627. export * from "babylonjs/XR/webXRDefaultExperience";
  80628. export * from "babylonjs/XR/webXRFeaturesManager";
  80629. export * from "babylonjs/XR/features/index";
  80630. export * from "babylonjs/XR/motionController/index";
  80631. }
  80632. declare module "babylonjs/index" {
  80633. export * from "babylonjs/abstractScene";
  80634. export * from "babylonjs/Actions/index";
  80635. export * from "babylonjs/Animations/index";
  80636. export * from "babylonjs/assetContainer";
  80637. export * from "babylonjs/Audio/index";
  80638. export * from "babylonjs/Behaviors/index";
  80639. export * from "babylonjs/Bones/index";
  80640. export * from "babylonjs/Cameras/index";
  80641. export * from "babylonjs/Collisions/index";
  80642. export * from "babylonjs/Culling/index";
  80643. export * from "babylonjs/Debug/index";
  80644. export * from "babylonjs/DeviceInput/index";
  80645. export * from "babylonjs/Engines/index";
  80646. export * from "babylonjs/Events/index";
  80647. export * from "babylonjs/Gamepads/index";
  80648. export * from "babylonjs/Gizmos/index";
  80649. export * from "babylonjs/Helpers/index";
  80650. export * from "babylonjs/Instrumentation/index";
  80651. export * from "babylonjs/Layers/index";
  80652. export * from "babylonjs/LensFlares/index";
  80653. export * from "babylonjs/Lights/index";
  80654. export * from "babylonjs/Loading/index";
  80655. export * from "babylonjs/Materials/index";
  80656. export * from "babylonjs/Maths/index";
  80657. export * from "babylonjs/Meshes/index";
  80658. export * from "babylonjs/Morph/index";
  80659. export * from "babylonjs/Navigation/index";
  80660. export * from "babylonjs/node";
  80661. export * from "babylonjs/Offline/index";
  80662. export * from "babylonjs/Particles/index";
  80663. export * from "babylonjs/Physics/index";
  80664. export * from "babylonjs/PostProcesses/index";
  80665. export * from "babylonjs/Probes/index";
  80666. export * from "babylonjs/Rendering/index";
  80667. export * from "babylonjs/scene";
  80668. export * from "babylonjs/sceneComponent";
  80669. export * from "babylonjs/Sprites/index";
  80670. export * from "babylonjs/States/index";
  80671. export * from "babylonjs/Misc/index";
  80672. export * from "babylonjs/XR/index";
  80673. export * from "babylonjs/types";
  80674. }
  80675. declare module "babylonjs/Animations/pathCursor" {
  80676. import { Vector3 } from "babylonjs/Maths/math.vector";
  80677. import { Path2 } from "babylonjs/Maths/math.path";
  80678. /**
  80679. * A cursor which tracks a point on a path
  80680. */
  80681. export class PathCursor {
  80682. private path;
  80683. /**
  80684. * Stores path cursor callbacks for when an onchange event is triggered
  80685. */
  80686. private _onchange;
  80687. /**
  80688. * The value of the path cursor
  80689. */
  80690. value: number;
  80691. /**
  80692. * The animation array of the path cursor
  80693. */
  80694. animations: Animation[];
  80695. /**
  80696. * Initializes the path cursor
  80697. * @param path The path to track
  80698. */
  80699. constructor(path: Path2);
  80700. /**
  80701. * Gets the cursor point on the path
  80702. * @returns A point on the path cursor at the cursor location
  80703. */
  80704. getPoint(): Vector3;
  80705. /**
  80706. * Moves the cursor ahead by the step amount
  80707. * @param step The amount to move the cursor forward
  80708. * @returns This path cursor
  80709. */
  80710. moveAhead(step?: number): PathCursor;
  80711. /**
  80712. * Moves the cursor behind by the step amount
  80713. * @param step The amount to move the cursor back
  80714. * @returns This path cursor
  80715. */
  80716. moveBack(step?: number): PathCursor;
  80717. /**
  80718. * Moves the cursor by the step amount
  80719. * If the step amount is greater than one, an exception is thrown
  80720. * @param step The amount to move the cursor
  80721. * @returns This path cursor
  80722. */
  80723. move(step: number): PathCursor;
  80724. /**
  80725. * Ensures that the value is limited between zero and one
  80726. * @returns This path cursor
  80727. */
  80728. private ensureLimits;
  80729. /**
  80730. * Runs onchange callbacks on change (used by the animation engine)
  80731. * @returns This path cursor
  80732. */
  80733. private raiseOnChange;
  80734. /**
  80735. * Executes a function on change
  80736. * @param f A path cursor onchange callback
  80737. * @returns This path cursor
  80738. */
  80739. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80740. }
  80741. }
  80742. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80743. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80744. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80745. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80746. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80747. }
  80748. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80749. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80750. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80751. }
  80752. declare module "babylonjs/Engines/Processors/index" {
  80753. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80754. export * from "babylonjs/Engines/Processors/Expressions/index";
  80755. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80756. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80757. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80758. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80759. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80760. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80761. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80762. }
  80763. declare module "babylonjs/Legacy/legacy" {
  80764. import * as Babylon from "babylonjs/index";
  80765. export * from "babylonjs/index";
  80766. }
  80767. declare module "babylonjs/Shaders/blur.fragment" {
  80768. /** @hidden */
  80769. export var blurPixelShader: {
  80770. name: string;
  80771. shader: string;
  80772. };
  80773. }
  80774. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80775. /** @hidden */
  80776. export var pointCloudVertexDeclaration: {
  80777. name: string;
  80778. shader: string;
  80779. };
  80780. }
  80781. declare module "babylonjs" {
  80782. export * from "babylonjs/Legacy/legacy";
  80783. }
  80784. declare module BABYLON {
  80785. /** Alias type for value that can be null */
  80786. export type Nullable<T> = T | null;
  80787. /**
  80788. * Alias type for number that are floats
  80789. * @ignorenaming
  80790. */
  80791. export type float = number;
  80792. /**
  80793. * Alias type for number that are doubles.
  80794. * @ignorenaming
  80795. */
  80796. export type double = number;
  80797. /**
  80798. * Alias type for number that are integer
  80799. * @ignorenaming
  80800. */
  80801. export type int = number;
  80802. /** Alias type for number array or Float32Array */
  80803. export type FloatArray = number[] | Float32Array;
  80804. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80805. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80806. /**
  80807. * Alias for types that can be used by a Buffer or VertexBuffer.
  80808. */
  80809. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80810. /**
  80811. * Alias type for primitive types
  80812. * @ignorenaming
  80813. */
  80814. type Primitive = undefined | null | boolean | string | number | Function;
  80815. /**
  80816. * Type modifier to make all the properties of an object Readonly
  80817. */
  80818. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80819. /**
  80820. * Type modifier to make all the properties of an object Readonly recursively
  80821. */
  80822. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80823. /**
  80824. * Type modifier to make object properties readonly.
  80825. */
  80826. export type DeepImmutableObject<T> = {
  80827. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80828. };
  80829. /** @hidden */
  80830. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80831. }
  80832. }
  80833. declare module BABYLON {
  80834. /**
  80835. * A class serves as a medium between the observable and its observers
  80836. */
  80837. export class EventState {
  80838. /**
  80839. * Create a new EventState
  80840. * @param mask defines the mask associated with this state
  80841. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80842. * @param target defines the original target of the state
  80843. * @param currentTarget defines the current target of the state
  80844. */
  80845. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80846. /**
  80847. * Initialize the current event state
  80848. * @param mask defines the mask associated with this state
  80849. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80850. * @param target defines the original target of the state
  80851. * @param currentTarget defines the current target of the state
  80852. * @returns the current event state
  80853. */
  80854. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80855. /**
  80856. * An Observer can set this property to true to prevent subsequent observers of being notified
  80857. */
  80858. skipNextObservers: boolean;
  80859. /**
  80860. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80861. */
  80862. mask: number;
  80863. /**
  80864. * The object that originally notified the event
  80865. */
  80866. target?: any;
  80867. /**
  80868. * The current object in the bubbling phase
  80869. */
  80870. currentTarget?: any;
  80871. /**
  80872. * This will be populated with the return value of the last function that was executed.
  80873. * If it is the first function in the callback chain it will be the event data.
  80874. */
  80875. lastReturnValue?: any;
  80876. /**
  80877. * User defined information that will be sent to observers
  80878. */
  80879. userInfo?: any;
  80880. }
  80881. /**
  80882. * Represent an Observer registered to a given Observable object.
  80883. */
  80884. export class Observer<T> {
  80885. /**
  80886. * Defines the callback to call when the observer is notified
  80887. */
  80888. callback: (eventData: T, eventState: EventState) => void;
  80889. /**
  80890. * Defines the mask of the observer (used to filter notifications)
  80891. */
  80892. mask: number;
  80893. /**
  80894. * Defines the current scope used to restore the JS context
  80895. */
  80896. scope: any;
  80897. /** @hidden */
  80898. _willBeUnregistered: boolean;
  80899. /**
  80900. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80901. */
  80902. unregisterOnNextCall: boolean;
  80903. /**
  80904. * Creates a new observer
  80905. * @param callback defines the callback to call when the observer is notified
  80906. * @param mask defines the mask of the observer (used to filter notifications)
  80907. * @param scope defines the current scope used to restore the JS context
  80908. */
  80909. constructor(
  80910. /**
  80911. * Defines the callback to call when the observer is notified
  80912. */
  80913. callback: (eventData: T, eventState: EventState) => void,
  80914. /**
  80915. * Defines the mask of the observer (used to filter notifications)
  80916. */
  80917. mask: number,
  80918. /**
  80919. * Defines the current scope used to restore the JS context
  80920. */
  80921. scope?: any);
  80922. }
  80923. /**
  80924. * Represent a list of observers registered to multiple Observables object.
  80925. */
  80926. export class MultiObserver<T> {
  80927. private _observers;
  80928. private _observables;
  80929. /**
  80930. * Release associated resources
  80931. */
  80932. dispose(): void;
  80933. /**
  80934. * Raise a callback when one of the observable will notify
  80935. * @param observables defines a list of observables to watch
  80936. * @param callback defines the callback to call on notification
  80937. * @param mask defines the mask used to filter notifications
  80938. * @param scope defines the current scope used to restore the JS context
  80939. * @returns the new MultiObserver
  80940. */
  80941. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80942. }
  80943. /**
  80944. * The Observable class is a simple implementation of the Observable pattern.
  80945. *
  80946. * 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.
  80947. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80948. * 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).
  80949. * 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.
  80950. */
  80951. export class Observable<T> {
  80952. private _observers;
  80953. private _eventState;
  80954. private _onObserverAdded;
  80955. /**
  80956. * Gets the list of observers
  80957. */
  80958. get observers(): Array<Observer<T>>;
  80959. /**
  80960. * Creates a new observable
  80961. * @param onObserverAdded defines a callback to call when a new observer is added
  80962. */
  80963. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80964. /**
  80965. * Create a new Observer with the specified callback
  80966. * @param callback the callback that will be executed for that Observer
  80967. * @param mask the mask used to filter observers
  80968. * @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.
  80969. * @param scope optional scope for the callback to be called from
  80970. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80971. * @returns the new observer created for the callback
  80972. */
  80973. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80974. /**
  80975. * Create a new Observer with the specified callback and unregisters after the next notification
  80976. * @param callback the callback that will be executed for that Observer
  80977. * @returns the new observer created for the callback
  80978. */
  80979. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80980. /**
  80981. * Remove an Observer from the Observable object
  80982. * @param observer the instance of the Observer to remove
  80983. * @returns false if it doesn't belong to this Observable
  80984. */
  80985. remove(observer: Nullable<Observer<T>>): boolean;
  80986. /**
  80987. * Remove a callback from the Observable object
  80988. * @param callback the callback to remove
  80989. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80990. * @returns false if it doesn't belong to this Observable
  80991. */
  80992. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80993. private _deferUnregister;
  80994. private _remove;
  80995. /**
  80996. * Moves the observable to the top of the observer list making it get called first when notified
  80997. * @param observer the observer to move
  80998. */
  80999. makeObserverTopPriority(observer: Observer<T>): void;
  81000. /**
  81001. * Moves the observable to the bottom of the observer list making it get called last when notified
  81002. * @param observer the observer to move
  81003. */
  81004. makeObserverBottomPriority(observer: Observer<T>): void;
  81005. /**
  81006. * Notify all Observers by calling their respective callback with the given data
  81007. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81008. * @param eventData defines the data to send to all observers
  81009. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81010. * @param target defines the original target of the state
  81011. * @param currentTarget defines the current target of the state
  81012. * @param userInfo defines any user info to send to observers
  81013. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81014. */
  81015. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81016. /**
  81017. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81018. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81019. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81020. * and it is crucial that all callbacks will be executed.
  81021. * The order of the callbacks is kept, callbacks are not executed parallel.
  81022. *
  81023. * @param eventData The data to be sent to each callback
  81024. * @param mask is used to filter observers defaults to -1
  81025. * @param target defines the callback target (see EventState)
  81026. * @param currentTarget defines he current object in the bubbling phase
  81027. * @param userInfo defines any user info to send to observers
  81028. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81029. */
  81030. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81031. /**
  81032. * Notify a specific observer
  81033. * @param observer defines the observer to notify
  81034. * @param eventData defines the data to be sent to each callback
  81035. * @param mask is used to filter observers defaults to -1
  81036. */
  81037. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81038. /**
  81039. * Gets a boolean indicating if the observable has at least one observer
  81040. * @returns true is the Observable has at least one Observer registered
  81041. */
  81042. hasObservers(): boolean;
  81043. /**
  81044. * Clear the list of observers
  81045. */
  81046. clear(): void;
  81047. /**
  81048. * Clone the current observable
  81049. * @returns a new observable
  81050. */
  81051. clone(): Observable<T>;
  81052. /**
  81053. * Does this observable handles observer registered with a given mask
  81054. * @param mask defines the mask to be tested
  81055. * @return whether or not one observer registered with the given mask is handeled
  81056. **/
  81057. hasSpecificMask(mask?: number): boolean;
  81058. }
  81059. }
  81060. declare module BABYLON {
  81061. /**
  81062. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81063. * Babylon.js
  81064. */
  81065. export class DomManagement {
  81066. /**
  81067. * Checks if the window object exists
  81068. * @returns true if the window object exists
  81069. */
  81070. static IsWindowObjectExist(): boolean;
  81071. /**
  81072. * Checks if the navigator object exists
  81073. * @returns true if the navigator object exists
  81074. */
  81075. static IsNavigatorAvailable(): boolean;
  81076. /**
  81077. * Check if the document object exists
  81078. * @returns true if the document object exists
  81079. */
  81080. static IsDocumentAvailable(): boolean;
  81081. /**
  81082. * Extracts text content from a DOM element hierarchy
  81083. * @param element defines the root element
  81084. * @returns a string
  81085. */
  81086. static GetDOMTextContent(element: HTMLElement): string;
  81087. }
  81088. }
  81089. declare module BABYLON {
  81090. /**
  81091. * Logger used througouht the application to allow configuration of
  81092. * the log level required for the messages.
  81093. */
  81094. export class Logger {
  81095. /**
  81096. * No log
  81097. */
  81098. static readonly NoneLogLevel: number;
  81099. /**
  81100. * Only message logs
  81101. */
  81102. static readonly MessageLogLevel: number;
  81103. /**
  81104. * Only warning logs
  81105. */
  81106. static readonly WarningLogLevel: number;
  81107. /**
  81108. * Only error logs
  81109. */
  81110. static readonly ErrorLogLevel: number;
  81111. /**
  81112. * All logs
  81113. */
  81114. static readonly AllLogLevel: number;
  81115. private static _LogCache;
  81116. /**
  81117. * Gets a value indicating the number of loading errors
  81118. * @ignorenaming
  81119. */
  81120. static errorsCount: number;
  81121. /**
  81122. * Callback called when a new log is added
  81123. */
  81124. static OnNewCacheEntry: (entry: string) => void;
  81125. private static _AddLogEntry;
  81126. private static _FormatMessage;
  81127. private static _LogDisabled;
  81128. private static _LogEnabled;
  81129. private static _WarnDisabled;
  81130. private static _WarnEnabled;
  81131. private static _ErrorDisabled;
  81132. private static _ErrorEnabled;
  81133. /**
  81134. * Log a message to the console
  81135. */
  81136. static Log: (message: string) => void;
  81137. /**
  81138. * Write a warning message to the console
  81139. */
  81140. static Warn: (message: string) => void;
  81141. /**
  81142. * Write an error message to the console
  81143. */
  81144. static Error: (message: string) => void;
  81145. /**
  81146. * Gets current log cache (list of logs)
  81147. */
  81148. static get LogCache(): string;
  81149. /**
  81150. * Clears the log cache
  81151. */
  81152. static ClearLogCache(): void;
  81153. /**
  81154. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81155. */
  81156. static set LogLevels(level: number);
  81157. }
  81158. }
  81159. declare module BABYLON {
  81160. /** @hidden */
  81161. export class _TypeStore {
  81162. /** @hidden */
  81163. static RegisteredTypes: {
  81164. [key: string]: Object;
  81165. };
  81166. /** @hidden */
  81167. static GetClass(fqdn: string): any;
  81168. }
  81169. }
  81170. declare module BABYLON {
  81171. /**
  81172. * Helper to manipulate strings
  81173. */
  81174. export class StringTools {
  81175. /**
  81176. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81177. * @param str Source string
  81178. * @param suffix Suffix to search for in the source string
  81179. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81180. */
  81181. static EndsWith(str: string, suffix: string): boolean;
  81182. /**
  81183. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81184. * @param str Source string
  81185. * @param suffix Suffix to search for in the source string
  81186. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81187. */
  81188. static StartsWith(str: string, suffix: string): boolean;
  81189. /**
  81190. * Decodes a buffer into a string
  81191. * @param buffer The buffer to decode
  81192. * @returns The decoded string
  81193. */
  81194. static Decode(buffer: Uint8Array | Uint16Array): string;
  81195. /**
  81196. * Encode a buffer to a base64 string
  81197. * @param buffer defines the buffer to encode
  81198. * @returns the encoded string
  81199. */
  81200. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81201. /**
  81202. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81203. * @param num the number to convert and pad
  81204. * @param length the expected length of the string
  81205. * @returns the padded string
  81206. */
  81207. static PadNumber(num: number, length: number): string;
  81208. }
  81209. }
  81210. declare module BABYLON {
  81211. /**
  81212. * Class containing a set of static utilities functions for deep copy.
  81213. */
  81214. export class DeepCopier {
  81215. /**
  81216. * Tries to copy an object by duplicating every property
  81217. * @param source defines the source object
  81218. * @param destination defines the target object
  81219. * @param doNotCopyList defines a list of properties to avoid
  81220. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81221. */
  81222. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81223. }
  81224. }
  81225. declare module BABYLON {
  81226. /**
  81227. * Class containing a set of static utilities functions for precision date
  81228. */
  81229. export class PrecisionDate {
  81230. /**
  81231. * Gets either window.performance.now() if supported or Date.now() else
  81232. */
  81233. static get Now(): number;
  81234. }
  81235. }
  81236. declare module BABYLON {
  81237. /** @hidden */
  81238. export class _DevTools {
  81239. static WarnImport(name: string): string;
  81240. }
  81241. }
  81242. declare module BABYLON {
  81243. /**
  81244. * Interface used to define the mechanism to get data from the network
  81245. */
  81246. export interface IWebRequest {
  81247. /**
  81248. * Returns client's response url
  81249. */
  81250. responseURL: string;
  81251. /**
  81252. * Returns client's status
  81253. */
  81254. status: number;
  81255. /**
  81256. * Returns client's status as a text
  81257. */
  81258. statusText: string;
  81259. }
  81260. }
  81261. declare module BABYLON {
  81262. /**
  81263. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81264. */
  81265. export class WebRequest implements IWebRequest {
  81266. private _xhr;
  81267. /**
  81268. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81269. * i.e. when loading files, where the server/service expects an Authorization header
  81270. */
  81271. static CustomRequestHeaders: {
  81272. [key: string]: string;
  81273. };
  81274. /**
  81275. * Add callback functions in this array to update all the requests before they get sent to the network
  81276. */
  81277. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81278. private _injectCustomRequestHeaders;
  81279. /**
  81280. * Gets or sets a function to be called when loading progress changes
  81281. */
  81282. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81283. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81284. /**
  81285. * Returns client's state
  81286. */
  81287. get readyState(): number;
  81288. /**
  81289. * Returns client's status
  81290. */
  81291. get status(): number;
  81292. /**
  81293. * Returns client's status as a text
  81294. */
  81295. get statusText(): string;
  81296. /**
  81297. * Returns client's response
  81298. */
  81299. get response(): any;
  81300. /**
  81301. * Returns client's response url
  81302. */
  81303. get responseURL(): string;
  81304. /**
  81305. * Returns client's response as text
  81306. */
  81307. get responseText(): string;
  81308. /**
  81309. * Gets or sets the expected response type
  81310. */
  81311. get responseType(): XMLHttpRequestResponseType;
  81312. set responseType(value: XMLHttpRequestResponseType);
  81313. /** @hidden */
  81314. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81315. /** @hidden */
  81316. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81317. /**
  81318. * Cancels any network activity
  81319. */
  81320. abort(): void;
  81321. /**
  81322. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81323. * @param body defines an optional request body
  81324. */
  81325. send(body?: Document | BodyInit | null): void;
  81326. /**
  81327. * Sets the request method, request URL
  81328. * @param method defines the method to use (GET, POST, etc..)
  81329. * @param url defines the url to connect with
  81330. */
  81331. open(method: string, url: string): void;
  81332. /**
  81333. * Sets the value of a request header.
  81334. * @param name The name of the header whose value is to be set
  81335. * @param value The value to set as the body of the header
  81336. */
  81337. setRequestHeader(name: string, value: string): void;
  81338. /**
  81339. * Get the string containing the text of a particular header's value.
  81340. * @param name The name of the header
  81341. * @returns The string containing the text of the given header name
  81342. */
  81343. getResponseHeader(name: string): Nullable<string>;
  81344. }
  81345. }
  81346. declare module BABYLON {
  81347. /**
  81348. * File request interface
  81349. */
  81350. export interface IFileRequest {
  81351. /**
  81352. * Raised when the request is complete (success or error).
  81353. */
  81354. onCompleteObservable: Observable<IFileRequest>;
  81355. /**
  81356. * Aborts the request for a file.
  81357. */
  81358. abort: () => void;
  81359. }
  81360. }
  81361. declare module BABYLON {
  81362. /**
  81363. * Define options used to create a render target texture
  81364. */
  81365. export class RenderTargetCreationOptions {
  81366. /**
  81367. * Specifies is mipmaps must be generated
  81368. */
  81369. generateMipMaps?: boolean;
  81370. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81371. generateDepthBuffer?: boolean;
  81372. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81373. generateStencilBuffer?: boolean;
  81374. /** Defines texture type (int by default) */
  81375. type?: number;
  81376. /** Defines sampling mode (trilinear by default) */
  81377. samplingMode?: number;
  81378. /** Defines format (RGBA by default) */
  81379. format?: number;
  81380. }
  81381. }
  81382. declare module BABYLON {
  81383. /** Defines the cross module used constants to avoid circular dependncies */
  81384. export class Constants {
  81385. /** Defines that alpha blending is disabled */
  81386. static readonly ALPHA_DISABLE: number;
  81387. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81388. static readonly ALPHA_ADD: number;
  81389. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81390. static readonly ALPHA_COMBINE: number;
  81391. /** Defines that alpha blending is DEST - SRC * DEST */
  81392. static readonly ALPHA_SUBTRACT: number;
  81393. /** Defines that alpha blending is SRC * DEST */
  81394. static readonly ALPHA_MULTIPLY: number;
  81395. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81396. static readonly ALPHA_MAXIMIZED: number;
  81397. /** Defines that alpha blending is SRC + DEST */
  81398. static readonly ALPHA_ONEONE: number;
  81399. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81400. static readonly ALPHA_PREMULTIPLIED: number;
  81401. /**
  81402. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81403. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81404. */
  81405. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81406. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81407. static readonly ALPHA_INTERPOLATE: number;
  81408. /**
  81409. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81410. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81411. */
  81412. static readonly ALPHA_SCREENMODE: number;
  81413. /**
  81414. * Defines that alpha blending is SRC + DST
  81415. * Alpha will be set to SRC ALPHA + DST ALPHA
  81416. */
  81417. static readonly ALPHA_ONEONE_ONEONE: number;
  81418. /**
  81419. * Defines that alpha blending is SRC * DST ALPHA + DST
  81420. * Alpha will be set to 0
  81421. */
  81422. static readonly ALPHA_ALPHATOCOLOR: number;
  81423. /**
  81424. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81425. */
  81426. static readonly ALPHA_REVERSEONEMINUS: number;
  81427. /**
  81428. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81429. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81430. */
  81431. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81432. /**
  81433. * Defines that alpha blending is SRC + DST
  81434. * Alpha will be set to SRC ALPHA
  81435. */
  81436. static readonly ALPHA_ONEONE_ONEZERO: number;
  81437. /**
  81438. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81439. * Alpha will be set to DST ALPHA
  81440. */
  81441. static readonly ALPHA_EXCLUSION: number;
  81442. /** Defines that alpha blending equation a SUM */
  81443. static readonly ALPHA_EQUATION_ADD: number;
  81444. /** Defines that alpha blending equation a SUBSTRACTION */
  81445. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81446. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81447. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81448. /** Defines that alpha blending equation a MAX operation */
  81449. static readonly ALPHA_EQUATION_MAX: number;
  81450. /** Defines that alpha blending equation a MIN operation */
  81451. static readonly ALPHA_EQUATION_MIN: number;
  81452. /**
  81453. * Defines that alpha blending equation a DARKEN operation:
  81454. * It takes the min of the src and sums the alpha channels.
  81455. */
  81456. static readonly ALPHA_EQUATION_DARKEN: number;
  81457. /** Defines that the ressource is not delayed*/
  81458. static readonly DELAYLOADSTATE_NONE: number;
  81459. /** Defines that the ressource was successfully delay loaded */
  81460. static readonly DELAYLOADSTATE_LOADED: number;
  81461. /** Defines that the ressource is currently delay loading */
  81462. static readonly DELAYLOADSTATE_LOADING: number;
  81463. /** Defines that the ressource is delayed and has not started loading */
  81464. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81466. static readonly NEVER: number;
  81467. /** 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 */
  81468. static readonly ALWAYS: number;
  81469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81470. static readonly LESS: number;
  81471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81472. static readonly EQUAL: number;
  81473. /** 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 */
  81474. static readonly LEQUAL: number;
  81475. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81476. static readonly GREATER: number;
  81477. /** 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 */
  81478. static readonly GEQUAL: number;
  81479. /** 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 */
  81480. static readonly NOTEQUAL: number;
  81481. /** Passed to stencilOperation to specify that stencil value must be kept */
  81482. static readonly KEEP: number;
  81483. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81484. static readonly REPLACE: number;
  81485. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81486. static readonly INCR: number;
  81487. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81488. static readonly DECR: number;
  81489. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81490. static readonly INVERT: number;
  81491. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81492. static readonly INCR_WRAP: number;
  81493. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81494. static readonly DECR_WRAP: number;
  81495. /** Texture is not repeating outside of 0..1 UVs */
  81496. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81497. /** Texture is repeating outside of 0..1 UVs */
  81498. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81499. /** Texture is repeating and mirrored */
  81500. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81501. /** ALPHA */
  81502. static readonly TEXTUREFORMAT_ALPHA: number;
  81503. /** LUMINANCE */
  81504. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81505. /** LUMINANCE_ALPHA */
  81506. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81507. /** RGB */
  81508. static readonly TEXTUREFORMAT_RGB: number;
  81509. /** RGBA */
  81510. static readonly TEXTUREFORMAT_RGBA: number;
  81511. /** RED */
  81512. static readonly TEXTUREFORMAT_RED: number;
  81513. /** RED (2nd reference) */
  81514. static readonly TEXTUREFORMAT_R: number;
  81515. /** RG */
  81516. static readonly TEXTUREFORMAT_RG: number;
  81517. /** RED_INTEGER */
  81518. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81519. /** RED_INTEGER (2nd reference) */
  81520. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81521. /** RG_INTEGER */
  81522. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81523. /** RGB_INTEGER */
  81524. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81525. /** RGBA_INTEGER */
  81526. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81527. /** UNSIGNED_BYTE */
  81528. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81529. /** UNSIGNED_BYTE (2nd reference) */
  81530. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81531. /** FLOAT */
  81532. static readonly TEXTURETYPE_FLOAT: number;
  81533. /** HALF_FLOAT */
  81534. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81535. /** BYTE */
  81536. static readonly TEXTURETYPE_BYTE: number;
  81537. /** SHORT */
  81538. static readonly TEXTURETYPE_SHORT: number;
  81539. /** UNSIGNED_SHORT */
  81540. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81541. /** INT */
  81542. static readonly TEXTURETYPE_INT: number;
  81543. /** UNSIGNED_INT */
  81544. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81545. /** UNSIGNED_SHORT_4_4_4_4 */
  81546. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81547. /** UNSIGNED_SHORT_5_5_5_1 */
  81548. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81549. /** UNSIGNED_SHORT_5_6_5 */
  81550. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81551. /** UNSIGNED_INT_2_10_10_10_REV */
  81552. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81553. /** UNSIGNED_INT_24_8 */
  81554. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81555. /** UNSIGNED_INT_10F_11F_11F_REV */
  81556. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81557. /** UNSIGNED_INT_5_9_9_9_REV */
  81558. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81559. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81560. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81561. /** nearest is mag = nearest and min = nearest and no mip */
  81562. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81563. /** mag = nearest and min = nearest and mip = none */
  81564. static readonly TEXTURE_NEAREST_NEAREST: number;
  81565. /** Bilinear is mag = linear and min = linear and no mip */
  81566. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81567. /** mag = linear and min = linear and mip = none */
  81568. static readonly TEXTURE_LINEAR_LINEAR: number;
  81569. /** Trilinear is mag = linear and min = linear and mip = linear */
  81570. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81571. /** Trilinear is mag = linear and min = linear and mip = linear */
  81572. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81573. /** mag = nearest and min = nearest and mip = nearest */
  81574. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81575. /** mag = nearest and min = linear and mip = nearest */
  81576. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81577. /** mag = nearest and min = linear and mip = linear */
  81578. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81579. /** mag = nearest and min = linear and mip = none */
  81580. static readonly TEXTURE_NEAREST_LINEAR: number;
  81581. /** nearest is mag = nearest and min = nearest and mip = linear */
  81582. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81583. /** mag = linear and min = nearest and mip = nearest */
  81584. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81585. /** mag = linear and min = nearest and mip = linear */
  81586. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81587. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81588. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81589. /** mag = linear and min = nearest and mip = none */
  81590. static readonly TEXTURE_LINEAR_NEAREST: number;
  81591. /** Explicit coordinates mode */
  81592. static readonly TEXTURE_EXPLICIT_MODE: number;
  81593. /** Spherical coordinates mode */
  81594. static readonly TEXTURE_SPHERICAL_MODE: number;
  81595. /** Planar coordinates mode */
  81596. static readonly TEXTURE_PLANAR_MODE: number;
  81597. /** Cubic coordinates mode */
  81598. static readonly TEXTURE_CUBIC_MODE: number;
  81599. /** Projection coordinates mode */
  81600. static readonly TEXTURE_PROJECTION_MODE: number;
  81601. /** Skybox coordinates mode */
  81602. static readonly TEXTURE_SKYBOX_MODE: number;
  81603. /** Inverse Cubic coordinates mode */
  81604. static readonly TEXTURE_INVCUBIC_MODE: number;
  81605. /** Equirectangular coordinates mode */
  81606. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81607. /** Equirectangular Fixed coordinates mode */
  81608. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81609. /** Equirectangular Fixed Mirrored coordinates mode */
  81610. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81611. /** Offline (baking) quality for texture filtering */
  81612. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81613. /** High quality for texture filtering */
  81614. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81615. /** Medium quality for texture filtering */
  81616. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81617. /** Low quality for texture filtering */
  81618. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81619. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81620. static readonly SCALEMODE_FLOOR: number;
  81621. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81622. static readonly SCALEMODE_NEAREST: number;
  81623. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81624. static readonly SCALEMODE_CEILING: number;
  81625. /**
  81626. * The dirty texture flag value
  81627. */
  81628. static readonly MATERIAL_TextureDirtyFlag: number;
  81629. /**
  81630. * The dirty light flag value
  81631. */
  81632. static readonly MATERIAL_LightDirtyFlag: number;
  81633. /**
  81634. * The dirty fresnel flag value
  81635. */
  81636. static readonly MATERIAL_FresnelDirtyFlag: number;
  81637. /**
  81638. * The dirty attribute flag value
  81639. */
  81640. static readonly MATERIAL_AttributesDirtyFlag: number;
  81641. /**
  81642. * The dirty misc flag value
  81643. */
  81644. static readonly MATERIAL_MiscDirtyFlag: number;
  81645. /**
  81646. * The dirty prepass flag value
  81647. */
  81648. static readonly MATERIAL_PrePassDirtyFlag: number;
  81649. /**
  81650. * The all dirty flag value
  81651. */
  81652. static readonly MATERIAL_AllDirtyFlag: number;
  81653. /**
  81654. * Returns the triangle fill mode
  81655. */
  81656. static readonly MATERIAL_TriangleFillMode: number;
  81657. /**
  81658. * Returns the wireframe mode
  81659. */
  81660. static readonly MATERIAL_WireFrameFillMode: number;
  81661. /**
  81662. * Returns the point fill mode
  81663. */
  81664. static readonly MATERIAL_PointFillMode: number;
  81665. /**
  81666. * Returns the point list draw mode
  81667. */
  81668. static readonly MATERIAL_PointListDrawMode: number;
  81669. /**
  81670. * Returns the line list draw mode
  81671. */
  81672. static readonly MATERIAL_LineListDrawMode: number;
  81673. /**
  81674. * Returns the line loop draw mode
  81675. */
  81676. static readonly MATERIAL_LineLoopDrawMode: number;
  81677. /**
  81678. * Returns the line strip draw mode
  81679. */
  81680. static readonly MATERIAL_LineStripDrawMode: number;
  81681. /**
  81682. * Returns the triangle strip draw mode
  81683. */
  81684. static readonly MATERIAL_TriangleStripDrawMode: number;
  81685. /**
  81686. * Returns the triangle fan draw mode
  81687. */
  81688. static readonly MATERIAL_TriangleFanDrawMode: number;
  81689. /**
  81690. * Stores the clock-wise side orientation
  81691. */
  81692. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81693. /**
  81694. * Stores the counter clock-wise side orientation
  81695. */
  81696. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81697. /**
  81698. * Nothing
  81699. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81700. */
  81701. static readonly ACTION_NothingTrigger: number;
  81702. /**
  81703. * On pick
  81704. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81705. */
  81706. static readonly ACTION_OnPickTrigger: number;
  81707. /**
  81708. * On left pick
  81709. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81710. */
  81711. static readonly ACTION_OnLeftPickTrigger: number;
  81712. /**
  81713. * On right pick
  81714. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81715. */
  81716. static readonly ACTION_OnRightPickTrigger: number;
  81717. /**
  81718. * On center pick
  81719. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81720. */
  81721. static readonly ACTION_OnCenterPickTrigger: number;
  81722. /**
  81723. * On pick down
  81724. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81725. */
  81726. static readonly ACTION_OnPickDownTrigger: number;
  81727. /**
  81728. * On double pick
  81729. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81730. */
  81731. static readonly ACTION_OnDoublePickTrigger: number;
  81732. /**
  81733. * On pick up
  81734. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81735. */
  81736. static readonly ACTION_OnPickUpTrigger: number;
  81737. /**
  81738. * On pick out.
  81739. * This trigger will only be raised if you also declared a OnPickDown
  81740. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81741. */
  81742. static readonly ACTION_OnPickOutTrigger: number;
  81743. /**
  81744. * On long press
  81745. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81746. */
  81747. static readonly ACTION_OnLongPressTrigger: number;
  81748. /**
  81749. * On pointer over
  81750. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81751. */
  81752. static readonly ACTION_OnPointerOverTrigger: number;
  81753. /**
  81754. * On pointer out
  81755. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81756. */
  81757. static readonly ACTION_OnPointerOutTrigger: number;
  81758. /**
  81759. * On every frame
  81760. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81761. */
  81762. static readonly ACTION_OnEveryFrameTrigger: number;
  81763. /**
  81764. * On intersection enter
  81765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81766. */
  81767. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81768. /**
  81769. * On intersection exit
  81770. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81771. */
  81772. static readonly ACTION_OnIntersectionExitTrigger: number;
  81773. /**
  81774. * On key down
  81775. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81776. */
  81777. static readonly ACTION_OnKeyDownTrigger: number;
  81778. /**
  81779. * On key up
  81780. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81781. */
  81782. static readonly ACTION_OnKeyUpTrigger: number;
  81783. /**
  81784. * Billboard mode will only apply to Y axis
  81785. */
  81786. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81787. /**
  81788. * Billboard mode will apply to all axes
  81789. */
  81790. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81791. /**
  81792. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81793. */
  81794. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81795. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81796. * Test order :
  81797. * Is the bounding sphere outside the frustum ?
  81798. * If not, are the bounding box vertices outside the frustum ?
  81799. * It not, then the cullable object is in the frustum.
  81800. */
  81801. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81802. /** Culling strategy : Bounding Sphere Only.
  81803. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81804. * It's also less accurate than the standard because some not visible objects can still be selected.
  81805. * Test : is the bounding sphere outside the frustum ?
  81806. * If not, then the cullable object is in the frustum.
  81807. */
  81808. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81809. /** Culling strategy : Optimistic Inclusion.
  81810. * This in an inclusion test first, then the standard exclusion test.
  81811. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81812. * 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.
  81813. * Anyway, it's as accurate as the standard strategy.
  81814. * Test :
  81815. * Is the cullable object bounding sphere center in the frustum ?
  81816. * If not, apply the default culling strategy.
  81817. */
  81818. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81819. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81820. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81821. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81822. * 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.
  81823. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81824. * Test :
  81825. * Is the cullable object bounding sphere center in the frustum ?
  81826. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81827. */
  81828. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81829. /**
  81830. * No logging while loading
  81831. */
  81832. static readonly SCENELOADER_NO_LOGGING: number;
  81833. /**
  81834. * Minimal logging while loading
  81835. */
  81836. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81837. /**
  81838. * Summary logging while loading
  81839. */
  81840. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81841. /**
  81842. * Detailled logging while loading
  81843. */
  81844. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81845. /**
  81846. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81847. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81848. */
  81849. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81850. /**
  81851. * Constant used to retrieve the position texture index in the textures array in the prepass
  81852. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81853. */
  81854. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81855. /**
  81856. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81857. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81858. */
  81859. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81860. /**
  81861. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81862. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81863. */
  81864. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81865. /**
  81866. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81867. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81868. */
  81869. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81870. /**
  81871. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81872. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81873. */
  81874. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81875. /**
  81876. * Constant used to retrieve albedo index in the textures array in the prepass
  81877. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81878. */
  81879. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81880. }
  81881. }
  81882. declare module BABYLON {
  81883. /**
  81884. * This represents the required contract to create a new type of texture loader.
  81885. */
  81886. export interface IInternalTextureLoader {
  81887. /**
  81888. * Defines wether the loader supports cascade loading the different faces.
  81889. */
  81890. supportCascades: boolean;
  81891. /**
  81892. * This returns if the loader support the current file information.
  81893. * @param extension defines the file extension of the file being loaded
  81894. * @param mimeType defines the optional mime type of the file being loaded
  81895. * @returns true if the loader can load the specified file
  81896. */
  81897. canLoad(extension: string, mimeType?: string): boolean;
  81898. /**
  81899. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81900. * @param data contains the texture data
  81901. * @param texture defines the BabylonJS internal texture
  81902. * @param createPolynomials will be true if polynomials have been requested
  81903. * @param onLoad defines the callback to trigger once the texture is ready
  81904. * @param onError defines the callback to trigger in case of error
  81905. * @param options options to be passed to the loader
  81906. */
  81907. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  81908. /**
  81909. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81910. * @param data contains the texture data
  81911. * @param texture defines the BabylonJS internal texture
  81912. * @param callback defines the method to call once ready to upload
  81913. * @param options options to be passed to the loader
  81914. */
  81915. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  81916. }
  81917. }
  81918. declare module BABYLON {
  81919. /**
  81920. * Class used to store and describe the pipeline context associated with an effect
  81921. */
  81922. export interface IPipelineContext {
  81923. /**
  81924. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81925. */
  81926. isAsync: boolean;
  81927. /**
  81928. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81929. */
  81930. isReady: boolean;
  81931. /** @hidden */
  81932. _getVertexShaderCode(): string | null;
  81933. /** @hidden */
  81934. _getFragmentShaderCode(): string | null;
  81935. /** @hidden */
  81936. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81937. }
  81938. }
  81939. declare module BABYLON {
  81940. /**
  81941. * Class used to store gfx data (like WebGLBuffer)
  81942. */
  81943. export class DataBuffer {
  81944. /**
  81945. * Gets or sets the number of objects referencing this buffer
  81946. */
  81947. references: number;
  81948. /** Gets or sets the size of the underlying buffer */
  81949. capacity: number;
  81950. /**
  81951. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81952. */
  81953. is32Bits: boolean;
  81954. /**
  81955. * Gets the underlying buffer
  81956. */
  81957. get underlyingResource(): any;
  81958. }
  81959. }
  81960. declare module BABYLON {
  81961. /** @hidden */
  81962. export interface IShaderProcessor {
  81963. attributeProcessor?: (attribute: string) => string;
  81964. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81965. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81966. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81967. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81968. lineProcessor?: (line: string, isFragment: boolean) => string;
  81969. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81970. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81971. }
  81972. }
  81973. declare module BABYLON {
  81974. /** @hidden */
  81975. export interface ProcessingOptions {
  81976. defines: string[];
  81977. indexParameters: any;
  81978. isFragment: boolean;
  81979. shouldUseHighPrecisionShader: boolean;
  81980. supportsUniformBuffers: boolean;
  81981. shadersRepository: string;
  81982. includesShadersStore: {
  81983. [key: string]: string;
  81984. };
  81985. processor?: IShaderProcessor;
  81986. version: string;
  81987. platformName: string;
  81988. lookForClosingBracketForUniformBuffer?: boolean;
  81989. }
  81990. }
  81991. declare module BABYLON {
  81992. /** @hidden */
  81993. export class ShaderCodeNode {
  81994. line: string;
  81995. children: ShaderCodeNode[];
  81996. additionalDefineKey?: string;
  81997. additionalDefineValue?: string;
  81998. isValid(preprocessors: {
  81999. [key: string]: string;
  82000. }): boolean;
  82001. process(preprocessors: {
  82002. [key: string]: string;
  82003. }, options: ProcessingOptions): string;
  82004. }
  82005. }
  82006. declare module BABYLON {
  82007. /** @hidden */
  82008. export class ShaderCodeCursor {
  82009. private _lines;
  82010. lineIndex: number;
  82011. get currentLine(): string;
  82012. get canRead(): boolean;
  82013. set lines(value: string[]);
  82014. }
  82015. }
  82016. declare module BABYLON {
  82017. /** @hidden */
  82018. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82019. process(preprocessors: {
  82020. [key: string]: string;
  82021. }, options: ProcessingOptions): string;
  82022. }
  82023. }
  82024. declare module BABYLON {
  82025. /** @hidden */
  82026. export class ShaderDefineExpression {
  82027. isTrue(preprocessors: {
  82028. [key: string]: string;
  82029. }): boolean;
  82030. private static _OperatorPriority;
  82031. private static _Stack;
  82032. static postfixToInfix(postfix: string[]): string;
  82033. static infixToPostfix(infix: string): string[];
  82034. }
  82035. }
  82036. declare module BABYLON {
  82037. /** @hidden */
  82038. export class ShaderCodeTestNode extends ShaderCodeNode {
  82039. testExpression: ShaderDefineExpression;
  82040. isValid(preprocessors: {
  82041. [key: string]: string;
  82042. }): boolean;
  82043. }
  82044. }
  82045. declare module BABYLON {
  82046. /** @hidden */
  82047. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82048. define: string;
  82049. not: boolean;
  82050. constructor(define: string, not?: boolean);
  82051. isTrue(preprocessors: {
  82052. [key: string]: string;
  82053. }): boolean;
  82054. }
  82055. }
  82056. declare module BABYLON {
  82057. /** @hidden */
  82058. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82059. leftOperand: ShaderDefineExpression;
  82060. rightOperand: ShaderDefineExpression;
  82061. isTrue(preprocessors: {
  82062. [key: string]: string;
  82063. }): boolean;
  82064. }
  82065. }
  82066. declare module BABYLON {
  82067. /** @hidden */
  82068. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82069. leftOperand: ShaderDefineExpression;
  82070. rightOperand: ShaderDefineExpression;
  82071. isTrue(preprocessors: {
  82072. [key: string]: string;
  82073. }): boolean;
  82074. }
  82075. }
  82076. declare module BABYLON {
  82077. /** @hidden */
  82078. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82079. define: string;
  82080. operand: string;
  82081. testValue: string;
  82082. constructor(define: string, operand: string, testValue: string);
  82083. isTrue(preprocessors: {
  82084. [key: string]: string;
  82085. }): boolean;
  82086. }
  82087. }
  82088. declare module BABYLON {
  82089. /**
  82090. * Class used to enable access to offline support
  82091. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82092. */
  82093. export interface IOfflineProvider {
  82094. /**
  82095. * Gets a boolean indicating if scene must be saved in the database
  82096. */
  82097. enableSceneOffline: boolean;
  82098. /**
  82099. * Gets a boolean indicating if textures must be saved in the database
  82100. */
  82101. enableTexturesOffline: boolean;
  82102. /**
  82103. * Open the offline support and make it available
  82104. * @param successCallback defines the callback to call on success
  82105. * @param errorCallback defines the callback to call on error
  82106. */
  82107. open(successCallback: () => void, errorCallback: () => void): void;
  82108. /**
  82109. * Loads an image from the offline support
  82110. * @param url defines the url to load from
  82111. * @param image defines the target DOM image
  82112. */
  82113. loadImage(url: string, image: HTMLImageElement): void;
  82114. /**
  82115. * Loads a file from offline support
  82116. * @param url defines the URL to load from
  82117. * @param sceneLoaded defines a callback to call on success
  82118. * @param progressCallBack defines a callback to call when progress changed
  82119. * @param errorCallback defines a callback to call on error
  82120. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82121. */
  82122. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82123. }
  82124. }
  82125. declare module BABYLON {
  82126. /**
  82127. * Class used to help managing file picking and drag'n'drop
  82128. * File Storage
  82129. */
  82130. export class FilesInputStore {
  82131. /**
  82132. * List of files ready to be loaded
  82133. */
  82134. static FilesToLoad: {
  82135. [key: string]: File;
  82136. };
  82137. }
  82138. }
  82139. declare module BABYLON {
  82140. /**
  82141. * Class used to define a retry strategy when error happens while loading assets
  82142. */
  82143. export class RetryStrategy {
  82144. /**
  82145. * Function used to defines an exponential back off strategy
  82146. * @param maxRetries defines the maximum number of retries (3 by default)
  82147. * @param baseInterval defines the interval between retries
  82148. * @returns the strategy function to use
  82149. */
  82150. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82151. }
  82152. }
  82153. declare module BABYLON {
  82154. /**
  82155. * @ignore
  82156. * Application error to support additional information when loading a file
  82157. */
  82158. export abstract class BaseError extends Error {
  82159. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82160. }
  82161. }
  82162. declare module BABYLON {
  82163. /** @ignore */
  82164. export class LoadFileError extends BaseError {
  82165. request?: WebRequest;
  82166. file?: File;
  82167. /**
  82168. * Creates a new LoadFileError
  82169. * @param message defines the message of the error
  82170. * @param request defines the optional web request
  82171. * @param file defines the optional file
  82172. */
  82173. constructor(message: string, object?: WebRequest | File);
  82174. }
  82175. /** @ignore */
  82176. export class RequestFileError extends BaseError {
  82177. request: WebRequest;
  82178. /**
  82179. * Creates a new LoadFileError
  82180. * @param message defines the message of the error
  82181. * @param request defines the optional web request
  82182. */
  82183. constructor(message: string, request: WebRequest);
  82184. }
  82185. /** @ignore */
  82186. export class ReadFileError extends BaseError {
  82187. file: File;
  82188. /**
  82189. * Creates a new ReadFileError
  82190. * @param message defines the message of the error
  82191. * @param file defines the optional file
  82192. */
  82193. constructor(message: string, file: File);
  82194. }
  82195. /**
  82196. * @hidden
  82197. */
  82198. export class FileTools {
  82199. /**
  82200. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82201. */
  82202. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82203. /**
  82204. * Gets or sets the base URL to use to load assets
  82205. */
  82206. static BaseUrl: string;
  82207. /**
  82208. * Default behaviour for cors in the application.
  82209. * It can be a string if the expected behavior is identical in the entire app.
  82210. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82211. */
  82212. static CorsBehavior: string | ((url: string | string[]) => string);
  82213. /**
  82214. * Gets or sets a function used to pre-process url before using them to load assets
  82215. */
  82216. static PreprocessUrl: (url: string) => string;
  82217. /**
  82218. * Removes unwanted characters from an url
  82219. * @param url defines the url to clean
  82220. * @returns the cleaned url
  82221. */
  82222. private static _CleanUrl;
  82223. /**
  82224. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82225. * @param url define the url we are trying
  82226. * @param element define the dom element where to configure the cors policy
  82227. */
  82228. static SetCorsBehavior(url: string | string[], element: {
  82229. crossOrigin: string | null;
  82230. }): void;
  82231. /**
  82232. * Loads an image as an HTMLImageElement.
  82233. * @param input url string, ArrayBuffer, or Blob to load
  82234. * @param onLoad callback called when the image successfully loads
  82235. * @param onError callback called when the image fails to load
  82236. * @param offlineProvider offline provider for caching
  82237. * @param mimeType optional mime type
  82238. * @returns the HTMLImageElement of the loaded image
  82239. */
  82240. 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>;
  82241. /**
  82242. * Reads a file from a File object
  82243. * @param file defines the file to load
  82244. * @param onSuccess defines the callback to call when data is loaded
  82245. * @param onProgress defines the callback to call during loading process
  82246. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82247. * @param onError defines the callback to call when an error occurs
  82248. * @returns a file request object
  82249. */
  82250. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82251. /**
  82252. * Loads a file from a url
  82253. * @param url url to load
  82254. * @param onSuccess callback called when the file successfully loads
  82255. * @param onProgress callback called while file is loading (if the server supports this mode)
  82256. * @param offlineProvider defines the offline provider for caching
  82257. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82258. * @param onError callback called when the file fails to load
  82259. * @returns a file request object
  82260. */
  82261. 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;
  82262. /**
  82263. * Loads a file
  82264. * @param url url to load
  82265. * @param onSuccess callback called when the file successfully loads
  82266. * @param onProgress callback called while file is loading (if the server supports this mode)
  82267. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82268. * @param onError callback called when the file fails to load
  82269. * @param onOpened callback called when the web request is opened
  82270. * @returns a file request object
  82271. */
  82272. 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;
  82273. /**
  82274. * Checks if the loaded document was accessed via `file:`-Protocol.
  82275. * @returns boolean
  82276. */
  82277. static IsFileURL(): boolean;
  82278. }
  82279. }
  82280. declare module BABYLON {
  82281. /** @hidden */
  82282. export class ShaderProcessor {
  82283. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  82284. private static _ProcessPrecision;
  82285. private static _ExtractOperation;
  82286. private static _BuildSubExpression;
  82287. private static _BuildExpression;
  82288. private static _MoveCursorWithinIf;
  82289. private static _MoveCursor;
  82290. private static _EvaluatePreProcessors;
  82291. private static _PreparePreProcessors;
  82292. private static _ProcessShaderConversion;
  82293. private static _ProcessIncludes;
  82294. /**
  82295. * Loads a file from a url
  82296. * @param url url to load
  82297. * @param onSuccess callback called when the file successfully loads
  82298. * @param onProgress callback called while file is loading (if the server supports this mode)
  82299. * @param offlineProvider defines the offline provider for caching
  82300. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82301. * @param onError callback called when the file fails to load
  82302. * @returns a file request object
  82303. * @hidden
  82304. */
  82305. 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;
  82306. }
  82307. }
  82308. declare module BABYLON {
  82309. /**
  82310. * @hidden
  82311. */
  82312. export interface IColor4Like {
  82313. r: float;
  82314. g: float;
  82315. b: float;
  82316. a: float;
  82317. }
  82318. /**
  82319. * @hidden
  82320. */
  82321. export interface IColor3Like {
  82322. r: float;
  82323. g: float;
  82324. b: float;
  82325. }
  82326. /**
  82327. * @hidden
  82328. */
  82329. export interface IVector4Like {
  82330. x: float;
  82331. y: float;
  82332. z: float;
  82333. w: float;
  82334. }
  82335. /**
  82336. * @hidden
  82337. */
  82338. export interface IVector3Like {
  82339. x: float;
  82340. y: float;
  82341. z: float;
  82342. }
  82343. /**
  82344. * @hidden
  82345. */
  82346. export interface IVector2Like {
  82347. x: float;
  82348. y: float;
  82349. }
  82350. /**
  82351. * @hidden
  82352. */
  82353. export interface IMatrixLike {
  82354. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82355. updateFlag: int;
  82356. }
  82357. /**
  82358. * @hidden
  82359. */
  82360. export interface IViewportLike {
  82361. x: float;
  82362. y: float;
  82363. width: float;
  82364. height: float;
  82365. }
  82366. /**
  82367. * @hidden
  82368. */
  82369. export interface IPlaneLike {
  82370. normal: IVector3Like;
  82371. d: float;
  82372. normalize(): void;
  82373. }
  82374. }
  82375. declare module BABYLON {
  82376. /**
  82377. * Interface used to define common properties for effect fallbacks
  82378. */
  82379. export interface IEffectFallbacks {
  82380. /**
  82381. * Removes the defines that should be removed when falling back.
  82382. * @param currentDefines defines the current define statements for the shader.
  82383. * @param effect defines the current effect we try to compile
  82384. * @returns The resulting defines with defines of the current rank removed.
  82385. */
  82386. reduce(currentDefines: string, effect: Effect): string;
  82387. /**
  82388. * Removes the fallback from the bound mesh.
  82389. */
  82390. unBindMesh(): void;
  82391. /**
  82392. * Checks to see if more fallbacks are still availible.
  82393. */
  82394. hasMoreFallbacks: boolean;
  82395. }
  82396. }
  82397. declare module BABYLON {
  82398. /**
  82399. * Class used to evalaute queries containing `and` and `or` operators
  82400. */
  82401. export class AndOrNotEvaluator {
  82402. /**
  82403. * Evaluate a query
  82404. * @param query defines the query to evaluate
  82405. * @param evaluateCallback defines the callback used to filter result
  82406. * @returns true if the query matches
  82407. */
  82408. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82409. private static _HandleParenthesisContent;
  82410. private static _SimplifyNegation;
  82411. }
  82412. }
  82413. declare module BABYLON {
  82414. /**
  82415. * Class used to store custom tags
  82416. */
  82417. export class Tags {
  82418. /**
  82419. * Adds support for tags on the given object
  82420. * @param obj defines the object to use
  82421. */
  82422. static EnableFor(obj: any): void;
  82423. /**
  82424. * Removes tags support
  82425. * @param obj defines the object to use
  82426. */
  82427. static DisableFor(obj: any): void;
  82428. /**
  82429. * Gets a boolean indicating if the given object has tags
  82430. * @param obj defines the object to use
  82431. * @returns a boolean
  82432. */
  82433. static HasTags(obj: any): boolean;
  82434. /**
  82435. * Gets the tags available on a given object
  82436. * @param obj defines the object to use
  82437. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82438. * @returns the tags
  82439. */
  82440. static GetTags(obj: any, asString?: boolean): any;
  82441. /**
  82442. * Adds tags to an object
  82443. * @param obj defines the object to use
  82444. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82445. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82446. */
  82447. static AddTagsTo(obj: any, tagsString: string): void;
  82448. /**
  82449. * @hidden
  82450. */
  82451. static _AddTagTo(obj: any, tag: string): void;
  82452. /**
  82453. * Removes specific tags from a specific object
  82454. * @param obj defines the object to use
  82455. * @param tagsString defines the tags to remove
  82456. */
  82457. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82458. /**
  82459. * @hidden
  82460. */
  82461. static _RemoveTagFrom(obj: any, tag: string): void;
  82462. /**
  82463. * Defines if tags hosted on an object match a given query
  82464. * @param obj defines the object to use
  82465. * @param tagsQuery defines the tag query
  82466. * @returns a boolean
  82467. */
  82468. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82469. }
  82470. }
  82471. declare module BABYLON {
  82472. /**
  82473. * Scalar computation library
  82474. */
  82475. export class Scalar {
  82476. /**
  82477. * Two pi constants convenient for computation.
  82478. */
  82479. static TwoPi: number;
  82480. /**
  82481. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82482. * @param a number
  82483. * @param b number
  82484. * @param epsilon (default = 1.401298E-45)
  82485. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82486. */
  82487. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82488. /**
  82489. * Returns a string : the upper case translation of the number i to hexadecimal.
  82490. * @param i number
  82491. * @returns the upper case translation of the number i to hexadecimal.
  82492. */
  82493. static ToHex(i: number): string;
  82494. /**
  82495. * Returns -1 if value is negative and +1 is value is positive.
  82496. * @param value the value
  82497. * @returns the value itself if it's equal to zero.
  82498. */
  82499. static Sign(value: number): number;
  82500. /**
  82501. * Returns the value itself if it's between min and max.
  82502. * Returns min if the value is lower than min.
  82503. * Returns max if the value is greater than max.
  82504. * @param value the value to clmap
  82505. * @param min the min value to clamp to (default: 0)
  82506. * @param max the max value to clamp to (default: 1)
  82507. * @returns the clamped value
  82508. */
  82509. static Clamp(value: number, min?: number, max?: number): number;
  82510. /**
  82511. * the log2 of value.
  82512. * @param value the value to compute log2 of
  82513. * @returns the log2 of value.
  82514. */
  82515. static Log2(value: number): number;
  82516. /**
  82517. * Loops the value, so that it is never larger than length and never smaller than 0.
  82518. *
  82519. * This is similar to the modulo operator but it works with floating point numbers.
  82520. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82521. * With t = 5 and length = 2.5, the result would be 0.0.
  82522. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82523. * @param value the value
  82524. * @param length the length
  82525. * @returns the looped value
  82526. */
  82527. static Repeat(value: number, length: number): number;
  82528. /**
  82529. * Normalize the value between 0.0 and 1.0 using min and max values
  82530. * @param value value to normalize
  82531. * @param min max to normalize between
  82532. * @param max min to normalize between
  82533. * @returns the normalized value
  82534. */
  82535. static Normalize(value: number, min: number, max: number): number;
  82536. /**
  82537. * Denormalize the value from 0.0 and 1.0 using min and max values
  82538. * @param normalized value to denormalize
  82539. * @param min max to denormalize between
  82540. * @param max min to denormalize between
  82541. * @returns the denormalized value
  82542. */
  82543. static Denormalize(normalized: number, min: number, max: number): number;
  82544. /**
  82545. * Calculates the shortest difference between two given angles given in degrees.
  82546. * @param current current angle in degrees
  82547. * @param target target angle in degrees
  82548. * @returns the delta
  82549. */
  82550. static DeltaAngle(current: number, target: number): number;
  82551. /**
  82552. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82553. * @param tx value
  82554. * @param length length
  82555. * @returns The returned value will move back and forth between 0 and length
  82556. */
  82557. static PingPong(tx: number, length: number): number;
  82558. /**
  82559. * Interpolates between min and max with smoothing at the limits.
  82560. *
  82561. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82562. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82563. * @param from from
  82564. * @param to to
  82565. * @param tx value
  82566. * @returns the smooth stepped value
  82567. */
  82568. static SmoothStep(from: number, to: number, tx: number): number;
  82569. /**
  82570. * Moves a value current towards target.
  82571. *
  82572. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82573. * Negative values of maxDelta pushes the value away from target.
  82574. * @param current current value
  82575. * @param target target value
  82576. * @param maxDelta max distance to move
  82577. * @returns resulting value
  82578. */
  82579. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82580. /**
  82581. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82582. *
  82583. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82584. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82585. * @param current current value
  82586. * @param target target value
  82587. * @param maxDelta max distance to move
  82588. * @returns resulting angle
  82589. */
  82590. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82591. /**
  82592. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82593. * @param start start value
  82594. * @param end target value
  82595. * @param amount amount to lerp between
  82596. * @returns the lerped value
  82597. */
  82598. static Lerp(start: number, end: number, amount: number): number;
  82599. /**
  82600. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82601. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82602. * @param start start value
  82603. * @param end target value
  82604. * @param amount amount to lerp between
  82605. * @returns the lerped value
  82606. */
  82607. static LerpAngle(start: number, end: number, amount: number): number;
  82608. /**
  82609. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82610. * @param a start value
  82611. * @param b target value
  82612. * @param value value between a and b
  82613. * @returns the inverseLerp value
  82614. */
  82615. static InverseLerp(a: number, b: number, value: number): number;
  82616. /**
  82617. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82618. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82619. * @param value1 spline value
  82620. * @param tangent1 spline value
  82621. * @param value2 spline value
  82622. * @param tangent2 spline value
  82623. * @param amount input value
  82624. * @returns hermite result
  82625. */
  82626. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82627. /**
  82628. * Returns a random float number between and min and max values
  82629. * @param min min value of random
  82630. * @param max max value of random
  82631. * @returns random value
  82632. */
  82633. static RandomRange(min: number, max: number): number;
  82634. /**
  82635. * This function returns percentage of a number in a given range.
  82636. *
  82637. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82638. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82639. * @param number to convert to percentage
  82640. * @param min min range
  82641. * @param max max range
  82642. * @returns the percentage
  82643. */
  82644. static RangeToPercent(number: number, min: number, max: number): number;
  82645. /**
  82646. * This function returns number that corresponds to the percentage in a given range.
  82647. *
  82648. * PercentToRange(0.34,0,100) will return 34.
  82649. * @param percent to convert to number
  82650. * @param min min range
  82651. * @param max max range
  82652. * @returns the number
  82653. */
  82654. static PercentToRange(percent: number, min: number, max: number): number;
  82655. /**
  82656. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82657. * @param angle The angle to normalize in radian.
  82658. * @return The converted angle.
  82659. */
  82660. static NormalizeRadians(angle: number): number;
  82661. }
  82662. }
  82663. declare module BABYLON {
  82664. /**
  82665. * Constant used to convert a value to gamma space
  82666. * @ignorenaming
  82667. */
  82668. export const ToGammaSpace: number;
  82669. /**
  82670. * Constant used to convert a value to linear space
  82671. * @ignorenaming
  82672. */
  82673. export const ToLinearSpace = 2.2;
  82674. /**
  82675. * Constant used to define the minimal number value in Babylon.js
  82676. * @ignorenaming
  82677. */
  82678. let Epsilon: number;
  82679. }
  82680. declare module BABYLON {
  82681. /**
  82682. * Class used to represent a viewport on screen
  82683. */
  82684. export class Viewport {
  82685. /** viewport left coordinate */
  82686. x: number;
  82687. /** viewport top coordinate */
  82688. y: number;
  82689. /**viewport width */
  82690. width: number;
  82691. /** viewport height */
  82692. height: number;
  82693. /**
  82694. * Creates a Viewport object located at (x, y) and sized (width, height)
  82695. * @param x defines viewport left coordinate
  82696. * @param y defines viewport top coordinate
  82697. * @param width defines the viewport width
  82698. * @param height defines the viewport height
  82699. */
  82700. constructor(
  82701. /** viewport left coordinate */
  82702. x: number,
  82703. /** viewport top coordinate */
  82704. y: number,
  82705. /**viewport width */
  82706. width: number,
  82707. /** viewport height */
  82708. height: number);
  82709. /**
  82710. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82711. * @param renderWidth defines the rendering width
  82712. * @param renderHeight defines the rendering height
  82713. * @returns a new Viewport
  82714. */
  82715. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82716. /**
  82717. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82718. * @param renderWidth defines the rendering width
  82719. * @param renderHeight defines the rendering height
  82720. * @param ref defines the target viewport
  82721. * @returns the current viewport
  82722. */
  82723. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82724. /**
  82725. * Returns a new Viewport copied from the current one
  82726. * @returns a new Viewport
  82727. */
  82728. clone(): Viewport;
  82729. }
  82730. }
  82731. declare module BABYLON {
  82732. /**
  82733. * Class containing a set of static utilities functions for arrays.
  82734. */
  82735. export class ArrayTools {
  82736. /**
  82737. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82738. * @param size the number of element to construct and put in the array
  82739. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82740. * @returns a new array filled with new objects
  82741. */
  82742. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82743. }
  82744. }
  82745. declare module BABYLON {
  82746. /**
  82747. * Represents a plane by the equation ax + by + cz + d = 0
  82748. */
  82749. export class Plane {
  82750. private static _TmpMatrix;
  82751. /**
  82752. * Normal of the plane (a,b,c)
  82753. */
  82754. normal: Vector3;
  82755. /**
  82756. * d component of the plane
  82757. */
  82758. d: number;
  82759. /**
  82760. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82761. * @param a a component of the plane
  82762. * @param b b component of the plane
  82763. * @param c c component of the plane
  82764. * @param d d component of the plane
  82765. */
  82766. constructor(a: number, b: number, c: number, d: number);
  82767. /**
  82768. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82769. */
  82770. asArray(): number[];
  82771. /**
  82772. * @returns a new plane copied from the current Plane.
  82773. */
  82774. clone(): Plane;
  82775. /**
  82776. * @returns the string "Plane".
  82777. */
  82778. getClassName(): string;
  82779. /**
  82780. * @returns the Plane hash code.
  82781. */
  82782. getHashCode(): number;
  82783. /**
  82784. * Normalize the current Plane in place.
  82785. * @returns the updated Plane.
  82786. */
  82787. normalize(): Plane;
  82788. /**
  82789. * Applies a transformation the plane and returns the result
  82790. * @param transformation the transformation matrix to be applied to the plane
  82791. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82792. */
  82793. transform(transformation: DeepImmutable<Matrix>): Plane;
  82794. /**
  82795. * Compute the dot product between the point and the plane normal
  82796. * @param point point to calculate the dot product with
  82797. * @returns the dot product (float) of the point coordinates and the plane normal.
  82798. */
  82799. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82800. /**
  82801. * Updates the current Plane from the plane defined by the three given points.
  82802. * @param point1 one of the points used to contruct the plane
  82803. * @param point2 one of the points used to contruct the plane
  82804. * @param point3 one of the points used to contruct the plane
  82805. * @returns the updated Plane.
  82806. */
  82807. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82808. /**
  82809. * Checks if the plane is facing a given direction
  82810. * @param direction the direction to check if the plane is facing
  82811. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82812. * @returns True is the vector "direction" is the same side than the plane normal.
  82813. */
  82814. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82815. /**
  82816. * Calculates the distance to a point
  82817. * @param point point to calculate distance to
  82818. * @returns the signed distance (float) from the given point to the Plane.
  82819. */
  82820. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82821. /**
  82822. * Creates a plane from an array
  82823. * @param array the array to create a plane from
  82824. * @returns a new Plane from the given array.
  82825. */
  82826. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82827. /**
  82828. * Creates a plane from three points
  82829. * @param point1 point used to create the plane
  82830. * @param point2 point used to create the plane
  82831. * @param point3 point used to create the plane
  82832. * @returns a new Plane defined by the three given points.
  82833. */
  82834. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82835. /**
  82836. * Creates a plane from an origin point and a normal
  82837. * @param origin origin of the plane to be constructed
  82838. * @param normal normal of the plane to be constructed
  82839. * @returns a new Plane the normal vector to this plane at the given origin point.
  82840. * Note : the vector "normal" is updated because normalized.
  82841. */
  82842. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82843. /**
  82844. * Calculates the distance from a plane and a point
  82845. * @param origin origin of the plane to be constructed
  82846. * @param normal normal of the plane to be constructed
  82847. * @param point point to calculate distance to
  82848. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82849. */
  82850. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82851. }
  82852. }
  82853. declare module BABYLON {
  82854. /** @hidden */
  82855. export class PerformanceConfigurator {
  82856. /** @hidden */
  82857. static MatrixUse64Bits: boolean;
  82858. /** @hidden */
  82859. static MatrixTrackPrecisionChange: boolean;
  82860. /** @hidden */
  82861. static MatrixCurrentType: any;
  82862. /** @hidden */
  82863. static MatrixTrackedMatrices: Array<any> | null;
  82864. /** @hidden */
  82865. static SetMatrixPrecision(use64bits: boolean): void;
  82866. }
  82867. }
  82868. declare module BABYLON {
  82869. /**
  82870. * Class representing a vector containing 2 coordinates
  82871. */
  82872. export class Vector2 {
  82873. /** defines the first coordinate */
  82874. x: number;
  82875. /** defines the second coordinate */
  82876. y: number;
  82877. /**
  82878. * Creates a new Vector2 from the given x and y coordinates
  82879. * @param x defines the first coordinate
  82880. * @param y defines the second coordinate
  82881. */
  82882. constructor(
  82883. /** defines the first coordinate */
  82884. x?: number,
  82885. /** defines the second coordinate */
  82886. y?: number);
  82887. /**
  82888. * Gets a string with the Vector2 coordinates
  82889. * @returns a string with the Vector2 coordinates
  82890. */
  82891. toString(): string;
  82892. /**
  82893. * Gets class name
  82894. * @returns the string "Vector2"
  82895. */
  82896. getClassName(): string;
  82897. /**
  82898. * Gets current vector hash code
  82899. * @returns the Vector2 hash code as a number
  82900. */
  82901. getHashCode(): number;
  82902. /**
  82903. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82904. * @param array defines the source array
  82905. * @param index defines the offset in source array
  82906. * @returns the current Vector2
  82907. */
  82908. toArray(array: FloatArray, index?: number): Vector2;
  82909. /**
  82910. * Update the current vector from an array
  82911. * @param array defines the destination array
  82912. * @param index defines the offset in the destination array
  82913. * @returns the current Vector3
  82914. */
  82915. fromArray(array: FloatArray, index?: number): Vector2;
  82916. /**
  82917. * Copy the current vector to an array
  82918. * @returns a new array with 2 elements: the Vector2 coordinates.
  82919. */
  82920. asArray(): number[];
  82921. /**
  82922. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82923. * @param source defines the source Vector2
  82924. * @returns the current updated Vector2
  82925. */
  82926. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82927. /**
  82928. * Sets the Vector2 coordinates with the given floats
  82929. * @param x defines the first coordinate
  82930. * @param y defines the second coordinate
  82931. * @returns the current updated Vector2
  82932. */
  82933. copyFromFloats(x: number, y: number): Vector2;
  82934. /**
  82935. * Sets the Vector2 coordinates with the given floats
  82936. * @param x defines the first coordinate
  82937. * @param y defines the second coordinate
  82938. * @returns the current updated Vector2
  82939. */
  82940. set(x: number, y: number): Vector2;
  82941. /**
  82942. * Add another vector with the current one
  82943. * @param otherVector defines the other vector
  82944. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82945. */
  82946. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82947. /**
  82948. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82949. * @param otherVector defines the other vector
  82950. * @param result defines the target vector
  82951. * @returns the unmodified current Vector2
  82952. */
  82953. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82954. /**
  82955. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82956. * @param otherVector defines the other vector
  82957. * @returns the current updated Vector2
  82958. */
  82959. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82960. /**
  82961. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82962. * @param otherVector defines the other vector
  82963. * @returns a new Vector2
  82964. */
  82965. addVector3(otherVector: Vector3): Vector2;
  82966. /**
  82967. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82968. * @param otherVector defines the other vector
  82969. * @returns a new Vector2
  82970. */
  82971. subtract(otherVector: Vector2): Vector2;
  82972. /**
  82973. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82974. * @param otherVector defines the other vector
  82975. * @param result defines the target vector
  82976. * @returns the unmodified current Vector2
  82977. */
  82978. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82979. /**
  82980. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82981. * @param otherVector defines the other vector
  82982. * @returns the current updated Vector2
  82983. */
  82984. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82985. /**
  82986. * Multiplies in place the current Vector2 coordinates by the given ones
  82987. * @param otherVector defines the other vector
  82988. * @returns the current updated Vector2
  82989. */
  82990. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82991. /**
  82992. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82993. * @param otherVector defines the other vector
  82994. * @returns a new Vector2
  82995. */
  82996. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82997. /**
  82998. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82999. * @param otherVector defines the other vector
  83000. * @param result defines the target vector
  83001. * @returns the unmodified current Vector2
  83002. */
  83003. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83004. /**
  83005. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  83006. * @param x defines the first coordinate
  83007. * @param y defines the second coordinate
  83008. * @returns a new Vector2
  83009. */
  83010. multiplyByFloats(x: number, y: number): Vector2;
  83011. /**
  83012. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  83013. * @param otherVector defines the other vector
  83014. * @returns a new Vector2
  83015. */
  83016. divide(otherVector: Vector2): Vector2;
  83017. /**
  83018. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  83019. * @param otherVector defines the other vector
  83020. * @param result defines the target vector
  83021. * @returns the unmodified current Vector2
  83022. */
  83023. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83024. /**
  83025. * Divides the current Vector2 coordinates by the given ones
  83026. * @param otherVector defines the other vector
  83027. * @returns the current updated Vector2
  83028. */
  83029. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83030. /**
  83031. * Gets a new Vector2 with current Vector2 negated coordinates
  83032. * @returns a new Vector2
  83033. */
  83034. negate(): Vector2;
  83035. /**
  83036. * Negate this vector in place
  83037. * @returns this
  83038. */
  83039. negateInPlace(): Vector2;
  83040. /**
  83041. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  83042. * @param result defines the Vector3 object where to store the result
  83043. * @returns the current Vector2
  83044. */
  83045. negateToRef(result: Vector2): Vector2;
  83046. /**
  83047. * Multiply the Vector2 coordinates by scale
  83048. * @param scale defines the scaling factor
  83049. * @returns the current updated Vector2
  83050. */
  83051. scaleInPlace(scale: number): Vector2;
  83052. /**
  83053. * Returns a new Vector2 scaled by "scale" from the current Vector2
  83054. * @param scale defines the scaling factor
  83055. * @returns a new Vector2
  83056. */
  83057. scale(scale: number): Vector2;
  83058. /**
  83059. * Scale the current Vector2 values by a factor to a given Vector2
  83060. * @param scale defines the scale factor
  83061. * @param result defines the Vector2 object where to store the result
  83062. * @returns the unmodified current Vector2
  83063. */
  83064. scaleToRef(scale: number, result: Vector2): Vector2;
  83065. /**
  83066. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  83067. * @param scale defines the scale factor
  83068. * @param result defines the Vector2 object where to store the result
  83069. * @returns the unmodified current Vector2
  83070. */
  83071. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  83072. /**
  83073. * Gets a boolean if two vectors are equals
  83074. * @param otherVector defines the other vector
  83075. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  83076. */
  83077. equals(otherVector: DeepImmutable<Vector2>): boolean;
  83078. /**
  83079. * Gets a boolean if two vectors are equals (using an epsilon value)
  83080. * @param otherVector defines the other vector
  83081. * @param epsilon defines the minimal distance to consider equality
  83082. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  83083. */
  83084. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  83085. /**
  83086. * Gets a new Vector2 from current Vector2 floored values
  83087. * @returns a new Vector2
  83088. */
  83089. floor(): Vector2;
  83090. /**
  83091. * Gets a new Vector2 from current Vector2 floored values
  83092. * @returns a new Vector2
  83093. */
  83094. fract(): Vector2;
  83095. /**
  83096. * Gets the length of the vector
  83097. * @returns the vector length (float)
  83098. */
  83099. length(): number;
  83100. /**
  83101. * Gets the vector squared length
  83102. * @returns the vector squared length (float)
  83103. */
  83104. lengthSquared(): number;
  83105. /**
  83106. * Normalize the vector
  83107. * @returns the current updated Vector2
  83108. */
  83109. normalize(): Vector2;
  83110. /**
  83111. * Gets a new Vector2 copied from the Vector2
  83112. * @returns a new Vector2
  83113. */
  83114. clone(): Vector2;
  83115. /**
  83116. * Gets a new Vector2(0, 0)
  83117. * @returns a new Vector2
  83118. */
  83119. static Zero(): Vector2;
  83120. /**
  83121. * Gets a new Vector2(1, 1)
  83122. * @returns a new Vector2
  83123. */
  83124. static One(): Vector2;
  83125. /**
  83126. * Gets a new Vector2 set from the given index element of the given array
  83127. * @param array defines the data source
  83128. * @param offset defines the offset in the data source
  83129. * @returns a new Vector2
  83130. */
  83131. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  83132. /**
  83133. * Sets "result" from the given index element of the given array
  83134. * @param array defines the data source
  83135. * @param offset defines the offset in the data source
  83136. * @param result defines the target vector
  83137. */
  83138. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  83139. /**
  83140. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  83141. * @param value1 defines 1st point of control
  83142. * @param value2 defines 2nd point of control
  83143. * @param value3 defines 3rd point of control
  83144. * @param value4 defines 4th point of control
  83145. * @param amount defines the interpolation factor
  83146. * @returns a new Vector2
  83147. */
  83148. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  83149. /**
  83150. * 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".
  83151. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  83152. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  83153. * @param value defines the value to clamp
  83154. * @param min defines the lower limit
  83155. * @param max defines the upper limit
  83156. * @returns a new Vector2
  83157. */
  83158. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  83159. /**
  83160. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  83161. * @param value1 defines the 1st control point
  83162. * @param tangent1 defines the outgoing tangent
  83163. * @param value2 defines the 2nd control point
  83164. * @param tangent2 defines the incoming tangent
  83165. * @param amount defines the interpolation factor
  83166. * @returns a new Vector2
  83167. */
  83168. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83169. /**
  83170. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83171. * @param start defines the start vector
  83172. * @param end defines the end vector
  83173. * @param amount defines the interpolation factor
  83174. * @returns a new Vector2
  83175. */
  83176. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83177. /**
  83178. * Gets the dot product of the vector "left" and the vector "right"
  83179. * @param left defines first vector
  83180. * @param right defines second vector
  83181. * @returns the dot product (float)
  83182. */
  83183. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83184. /**
  83185. * Returns a new Vector2 equal to the normalized given vector
  83186. * @param vector defines the vector to normalize
  83187. * @returns a new Vector2
  83188. */
  83189. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83190. /**
  83191. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83192. * @param left defines 1st vector
  83193. * @param right defines 2nd vector
  83194. * @returns a new Vector2
  83195. */
  83196. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83197. /**
  83198. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83199. * @param left defines 1st vector
  83200. * @param right defines 2nd vector
  83201. * @returns a new Vector2
  83202. */
  83203. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83204. /**
  83205. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83206. * @param vector defines the vector to transform
  83207. * @param transformation defines the matrix to apply
  83208. * @returns a new Vector2
  83209. */
  83210. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83211. /**
  83212. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83213. * @param vector defines the vector to transform
  83214. * @param transformation defines the matrix to apply
  83215. * @param result defines the target vector
  83216. */
  83217. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83218. /**
  83219. * Determines if a given vector is included in a triangle
  83220. * @param p defines the vector to test
  83221. * @param p0 defines 1st triangle point
  83222. * @param p1 defines 2nd triangle point
  83223. * @param p2 defines 3rd triangle point
  83224. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83225. */
  83226. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83227. /**
  83228. * Gets the distance between the vectors "value1" and "value2"
  83229. * @param value1 defines first vector
  83230. * @param value2 defines second vector
  83231. * @returns the distance between vectors
  83232. */
  83233. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83234. /**
  83235. * Returns the squared distance between the vectors "value1" and "value2"
  83236. * @param value1 defines first vector
  83237. * @param value2 defines second vector
  83238. * @returns the squared distance between vectors
  83239. */
  83240. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83241. /**
  83242. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83243. * @param value1 defines first vector
  83244. * @param value2 defines second vector
  83245. * @returns a new Vector2
  83246. */
  83247. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83248. /**
  83249. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83250. * @param p defines the middle point
  83251. * @param segA defines one point of the segment
  83252. * @param segB defines the other point of the segment
  83253. * @returns the shortest distance
  83254. */
  83255. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83256. }
  83257. /**
  83258. * Class used to store (x,y,z) vector representation
  83259. * A Vector3 is the main object used in 3D geometry
  83260. * It can represent etiher the coordinates of a point the space, either a direction
  83261. * Reminder: js uses a left handed forward facing system
  83262. */
  83263. export class Vector3 {
  83264. private static _UpReadOnly;
  83265. private static _ZeroReadOnly;
  83266. /** @hidden */
  83267. _x: number;
  83268. /** @hidden */
  83269. _y: number;
  83270. /** @hidden */
  83271. _z: number;
  83272. /** @hidden */
  83273. _isDirty: boolean;
  83274. /** Gets or sets the x coordinate */
  83275. get x(): number;
  83276. set x(value: number);
  83277. /** Gets or sets the y coordinate */
  83278. get y(): number;
  83279. set y(value: number);
  83280. /** Gets or sets the z coordinate */
  83281. get z(): number;
  83282. set z(value: number);
  83283. /**
  83284. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83285. * @param x defines the first coordinates (on X axis)
  83286. * @param y defines the second coordinates (on Y axis)
  83287. * @param z defines the third coordinates (on Z axis)
  83288. */
  83289. constructor(x?: number, y?: number, z?: number);
  83290. /**
  83291. * Creates a string representation of the Vector3
  83292. * @returns a string with the Vector3 coordinates.
  83293. */
  83294. toString(): string;
  83295. /**
  83296. * Gets the class name
  83297. * @returns the string "Vector3"
  83298. */
  83299. getClassName(): string;
  83300. /**
  83301. * Creates the Vector3 hash code
  83302. * @returns a number which tends to be unique between Vector3 instances
  83303. */
  83304. getHashCode(): number;
  83305. /**
  83306. * Creates an array containing three elements : the coordinates of the Vector3
  83307. * @returns a new array of numbers
  83308. */
  83309. asArray(): number[];
  83310. /**
  83311. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83312. * @param array defines the destination array
  83313. * @param index defines the offset in the destination array
  83314. * @returns the current Vector3
  83315. */
  83316. toArray(array: FloatArray, index?: number): Vector3;
  83317. /**
  83318. * Update the current vector from an array
  83319. * @param array defines the destination array
  83320. * @param index defines the offset in the destination array
  83321. * @returns the current Vector3
  83322. */
  83323. fromArray(array: FloatArray, index?: number): Vector3;
  83324. /**
  83325. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83326. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83327. */
  83328. toQuaternion(): Quaternion;
  83329. /**
  83330. * Adds the given vector to the current Vector3
  83331. * @param otherVector defines the second operand
  83332. * @returns the current updated Vector3
  83333. */
  83334. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83335. /**
  83336. * Adds the given coordinates to the current Vector3
  83337. * @param x defines the x coordinate of the operand
  83338. * @param y defines the y coordinate of the operand
  83339. * @param z defines the z coordinate of the operand
  83340. * @returns the current updated Vector3
  83341. */
  83342. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83343. /**
  83344. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83345. * @param otherVector defines the second operand
  83346. * @returns the resulting Vector3
  83347. */
  83348. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83349. /**
  83350. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83351. * @param otherVector defines the second operand
  83352. * @param result defines the Vector3 object where to store the result
  83353. * @returns the current Vector3
  83354. */
  83355. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83356. /**
  83357. * Subtract the given vector from the current Vector3
  83358. * @param otherVector defines the second operand
  83359. * @returns the current updated Vector3
  83360. */
  83361. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83362. /**
  83363. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83364. * @param otherVector defines the second operand
  83365. * @returns the resulting Vector3
  83366. */
  83367. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83368. /**
  83369. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83370. * @param otherVector defines the second operand
  83371. * @param result defines the Vector3 object where to store the result
  83372. * @returns the current Vector3
  83373. */
  83374. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83375. /**
  83376. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83377. * @param x defines the x coordinate of the operand
  83378. * @param y defines the y coordinate of the operand
  83379. * @param z defines the z coordinate of the operand
  83380. * @returns the resulting Vector3
  83381. */
  83382. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83383. /**
  83384. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83385. * @param x defines the x coordinate of the operand
  83386. * @param y defines the y coordinate of the operand
  83387. * @param z defines the z coordinate of the operand
  83388. * @param result defines the Vector3 object where to store the result
  83389. * @returns the current Vector3
  83390. */
  83391. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83392. /**
  83393. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83394. * @returns a new Vector3
  83395. */
  83396. negate(): Vector3;
  83397. /**
  83398. * Negate this vector in place
  83399. * @returns this
  83400. */
  83401. negateInPlace(): Vector3;
  83402. /**
  83403. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83404. * @param result defines the Vector3 object where to store the result
  83405. * @returns the current Vector3
  83406. */
  83407. negateToRef(result: Vector3): Vector3;
  83408. /**
  83409. * Multiplies the Vector3 coordinates by the float "scale"
  83410. * @param scale defines the multiplier factor
  83411. * @returns the current updated Vector3
  83412. */
  83413. scaleInPlace(scale: number): Vector3;
  83414. /**
  83415. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83416. * @param scale defines the multiplier factor
  83417. * @returns a new Vector3
  83418. */
  83419. scale(scale: number): Vector3;
  83420. /**
  83421. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83422. * @param scale defines the multiplier factor
  83423. * @param result defines the Vector3 object where to store the result
  83424. * @returns the current Vector3
  83425. */
  83426. scaleToRef(scale: number, result: Vector3): Vector3;
  83427. /**
  83428. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83429. * @param scale defines the scale factor
  83430. * @param result defines the Vector3 object where to store the result
  83431. * @returns the unmodified current Vector3
  83432. */
  83433. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83434. /**
  83435. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83436. * @param origin defines the origin of the projection ray
  83437. * @param plane defines the plane to project to
  83438. * @returns the projected vector3
  83439. */
  83440. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83441. /**
  83442. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83443. * @param origin defines the origin of the projection ray
  83444. * @param plane defines the plane to project to
  83445. * @param result defines the Vector3 where to store the result
  83446. */
  83447. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83448. /**
  83449. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83450. * @param otherVector defines the second operand
  83451. * @returns true if both vectors are equals
  83452. */
  83453. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83454. /**
  83455. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83456. * @param otherVector defines the second operand
  83457. * @param epsilon defines the minimal distance to define values as equals
  83458. * @returns true if both vectors are distant less than epsilon
  83459. */
  83460. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83461. /**
  83462. * Returns true if the current Vector3 coordinates equals the given floats
  83463. * @param x defines the x coordinate of the operand
  83464. * @param y defines the y coordinate of the operand
  83465. * @param z defines the z coordinate of the operand
  83466. * @returns true if both vectors are equals
  83467. */
  83468. equalsToFloats(x: number, y: number, z: number): boolean;
  83469. /**
  83470. * Multiplies the current Vector3 coordinates by the given ones
  83471. * @param otherVector defines the second operand
  83472. * @returns the current updated Vector3
  83473. */
  83474. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83475. /**
  83476. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83477. * @param otherVector defines the second operand
  83478. * @returns the new Vector3
  83479. */
  83480. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83481. /**
  83482. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83483. * @param otherVector defines the second operand
  83484. * @param result defines the Vector3 object where to store the result
  83485. * @returns the current Vector3
  83486. */
  83487. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83488. /**
  83489. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83490. * @param x defines the x coordinate of the operand
  83491. * @param y defines the y coordinate of the operand
  83492. * @param z defines the z coordinate of the operand
  83493. * @returns the new Vector3
  83494. */
  83495. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83496. /**
  83497. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83498. * @param otherVector defines the second operand
  83499. * @returns the new Vector3
  83500. */
  83501. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83502. /**
  83503. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83504. * @param otherVector defines the second operand
  83505. * @param result defines the Vector3 object where to store the result
  83506. * @returns the current Vector3
  83507. */
  83508. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83509. /**
  83510. * Divides the current Vector3 coordinates by the given ones.
  83511. * @param otherVector defines the second operand
  83512. * @returns the current updated Vector3
  83513. */
  83514. divideInPlace(otherVector: Vector3): Vector3;
  83515. /**
  83516. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83517. * @param other defines the second operand
  83518. * @returns the current updated Vector3
  83519. */
  83520. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83521. /**
  83522. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83523. * @param other defines the second operand
  83524. * @returns the current updated Vector3
  83525. */
  83526. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83527. /**
  83528. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83529. * @param x defines the x coordinate of the operand
  83530. * @param y defines the y coordinate of the operand
  83531. * @param z defines the z coordinate of the operand
  83532. * @returns the current updated Vector3
  83533. */
  83534. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83535. /**
  83536. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83537. * @param x defines the x coordinate of the operand
  83538. * @param y defines the y coordinate of the operand
  83539. * @param z defines the z coordinate of the operand
  83540. * @returns the current updated Vector3
  83541. */
  83542. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83543. /**
  83544. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83545. * Check if is non uniform within a certain amount of decimal places to account for this
  83546. * @param epsilon the amount the values can differ
  83547. * @returns if the the vector is non uniform to a certain number of decimal places
  83548. */
  83549. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83550. /**
  83551. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83552. */
  83553. get isNonUniform(): boolean;
  83554. /**
  83555. * Gets a new Vector3 from current Vector3 floored values
  83556. * @returns a new Vector3
  83557. */
  83558. floor(): Vector3;
  83559. /**
  83560. * Gets a new Vector3 from current Vector3 floored values
  83561. * @returns a new Vector3
  83562. */
  83563. fract(): Vector3;
  83564. /**
  83565. * Gets the length of the Vector3
  83566. * @returns the length of the Vector3
  83567. */
  83568. length(): number;
  83569. /**
  83570. * Gets the squared length of the Vector3
  83571. * @returns squared length of the Vector3
  83572. */
  83573. lengthSquared(): number;
  83574. /**
  83575. * Normalize the current Vector3.
  83576. * Please note that this is an in place operation.
  83577. * @returns the current updated Vector3
  83578. */
  83579. normalize(): Vector3;
  83580. /**
  83581. * Reorders the x y z properties of the vector in place
  83582. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83583. * @returns the current updated vector
  83584. */
  83585. reorderInPlace(order: string): this;
  83586. /**
  83587. * Rotates the vector around 0,0,0 by a quaternion
  83588. * @param quaternion the rotation quaternion
  83589. * @param result vector to store the result
  83590. * @returns the resulting vector
  83591. */
  83592. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83593. /**
  83594. * Rotates a vector around a given point
  83595. * @param quaternion the rotation quaternion
  83596. * @param point the point to rotate around
  83597. * @param result vector to store the result
  83598. * @returns the resulting vector
  83599. */
  83600. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83601. /**
  83602. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83603. * The cross product is then orthogonal to both current and "other"
  83604. * @param other defines the right operand
  83605. * @returns the cross product
  83606. */
  83607. cross(other: Vector3): Vector3;
  83608. /**
  83609. * Normalize the current Vector3 with the given input length.
  83610. * Please note that this is an in place operation.
  83611. * @param len the length of the vector
  83612. * @returns the current updated Vector3
  83613. */
  83614. normalizeFromLength(len: number): Vector3;
  83615. /**
  83616. * Normalize the current Vector3 to a new vector
  83617. * @returns the new Vector3
  83618. */
  83619. normalizeToNew(): Vector3;
  83620. /**
  83621. * Normalize the current Vector3 to the reference
  83622. * @param reference define the Vector3 to update
  83623. * @returns the updated Vector3
  83624. */
  83625. normalizeToRef(reference: Vector3): Vector3;
  83626. /**
  83627. * Creates a new Vector3 copied from the current Vector3
  83628. * @returns the new Vector3
  83629. */
  83630. clone(): Vector3;
  83631. /**
  83632. * Copies the given vector coordinates to the current Vector3 ones
  83633. * @param source defines the source Vector3
  83634. * @returns the current updated Vector3
  83635. */
  83636. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83637. /**
  83638. * Copies the given floats to the current Vector3 coordinates
  83639. * @param x defines the x coordinate of the operand
  83640. * @param y defines the y coordinate of the operand
  83641. * @param z defines the z coordinate of the operand
  83642. * @returns the current updated Vector3
  83643. */
  83644. copyFromFloats(x: number, y: number, z: number): Vector3;
  83645. /**
  83646. * Copies the given floats to the current Vector3 coordinates
  83647. * @param x defines the x coordinate of the operand
  83648. * @param y defines the y coordinate of the operand
  83649. * @param z defines the z coordinate of the operand
  83650. * @returns the current updated Vector3
  83651. */
  83652. set(x: number, y: number, z: number): Vector3;
  83653. /**
  83654. * Copies the given float to the current Vector3 coordinates
  83655. * @param v defines the x, y and z coordinates of the operand
  83656. * @returns the current updated Vector3
  83657. */
  83658. setAll(v: number): Vector3;
  83659. /**
  83660. * Get the clip factor between two vectors
  83661. * @param vector0 defines the first operand
  83662. * @param vector1 defines the second operand
  83663. * @param axis defines the axis to use
  83664. * @param size defines the size along the axis
  83665. * @returns the clip factor
  83666. */
  83667. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83668. /**
  83669. * Get angle between two vectors
  83670. * @param vector0 angle between vector0 and vector1
  83671. * @param vector1 angle between vector0 and vector1
  83672. * @param normal direction of the normal
  83673. * @return the angle between vector0 and vector1
  83674. */
  83675. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83676. /**
  83677. * Returns a new Vector3 set from the index "offset" of the given array
  83678. * @param array defines the source array
  83679. * @param offset defines the offset in the source array
  83680. * @returns the new Vector3
  83681. */
  83682. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83683. /**
  83684. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83685. * @param array defines the source array
  83686. * @param offset defines the offset in the source array
  83687. * @returns the new Vector3
  83688. * @deprecated Please use FromArray instead.
  83689. */
  83690. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83691. /**
  83692. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83693. * @param array defines the source array
  83694. * @param offset defines the offset in the source array
  83695. * @param result defines the Vector3 where to store the result
  83696. */
  83697. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83698. /**
  83699. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83700. * @param array defines the source array
  83701. * @param offset defines the offset in the source array
  83702. * @param result defines the Vector3 where to store the result
  83703. * @deprecated Please use FromArrayToRef instead.
  83704. */
  83705. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83706. /**
  83707. * Sets the given vector "result" with the given floats.
  83708. * @param x defines the x coordinate of the source
  83709. * @param y defines the y coordinate of the source
  83710. * @param z defines the z coordinate of the source
  83711. * @param result defines the Vector3 where to store the result
  83712. */
  83713. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83714. /**
  83715. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83716. * @returns a new empty Vector3
  83717. */
  83718. static Zero(): Vector3;
  83719. /**
  83720. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83721. * @returns a new unit Vector3
  83722. */
  83723. static One(): Vector3;
  83724. /**
  83725. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83726. * @returns a new up Vector3
  83727. */
  83728. static Up(): Vector3;
  83729. /**
  83730. * Gets a up Vector3 that must not be updated
  83731. */
  83732. static get UpReadOnly(): DeepImmutable<Vector3>;
  83733. /**
  83734. * Gets a zero Vector3 that must not be updated
  83735. */
  83736. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83737. /**
  83738. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83739. * @returns a new down Vector3
  83740. */
  83741. static Down(): Vector3;
  83742. /**
  83743. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83744. * @param rightHandedSystem is the scene right-handed (negative z)
  83745. * @returns a new forward Vector3
  83746. */
  83747. static Forward(rightHandedSystem?: boolean): Vector3;
  83748. /**
  83749. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83750. * @param rightHandedSystem is the scene right-handed (negative-z)
  83751. * @returns a new forward Vector3
  83752. */
  83753. static Backward(rightHandedSystem?: boolean): Vector3;
  83754. /**
  83755. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83756. * @returns a new right Vector3
  83757. */
  83758. static Right(): Vector3;
  83759. /**
  83760. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83761. * @returns a new left Vector3
  83762. */
  83763. static Left(): Vector3;
  83764. /**
  83765. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83766. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83767. * @param vector defines the Vector3 to transform
  83768. * @param transformation defines the transformation matrix
  83769. * @returns the transformed Vector3
  83770. */
  83771. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83772. /**
  83773. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83774. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83775. * @param vector defines the Vector3 to transform
  83776. * @param transformation defines the transformation matrix
  83777. * @param result defines the Vector3 where to store the result
  83778. */
  83779. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83780. /**
  83781. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83782. * This method computes tranformed coordinates only, not transformed direction vectors
  83783. * @param x define the x coordinate of the source vector
  83784. * @param y define the y coordinate of the source vector
  83785. * @param z define the z coordinate of the source vector
  83786. * @param transformation defines the transformation matrix
  83787. * @param result defines the Vector3 where to store the result
  83788. */
  83789. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83790. /**
  83791. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83792. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83793. * @param vector defines the Vector3 to transform
  83794. * @param transformation defines the transformation matrix
  83795. * @returns the new Vector3
  83796. */
  83797. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83798. /**
  83799. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83800. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83801. * @param vector defines the Vector3 to transform
  83802. * @param transformation defines the transformation matrix
  83803. * @param result defines the Vector3 where to store the result
  83804. */
  83805. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83806. /**
  83807. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83808. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83809. * @param x define the x coordinate of the source vector
  83810. * @param y define the y coordinate of the source vector
  83811. * @param z define the z coordinate of the source vector
  83812. * @param transformation defines the transformation matrix
  83813. * @param result defines the Vector3 where to store the result
  83814. */
  83815. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83816. /**
  83817. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83818. * @param value1 defines the first control point
  83819. * @param value2 defines the second control point
  83820. * @param value3 defines the third control point
  83821. * @param value4 defines the fourth control point
  83822. * @param amount defines the amount on the spline to use
  83823. * @returns the new Vector3
  83824. */
  83825. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83826. /**
  83827. * 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"
  83828. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83829. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83830. * @param value defines the current value
  83831. * @param min defines the lower range value
  83832. * @param max defines the upper range value
  83833. * @returns the new Vector3
  83834. */
  83835. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83836. /**
  83837. * 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"
  83838. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83839. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83840. * @param value defines the current value
  83841. * @param min defines the lower range value
  83842. * @param max defines the upper range value
  83843. * @param result defines the Vector3 where to store the result
  83844. */
  83845. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83846. /**
  83847. * Checks if a given vector is inside a specific range
  83848. * @param v defines the vector to test
  83849. * @param min defines the minimum range
  83850. * @param max defines the maximum range
  83851. */
  83852. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83853. /**
  83854. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83855. * @param value1 defines the first control point
  83856. * @param tangent1 defines the first tangent vector
  83857. * @param value2 defines the second control point
  83858. * @param tangent2 defines the second tangent vector
  83859. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83860. * @returns the new Vector3
  83861. */
  83862. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83863. /**
  83864. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83865. * @param start defines the start value
  83866. * @param end defines the end value
  83867. * @param amount max defines amount between both (between 0 and 1)
  83868. * @returns the new Vector3
  83869. */
  83870. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83871. /**
  83872. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83873. * @param start defines the start value
  83874. * @param end defines the end value
  83875. * @param amount max defines amount between both (between 0 and 1)
  83876. * @param result defines the Vector3 where to store the result
  83877. */
  83878. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83879. /**
  83880. * Returns the dot product (float) between the vectors "left" and "right"
  83881. * @param left defines the left operand
  83882. * @param right defines the right operand
  83883. * @returns the dot product
  83884. */
  83885. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83886. /**
  83887. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83888. * The cross product is then orthogonal to both "left" and "right"
  83889. * @param left defines the left operand
  83890. * @param right defines the right operand
  83891. * @returns the cross product
  83892. */
  83893. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83894. /**
  83895. * Sets the given vector "result" with the cross product of "left" and "right"
  83896. * The cross product is then orthogonal to both "left" and "right"
  83897. * @param left defines the left operand
  83898. * @param right defines the right operand
  83899. * @param result defines the Vector3 where to store the result
  83900. */
  83901. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83902. /**
  83903. * Returns a new Vector3 as the normalization of the given vector
  83904. * @param vector defines the Vector3 to normalize
  83905. * @returns the new Vector3
  83906. */
  83907. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83908. /**
  83909. * Sets the given vector "result" with the normalization of the given first vector
  83910. * @param vector defines the Vector3 to normalize
  83911. * @param result defines the Vector3 where to store the result
  83912. */
  83913. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83914. /**
  83915. * Project a Vector3 onto screen space
  83916. * @param vector defines the Vector3 to project
  83917. * @param world defines the world matrix to use
  83918. * @param transform defines the transform (view x projection) matrix to use
  83919. * @param viewport defines the screen viewport to use
  83920. * @returns the new Vector3
  83921. */
  83922. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83923. /**
  83924. * Project a Vector3 onto screen space to reference
  83925. * @param vector defines the Vector3 to project
  83926. * @param world defines the world matrix to use
  83927. * @param transform defines the transform (view x projection) matrix to use
  83928. * @param viewport defines the screen viewport to use
  83929. * @param result the vector in which the screen space will be stored
  83930. * @returns the new Vector3
  83931. */
  83932. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  83933. /** @hidden */
  83934. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83935. /**
  83936. * Unproject from screen space to object space
  83937. * @param source defines the screen space Vector3 to use
  83938. * @param viewportWidth defines the current width of the viewport
  83939. * @param viewportHeight defines the current height of the viewport
  83940. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83941. * @param transform defines the transform (view x projection) matrix to use
  83942. * @returns the new Vector3
  83943. */
  83944. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83945. /**
  83946. * Unproject from screen space to object space
  83947. * @param source defines the screen space Vector3 to use
  83948. * @param viewportWidth defines the current width of the viewport
  83949. * @param viewportHeight defines the current height of the viewport
  83950. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83951. * @param view defines the view matrix to use
  83952. * @param projection defines the projection matrix to use
  83953. * @returns the new Vector3
  83954. */
  83955. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83956. /**
  83957. * Unproject from screen space to object space
  83958. * @param source defines the screen space Vector3 to use
  83959. * @param viewportWidth defines the current width of the viewport
  83960. * @param viewportHeight defines the current height of the viewport
  83961. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83962. * @param view defines the view matrix to use
  83963. * @param projection defines the projection matrix to use
  83964. * @param result defines the Vector3 where to store the result
  83965. */
  83966. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83967. /**
  83968. * Unproject from screen space to object space
  83969. * @param sourceX defines the screen space x coordinate to use
  83970. * @param sourceY defines the screen space y coordinate to use
  83971. * @param sourceZ defines the screen space z coordinate to use
  83972. * @param viewportWidth defines the current width of the viewport
  83973. * @param viewportHeight defines the current height of the viewport
  83974. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83975. * @param view defines the view matrix to use
  83976. * @param projection defines the projection matrix to use
  83977. * @param result defines the Vector3 where to store the result
  83978. */
  83979. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83980. /**
  83981. * Gets the minimal coordinate values between two Vector3
  83982. * @param left defines the first operand
  83983. * @param right defines the second operand
  83984. * @returns the new Vector3
  83985. */
  83986. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83987. /**
  83988. * Gets the maximal coordinate values between two Vector3
  83989. * @param left defines the first operand
  83990. * @param right defines the second operand
  83991. * @returns the new Vector3
  83992. */
  83993. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83994. /**
  83995. * Returns the distance between the vectors "value1" and "value2"
  83996. * @param value1 defines the first operand
  83997. * @param value2 defines the second operand
  83998. * @returns the distance
  83999. */
  84000. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84001. /**
  84002. * Returns the squared distance between the vectors "value1" and "value2"
  84003. * @param value1 defines the first operand
  84004. * @param value2 defines the second operand
  84005. * @returns the squared distance
  84006. */
  84007. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84008. /**
  84009. * Returns a new Vector3 located at the center between "value1" and "value2"
  84010. * @param value1 defines the first operand
  84011. * @param value2 defines the second operand
  84012. * @returns the new Vector3
  84013. */
  84014. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  84015. /**
  84016. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  84017. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  84018. * to something in order to rotate it from its local system to the given target system
  84019. * Note: axis1, axis2 and axis3 are normalized during this operation
  84020. * @param axis1 defines the first axis
  84021. * @param axis2 defines the second axis
  84022. * @param axis3 defines the third axis
  84023. * @returns a new Vector3
  84024. */
  84025. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  84026. /**
  84027. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  84028. * @param axis1 defines the first axis
  84029. * @param axis2 defines the second axis
  84030. * @param axis3 defines the third axis
  84031. * @param ref defines the Vector3 where to store the result
  84032. */
  84033. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  84034. }
  84035. /**
  84036. * Vector4 class created for EulerAngle class conversion to Quaternion
  84037. */
  84038. export class Vector4 {
  84039. /** x value of the vector */
  84040. x: number;
  84041. /** y value of the vector */
  84042. y: number;
  84043. /** z value of the vector */
  84044. z: number;
  84045. /** w value of the vector */
  84046. w: number;
  84047. /**
  84048. * Creates a Vector4 object from the given floats.
  84049. * @param x x value of the vector
  84050. * @param y y value of the vector
  84051. * @param z z value of the vector
  84052. * @param w w value of the vector
  84053. */
  84054. constructor(
  84055. /** x value of the vector */
  84056. x: number,
  84057. /** y value of the vector */
  84058. y: number,
  84059. /** z value of the vector */
  84060. z: number,
  84061. /** w value of the vector */
  84062. w: number);
  84063. /**
  84064. * Returns the string with the Vector4 coordinates.
  84065. * @returns a string containing all the vector values
  84066. */
  84067. toString(): string;
  84068. /**
  84069. * Returns the string "Vector4".
  84070. * @returns "Vector4"
  84071. */
  84072. getClassName(): string;
  84073. /**
  84074. * Returns the Vector4 hash code.
  84075. * @returns a unique hash code
  84076. */
  84077. getHashCode(): number;
  84078. /**
  84079. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  84080. * @returns the resulting array
  84081. */
  84082. asArray(): number[];
  84083. /**
  84084. * Populates the given array from the given index with the Vector4 coordinates.
  84085. * @param array array to populate
  84086. * @param index index of the array to start at (default: 0)
  84087. * @returns the Vector4.
  84088. */
  84089. toArray(array: FloatArray, index?: number): Vector4;
  84090. /**
  84091. * Update the current vector from an array
  84092. * @param array defines the destination array
  84093. * @param index defines the offset in the destination array
  84094. * @returns the current Vector3
  84095. */
  84096. fromArray(array: FloatArray, index?: number): Vector4;
  84097. /**
  84098. * Adds the given vector to the current Vector4.
  84099. * @param otherVector the vector to add
  84100. * @returns the updated Vector4.
  84101. */
  84102. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84103. /**
  84104. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  84105. * @param otherVector the vector to add
  84106. * @returns the resulting vector
  84107. */
  84108. add(otherVector: DeepImmutable<Vector4>): Vector4;
  84109. /**
  84110. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  84111. * @param otherVector the vector to add
  84112. * @param result the vector to store the result
  84113. * @returns the current Vector4.
  84114. */
  84115. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84116. /**
  84117. * Subtract in place the given vector from the current Vector4.
  84118. * @param otherVector the vector to subtract
  84119. * @returns the updated Vector4.
  84120. */
  84121. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84122. /**
  84123. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  84124. * @param otherVector the vector to add
  84125. * @returns the new vector with the result
  84126. */
  84127. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  84128. /**
  84129. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  84130. * @param otherVector the vector to subtract
  84131. * @param result the vector to store the result
  84132. * @returns the current Vector4.
  84133. */
  84134. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84135. /**
  84136. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84137. */
  84138. /**
  84139. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84140. * @param x value to subtract
  84141. * @param y value to subtract
  84142. * @param z value to subtract
  84143. * @param w value to subtract
  84144. * @returns new vector containing the result
  84145. */
  84146. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84147. /**
  84148. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84149. * @param x value to subtract
  84150. * @param y value to subtract
  84151. * @param z value to subtract
  84152. * @param w value to subtract
  84153. * @param result the vector to store the result in
  84154. * @returns the current Vector4.
  84155. */
  84156. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  84157. /**
  84158. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  84159. * @returns a new vector with the negated values
  84160. */
  84161. negate(): Vector4;
  84162. /**
  84163. * Negate this vector in place
  84164. * @returns this
  84165. */
  84166. negateInPlace(): Vector4;
  84167. /**
  84168. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  84169. * @param result defines the Vector3 object where to store the result
  84170. * @returns the current Vector4
  84171. */
  84172. negateToRef(result: Vector4): Vector4;
  84173. /**
  84174. * Multiplies the current Vector4 coordinates by scale (float).
  84175. * @param scale the number to scale with
  84176. * @returns the updated Vector4.
  84177. */
  84178. scaleInPlace(scale: number): Vector4;
  84179. /**
  84180. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84181. * @param scale the number to scale with
  84182. * @returns a new vector with the result
  84183. */
  84184. scale(scale: number): Vector4;
  84185. /**
  84186. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84187. * @param scale the number to scale with
  84188. * @param result a vector to store the result in
  84189. * @returns the current Vector4.
  84190. */
  84191. scaleToRef(scale: number, result: Vector4): Vector4;
  84192. /**
  84193. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84194. * @param scale defines the scale factor
  84195. * @param result defines the Vector4 object where to store the result
  84196. * @returns the unmodified current Vector4
  84197. */
  84198. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84199. /**
  84200. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84201. * @param otherVector the vector to compare against
  84202. * @returns true if they are equal
  84203. */
  84204. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84205. /**
  84206. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84207. * @param otherVector vector to compare against
  84208. * @param epsilon (Default: very small number)
  84209. * @returns true if they are equal
  84210. */
  84211. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84212. /**
  84213. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84214. * @param x x value to compare against
  84215. * @param y y value to compare against
  84216. * @param z z value to compare against
  84217. * @param w w value to compare against
  84218. * @returns true if equal
  84219. */
  84220. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84221. /**
  84222. * Multiplies in place the current Vector4 by the given one.
  84223. * @param otherVector vector to multiple with
  84224. * @returns the updated Vector4.
  84225. */
  84226. multiplyInPlace(otherVector: Vector4): Vector4;
  84227. /**
  84228. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84229. * @param otherVector vector to multiple with
  84230. * @returns resulting new vector
  84231. */
  84232. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84233. /**
  84234. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84235. * @param otherVector vector to multiple with
  84236. * @param result vector to store the result
  84237. * @returns the current Vector4.
  84238. */
  84239. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84240. /**
  84241. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84242. * @param x x value multiply with
  84243. * @param y y value multiply with
  84244. * @param z z value multiply with
  84245. * @param w w value multiply with
  84246. * @returns resulting new vector
  84247. */
  84248. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84249. /**
  84250. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84251. * @param otherVector vector to devide with
  84252. * @returns resulting new vector
  84253. */
  84254. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84255. /**
  84256. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84257. * @param otherVector vector to devide with
  84258. * @param result vector to store the result
  84259. * @returns the current Vector4.
  84260. */
  84261. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84262. /**
  84263. * Divides the current Vector3 coordinates by the given ones.
  84264. * @param otherVector vector to devide with
  84265. * @returns the updated Vector3.
  84266. */
  84267. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84268. /**
  84269. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84270. * @param other defines the second operand
  84271. * @returns the current updated Vector4
  84272. */
  84273. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84274. /**
  84275. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84276. * @param other defines the second operand
  84277. * @returns the current updated Vector4
  84278. */
  84279. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84280. /**
  84281. * Gets a new Vector4 from current Vector4 floored values
  84282. * @returns a new Vector4
  84283. */
  84284. floor(): Vector4;
  84285. /**
  84286. * Gets a new Vector4 from current Vector3 floored values
  84287. * @returns a new Vector4
  84288. */
  84289. fract(): Vector4;
  84290. /**
  84291. * Returns the Vector4 length (float).
  84292. * @returns the length
  84293. */
  84294. length(): number;
  84295. /**
  84296. * Returns the Vector4 squared length (float).
  84297. * @returns the length squared
  84298. */
  84299. lengthSquared(): number;
  84300. /**
  84301. * Normalizes in place the Vector4.
  84302. * @returns the updated Vector4.
  84303. */
  84304. normalize(): Vector4;
  84305. /**
  84306. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84307. * @returns this converted to a new vector3
  84308. */
  84309. toVector3(): Vector3;
  84310. /**
  84311. * Returns a new Vector4 copied from the current one.
  84312. * @returns the new cloned vector
  84313. */
  84314. clone(): Vector4;
  84315. /**
  84316. * Updates the current Vector4 with the given one coordinates.
  84317. * @param source the source vector to copy from
  84318. * @returns the updated Vector4.
  84319. */
  84320. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84321. /**
  84322. * Updates the current Vector4 coordinates with the given floats.
  84323. * @param x float to copy from
  84324. * @param y float to copy from
  84325. * @param z float to copy from
  84326. * @param w float to copy from
  84327. * @returns the updated Vector4.
  84328. */
  84329. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84330. /**
  84331. * Updates the current Vector4 coordinates with the given floats.
  84332. * @param x float to set from
  84333. * @param y float to set from
  84334. * @param z float to set from
  84335. * @param w float to set from
  84336. * @returns the updated Vector4.
  84337. */
  84338. set(x: number, y: number, z: number, w: number): Vector4;
  84339. /**
  84340. * Copies the given float to the current Vector3 coordinates
  84341. * @param v defines the x, y, z and w coordinates of the operand
  84342. * @returns the current updated Vector3
  84343. */
  84344. setAll(v: number): Vector4;
  84345. /**
  84346. * Returns a new Vector4 set from the starting index of the given array.
  84347. * @param array the array to pull values from
  84348. * @param offset the offset into the array to start at
  84349. * @returns the new vector
  84350. */
  84351. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84352. /**
  84353. * Updates the given vector "result" from the starting index of the given array.
  84354. * @param array the array to pull values from
  84355. * @param offset the offset into the array to start at
  84356. * @param result the vector to store the result in
  84357. */
  84358. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84359. /**
  84360. * Updates the given vector "result" from the starting index of the given Float32Array.
  84361. * @param array the array to pull values from
  84362. * @param offset the offset into the array to start at
  84363. * @param result the vector to store the result in
  84364. */
  84365. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84366. /**
  84367. * Updates the given vector "result" coordinates from the given floats.
  84368. * @param x float to set from
  84369. * @param y float to set from
  84370. * @param z float to set from
  84371. * @param w float to set from
  84372. * @param result the vector to the floats in
  84373. */
  84374. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84375. /**
  84376. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84377. * @returns the new vector
  84378. */
  84379. static Zero(): Vector4;
  84380. /**
  84381. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84382. * @returns the new vector
  84383. */
  84384. static One(): Vector4;
  84385. /**
  84386. * Returns a new normalized Vector4 from the given one.
  84387. * @param vector the vector to normalize
  84388. * @returns the vector
  84389. */
  84390. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84391. /**
  84392. * Updates the given vector "result" from the normalization of the given one.
  84393. * @param vector the vector to normalize
  84394. * @param result the vector to store the result in
  84395. */
  84396. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84397. /**
  84398. * Returns a vector with the minimum values from the left and right vectors
  84399. * @param left left vector to minimize
  84400. * @param right right vector to minimize
  84401. * @returns a new vector with the minimum of the left and right vector values
  84402. */
  84403. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84404. /**
  84405. * Returns a vector with the maximum values from the left and right vectors
  84406. * @param left left vector to maximize
  84407. * @param right right vector to maximize
  84408. * @returns a new vector with the maximum of the left and right vector values
  84409. */
  84410. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84411. /**
  84412. * Returns the distance (float) between the vectors "value1" and "value2".
  84413. * @param value1 value to calulate the distance between
  84414. * @param value2 value to calulate the distance between
  84415. * @return the distance between the two vectors
  84416. */
  84417. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84418. /**
  84419. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84420. * @param value1 value to calulate the distance between
  84421. * @param value2 value to calulate the distance between
  84422. * @return the distance between the two vectors squared
  84423. */
  84424. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84425. /**
  84426. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84427. * @param value1 value to calulate the center between
  84428. * @param value2 value to calulate the center between
  84429. * @return the center between the two vectors
  84430. */
  84431. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84432. /**
  84433. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84434. * This methods computes transformed normalized direction vectors only.
  84435. * @param vector the vector to transform
  84436. * @param transformation the transformation matrix to apply
  84437. * @returns the new vector
  84438. */
  84439. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84440. /**
  84441. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84442. * This methods computes transformed normalized direction vectors only.
  84443. * @param vector the vector to transform
  84444. * @param transformation the transformation matrix to apply
  84445. * @param result the vector to store the result in
  84446. */
  84447. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84448. /**
  84449. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84450. * This methods computes transformed normalized direction vectors only.
  84451. * @param x value to transform
  84452. * @param y value to transform
  84453. * @param z value to transform
  84454. * @param w value to transform
  84455. * @param transformation the transformation matrix to apply
  84456. * @param result the vector to store the results in
  84457. */
  84458. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84459. /**
  84460. * Creates a new Vector4 from a Vector3
  84461. * @param source defines the source data
  84462. * @param w defines the 4th component (default is 0)
  84463. * @returns a new Vector4
  84464. */
  84465. static FromVector3(source: Vector3, w?: number): Vector4;
  84466. }
  84467. /**
  84468. * Class used to store quaternion data
  84469. * @see https://en.wikipedia.org/wiki/Quaternion
  84470. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84471. */
  84472. export class Quaternion {
  84473. /** @hidden */
  84474. _x: number;
  84475. /** @hidden */
  84476. _y: number;
  84477. /** @hidden */
  84478. _z: number;
  84479. /** @hidden */
  84480. _w: number;
  84481. /** @hidden */
  84482. _isDirty: boolean;
  84483. /** Gets or sets the x coordinate */
  84484. get x(): number;
  84485. set x(value: number);
  84486. /** Gets or sets the y coordinate */
  84487. get y(): number;
  84488. set y(value: number);
  84489. /** Gets or sets the z coordinate */
  84490. get z(): number;
  84491. set z(value: number);
  84492. /** Gets or sets the w coordinate */
  84493. get w(): number;
  84494. set w(value: number);
  84495. /**
  84496. * Creates a new Quaternion from the given floats
  84497. * @param x defines the first component (0 by default)
  84498. * @param y defines the second component (0 by default)
  84499. * @param z defines the third component (0 by default)
  84500. * @param w defines the fourth component (1.0 by default)
  84501. */
  84502. constructor(x?: number, y?: number, z?: number, w?: number);
  84503. /**
  84504. * Gets a string representation for the current quaternion
  84505. * @returns a string with the Quaternion coordinates
  84506. */
  84507. toString(): string;
  84508. /**
  84509. * Gets the class name of the quaternion
  84510. * @returns the string "Quaternion"
  84511. */
  84512. getClassName(): string;
  84513. /**
  84514. * Gets a hash code for this quaternion
  84515. * @returns the quaternion hash code
  84516. */
  84517. getHashCode(): number;
  84518. /**
  84519. * Copy the quaternion to an array
  84520. * @returns a new array populated with 4 elements from the quaternion coordinates
  84521. */
  84522. asArray(): number[];
  84523. /**
  84524. * Check if two quaternions are equals
  84525. * @param otherQuaternion defines the second operand
  84526. * @return true if the current quaternion and the given one coordinates are strictly equals
  84527. */
  84528. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84529. /**
  84530. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84531. * @param otherQuaternion defines the other quaternion
  84532. * @param epsilon defines the minimal distance to consider equality
  84533. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84534. */
  84535. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84536. /**
  84537. * Clone the current quaternion
  84538. * @returns a new quaternion copied from the current one
  84539. */
  84540. clone(): Quaternion;
  84541. /**
  84542. * Copy a quaternion to the current one
  84543. * @param other defines the other quaternion
  84544. * @returns the updated current quaternion
  84545. */
  84546. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84547. /**
  84548. * Updates the current quaternion with the given float coordinates
  84549. * @param x defines the x coordinate
  84550. * @param y defines the y coordinate
  84551. * @param z defines the z coordinate
  84552. * @param w defines the w coordinate
  84553. * @returns the updated current quaternion
  84554. */
  84555. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84556. /**
  84557. * Updates the current quaternion from the given float coordinates
  84558. * @param x defines the x coordinate
  84559. * @param y defines the y coordinate
  84560. * @param z defines the z coordinate
  84561. * @param w defines the w coordinate
  84562. * @returns the updated current quaternion
  84563. */
  84564. set(x: number, y: number, z: number, w: number): Quaternion;
  84565. /**
  84566. * Adds two quaternions
  84567. * @param other defines the second operand
  84568. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84569. */
  84570. add(other: DeepImmutable<Quaternion>): Quaternion;
  84571. /**
  84572. * Add a quaternion to the current one
  84573. * @param other defines the quaternion to add
  84574. * @returns the current quaternion
  84575. */
  84576. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84577. /**
  84578. * Subtract two quaternions
  84579. * @param other defines the second operand
  84580. * @returns a new quaternion as the subtraction result of the given one from the current one
  84581. */
  84582. subtract(other: Quaternion): Quaternion;
  84583. /**
  84584. * Multiplies the current quaternion by a scale factor
  84585. * @param value defines the scale factor
  84586. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84587. */
  84588. scale(value: number): Quaternion;
  84589. /**
  84590. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84591. * @param scale defines the scale factor
  84592. * @param result defines the Quaternion object where to store the result
  84593. * @returns the unmodified current quaternion
  84594. */
  84595. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84596. /**
  84597. * Multiplies in place the current quaternion by a scale factor
  84598. * @param value defines the scale factor
  84599. * @returns the current modified quaternion
  84600. */
  84601. scaleInPlace(value: number): Quaternion;
  84602. /**
  84603. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84604. * @param scale defines the scale factor
  84605. * @param result defines the Quaternion object where to store the result
  84606. * @returns the unmodified current quaternion
  84607. */
  84608. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84609. /**
  84610. * Multiplies two quaternions
  84611. * @param q1 defines the second operand
  84612. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84613. */
  84614. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84615. /**
  84616. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84617. * @param q1 defines the second operand
  84618. * @param result defines the target quaternion
  84619. * @returns the current quaternion
  84620. */
  84621. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84622. /**
  84623. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84624. * @param q1 defines the second operand
  84625. * @returns the currentupdated quaternion
  84626. */
  84627. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84628. /**
  84629. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84630. * @param ref defines the target quaternion
  84631. * @returns the current quaternion
  84632. */
  84633. conjugateToRef(ref: Quaternion): Quaternion;
  84634. /**
  84635. * Conjugates in place (1-q) the current quaternion
  84636. * @returns the current updated quaternion
  84637. */
  84638. conjugateInPlace(): Quaternion;
  84639. /**
  84640. * Conjugates in place (1-q) the current quaternion
  84641. * @returns a new quaternion
  84642. */
  84643. conjugate(): Quaternion;
  84644. /**
  84645. * Gets length of current quaternion
  84646. * @returns the quaternion length (float)
  84647. */
  84648. length(): number;
  84649. /**
  84650. * Normalize in place the current quaternion
  84651. * @returns the current updated quaternion
  84652. */
  84653. normalize(): Quaternion;
  84654. /**
  84655. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84656. * @param order is a reserved parameter and is ignored for now
  84657. * @returns a new Vector3 containing the Euler angles
  84658. */
  84659. toEulerAngles(order?: string): Vector3;
  84660. /**
  84661. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84662. * @param result defines the vector which will be filled with the Euler angles
  84663. * @returns the current unchanged quaternion
  84664. */
  84665. toEulerAnglesToRef(result: Vector3): Quaternion;
  84666. /**
  84667. * Updates the given rotation matrix with the current quaternion values
  84668. * @param result defines the target matrix
  84669. * @returns the current unchanged quaternion
  84670. */
  84671. toRotationMatrix(result: Matrix): Quaternion;
  84672. /**
  84673. * Updates the current quaternion from the given rotation matrix values
  84674. * @param matrix defines the source matrix
  84675. * @returns the current updated quaternion
  84676. */
  84677. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84678. /**
  84679. * Creates a new quaternion from a rotation matrix
  84680. * @param matrix defines the source matrix
  84681. * @returns a new quaternion created from the given rotation matrix values
  84682. */
  84683. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84684. /**
  84685. * Updates the given quaternion with the given rotation matrix values
  84686. * @param matrix defines the source matrix
  84687. * @param result defines the target quaternion
  84688. */
  84689. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84690. /**
  84691. * Returns the dot product (float) between the quaternions "left" and "right"
  84692. * @param left defines the left operand
  84693. * @param right defines the right operand
  84694. * @returns the dot product
  84695. */
  84696. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84697. /**
  84698. * Checks if the two quaternions are close to each other
  84699. * @param quat0 defines the first quaternion to check
  84700. * @param quat1 defines the second quaternion to check
  84701. * @returns true if the two quaternions are close to each other
  84702. */
  84703. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84704. /**
  84705. * Creates an empty quaternion
  84706. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84707. */
  84708. static Zero(): Quaternion;
  84709. /**
  84710. * Inverse a given quaternion
  84711. * @param q defines the source quaternion
  84712. * @returns a new quaternion as the inverted current quaternion
  84713. */
  84714. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84715. /**
  84716. * Inverse a given quaternion
  84717. * @param q defines the source quaternion
  84718. * @param result the quaternion the result will be stored in
  84719. * @returns the result quaternion
  84720. */
  84721. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84722. /**
  84723. * Creates an identity quaternion
  84724. * @returns the identity quaternion
  84725. */
  84726. static Identity(): Quaternion;
  84727. /**
  84728. * Gets a boolean indicating if the given quaternion is identity
  84729. * @param quaternion defines the quaternion to check
  84730. * @returns true if the quaternion is identity
  84731. */
  84732. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84733. /**
  84734. * Creates a quaternion from a rotation around an axis
  84735. * @param axis defines the axis to use
  84736. * @param angle defines the angle to use
  84737. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84738. */
  84739. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84740. /**
  84741. * Creates a rotation around an axis and stores it into the given quaternion
  84742. * @param axis defines the axis to use
  84743. * @param angle defines the angle to use
  84744. * @param result defines the target quaternion
  84745. * @returns the target quaternion
  84746. */
  84747. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84748. /**
  84749. * Creates a new quaternion from data stored into an array
  84750. * @param array defines the data source
  84751. * @param offset defines the offset in the source array where the data starts
  84752. * @returns a new quaternion
  84753. */
  84754. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84755. /**
  84756. * Updates the given quaternion "result" from the starting index of the given array.
  84757. * @param array the array to pull values from
  84758. * @param offset the offset into the array to start at
  84759. * @param result the quaternion to store the result in
  84760. */
  84761. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84762. /**
  84763. * Create a quaternion from Euler rotation angles
  84764. * @param x Pitch
  84765. * @param y Yaw
  84766. * @param z Roll
  84767. * @returns the new Quaternion
  84768. */
  84769. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84770. /**
  84771. * Updates a quaternion from Euler rotation angles
  84772. * @param x Pitch
  84773. * @param y Yaw
  84774. * @param z Roll
  84775. * @param result the quaternion to store the result
  84776. * @returns the updated quaternion
  84777. */
  84778. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84779. /**
  84780. * Create a quaternion from Euler rotation vector
  84781. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84782. * @returns the new Quaternion
  84783. */
  84784. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84785. /**
  84786. * Updates a quaternion from Euler rotation vector
  84787. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84788. * @param result the quaternion to store the result
  84789. * @returns the updated quaternion
  84790. */
  84791. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84792. /**
  84793. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84794. * @param yaw defines the rotation around Y axis
  84795. * @param pitch defines the rotation around X axis
  84796. * @param roll defines the rotation around Z axis
  84797. * @returns the new quaternion
  84798. */
  84799. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84800. /**
  84801. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84802. * @param yaw defines the rotation around Y axis
  84803. * @param pitch defines the rotation around X axis
  84804. * @param roll defines the rotation around Z axis
  84805. * @param result defines the target quaternion
  84806. */
  84807. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84808. /**
  84809. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84810. * @param alpha defines the rotation around first axis
  84811. * @param beta defines the rotation around second axis
  84812. * @param gamma defines the rotation around third axis
  84813. * @returns the new quaternion
  84814. */
  84815. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84816. /**
  84817. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84818. * @param alpha defines the rotation around first axis
  84819. * @param beta defines the rotation around second axis
  84820. * @param gamma defines the rotation around third axis
  84821. * @param result defines the target quaternion
  84822. */
  84823. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84824. /**
  84825. * 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)
  84826. * @param axis1 defines the first axis
  84827. * @param axis2 defines the second axis
  84828. * @param axis3 defines the third axis
  84829. * @returns the new quaternion
  84830. */
  84831. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84832. /**
  84833. * 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
  84834. * @param axis1 defines the first axis
  84835. * @param axis2 defines the second axis
  84836. * @param axis3 defines the third axis
  84837. * @param ref defines the target quaternion
  84838. */
  84839. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84840. /**
  84841. * Interpolates between two quaternions
  84842. * @param left defines first quaternion
  84843. * @param right defines second quaternion
  84844. * @param amount defines the gradient to use
  84845. * @returns the new interpolated quaternion
  84846. */
  84847. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84848. /**
  84849. * Interpolates between two quaternions and stores it into a target quaternion
  84850. * @param left defines first quaternion
  84851. * @param right defines second quaternion
  84852. * @param amount defines the gradient to use
  84853. * @param result defines the target quaternion
  84854. */
  84855. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84856. /**
  84857. * Interpolate between two quaternions using Hermite interpolation
  84858. * @param value1 defines first quaternion
  84859. * @param tangent1 defines the incoming tangent
  84860. * @param value2 defines second quaternion
  84861. * @param tangent2 defines the outgoing tangent
  84862. * @param amount defines the target quaternion
  84863. * @returns the new interpolated quaternion
  84864. */
  84865. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84866. }
  84867. /**
  84868. * Class used to store matrix data (4x4)
  84869. */
  84870. export class Matrix {
  84871. /**
  84872. * Gets the precision of matrix computations
  84873. */
  84874. static get Use64Bits(): boolean;
  84875. private static _updateFlagSeed;
  84876. private static _identityReadOnly;
  84877. private _isIdentity;
  84878. private _isIdentityDirty;
  84879. private _isIdentity3x2;
  84880. private _isIdentity3x2Dirty;
  84881. /**
  84882. * Gets the update flag of the matrix which is an unique number for the matrix.
  84883. * It will be incremented every time the matrix data change.
  84884. * You can use it to speed the comparison between two versions of the same matrix.
  84885. */
  84886. updateFlag: number;
  84887. private readonly _m;
  84888. /**
  84889. * Gets the internal data of the matrix
  84890. */
  84891. get m(): DeepImmutable<Float32Array | Array<number>>;
  84892. /** @hidden */
  84893. _markAsUpdated(): void;
  84894. /** @hidden */
  84895. private _updateIdentityStatus;
  84896. /**
  84897. * Creates an empty matrix (filled with zeros)
  84898. */
  84899. constructor();
  84900. /**
  84901. * Check if the current matrix is identity
  84902. * @returns true is the matrix is the identity matrix
  84903. */
  84904. isIdentity(): boolean;
  84905. /**
  84906. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84907. * @returns true is the matrix is the identity matrix
  84908. */
  84909. isIdentityAs3x2(): boolean;
  84910. /**
  84911. * Gets the determinant of the matrix
  84912. * @returns the matrix determinant
  84913. */
  84914. determinant(): number;
  84915. /**
  84916. * Returns the matrix as a Float32Array or Array<number>
  84917. * @returns the matrix underlying array
  84918. */
  84919. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84920. /**
  84921. * Returns the matrix as a Float32Array or Array<number>
  84922. * @returns the matrix underlying array.
  84923. */
  84924. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84925. /**
  84926. * Inverts the current matrix in place
  84927. * @returns the current inverted matrix
  84928. */
  84929. invert(): Matrix;
  84930. /**
  84931. * Sets all the matrix elements to zero
  84932. * @returns the current matrix
  84933. */
  84934. reset(): Matrix;
  84935. /**
  84936. * Adds the current matrix with a second one
  84937. * @param other defines the matrix to add
  84938. * @returns a new matrix as the addition of the current matrix and the given one
  84939. */
  84940. add(other: DeepImmutable<Matrix>): Matrix;
  84941. /**
  84942. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84943. * @param other defines the matrix to add
  84944. * @param result defines the target matrix
  84945. * @returns the current matrix
  84946. */
  84947. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84948. /**
  84949. * Adds in place the given matrix to the current matrix
  84950. * @param other defines the second operand
  84951. * @returns the current updated matrix
  84952. */
  84953. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84954. /**
  84955. * Sets the given matrix to the current inverted Matrix
  84956. * @param other defines the target matrix
  84957. * @returns the unmodified current matrix
  84958. */
  84959. invertToRef(other: Matrix): Matrix;
  84960. /**
  84961. * add a value at the specified position in the current Matrix
  84962. * @param index the index of the value within the matrix. between 0 and 15.
  84963. * @param value the value to be added
  84964. * @returns the current updated matrix
  84965. */
  84966. addAtIndex(index: number, value: number): Matrix;
  84967. /**
  84968. * mutiply the specified position in the current Matrix by a value
  84969. * @param index the index of the value within the matrix. between 0 and 15.
  84970. * @param value the value to be added
  84971. * @returns the current updated matrix
  84972. */
  84973. multiplyAtIndex(index: number, value: number): Matrix;
  84974. /**
  84975. * Inserts the translation vector (using 3 floats) in the current matrix
  84976. * @param x defines the 1st component of the translation
  84977. * @param y defines the 2nd component of the translation
  84978. * @param z defines the 3rd component of the translation
  84979. * @returns the current updated matrix
  84980. */
  84981. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84982. /**
  84983. * Adds the translation vector (using 3 floats) in the current matrix
  84984. * @param x defines the 1st component of the translation
  84985. * @param y defines the 2nd component of the translation
  84986. * @param z defines the 3rd component of the translation
  84987. * @returns the current updated matrix
  84988. */
  84989. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84990. /**
  84991. * Inserts the translation vector in the current matrix
  84992. * @param vector3 defines the translation to insert
  84993. * @returns the current updated matrix
  84994. */
  84995. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84996. /**
  84997. * Gets the translation value of the current matrix
  84998. * @returns a new Vector3 as the extracted translation from the matrix
  84999. */
  85000. getTranslation(): Vector3;
  85001. /**
  85002. * Fill a Vector3 with the extracted translation from the matrix
  85003. * @param result defines the Vector3 where to store the translation
  85004. * @returns the current matrix
  85005. */
  85006. getTranslationToRef(result: Vector3): Matrix;
  85007. /**
  85008. * Remove rotation and scaling part from the matrix
  85009. * @returns the updated matrix
  85010. */
  85011. removeRotationAndScaling(): Matrix;
  85012. /**
  85013. * Multiply two matrices
  85014. * @param other defines the second operand
  85015. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  85016. */
  85017. multiply(other: DeepImmutable<Matrix>): Matrix;
  85018. /**
  85019. * Copy the current matrix from the given one
  85020. * @param other defines the source matrix
  85021. * @returns the current updated matrix
  85022. */
  85023. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  85024. /**
  85025. * Populates the given array from the starting index with the current matrix values
  85026. * @param array defines the target array
  85027. * @param offset defines the offset in the target array where to start storing values
  85028. * @returns the current matrix
  85029. */
  85030. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  85031. /**
  85032. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  85033. * @param other defines the second operand
  85034. * @param result defines the matrix where to store the multiplication
  85035. * @returns the current matrix
  85036. */
  85037. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85038. /**
  85039. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  85040. * @param other defines the second operand
  85041. * @param result defines the array where to store the multiplication
  85042. * @param offset defines the offset in the target array where to start storing values
  85043. * @returns the current matrix
  85044. */
  85045. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  85046. /**
  85047. * Check equality between this matrix and a second one
  85048. * @param value defines the second matrix to compare
  85049. * @returns true is the current matrix and the given one values are strictly equal
  85050. */
  85051. equals(value: DeepImmutable<Matrix>): boolean;
  85052. /**
  85053. * Clone the current matrix
  85054. * @returns a new matrix from the current matrix
  85055. */
  85056. clone(): Matrix;
  85057. /**
  85058. * Returns the name of the current matrix class
  85059. * @returns the string "Matrix"
  85060. */
  85061. getClassName(): string;
  85062. /**
  85063. * Gets the hash code of the current matrix
  85064. * @returns the hash code
  85065. */
  85066. getHashCode(): number;
  85067. /**
  85068. * Decomposes the current Matrix into a translation, rotation and scaling components
  85069. * @param scale defines the scale vector3 given as a reference to update
  85070. * @param rotation defines the rotation quaternion given as a reference to update
  85071. * @param translation defines the translation vector3 given as a reference to update
  85072. * @returns true if operation was successful
  85073. */
  85074. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  85075. /**
  85076. * Gets specific row of the matrix
  85077. * @param index defines the number of the row to get
  85078. * @returns the index-th row of the current matrix as a new Vector4
  85079. */
  85080. getRow(index: number): Nullable<Vector4>;
  85081. /**
  85082. * Sets the index-th row of the current matrix to the vector4 values
  85083. * @param index defines the number of the row to set
  85084. * @param row defines the target vector4
  85085. * @returns the updated current matrix
  85086. */
  85087. setRow(index: number, row: Vector4): Matrix;
  85088. /**
  85089. * Compute the transpose of the matrix
  85090. * @returns the new transposed matrix
  85091. */
  85092. transpose(): Matrix;
  85093. /**
  85094. * Compute the transpose of the matrix and store it in a given matrix
  85095. * @param result defines the target matrix
  85096. * @returns the current matrix
  85097. */
  85098. transposeToRef(result: Matrix): Matrix;
  85099. /**
  85100. * Sets the index-th row of the current matrix with the given 4 x float values
  85101. * @param index defines the row index
  85102. * @param x defines the x component to set
  85103. * @param y defines the y component to set
  85104. * @param z defines the z component to set
  85105. * @param w defines the w component to set
  85106. * @returns the updated current matrix
  85107. */
  85108. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  85109. /**
  85110. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  85111. * @param scale defines the scale factor
  85112. * @returns a new matrix
  85113. */
  85114. scale(scale: number): Matrix;
  85115. /**
  85116. * Scale the current matrix values by a factor to a given result matrix
  85117. * @param scale defines the scale factor
  85118. * @param result defines the matrix to store the result
  85119. * @returns the current matrix
  85120. */
  85121. scaleToRef(scale: number, result: Matrix): Matrix;
  85122. /**
  85123. * Scale the current matrix values by a factor and add the result to a given matrix
  85124. * @param scale defines the scale factor
  85125. * @param result defines the Matrix to store the result
  85126. * @returns the current matrix
  85127. */
  85128. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  85129. /**
  85130. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  85131. * @param ref matrix to store the result
  85132. */
  85133. toNormalMatrix(ref: Matrix): void;
  85134. /**
  85135. * Gets only rotation part of the current matrix
  85136. * @returns a new matrix sets to the extracted rotation matrix from the current one
  85137. */
  85138. getRotationMatrix(): Matrix;
  85139. /**
  85140. * Extracts the rotation matrix from the current one and sets it as the given "result"
  85141. * @param result defines the target matrix to store data to
  85142. * @returns the current matrix
  85143. */
  85144. getRotationMatrixToRef(result: Matrix): Matrix;
  85145. /**
  85146. * Toggles model matrix from being right handed to left handed in place and vice versa
  85147. */
  85148. toggleModelMatrixHandInPlace(): void;
  85149. /**
  85150. * Toggles projection matrix from being right handed to left handed in place and vice versa
  85151. */
  85152. toggleProjectionMatrixHandInPlace(): void;
  85153. /**
  85154. * Creates a matrix from an array
  85155. * @param array defines the source array
  85156. * @param offset defines an offset in the source array
  85157. * @returns a new Matrix set from the starting index of the given array
  85158. */
  85159. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  85160. /**
  85161. * Copy the content of an array into a given matrix
  85162. * @param array defines the source array
  85163. * @param offset defines an offset in the source array
  85164. * @param result defines the target matrix
  85165. */
  85166. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  85167. /**
  85168. * Stores an array into a matrix after having multiplied each component by a given factor
  85169. * @param array defines the source array
  85170. * @param offset defines the offset in the source array
  85171. * @param scale defines the scaling factor
  85172. * @param result defines the target matrix
  85173. */
  85174. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  85175. /**
  85176. * Gets an identity matrix that must not be updated
  85177. */
  85178. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85179. /**
  85180. * Stores a list of values (16) inside a given matrix
  85181. * @param initialM11 defines 1st value of 1st row
  85182. * @param initialM12 defines 2nd value of 1st row
  85183. * @param initialM13 defines 3rd value of 1st row
  85184. * @param initialM14 defines 4th value of 1st row
  85185. * @param initialM21 defines 1st value of 2nd row
  85186. * @param initialM22 defines 2nd value of 2nd row
  85187. * @param initialM23 defines 3rd value of 2nd row
  85188. * @param initialM24 defines 4th value of 2nd row
  85189. * @param initialM31 defines 1st value of 3rd row
  85190. * @param initialM32 defines 2nd value of 3rd row
  85191. * @param initialM33 defines 3rd value of 3rd row
  85192. * @param initialM34 defines 4th value of 3rd row
  85193. * @param initialM41 defines 1st value of 4th row
  85194. * @param initialM42 defines 2nd value of 4th row
  85195. * @param initialM43 defines 3rd value of 4th row
  85196. * @param initialM44 defines 4th value of 4th row
  85197. * @param result defines the target matrix
  85198. */
  85199. 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;
  85200. /**
  85201. * Creates new matrix from a list of values (16)
  85202. * @param initialM11 defines 1st value of 1st row
  85203. * @param initialM12 defines 2nd value of 1st row
  85204. * @param initialM13 defines 3rd value of 1st row
  85205. * @param initialM14 defines 4th value of 1st row
  85206. * @param initialM21 defines 1st value of 2nd row
  85207. * @param initialM22 defines 2nd value of 2nd row
  85208. * @param initialM23 defines 3rd value of 2nd row
  85209. * @param initialM24 defines 4th value of 2nd row
  85210. * @param initialM31 defines 1st value of 3rd row
  85211. * @param initialM32 defines 2nd value of 3rd row
  85212. * @param initialM33 defines 3rd value of 3rd row
  85213. * @param initialM34 defines 4th value of 3rd row
  85214. * @param initialM41 defines 1st value of 4th row
  85215. * @param initialM42 defines 2nd value of 4th row
  85216. * @param initialM43 defines 3rd value of 4th row
  85217. * @param initialM44 defines 4th value of 4th row
  85218. * @returns the new matrix
  85219. */
  85220. 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;
  85221. /**
  85222. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85223. * @param scale defines the scale vector3
  85224. * @param rotation defines the rotation quaternion
  85225. * @param translation defines the translation vector3
  85226. * @returns a new matrix
  85227. */
  85228. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85229. /**
  85230. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85231. * @param scale defines the scale vector3
  85232. * @param rotation defines the rotation quaternion
  85233. * @param translation defines the translation vector3
  85234. * @param result defines the target matrix
  85235. */
  85236. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85237. /**
  85238. * Creates a new identity matrix
  85239. * @returns a new identity matrix
  85240. */
  85241. static Identity(): Matrix;
  85242. /**
  85243. * Creates a new identity matrix and stores the result in a given matrix
  85244. * @param result defines the target matrix
  85245. */
  85246. static IdentityToRef(result: Matrix): void;
  85247. /**
  85248. * Creates a new zero matrix
  85249. * @returns a new zero matrix
  85250. */
  85251. static Zero(): Matrix;
  85252. /**
  85253. * Creates a new rotation matrix for "angle" radians around the X axis
  85254. * @param angle defines the angle (in radians) to use
  85255. * @return the new matrix
  85256. */
  85257. static RotationX(angle: number): Matrix;
  85258. /**
  85259. * Creates a new matrix as the invert of a given matrix
  85260. * @param source defines the source matrix
  85261. * @returns the new matrix
  85262. */
  85263. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85264. /**
  85265. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85266. * @param angle defines the angle (in radians) to use
  85267. * @param result defines the target matrix
  85268. */
  85269. static RotationXToRef(angle: number, result: Matrix): void;
  85270. /**
  85271. * Creates a new rotation matrix for "angle" radians around the Y axis
  85272. * @param angle defines the angle (in radians) to use
  85273. * @return the new matrix
  85274. */
  85275. static RotationY(angle: number): Matrix;
  85276. /**
  85277. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85278. * @param angle defines the angle (in radians) to use
  85279. * @param result defines the target matrix
  85280. */
  85281. static RotationYToRef(angle: number, result: Matrix): void;
  85282. /**
  85283. * Creates a new rotation matrix for "angle" radians around the Z axis
  85284. * @param angle defines the angle (in radians) to use
  85285. * @return the new matrix
  85286. */
  85287. static RotationZ(angle: number): Matrix;
  85288. /**
  85289. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85290. * @param angle defines the angle (in radians) to use
  85291. * @param result defines the target matrix
  85292. */
  85293. static RotationZToRef(angle: number, result: Matrix): void;
  85294. /**
  85295. * Creates a new rotation matrix for "angle" radians around the given axis
  85296. * @param axis defines the axis to use
  85297. * @param angle defines the angle (in radians) to use
  85298. * @return the new matrix
  85299. */
  85300. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85301. /**
  85302. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85303. * @param axis defines the axis to use
  85304. * @param angle defines the angle (in radians) to use
  85305. * @param result defines the target matrix
  85306. */
  85307. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85308. /**
  85309. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85310. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85311. * @param from defines the vector to align
  85312. * @param to defines the vector to align to
  85313. * @param result defines the target matrix
  85314. */
  85315. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85316. /**
  85317. * Creates a rotation matrix
  85318. * @param yaw defines the yaw angle in radians (Y axis)
  85319. * @param pitch defines the pitch angle in radians (X axis)
  85320. * @param roll defines the roll angle in radians (Z axis)
  85321. * @returns the new rotation matrix
  85322. */
  85323. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85324. /**
  85325. * Creates a rotation matrix and stores it in a given matrix
  85326. * @param yaw defines the yaw angle in radians (Y axis)
  85327. * @param pitch defines the pitch angle in radians (X axis)
  85328. * @param roll defines the roll angle in radians (Z axis)
  85329. * @param result defines the target matrix
  85330. */
  85331. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85332. /**
  85333. * Creates a scaling matrix
  85334. * @param x defines the scale factor on X axis
  85335. * @param y defines the scale factor on Y axis
  85336. * @param z defines the scale factor on Z axis
  85337. * @returns the new matrix
  85338. */
  85339. static Scaling(x: number, y: number, z: number): Matrix;
  85340. /**
  85341. * Creates a scaling matrix and stores it in a given matrix
  85342. * @param x defines the scale factor on X axis
  85343. * @param y defines the scale factor on Y axis
  85344. * @param z defines the scale factor on Z axis
  85345. * @param result defines the target matrix
  85346. */
  85347. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85348. /**
  85349. * Creates a translation matrix
  85350. * @param x defines the translation on X axis
  85351. * @param y defines the translation on Y axis
  85352. * @param z defines the translationon Z axis
  85353. * @returns the new matrix
  85354. */
  85355. static Translation(x: number, y: number, z: number): Matrix;
  85356. /**
  85357. * Creates a translation matrix and stores it in a given matrix
  85358. * @param x defines the translation on X axis
  85359. * @param y defines the translation on Y axis
  85360. * @param z defines the translationon Z axis
  85361. * @param result defines the target matrix
  85362. */
  85363. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85364. /**
  85365. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85366. * @param startValue defines the start value
  85367. * @param endValue defines the end value
  85368. * @param gradient defines the gradient factor
  85369. * @returns the new matrix
  85370. */
  85371. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85372. /**
  85373. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85374. * @param startValue defines the start value
  85375. * @param endValue defines the end value
  85376. * @param gradient defines the gradient factor
  85377. * @param result defines the Matrix object where to store data
  85378. */
  85379. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85380. /**
  85381. * Builds a new matrix whose values are computed by:
  85382. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85383. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85384. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85385. * @param startValue defines the first matrix
  85386. * @param endValue defines the second matrix
  85387. * @param gradient defines the gradient between the two matrices
  85388. * @returns the new matrix
  85389. */
  85390. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85391. /**
  85392. * Update a matrix to values which are computed by:
  85393. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85394. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85395. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85396. * @param startValue defines the first matrix
  85397. * @param endValue defines the second matrix
  85398. * @param gradient defines the gradient between the two matrices
  85399. * @param result defines the target matrix
  85400. */
  85401. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85402. /**
  85403. * 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"
  85404. * This function works in left handed mode
  85405. * @param eye defines the final position of the entity
  85406. * @param target defines where the entity should look at
  85407. * @param up defines the up vector for the entity
  85408. * @returns the new matrix
  85409. */
  85410. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85411. /**
  85412. * 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".
  85413. * This function works in left handed mode
  85414. * @param eye defines the final position of the entity
  85415. * @param target defines where the entity should look at
  85416. * @param up defines the up vector for the entity
  85417. * @param result defines the target matrix
  85418. */
  85419. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85420. /**
  85421. * 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"
  85422. * This function works in right handed mode
  85423. * @param eye defines the final position of the entity
  85424. * @param target defines where the entity should look at
  85425. * @param up defines the up vector for the entity
  85426. * @returns the new matrix
  85427. */
  85428. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85429. /**
  85430. * 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".
  85431. * This function works in right handed mode
  85432. * @param eye defines the final position of the entity
  85433. * @param target defines where the entity should look at
  85434. * @param up defines the up vector for the entity
  85435. * @param result defines the target matrix
  85436. */
  85437. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85438. /**
  85439. * Create a left-handed orthographic projection matrix
  85440. * @param width defines the viewport width
  85441. * @param height defines the viewport height
  85442. * @param znear defines the near clip plane
  85443. * @param zfar defines the far clip plane
  85444. * @returns a new matrix as a left-handed orthographic projection matrix
  85445. */
  85446. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85447. /**
  85448. * Store a left-handed orthographic projection to a given matrix
  85449. * @param width defines the viewport width
  85450. * @param height defines the viewport height
  85451. * @param znear defines the near clip plane
  85452. * @param zfar defines the far clip plane
  85453. * @param result defines the target matrix
  85454. */
  85455. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85456. /**
  85457. * Create a left-handed orthographic projection matrix
  85458. * @param left defines the viewport left coordinate
  85459. * @param right defines the viewport right coordinate
  85460. * @param bottom defines the viewport bottom coordinate
  85461. * @param top defines the viewport top coordinate
  85462. * @param znear defines the near clip plane
  85463. * @param zfar defines the far clip plane
  85464. * @returns a new matrix as a left-handed orthographic projection matrix
  85465. */
  85466. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85467. /**
  85468. * Stores a left-handed orthographic projection into a given matrix
  85469. * @param left defines the viewport left coordinate
  85470. * @param right defines the viewport right coordinate
  85471. * @param bottom defines the viewport bottom coordinate
  85472. * @param top defines the viewport top coordinate
  85473. * @param znear defines the near clip plane
  85474. * @param zfar defines the far clip plane
  85475. * @param result defines the target matrix
  85476. */
  85477. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85478. /**
  85479. * Creates a right-handed orthographic projection matrix
  85480. * @param left defines the viewport left coordinate
  85481. * @param right defines the viewport right coordinate
  85482. * @param bottom defines the viewport bottom coordinate
  85483. * @param top defines the viewport top coordinate
  85484. * @param znear defines the near clip plane
  85485. * @param zfar defines the far clip plane
  85486. * @returns a new matrix as a right-handed orthographic projection matrix
  85487. */
  85488. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85489. /**
  85490. * Stores a right-handed orthographic projection into a given matrix
  85491. * @param left defines the viewport left coordinate
  85492. * @param right defines the viewport right coordinate
  85493. * @param bottom defines the viewport bottom coordinate
  85494. * @param top defines the viewport top coordinate
  85495. * @param znear defines the near clip plane
  85496. * @param zfar defines the far clip plane
  85497. * @param result defines the target matrix
  85498. */
  85499. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85500. /**
  85501. * Creates a left-handed perspective projection matrix
  85502. * @param width defines the viewport width
  85503. * @param height defines the viewport height
  85504. * @param znear defines the near clip plane
  85505. * @param zfar defines the far clip plane
  85506. * @returns a new matrix as a left-handed perspective projection matrix
  85507. */
  85508. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85509. /**
  85510. * Creates a left-handed perspective projection matrix
  85511. * @param fov defines the horizontal field of view
  85512. * @param aspect defines the aspect ratio
  85513. * @param znear defines the near clip plane
  85514. * @param zfar defines the far clip plane
  85515. * @returns a new matrix as a left-handed perspective projection matrix
  85516. */
  85517. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85518. /**
  85519. * Stores a left-handed perspective projection into a given matrix
  85520. * @param fov defines the horizontal field of view
  85521. * @param aspect defines the aspect ratio
  85522. * @param znear defines the near clip plane
  85523. * @param zfar defines the far clip plane
  85524. * @param result defines the target matrix
  85525. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85526. */
  85527. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85528. /**
  85529. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85530. * @param fov defines the horizontal field of view
  85531. * @param aspect defines the aspect ratio
  85532. * @param znear defines the near clip plane
  85533. * @param zfar not used as infinity is used as far clip
  85534. * @param result defines the target matrix
  85535. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85536. */
  85537. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85538. /**
  85539. * Creates a right-handed perspective projection matrix
  85540. * @param fov defines the horizontal field of view
  85541. * @param aspect defines the aspect ratio
  85542. * @param znear defines the near clip plane
  85543. * @param zfar defines the far clip plane
  85544. * @returns a new matrix as a right-handed perspective projection matrix
  85545. */
  85546. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85547. /**
  85548. * Stores a right-handed perspective projection into a given matrix
  85549. * @param fov defines the horizontal field of view
  85550. * @param aspect defines the aspect ratio
  85551. * @param znear defines the near clip plane
  85552. * @param zfar defines the far clip plane
  85553. * @param result defines the target matrix
  85554. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85555. */
  85556. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85557. /**
  85558. * Stores a right-handed perspective projection into a given matrix
  85559. * @param fov defines the horizontal field of view
  85560. * @param aspect defines the aspect ratio
  85561. * @param znear defines the near clip plane
  85562. * @param zfar not used as infinity is used as far clip
  85563. * @param result defines the target matrix
  85564. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85565. */
  85566. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85567. /**
  85568. * Stores a perspective projection for WebVR info a given matrix
  85569. * @param fov defines the field of view
  85570. * @param znear defines the near clip plane
  85571. * @param zfar defines the far clip plane
  85572. * @param result defines the target matrix
  85573. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85574. */
  85575. static PerspectiveFovWebVRToRef(fov: {
  85576. upDegrees: number;
  85577. downDegrees: number;
  85578. leftDegrees: number;
  85579. rightDegrees: number;
  85580. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85581. /**
  85582. * Computes a complete transformation matrix
  85583. * @param viewport defines the viewport to use
  85584. * @param world defines the world matrix
  85585. * @param view defines the view matrix
  85586. * @param projection defines the projection matrix
  85587. * @param zmin defines the near clip plane
  85588. * @param zmax defines the far clip plane
  85589. * @returns the transformation matrix
  85590. */
  85591. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85592. /**
  85593. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85594. * @param matrix defines the matrix to use
  85595. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85596. */
  85597. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85598. /**
  85599. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85600. * @param matrix defines the matrix to use
  85601. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85602. */
  85603. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85604. /**
  85605. * Compute the transpose of a given matrix
  85606. * @param matrix defines the matrix to transpose
  85607. * @returns the new matrix
  85608. */
  85609. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85610. /**
  85611. * Compute the transpose of a matrix and store it in a target matrix
  85612. * @param matrix defines the matrix to transpose
  85613. * @param result defines the target matrix
  85614. */
  85615. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85616. /**
  85617. * Computes a reflection matrix from a plane
  85618. * @param plane defines the reflection plane
  85619. * @returns a new matrix
  85620. */
  85621. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85622. /**
  85623. * Computes a reflection matrix from a plane
  85624. * @param plane defines the reflection plane
  85625. * @param result defines the target matrix
  85626. */
  85627. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85628. /**
  85629. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85630. * @param xaxis defines the value of the 1st axis
  85631. * @param yaxis defines the value of the 2nd axis
  85632. * @param zaxis defines the value of the 3rd axis
  85633. * @param result defines the target matrix
  85634. */
  85635. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85636. /**
  85637. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85638. * @param quat defines the quaternion to use
  85639. * @param result defines the target matrix
  85640. */
  85641. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85642. }
  85643. /**
  85644. * @hidden
  85645. */
  85646. export class TmpVectors {
  85647. static Vector2: Vector2[];
  85648. static Vector3: Vector3[];
  85649. static Vector4: Vector4[];
  85650. static Quaternion: Quaternion[];
  85651. static Matrix: Matrix[];
  85652. }
  85653. }
  85654. declare module BABYLON {
  85655. /**
  85656. * Defines potential orientation for back face culling
  85657. */
  85658. export enum Orientation {
  85659. /**
  85660. * Clockwise
  85661. */
  85662. CW = 0,
  85663. /** Counter clockwise */
  85664. CCW = 1
  85665. }
  85666. /** Class used to represent a Bezier curve */
  85667. export class BezierCurve {
  85668. /**
  85669. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85670. * @param t defines the time
  85671. * @param x1 defines the left coordinate on X axis
  85672. * @param y1 defines the left coordinate on Y axis
  85673. * @param x2 defines the right coordinate on X axis
  85674. * @param y2 defines the right coordinate on Y axis
  85675. * @returns the interpolated value
  85676. */
  85677. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85678. }
  85679. /**
  85680. * Defines angle representation
  85681. */
  85682. export class Angle {
  85683. private _radians;
  85684. /**
  85685. * Creates an Angle object of "radians" radians (float).
  85686. * @param radians the angle in radians
  85687. */
  85688. constructor(radians: number);
  85689. /**
  85690. * Get value in degrees
  85691. * @returns the Angle value in degrees (float)
  85692. */
  85693. degrees(): number;
  85694. /**
  85695. * Get value in radians
  85696. * @returns the Angle value in radians (float)
  85697. */
  85698. radians(): number;
  85699. /**
  85700. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85701. * @param a defines first point as the origin
  85702. * @param b defines point
  85703. * @returns a new Angle
  85704. */
  85705. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85706. /**
  85707. * Gets a new Angle object from the given float in radians
  85708. * @param radians defines the angle value in radians
  85709. * @returns a new Angle
  85710. */
  85711. static FromRadians(radians: number): Angle;
  85712. /**
  85713. * Gets a new Angle object from the given float in degrees
  85714. * @param degrees defines the angle value in degrees
  85715. * @returns a new Angle
  85716. */
  85717. static FromDegrees(degrees: number): Angle;
  85718. }
  85719. /**
  85720. * This represents an arc in a 2d space.
  85721. */
  85722. export class Arc2 {
  85723. /** Defines the start point of the arc */
  85724. startPoint: Vector2;
  85725. /** Defines the mid point of the arc */
  85726. midPoint: Vector2;
  85727. /** Defines the end point of the arc */
  85728. endPoint: Vector2;
  85729. /**
  85730. * Defines the center point of the arc.
  85731. */
  85732. centerPoint: Vector2;
  85733. /**
  85734. * Defines the radius of the arc.
  85735. */
  85736. radius: number;
  85737. /**
  85738. * Defines the angle of the arc (from mid point to end point).
  85739. */
  85740. angle: Angle;
  85741. /**
  85742. * Defines the start angle of the arc (from start point to middle point).
  85743. */
  85744. startAngle: Angle;
  85745. /**
  85746. * Defines the orientation of the arc (clock wise/counter clock wise).
  85747. */
  85748. orientation: Orientation;
  85749. /**
  85750. * Creates an Arc object from the three given points : start, middle and end.
  85751. * @param startPoint Defines the start point of the arc
  85752. * @param midPoint Defines the midlle point of the arc
  85753. * @param endPoint Defines the end point of the arc
  85754. */
  85755. constructor(
  85756. /** Defines the start point of the arc */
  85757. startPoint: Vector2,
  85758. /** Defines the mid point of the arc */
  85759. midPoint: Vector2,
  85760. /** Defines the end point of the arc */
  85761. endPoint: Vector2);
  85762. }
  85763. /**
  85764. * Represents a 2D path made up of multiple 2D points
  85765. */
  85766. export class Path2 {
  85767. private _points;
  85768. private _length;
  85769. /**
  85770. * If the path start and end point are the same
  85771. */
  85772. closed: boolean;
  85773. /**
  85774. * Creates a Path2 object from the starting 2D coordinates x and y.
  85775. * @param x the starting points x value
  85776. * @param y the starting points y value
  85777. */
  85778. constructor(x: number, y: number);
  85779. /**
  85780. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85781. * @param x the added points x value
  85782. * @param y the added points y value
  85783. * @returns the updated Path2.
  85784. */
  85785. addLineTo(x: number, y: number): Path2;
  85786. /**
  85787. * 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.
  85788. * @param midX middle point x value
  85789. * @param midY middle point y value
  85790. * @param endX end point x value
  85791. * @param endY end point y value
  85792. * @param numberOfSegments (default: 36)
  85793. * @returns the updated Path2.
  85794. */
  85795. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85796. /**
  85797. * Closes the Path2.
  85798. * @returns the Path2.
  85799. */
  85800. close(): Path2;
  85801. /**
  85802. * Gets the sum of the distance between each sequential point in the path
  85803. * @returns the Path2 total length (float).
  85804. */
  85805. length(): number;
  85806. /**
  85807. * Gets the points which construct the path
  85808. * @returns the Path2 internal array of points.
  85809. */
  85810. getPoints(): Vector2[];
  85811. /**
  85812. * Retreives the point at the distance aways from the starting point
  85813. * @param normalizedLengthPosition the length along the path to retreive the point from
  85814. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85815. */
  85816. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85817. /**
  85818. * Creates a new path starting from an x and y position
  85819. * @param x starting x value
  85820. * @param y starting y value
  85821. * @returns a new Path2 starting at the coordinates (x, y).
  85822. */
  85823. static StartingAt(x: number, y: number): Path2;
  85824. }
  85825. /**
  85826. * Represents a 3D path made up of multiple 3D points
  85827. */
  85828. export class Path3D {
  85829. /**
  85830. * an array of Vector3, the curve axis of the Path3D
  85831. */
  85832. path: Vector3[];
  85833. private _curve;
  85834. private _distances;
  85835. private _tangents;
  85836. private _normals;
  85837. private _binormals;
  85838. private _raw;
  85839. private _alignTangentsWithPath;
  85840. private readonly _pointAtData;
  85841. /**
  85842. * new Path3D(path, normal, raw)
  85843. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85844. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85845. * @param path an array of Vector3, the curve axis of the Path3D
  85846. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85847. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85848. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85849. */
  85850. constructor(
  85851. /**
  85852. * an array of Vector3, the curve axis of the Path3D
  85853. */
  85854. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85855. /**
  85856. * Returns the Path3D array of successive Vector3 designing its curve.
  85857. * @returns the Path3D array of successive Vector3 designing its curve.
  85858. */
  85859. getCurve(): Vector3[];
  85860. /**
  85861. * Returns the Path3D array of successive Vector3 designing its curve.
  85862. * @returns the Path3D array of successive Vector3 designing its curve.
  85863. */
  85864. getPoints(): Vector3[];
  85865. /**
  85866. * @returns the computed length (float) of the path.
  85867. */
  85868. length(): number;
  85869. /**
  85870. * Returns an array populated with tangent vectors on each Path3D curve point.
  85871. * @returns an array populated with tangent vectors on each Path3D curve point.
  85872. */
  85873. getTangents(): Vector3[];
  85874. /**
  85875. * Returns an array populated with normal vectors on each Path3D curve point.
  85876. * @returns an array populated with normal vectors on each Path3D curve point.
  85877. */
  85878. getNormals(): Vector3[];
  85879. /**
  85880. * Returns an array populated with binormal vectors on each Path3D curve point.
  85881. * @returns an array populated with binormal vectors on each Path3D curve point.
  85882. */
  85883. getBinormals(): Vector3[];
  85884. /**
  85885. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85886. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85887. */
  85888. getDistances(): number[];
  85889. /**
  85890. * Returns an interpolated point along this path
  85891. * @param position the position of the point along this path, from 0.0 to 1.0
  85892. * @returns a new Vector3 as the point
  85893. */
  85894. getPointAt(position: number): Vector3;
  85895. /**
  85896. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85897. * @param position the position of the point along this path, from 0.0 to 1.0
  85898. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85899. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85900. */
  85901. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85902. /**
  85903. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85904. * @param position the position of the point along this path, from 0.0 to 1.0
  85905. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85906. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85907. */
  85908. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85909. /**
  85910. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85911. * @param position the position of the point along this path, from 0.0 to 1.0
  85912. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85913. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85914. */
  85915. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85916. /**
  85917. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85918. * @param position the position of the point along this path, from 0.0 to 1.0
  85919. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85920. */
  85921. getDistanceAt(position: number): number;
  85922. /**
  85923. * Returns the array index of the previous point of an interpolated point along this path
  85924. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85925. * @returns the array index
  85926. */
  85927. getPreviousPointIndexAt(position: number): number;
  85928. /**
  85929. * 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)
  85930. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85931. * @returns the sub position
  85932. */
  85933. getSubPositionAt(position: number): number;
  85934. /**
  85935. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85936. * @param target the vector of which to get the closest position to
  85937. * @returns the position of the closest virtual point on this path to the target vector
  85938. */
  85939. getClosestPositionTo(target: Vector3): number;
  85940. /**
  85941. * Returns a sub path (slice) of this path
  85942. * @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
  85943. * @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
  85944. * @returns a sub path (slice) of this path
  85945. */
  85946. slice(start?: number, end?: number): Path3D;
  85947. /**
  85948. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85949. * @param path path which all values are copied into the curves points
  85950. * @param firstNormal which should be projected onto the curve
  85951. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85952. * @returns the same object updated.
  85953. */
  85954. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85955. private _compute;
  85956. private _getFirstNonNullVector;
  85957. private _getLastNonNullVector;
  85958. private _normalVector;
  85959. /**
  85960. * Updates the point at data for an interpolated point along this curve
  85961. * @param position the position of the point along this curve, from 0.0 to 1.0
  85962. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85963. * @returns the (updated) point at data
  85964. */
  85965. private _updatePointAtData;
  85966. /**
  85967. * Updates the point at data from the specified parameters
  85968. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85969. * @param point the interpolated point
  85970. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85971. */
  85972. private _setPointAtData;
  85973. /**
  85974. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85975. */
  85976. private _updateInterpolationMatrix;
  85977. }
  85978. /**
  85979. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85980. * A Curve3 is designed from a series of successive Vector3.
  85981. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85982. */
  85983. export class Curve3 {
  85984. private _points;
  85985. private _length;
  85986. /**
  85987. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85988. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85989. * @param v1 (Vector3) the control point
  85990. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85991. * @param nbPoints (integer) the wanted number of points in the curve
  85992. * @returns the created Curve3
  85993. */
  85994. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85995. /**
  85996. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85997. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85998. * @param v1 (Vector3) the first control point
  85999. * @param v2 (Vector3) the second control point
  86000. * @param v3 (Vector3) the end point of the Cubic Bezier
  86001. * @param nbPoints (integer) the wanted number of points in the curve
  86002. * @returns the created Curve3
  86003. */
  86004. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86005. /**
  86006. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  86007. * @param p1 (Vector3) the origin point of the Hermite Spline
  86008. * @param t1 (Vector3) the tangent vector at the origin point
  86009. * @param p2 (Vector3) the end point of the Hermite Spline
  86010. * @param t2 (Vector3) the tangent vector at the end point
  86011. * @param nbPoints (integer) the wanted number of points in the curve
  86012. * @returns the created Curve3
  86013. */
  86014. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86015. /**
  86016. * Returns a Curve3 object along a CatmullRom Spline curve :
  86017. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  86018. * @param nbPoints (integer) the wanted number of points between each curve control points
  86019. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  86020. * @returns the created Curve3
  86021. */
  86022. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  86023. /**
  86024. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86025. * A Curve3 is designed from a series of successive Vector3.
  86026. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  86027. * @param points points which make up the curve
  86028. */
  86029. constructor(points: Vector3[]);
  86030. /**
  86031. * @returns the Curve3 stored array of successive Vector3
  86032. */
  86033. getPoints(): Vector3[];
  86034. /**
  86035. * @returns the computed length (float) of the curve.
  86036. */
  86037. length(): number;
  86038. /**
  86039. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  86040. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  86041. * curveA and curveB keep unchanged.
  86042. * @param curve the curve to continue from this curve
  86043. * @returns the newly constructed curve
  86044. */
  86045. continue(curve: DeepImmutable<Curve3>): Curve3;
  86046. private _computeLength;
  86047. }
  86048. }
  86049. declare module BABYLON {
  86050. /**
  86051. * This represents the main contract an easing function should follow.
  86052. * Easing functions are used throughout the animation system.
  86053. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86054. */
  86055. export interface IEasingFunction {
  86056. /**
  86057. * Given an input gradient between 0 and 1, this returns the corrseponding value
  86058. * of the easing function.
  86059. * The link below provides some of the most common examples of easing functions.
  86060. * @see https://easings.net/
  86061. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86062. * @returns the corresponding value on the curve defined by the easing function
  86063. */
  86064. ease(gradient: number): number;
  86065. }
  86066. /**
  86067. * Base class used for every default easing function.
  86068. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86069. */
  86070. export class EasingFunction implements IEasingFunction {
  86071. /**
  86072. * Interpolation follows the mathematical formula associated with the easing function.
  86073. */
  86074. static readonly EASINGMODE_EASEIN: number;
  86075. /**
  86076. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  86077. */
  86078. static readonly EASINGMODE_EASEOUT: number;
  86079. /**
  86080. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  86081. */
  86082. static readonly EASINGMODE_EASEINOUT: number;
  86083. private _easingMode;
  86084. /**
  86085. * Sets the easing mode of the current function.
  86086. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  86087. */
  86088. setEasingMode(easingMode: number): void;
  86089. /**
  86090. * Gets the current easing mode.
  86091. * @returns the easing mode
  86092. */
  86093. getEasingMode(): number;
  86094. /**
  86095. * @hidden
  86096. */
  86097. easeInCore(gradient: number): number;
  86098. /**
  86099. * Given an input gradient between 0 and 1, this returns the corresponding value
  86100. * of the easing function.
  86101. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86102. * @returns the corresponding value on the curve defined by the easing function
  86103. */
  86104. ease(gradient: number): number;
  86105. }
  86106. /**
  86107. * Easing function with a circle shape (see link below).
  86108. * @see https://easings.net/#easeInCirc
  86109. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86110. */
  86111. export class CircleEase extends EasingFunction implements IEasingFunction {
  86112. /** @hidden */
  86113. easeInCore(gradient: number): number;
  86114. }
  86115. /**
  86116. * Easing function with a ease back shape (see link below).
  86117. * @see https://easings.net/#easeInBack
  86118. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86119. */
  86120. export class BackEase extends EasingFunction implements IEasingFunction {
  86121. /** Defines the amplitude of the function */
  86122. amplitude: number;
  86123. /**
  86124. * Instantiates a back ease easing
  86125. * @see https://easings.net/#easeInBack
  86126. * @param amplitude Defines the amplitude of the function
  86127. */
  86128. constructor(
  86129. /** Defines the amplitude of the function */
  86130. amplitude?: number);
  86131. /** @hidden */
  86132. easeInCore(gradient: number): number;
  86133. }
  86134. /**
  86135. * Easing function with a bouncing shape (see link below).
  86136. * @see https://easings.net/#easeInBounce
  86137. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86138. */
  86139. export class BounceEase extends EasingFunction implements IEasingFunction {
  86140. /** Defines the number of bounces */
  86141. bounces: number;
  86142. /** Defines the amplitude of the bounce */
  86143. bounciness: number;
  86144. /**
  86145. * Instantiates a bounce easing
  86146. * @see https://easings.net/#easeInBounce
  86147. * @param bounces Defines the number of bounces
  86148. * @param bounciness Defines the amplitude of the bounce
  86149. */
  86150. constructor(
  86151. /** Defines the number of bounces */
  86152. bounces?: number,
  86153. /** Defines the amplitude of the bounce */
  86154. bounciness?: number);
  86155. /** @hidden */
  86156. easeInCore(gradient: number): number;
  86157. }
  86158. /**
  86159. * Easing function with a power of 3 shape (see link below).
  86160. * @see https://easings.net/#easeInCubic
  86161. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86162. */
  86163. export class CubicEase extends EasingFunction implements IEasingFunction {
  86164. /** @hidden */
  86165. easeInCore(gradient: number): number;
  86166. }
  86167. /**
  86168. * Easing function with an elastic shape (see link below).
  86169. * @see https://easings.net/#easeInElastic
  86170. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86171. */
  86172. export class ElasticEase extends EasingFunction implements IEasingFunction {
  86173. /** Defines the number of oscillations*/
  86174. oscillations: number;
  86175. /** Defines the amplitude of the oscillations*/
  86176. springiness: number;
  86177. /**
  86178. * Instantiates an elastic easing function
  86179. * @see https://easings.net/#easeInElastic
  86180. * @param oscillations Defines the number of oscillations
  86181. * @param springiness Defines the amplitude of the oscillations
  86182. */
  86183. constructor(
  86184. /** Defines the number of oscillations*/
  86185. oscillations?: number,
  86186. /** Defines the amplitude of the oscillations*/
  86187. springiness?: number);
  86188. /** @hidden */
  86189. easeInCore(gradient: number): number;
  86190. }
  86191. /**
  86192. * Easing function with an exponential shape (see link below).
  86193. * @see https://easings.net/#easeInExpo
  86194. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86195. */
  86196. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86197. /** Defines the exponent of the function */
  86198. exponent: number;
  86199. /**
  86200. * Instantiates an exponential easing function
  86201. * @see https://easings.net/#easeInExpo
  86202. * @param exponent Defines the exponent of the function
  86203. */
  86204. constructor(
  86205. /** Defines the exponent of the function */
  86206. exponent?: number);
  86207. /** @hidden */
  86208. easeInCore(gradient: number): number;
  86209. }
  86210. /**
  86211. * Easing function with a power shape (see link below).
  86212. * @see https://easings.net/#easeInQuad
  86213. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86214. */
  86215. export class PowerEase extends EasingFunction implements IEasingFunction {
  86216. /** Defines the power of the function */
  86217. power: number;
  86218. /**
  86219. * Instantiates an power base easing function
  86220. * @see https://easings.net/#easeInQuad
  86221. * @param power Defines the power of the function
  86222. */
  86223. constructor(
  86224. /** Defines the power of the function */
  86225. power?: number);
  86226. /** @hidden */
  86227. easeInCore(gradient: number): number;
  86228. }
  86229. /**
  86230. * Easing function with a power of 2 shape (see link below).
  86231. * @see https://easings.net/#easeInQuad
  86232. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86233. */
  86234. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86235. /** @hidden */
  86236. easeInCore(gradient: number): number;
  86237. }
  86238. /**
  86239. * Easing function with a power of 4 shape (see link below).
  86240. * @see https://easings.net/#easeInQuart
  86241. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86242. */
  86243. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86244. /** @hidden */
  86245. easeInCore(gradient: number): number;
  86246. }
  86247. /**
  86248. * Easing function with a power of 5 shape (see link below).
  86249. * @see https://easings.net/#easeInQuint
  86250. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86251. */
  86252. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86253. /** @hidden */
  86254. easeInCore(gradient: number): number;
  86255. }
  86256. /**
  86257. * Easing function with a sin shape (see link below).
  86258. * @see https://easings.net/#easeInSine
  86259. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86260. */
  86261. export class SineEase extends EasingFunction implements IEasingFunction {
  86262. /** @hidden */
  86263. easeInCore(gradient: number): number;
  86264. }
  86265. /**
  86266. * Easing function with a bezier shape (see link below).
  86267. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86269. */
  86270. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86271. /** Defines the x component of the start tangent in the bezier curve */
  86272. x1: number;
  86273. /** Defines the y component of the start tangent in the bezier curve */
  86274. y1: number;
  86275. /** Defines the x component of the end tangent in the bezier curve */
  86276. x2: number;
  86277. /** Defines the y component of the end tangent in the bezier curve */
  86278. y2: number;
  86279. /**
  86280. * Instantiates a bezier function
  86281. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86282. * @param x1 Defines the x component of the start tangent in the bezier curve
  86283. * @param y1 Defines the y component of the start tangent in the bezier curve
  86284. * @param x2 Defines the x component of the end tangent in the bezier curve
  86285. * @param y2 Defines the y component of the end tangent in the bezier curve
  86286. */
  86287. constructor(
  86288. /** Defines the x component of the start tangent in the bezier curve */
  86289. x1?: number,
  86290. /** Defines the y component of the start tangent in the bezier curve */
  86291. y1?: number,
  86292. /** Defines the x component of the end tangent in the bezier curve */
  86293. x2?: number,
  86294. /** Defines the y component of the end tangent in the bezier curve */
  86295. y2?: number);
  86296. /** @hidden */
  86297. easeInCore(gradient: number): number;
  86298. }
  86299. }
  86300. declare module BABYLON {
  86301. /**
  86302. * Class used to hold a RBG color
  86303. */
  86304. export class Color3 {
  86305. /**
  86306. * Defines the red component (between 0 and 1, default is 0)
  86307. */
  86308. r: number;
  86309. /**
  86310. * Defines the green component (between 0 and 1, default is 0)
  86311. */
  86312. g: number;
  86313. /**
  86314. * Defines the blue component (between 0 and 1, default is 0)
  86315. */
  86316. b: number;
  86317. /**
  86318. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86319. * @param r defines the red component (between 0 and 1, default is 0)
  86320. * @param g defines the green component (between 0 and 1, default is 0)
  86321. * @param b defines the blue component (between 0 and 1, default is 0)
  86322. */
  86323. constructor(
  86324. /**
  86325. * Defines the red component (between 0 and 1, default is 0)
  86326. */
  86327. r?: number,
  86328. /**
  86329. * Defines the green component (between 0 and 1, default is 0)
  86330. */
  86331. g?: number,
  86332. /**
  86333. * Defines the blue component (between 0 and 1, default is 0)
  86334. */
  86335. b?: number);
  86336. /**
  86337. * Creates a string with the Color3 current values
  86338. * @returns the string representation of the Color3 object
  86339. */
  86340. toString(): string;
  86341. /**
  86342. * Returns the string "Color3"
  86343. * @returns "Color3"
  86344. */
  86345. getClassName(): string;
  86346. /**
  86347. * Compute the Color3 hash code
  86348. * @returns an unique number that can be used to hash Color3 objects
  86349. */
  86350. getHashCode(): number;
  86351. /**
  86352. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86353. * @param array defines the array where to store the r,g,b components
  86354. * @param index defines an optional index in the target array to define where to start storing values
  86355. * @returns the current Color3 object
  86356. */
  86357. toArray(array: FloatArray, index?: number): Color3;
  86358. /**
  86359. * Update the current color with values stored in an array from the starting index of the given array
  86360. * @param array defines the source array
  86361. * @param offset defines an offset in the source array
  86362. * @returns the current Color3 object
  86363. */
  86364. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86365. /**
  86366. * Returns a new Color4 object from the current Color3 and the given alpha
  86367. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86368. * @returns a new Color4 object
  86369. */
  86370. toColor4(alpha?: number): Color4;
  86371. /**
  86372. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86373. * @returns the new array
  86374. */
  86375. asArray(): number[];
  86376. /**
  86377. * Returns the luminance value
  86378. * @returns a float value
  86379. */
  86380. toLuminance(): number;
  86381. /**
  86382. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86383. * @param otherColor defines the second operand
  86384. * @returns the new Color3 object
  86385. */
  86386. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86387. /**
  86388. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86389. * @param otherColor defines the second operand
  86390. * @param result defines the Color3 object where to store the result
  86391. * @returns the current Color3
  86392. */
  86393. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86394. /**
  86395. * Determines equality between Color3 objects
  86396. * @param otherColor defines the second operand
  86397. * @returns true if the rgb values are equal to the given ones
  86398. */
  86399. equals(otherColor: DeepImmutable<Color3>): boolean;
  86400. /**
  86401. * Determines equality between the current Color3 object and a set of r,b,g values
  86402. * @param r defines the red component to check
  86403. * @param g defines the green component to check
  86404. * @param b defines the blue component to check
  86405. * @returns true if the rgb values are equal to the given ones
  86406. */
  86407. equalsFloats(r: number, g: number, b: number): boolean;
  86408. /**
  86409. * Multiplies in place each rgb value by scale
  86410. * @param scale defines the scaling factor
  86411. * @returns the updated Color3
  86412. */
  86413. scale(scale: number): Color3;
  86414. /**
  86415. * Multiplies the rgb values by scale and stores the result into "result"
  86416. * @param scale defines the scaling factor
  86417. * @param result defines the Color3 object where to store the result
  86418. * @returns the unmodified current Color3
  86419. */
  86420. scaleToRef(scale: number, result: Color3): Color3;
  86421. /**
  86422. * Scale the current Color3 values by a factor and add the result to a given Color3
  86423. * @param scale defines the scale factor
  86424. * @param result defines color to store the result into
  86425. * @returns the unmodified current Color3
  86426. */
  86427. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86428. /**
  86429. * Clamps the rgb values by the min and max values and stores the result into "result"
  86430. * @param min defines minimum clamping value (default is 0)
  86431. * @param max defines maximum clamping value (default is 1)
  86432. * @param result defines color to store the result into
  86433. * @returns the original Color3
  86434. */
  86435. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86436. /**
  86437. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86438. * @param otherColor defines the second operand
  86439. * @returns the new Color3
  86440. */
  86441. add(otherColor: DeepImmutable<Color3>): Color3;
  86442. /**
  86443. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86444. * @param otherColor defines the second operand
  86445. * @param result defines Color3 object to store the result into
  86446. * @returns the unmodified current Color3
  86447. */
  86448. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86449. /**
  86450. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86451. * @param otherColor defines the second operand
  86452. * @returns the new Color3
  86453. */
  86454. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86455. /**
  86456. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86457. * @param otherColor defines the second operand
  86458. * @param result defines Color3 object to store the result into
  86459. * @returns the unmodified current Color3
  86460. */
  86461. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86462. /**
  86463. * Copy the current object
  86464. * @returns a new Color3 copied the current one
  86465. */
  86466. clone(): Color3;
  86467. /**
  86468. * Copies the rgb values from the source in the current Color3
  86469. * @param source defines the source Color3 object
  86470. * @returns the updated Color3 object
  86471. */
  86472. copyFrom(source: DeepImmutable<Color3>): Color3;
  86473. /**
  86474. * Updates the Color3 rgb values from the given floats
  86475. * @param r defines the red component to read from
  86476. * @param g defines the green component to read from
  86477. * @param b defines the blue component to read from
  86478. * @returns the current Color3 object
  86479. */
  86480. copyFromFloats(r: number, g: number, b: number): Color3;
  86481. /**
  86482. * Updates the Color3 rgb values from the given floats
  86483. * @param r defines the red component to read from
  86484. * @param g defines the green component to read from
  86485. * @param b defines the blue component to read from
  86486. * @returns the current Color3 object
  86487. */
  86488. set(r: number, g: number, b: number): Color3;
  86489. /**
  86490. * Compute the Color3 hexadecimal code as a string
  86491. * @returns a string containing the hexadecimal representation of the Color3 object
  86492. */
  86493. toHexString(): string;
  86494. /**
  86495. * Computes a new Color3 converted from the current one to linear space
  86496. * @returns a new Color3 object
  86497. */
  86498. toLinearSpace(): Color3;
  86499. /**
  86500. * Converts current color in rgb space to HSV values
  86501. * @returns a new color3 representing the HSV values
  86502. */
  86503. toHSV(): Color3;
  86504. /**
  86505. * Converts current color in rgb space to HSV values
  86506. * @param result defines the Color3 where to store the HSV values
  86507. */
  86508. toHSVToRef(result: Color3): void;
  86509. /**
  86510. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86511. * @param convertedColor defines the Color3 object where to store the linear space version
  86512. * @returns the unmodified Color3
  86513. */
  86514. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86515. /**
  86516. * Computes a new Color3 converted from the current one to gamma space
  86517. * @returns a new Color3 object
  86518. */
  86519. toGammaSpace(): Color3;
  86520. /**
  86521. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86522. * @param convertedColor defines the Color3 object where to store the gamma space version
  86523. * @returns the unmodified Color3
  86524. */
  86525. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86526. private static _BlackReadOnly;
  86527. /**
  86528. * Convert Hue, saturation and value to a Color3 (RGB)
  86529. * @param hue defines the hue
  86530. * @param saturation defines the saturation
  86531. * @param value defines the value
  86532. * @param result defines the Color3 where to store the RGB values
  86533. */
  86534. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86535. /**
  86536. * Creates a new Color3 from the string containing valid hexadecimal values
  86537. * @param hex defines a string containing valid hexadecimal values
  86538. * @returns a new Color3 object
  86539. */
  86540. static FromHexString(hex: string): Color3;
  86541. /**
  86542. * Creates a new Color3 from the starting index of the given array
  86543. * @param array defines the source array
  86544. * @param offset defines an offset in the source array
  86545. * @returns a new Color3 object
  86546. */
  86547. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86548. /**
  86549. * Creates a new Color3 from the starting index element of the given array
  86550. * @param array defines the source array to read from
  86551. * @param offset defines the offset in the source array
  86552. * @param result defines the target Color3 object
  86553. */
  86554. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86555. /**
  86556. * Creates a new Color3 from integer values (< 256)
  86557. * @param r defines the red component to read from (value between 0 and 255)
  86558. * @param g defines the green component to read from (value between 0 and 255)
  86559. * @param b defines the blue component to read from (value between 0 and 255)
  86560. * @returns a new Color3 object
  86561. */
  86562. static FromInts(r: number, g: number, b: number): Color3;
  86563. /**
  86564. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86565. * @param start defines the start Color3 value
  86566. * @param end defines the end Color3 value
  86567. * @param amount defines the gradient value between start and end
  86568. * @returns a new Color3 object
  86569. */
  86570. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86571. /**
  86572. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86573. * @param left defines the start value
  86574. * @param right defines the end value
  86575. * @param amount defines the gradient factor
  86576. * @param result defines the Color3 object where to store the result
  86577. */
  86578. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86579. /**
  86580. * Returns a Color3 value containing a red color
  86581. * @returns a new Color3 object
  86582. */
  86583. static Red(): Color3;
  86584. /**
  86585. * Returns a Color3 value containing a green color
  86586. * @returns a new Color3 object
  86587. */
  86588. static Green(): Color3;
  86589. /**
  86590. * Returns a Color3 value containing a blue color
  86591. * @returns a new Color3 object
  86592. */
  86593. static Blue(): Color3;
  86594. /**
  86595. * Returns a Color3 value containing a black color
  86596. * @returns a new Color3 object
  86597. */
  86598. static Black(): Color3;
  86599. /**
  86600. * Gets a Color3 value containing a black color that must not be updated
  86601. */
  86602. static get BlackReadOnly(): DeepImmutable<Color3>;
  86603. /**
  86604. * Returns a Color3 value containing a white color
  86605. * @returns a new Color3 object
  86606. */
  86607. static White(): Color3;
  86608. /**
  86609. * Returns a Color3 value containing a purple color
  86610. * @returns a new Color3 object
  86611. */
  86612. static Purple(): Color3;
  86613. /**
  86614. * Returns a Color3 value containing a magenta color
  86615. * @returns a new Color3 object
  86616. */
  86617. static Magenta(): Color3;
  86618. /**
  86619. * Returns a Color3 value containing a yellow color
  86620. * @returns a new Color3 object
  86621. */
  86622. static Yellow(): Color3;
  86623. /**
  86624. * Returns a Color3 value containing a gray color
  86625. * @returns a new Color3 object
  86626. */
  86627. static Gray(): Color3;
  86628. /**
  86629. * Returns a Color3 value containing a teal color
  86630. * @returns a new Color3 object
  86631. */
  86632. static Teal(): Color3;
  86633. /**
  86634. * Returns a Color3 value containing a random color
  86635. * @returns a new Color3 object
  86636. */
  86637. static Random(): Color3;
  86638. }
  86639. /**
  86640. * Class used to hold a RBGA color
  86641. */
  86642. export class Color4 {
  86643. /**
  86644. * Defines the red component (between 0 and 1, default is 0)
  86645. */
  86646. r: number;
  86647. /**
  86648. * Defines the green component (between 0 and 1, default is 0)
  86649. */
  86650. g: number;
  86651. /**
  86652. * Defines the blue component (between 0 and 1, default is 0)
  86653. */
  86654. b: number;
  86655. /**
  86656. * Defines the alpha component (between 0 and 1, default is 1)
  86657. */
  86658. a: number;
  86659. /**
  86660. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86661. * @param r defines the red component (between 0 and 1, default is 0)
  86662. * @param g defines the green component (between 0 and 1, default is 0)
  86663. * @param b defines the blue component (between 0 and 1, default is 0)
  86664. * @param a defines the alpha component (between 0 and 1, default is 1)
  86665. */
  86666. constructor(
  86667. /**
  86668. * Defines the red component (between 0 and 1, default is 0)
  86669. */
  86670. r?: number,
  86671. /**
  86672. * Defines the green component (between 0 and 1, default is 0)
  86673. */
  86674. g?: number,
  86675. /**
  86676. * Defines the blue component (between 0 and 1, default is 0)
  86677. */
  86678. b?: number,
  86679. /**
  86680. * Defines the alpha component (between 0 and 1, default is 1)
  86681. */
  86682. a?: number);
  86683. /**
  86684. * Adds in place the given Color4 values to the current Color4 object
  86685. * @param right defines the second operand
  86686. * @returns the current updated Color4 object
  86687. */
  86688. addInPlace(right: DeepImmutable<Color4>): Color4;
  86689. /**
  86690. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86691. * @returns the new array
  86692. */
  86693. asArray(): number[];
  86694. /**
  86695. * Stores from the starting index in the given array the Color4 successive values
  86696. * @param array defines the array where to store the r,g,b components
  86697. * @param index defines an optional index in the target array to define where to start storing values
  86698. * @returns the current Color4 object
  86699. */
  86700. toArray(array: number[], index?: number): Color4;
  86701. /**
  86702. * Update the current color with values stored in an array from the starting index of the given array
  86703. * @param array defines the source array
  86704. * @param offset defines an offset in the source array
  86705. * @returns the current Color4 object
  86706. */
  86707. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86708. /**
  86709. * Determines equality between Color4 objects
  86710. * @param otherColor defines the second operand
  86711. * @returns true if the rgba values are equal to the given ones
  86712. */
  86713. equals(otherColor: DeepImmutable<Color4>): boolean;
  86714. /**
  86715. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86716. * @param right defines the second operand
  86717. * @returns a new Color4 object
  86718. */
  86719. add(right: DeepImmutable<Color4>): Color4;
  86720. /**
  86721. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86722. * @param right defines the second operand
  86723. * @returns a new Color4 object
  86724. */
  86725. subtract(right: DeepImmutable<Color4>): Color4;
  86726. /**
  86727. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86728. * @param right defines the second operand
  86729. * @param result defines the Color4 object where to store the result
  86730. * @returns the current Color4 object
  86731. */
  86732. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86733. /**
  86734. * Creates a new Color4 with the current Color4 values multiplied by scale
  86735. * @param scale defines the scaling factor to apply
  86736. * @returns a new Color4 object
  86737. */
  86738. scale(scale: number): Color4;
  86739. /**
  86740. * Multiplies the current Color4 values by scale and stores the result in "result"
  86741. * @param scale defines the scaling factor to apply
  86742. * @param result defines the Color4 object where to store the result
  86743. * @returns the current unmodified Color4
  86744. */
  86745. scaleToRef(scale: number, result: Color4): Color4;
  86746. /**
  86747. * Scale the current Color4 values by a factor and add the result to a given Color4
  86748. * @param scale defines the scale factor
  86749. * @param result defines the Color4 object where to store the result
  86750. * @returns the unmodified current Color4
  86751. */
  86752. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86753. /**
  86754. * Clamps the rgb values by the min and max values and stores the result into "result"
  86755. * @param min defines minimum clamping value (default is 0)
  86756. * @param max defines maximum clamping value (default is 1)
  86757. * @param result defines color to store the result into.
  86758. * @returns the cuurent Color4
  86759. */
  86760. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86761. /**
  86762. * Multipy an Color4 value by another and return a new Color4 object
  86763. * @param color defines the Color4 value to multiply by
  86764. * @returns a new Color4 object
  86765. */
  86766. multiply(color: Color4): Color4;
  86767. /**
  86768. * Multipy a Color4 value by another and push the result in a reference value
  86769. * @param color defines the Color4 value to multiply by
  86770. * @param result defines the Color4 to fill the result in
  86771. * @returns the result Color4
  86772. */
  86773. multiplyToRef(color: Color4, result: Color4): Color4;
  86774. /**
  86775. * Creates a string with the Color4 current values
  86776. * @returns the string representation of the Color4 object
  86777. */
  86778. toString(): string;
  86779. /**
  86780. * Returns the string "Color4"
  86781. * @returns "Color4"
  86782. */
  86783. getClassName(): string;
  86784. /**
  86785. * Compute the Color4 hash code
  86786. * @returns an unique number that can be used to hash Color4 objects
  86787. */
  86788. getHashCode(): number;
  86789. /**
  86790. * Creates a new Color4 copied from the current one
  86791. * @returns a new Color4 object
  86792. */
  86793. clone(): Color4;
  86794. /**
  86795. * Copies the given Color4 values into the current one
  86796. * @param source defines the source Color4 object
  86797. * @returns the current updated Color4 object
  86798. */
  86799. copyFrom(source: Color4): Color4;
  86800. /**
  86801. * Copies the given float values into the current one
  86802. * @param r defines the red component to read from
  86803. * @param g defines the green component to read from
  86804. * @param b defines the blue component to read from
  86805. * @param a defines the alpha component to read from
  86806. * @returns the current updated Color4 object
  86807. */
  86808. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86809. /**
  86810. * Copies the given float values into the current one
  86811. * @param r defines the red component to read from
  86812. * @param g defines the green component to read from
  86813. * @param b defines the blue component to read from
  86814. * @param a defines the alpha component to read from
  86815. * @returns the current updated Color4 object
  86816. */
  86817. set(r: number, g: number, b: number, a: number): Color4;
  86818. /**
  86819. * Compute the Color4 hexadecimal code as a string
  86820. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86821. * @returns a string containing the hexadecimal representation of the Color4 object
  86822. */
  86823. toHexString(returnAsColor3?: boolean): string;
  86824. /**
  86825. * Computes a new Color4 converted from the current one to linear space
  86826. * @returns a new Color4 object
  86827. */
  86828. toLinearSpace(): Color4;
  86829. /**
  86830. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86831. * @param convertedColor defines the Color4 object where to store the linear space version
  86832. * @returns the unmodified Color4
  86833. */
  86834. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86835. /**
  86836. * Computes a new Color4 converted from the current one to gamma space
  86837. * @returns a new Color4 object
  86838. */
  86839. toGammaSpace(): Color4;
  86840. /**
  86841. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86842. * @param convertedColor defines the Color4 object where to store the gamma space version
  86843. * @returns the unmodified Color4
  86844. */
  86845. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86846. /**
  86847. * Creates a new Color4 from the string containing valid hexadecimal values
  86848. * @param hex defines a string containing valid hexadecimal values
  86849. * @returns a new Color4 object
  86850. */
  86851. static FromHexString(hex: string): Color4;
  86852. /**
  86853. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86854. * @param left defines the start value
  86855. * @param right defines the end value
  86856. * @param amount defines the gradient factor
  86857. * @returns a new Color4 object
  86858. */
  86859. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86860. /**
  86861. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86862. * @param left defines the start value
  86863. * @param right defines the end value
  86864. * @param amount defines the gradient factor
  86865. * @param result defines the Color4 object where to store data
  86866. */
  86867. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86868. /**
  86869. * Creates a new Color4 from a Color3 and an alpha value
  86870. * @param color3 defines the source Color3 to read from
  86871. * @param alpha defines the alpha component (1.0 by default)
  86872. * @returns a new Color4 object
  86873. */
  86874. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86875. /**
  86876. * Creates a new Color4 from the starting index element of the given array
  86877. * @param array defines the source array to read from
  86878. * @param offset defines the offset in the source array
  86879. * @returns a new Color4 object
  86880. */
  86881. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86882. /**
  86883. * Creates a new Color4 from the starting index element of the given array
  86884. * @param array defines the source array to read from
  86885. * @param offset defines the offset in the source array
  86886. * @param result defines the target Color4 object
  86887. */
  86888. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86889. /**
  86890. * Creates a new Color3 from integer values (< 256)
  86891. * @param r defines the red component to read from (value between 0 and 255)
  86892. * @param g defines the green component to read from (value between 0 and 255)
  86893. * @param b defines the blue component to read from (value between 0 and 255)
  86894. * @param a defines the alpha component to read from (value between 0 and 255)
  86895. * @returns a new Color3 object
  86896. */
  86897. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86898. /**
  86899. * Check the content of a given array and convert it to an array containing RGBA data
  86900. * If the original array was already containing count * 4 values then it is returned directly
  86901. * @param colors defines the array to check
  86902. * @param count defines the number of RGBA data to expect
  86903. * @returns an array containing count * 4 values (RGBA)
  86904. */
  86905. static CheckColors4(colors: number[], count: number): number[];
  86906. }
  86907. /**
  86908. * @hidden
  86909. */
  86910. export class TmpColors {
  86911. static Color3: Color3[];
  86912. static Color4: Color4[];
  86913. }
  86914. }
  86915. declare module BABYLON {
  86916. /**
  86917. * Defines an interface which represents an animation key frame
  86918. */
  86919. export interface IAnimationKey {
  86920. /**
  86921. * Frame of the key frame
  86922. */
  86923. frame: number;
  86924. /**
  86925. * Value at the specifies key frame
  86926. */
  86927. value: any;
  86928. /**
  86929. * The input tangent for the cubic hermite spline
  86930. */
  86931. inTangent?: any;
  86932. /**
  86933. * The output tangent for the cubic hermite spline
  86934. */
  86935. outTangent?: any;
  86936. /**
  86937. * The animation interpolation type
  86938. */
  86939. interpolation?: AnimationKeyInterpolation;
  86940. }
  86941. /**
  86942. * Enum for the animation key frame interpolation type
  86943. */
  86944. export enum AnimationKeyInterpolation {
  86945. /**
  86946. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86947. */
  86948. STEP = 1
  86949. }
  86950. }
  86951. declare module BABYLON {
  86952. /**
  86953. * Represents the range of an animation
  86954. */
  86955. export class AnimationRange {
  86956. /**The name of the animation range**/
  86957. name: string;
  86958. /**The starting frame of the animation */
  86959. from: number;
  86960. /**The ending frame of the animation*/
  86961. to: number;
  86962. /**
  86963. * Initializes the range of an animation
  86964. * @param name The name of the animation range
  86965. * @param from The starting frame of the animation
  86966. * @param to The ending frame of the animation
  86967. */
  86968. constructor(
  86969. /**The name of the animation range**/
  86970. name: string,
  86971. /**The starting frame of the animation */
  86972. from: number,
  86973. /**The ending frame of the animation*/
  86974. to: number);
  86975. /**
  86976. * Makes a copy of the animation range
  86977. * @returns A copy of the animation range
  86978. */
  86979. clone(): AnimationRange;
  86980. }
  86981. }
  86982. declare module BABYLON {
  86983. /**
  86984. * Composed of a frame, and an action function
  86985. */
  86986. export class AnimationEvent {
  86987. /** The frame for which the event is triggered **/
  86988. frame: number;
  86989. /** The event to perform when triggered **/
  86990. action: (currentFrame: number) => void;
  86991. /** Specifies if the event should be triggered only once**/
  86992. onlyOnce?: boolean | undefined;
  86993. /**
  86994. * Specifies if the animation event is done
  86995. */
  86996. isDone: boolean;
  86997. /**
  86998. * Initializes the animation event
  86999. * @param frame The frame for which the event is triggered
  87000. * @param action The event to perform when triggered
  87001. * @param onlyOnce Specifies if the event should be triggered only once
  87002. */
  87003. constructor(
  87004. /** The frame for which the event is triggered **/
  87005. frame: number,
  87006. /** The event to perform when triggered **/
  87007. action: (currentFrame: number) => void,
  87008. /** Specifies if the event should be triggered only once**/
  87009. onlyOnce?: boolean | undefined);
  87010. /** @hidden */
  87011. _clone(): AnimationEvent;
  87012. }
  87013. }
  87014. declare module BABYLON {
  87015. /**
  87016. * Interface used to define a behavior
  87017. */
  87018. export interface Behavior<T> {
  87019. /** gets or sets behavior's name */
  87020. name: string;
  87021. /**
  87022. * Function called when the behavior needs to be initialized (after attaching it to a target)
  87023. */
  87024. init(): void;
  87025. /**
  87026. * Called when the behavior is attached to a target
  87027. * @param target defines the target where the behavior is attached to
  87028. */
  87029. attach(target: T): void;
  87030. /**
  87031. * Called when the behavior is detached from its target
  87032. */
  87033. detach(): void;
  87034. }
  87035. /**
  87036. * Interface implemented by classes supporting behaviors
  87037. */
  87038. export interface IBehaviorAware<T> {
  87039. /**
  87040. * Attach a behavior
  87041. * @param behavior defines the behavior to attach
  87042. * @returns the current host
  87043. */
  87044. addBehavior(behavior: Behavior<T>): T;
  87045. /**
  87046. * Remove a behavior from the current object
  87047. * @param behavior defines the behavior to detach
  87048. * @returns the current host
  87049. */
  87050. removeBehavior(behavior: Behavior<T>): T;
  87051. /**
  87052. * Gets a behavior using its name to search
  87053. * @param name defines the name to search
  87054. * @returns the behavior or null if not found
  87055. */
  87056. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  87057. }
  87058. }
  87059. declare module BABYLON {
  87060. /**
  87061. * Defines an array and its length.
  87062. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  87063. */
  87064. export interface ISmartArrayLike<T> {
  87065. /**
  87066. * The data of the array.
  87067. */
  87068. data: Array<T>;
  87069. /**
  87070. * The active length of the array.
  87071. */
  87072. length: number;
  87073. }
  87074. /**
  87075. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87076. */
  87077. export class SmartArray<T> implements ISmartArrayLike<T> {
  87078. /**
  87079. * The full set of data from the array.
  87080. */
  87081. data: Array<T>;
  87082. /**
  87083. * The active length of the array.
  87084. */
  87085. length: number;
  87086. protected _id: number;
  87087. /**
  87088. * Instantiates a Smart Array.
  87089. * @param capacity defines the default capacity of the array.
  87090. */
  87091. constructor(capacity: number);
  87092. /**
  87093. * Pushes a value at the end of the active data.
  87094. * @param value defines the object to push in the array.
  87095. */
  87096. push(value: T): void;
  87097. /**
  87098. * Iterates over the active data and apply the lambda to them.
  87099. * @param func defines the action to apply on each value.
  87100. */
  87101. forEach(func: (content: T) => void): void;
  87102. /**
  87103. * Sorts the full sets of data.
  87104. * @param compareFn defines the comparison function to apply.
  87105. */
  87106. sort(compareFn: (a: T, b: T) => number): void;
  87107. /**
  87108. * Resets the active data to an empty array.
  87109. */
  87110. reset(): void;
  87111. /**
  87112. * Releases all the data from the array as well as the array.
  87113. */
  87114. dispose(): void;
  87115. /**
  87116. * Concats the active data with a given array.
  87117. * @param array defines the data to concatenate with.
  87118. */
  87119. concat(array: any): void;
  87120. /**
  87121. * Returns the position of a value in the active data.
  87122. * @param value defines the value to find the index for
  87123. * @returns the index if found in the active data otherwise -1
  87124. */
  87125. indexOf(value: T): number;
  87126. /**
  87127. * Returns whether an element is part of the active data.
  87128. * @param value defines the value to look for
  87129. * @returns true if found in the active data otherwise false
  87130. */
  87131. contains(value: T): boolean;
  87132. private static _GlobalId;
  87133. }
  87134. /**
  87135. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87136. * The data in this array can only be present once
  87137. */
  87138. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87139. private _duplicateId;
  87140. /**
  87141. * Pushes a value at the end of the active data.
  87142. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87143. * @param value defines the object to push in the array.
  87144. */
  87145. push(value: T): void;
  87146. /**
  87147. * Pushes a value at the end of the active data.
  87148. * If the data is already present, it won t be added again
  87149. * @param value defines the object to push in the array.
  87150. * @returns true if added false if it was already present
  87151. */
  87152. pushNoDuplicate(value: T): boolean;
  87153. /**
  87154. * Resets the active data to an empty array.
  87155. */
  87156. reset(): void;
  87157. /**
  87158. * Concats the active data with a given array.
  87159. * This ensures no dupplicate will be present in the result.
  87160. * @param array defines the data to concatenate with.
  87161. */
  87162. concatWithNoDuplicate(array: any): void;
  87163. }
  87164. }
  87165. declare module BABYLON {
  87166. /**
  87167. * @ignore
  87168. * This is a list of all the different input types that are available in the application.
  87169. * Fo instance: ArcRotateCameraGamepadInput...
  87170. */
  87171. export var CameraInputTypes: {};
  87172. /**
  87173. * This is the contract to implement in order to create a new input class.
  87174. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  87175. */
  87176. export interface ICameraInput<TCamera extends Camera> {
  87177. /**
  87178. * Defines the camera the input is attached to.
  87179. */
  87180. camera: Nullable<TCamera>;
  87181. /**
  87182. * Gets the class name of the current intput.
  87183. * @returns the class name
  87184. */
  87185. getClassName(): string;
  87186. /**
  87187. * Get the friendly name associated with the input class.
  87188. * @returns the input friendly name
  87189. */
  87190. getSimpleName(): string;
  87191. /**
  87192. * Attach the input controls to a specific dom element to get the input from.
  87193. * @param element Defines the element the controls should be listened from
  87194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87195. */
  87196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87197. /**
  87198. * Detach the current controls from the specified dom element.
  87199. * @param element Defines the element to stop listening the inputs from
  87200. */
  87201. detachControl(element: Nullable<HTMLElement>): void;
  87202. /**
  87203. * Update the current camera state depending on the inputs that have been used this frame.
  87204. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87205. */
  87206. checkInputs?: () => void;
  87207. }
  87208. /**
  87209. * Represents a map of input types to input instance or input index to input instance.
  87210. */
  87211. export interface CameraInputsMap<TCamera extends Camera> {
  87212. /**
  87213. * Accessor to the input by input type.
  87214. */
  87215. [name: string]: ICameraInput<TCamera>;
  87216. /**
  87217. * Accessor to the input by input index.
  87218. */
  87219. [idx: number]: ICameraInput<TCamera>;
  87220. }
  87221. /**
  87222. * This represents the input manager used within a camera.
  87223. * It helps dealing with all the different kind of input attached to a camera.
  87224. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87225. */
  87226. export class CameraInputsManager<TCamera extends Camera> {
  87227. /**
  87228. * Defines the list of inputs attahed to the camera.
  87229. */
  87230. attached: CameraInputsMap<TCamera>;
  87231. /**
  87232. * Defines the dom element the camera is collecting inputs from.
  87233. * This is null if the controls have not been attached.
  87234. */
  87235. attachedElement: Nullable<HTMLElement>;
  87236. /**
  87237. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87238. */
  87239. noPreventDefault: boolean;
  87240. /**
  87241. * Defined the camera the input manager belongs to.
  87242. */
  87243. camera: TCamera;
  87244. /**
  87245. * Update the current camera state depending on the inputs that have been used this frame.
  87246. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87247. */
  87248. checkInputs: () => void;
  87249. /**
  87250. * Instantiate a new Camera Input Manager.
  87251. * @param camera Defines the camera the input manager blongs to
  87252. */
  87253. constructor(camera: TCamera);
  87254. /**
  87255. * Add an input method to a camera
  87256. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87257. * @param input camera input method
  87258. */
  87259. add(input: ICameraInput<TCamera>): void;
  87260. /**
  87261. * Remove a specific input method from a camera
  87262. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87263. * @param inputToRemove camera input method
  87264. */
  87265. remove(inputToRemove: ICameraInput<TCamera>): void;
  87266. /**
  87267. * Remove a specific input type from a camera
  87268. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87269. * @param inputType the type of the input to remove
  87270. */
  87271. removeByType(inputType: string): void;
  87272. private _addCheckInputs;
  87273. /**
  87274. * Attach the input controls to the currently attached dom element to listen the events from.
  87275. * @param input Defines the input to attach
  87276. */
  87277. attachInput(input: ICameraInput<TCamera>): void;
  87278. /**
  87279. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87280. * @param element Defines the dom element to collect the events from
  87281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87282. */
  87283. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  87284. /**
  87285. * Detach the current manager inputs controls from a specific dom element.
  87286. * @param element Defines the dom element to collect the events from
  87287. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87288. */
  87289. detachElement(element: HTMLElement, disconnect?: boolean): void;
  87290. /**
  87291. * Rebuild the dynamic inputCheck function from the current list of
  87292. * defined inputs in the manager.
  87293. */
  87294. rebuildInputCheck(): void;
  87295. /**
  87296. * Remove all attached input methods from a camera
  87297. */
  87298. clear(): void;
  87299. /**
  87300. * Serialize the current input manager attached to a camera.
  87301. * This ensures than once parsed,
  87302. * the input associated to the camera will be identical to the current ones
  87303. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87304. */
  87305. serialize(serializedCamera: any): void;
  87306. /**
  87307. * Parses an input manager serialized JSON to restore the previous list of inputs
  87308. * and states associated to a camera.
  87309. * @param parsedCamera Defines the JSON to parse
  87310. */
  87311. parse(parsedCamera: any): void;
  87312. }
  87313. }
  87314. declare module BABYLON {
  87315. /**
  87316. * Class used to store data that will be store in GPU memory
  87317. */
  87318. export class Buffer {
  87319. private _engine;
  87320. private _buffer;
  87321. /** @hidden */
  87322. _data: Nullable<DataArray>;
  87323. private _updatable;
  87324. private _instanced;
  87325. private _divisor;
  87326. /**
  87327. * Gets the byte stride.
  87328. */
  87329. readonly byteStride: number;
  87330. /**
  87331. * Constructor
  87332. * @param engine the engine
  87333. * @param data the data to use for this buffer
  87334. * @param updatable whether the data is updatable
  87335. * @param stride the stride (optional)
  87336. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87337. * @param instanced whether the buffer is instanced (optional)
  87338. * @param useBytes set to true if the stride in in bytes (optional)
  87339. * @param divisor sets an optional divisor for instances (1 by default)
  87340. */
  87341. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87342. /**
  87343. * Create a new VertexBuffer based on the current buffer
  87344. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87345. * @param offset defines offset in the buffer (0 by default)
  87346. * @param size defines the size in floats of attributes (position is 3 for instance)
  87347. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87348. * @param instanced defines if the vertex buffer contains indexed data
  87349. * @param useBytes defines if the offset and stride are in bytes *
  87350. * @param divisor sets an optional divisor for instances (1 by default)
  87351. * @returns the new vertex buffer
  87352. */
  87353. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87354. /**
  87355. * Gets a boolean indicating if the Buffer is updatable?
  87356. * @returns true if the buffer is updatable
  87357. */
  87358. isUpdatable(): boolean;
  87359. /**
  87360. * Gets current buffer's data
  87361. * @returns a DataArray or null
  87362. */
  87363. getData(): Nullable<DataArray>;
  87364. /**
  87365. * Gets underlying native buffer
  87366. * @returns underlying native buffer
  87367. */
  87368. getBuffer(): Nullable<DataBuffer>;
  87369. /**
  87370. * Gets the stride in float32 units (i.e. byte stride / 4).
  87371. * May not be an integer if the byte stride is not divisible by 4.
  87372. * @returns the stride in float32 units
  87373. * @deprecated Please use byteStride instead.
  87374. */
  87375. getStrideSize(): number;
  87376. /**
  87377. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87378. * @param data defines the data to store
  87379. */
  87380. create(data?: Nullable<DataArray>): void;
  87381. /** @hidden */
  87382. _rebuild(): void;
  87383. /**
  87384. * Update current buffer data
  87385. * @param data defines the data to store
  87386. */
  87387. update(data: DataArray): void;
  87388. /**
  87389. * Updates the data directly.
  87390. * @param data the new data
  87391. * @param offset the new offset
  87392. * @param vertexCount the vertex count (optional)
  87393. * @param useBytes set to true if the offset is in bytes
  87394. */
  87395. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87396. /**
  87397. * Release all resources
  87398. */
  87399. dispose(): void;
  87400. }
  87401. /**
  87402. * Specialized buffer used to store vertex data
  87403. */
  87404. export class VertexBuffer {
  87405. /** @hidden */
  87406. _buffer: Buffer;
  87407. private _kind;
  87408. private _size;
  87409. private _ownsBuffer;
  87410. private _instanced;
  87411. private _instanceDivisor;
  87412. /**
  87413. * The byte type.
  87414. */
  87415. static readonly BYTE: number;
  87416. /**
  87417. * The unsigned byte type.
  87418. */
  87419. static readonly UNSIGNED_BYTE: number;
  87420. /**
  87421. * The short type.
  87422. */
  87423. static readonly SHORT: number;
  87424. /**
  87425. * The unsigned short type.
  87426. */
  87427. static readonly UNSIGNED_SHORT: number;
  87428. /**
  87429. * The integer type.
  87430. */
  87431. static readonly INT: number;
  87432. /**
  87433. * The unsigned integer type.
  87434. */
  87435. static readonly UNSIGNED_INT: number;
  87436. /**
  87437. * The float type.
  87438. */
  87439. static readonly FLOAT: number;
  87440. /**
  87441. * Gets or sets the instance divisor when in instanced mode
  87442. */
  87443. get instanceDivisor(): number;
  87444. set instanceDivisor(value: number);
  87445. /**
  87446. * Gets the byte stride.
  87447. */
  87448. readonly byteStride: number;
  87449. /**
  87450. * Gets the byte offset.
  87451. */
  87452. readonly byteOffset: number;
  87453. /**
  87454. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87455. */
  87456. readonly normalized: boolean;
  87457. /**
  87458. * Gets the data type of each component in the array.
  87459. */
  87460. readonly type: number;
  87461. /**
  87462. * Constructor
  87463. * @param engine the engine
  87464. * @param data the data to use for this vertex buffer
  87465. * @param kind the vertex buffer kind
  87466. * @param updatable whether the data is updatable
  87467. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87468. * @param stride the stride (optional)
  87469. * @param instanced whether the buffer is instanced (optional)
  87470. * @param offset the offset of the data (optional)
  87471. * @param size the number of components (optional)
  87472. * @param type the type of the component (optional)
  87473. * @param normalized whether the data contains normalized data (optional)
  87474. * @param useBytes set to true if stride and offset are in bytes (optional)
  87475. * @param divisor defines the instance divisor to use (1 by default)
  87476. */
  87477. 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);
  87478. /** @hidden */
  87479. _rebuild(): void;
  87480. /**
  87481. * Returns the kind of the VertexBuffer (string)
  87482. * @returns a string
  87483. */
  87484. getKind(): string;
  87485. /**
  87486. * Gets a boolean indicating if the VertexBuffer is updatable?
  87487. * @returns true if the buffer is updatable
  87488. */
  87489. isUpdatable(): boolean;
  87490. /**
  87491. * Gets current buffer's data
  87492. * @returns a DataArray or null
  87493. */
  87494. getData(): Nullable<DataArray>;
  87495. /**
  87496. * Gets underlying native buffer
  87497. * @returns underlying native buffer
  87498. */
  87499. getBuffer(): Nullable<DataBuffer>;
  87500. /**
  87501. * Gets the stride in float32 units (i.e. byte stride / 4).
  87502. * May not be an integer if the byte stride is not divisible by 4.
  87503. * @returns the stride in float32 units
  87504. * @deprecated Please use byteStride instead.
  87505. */
  87506. getStrideSize(): number;
  87507. /**
  87508. * Returns the offset as a multiple of the type byte length.
  87509. * @returns the offset in bytes
  87510. * @deprecated Please use byteOffset instead.
  87511. */
  87512. getOffset(): number;
  87513. /**
  87514. * Returns the number of components per vertex attribute (integer)
  87515. * @returns the size in float
  87516. */
  87517. getSize(): number;
  87518. /**
  87519. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87520. * @returns true if this buffer is instanced
  87521. */
  87522. getIsInstanced(): boolean;
  87523. /**
  87524. * Returns the instancing divisor, zero for non-instanced (integer).
  87525. * @returns a number
  87526. */
  87527. getInstanceDivisor(): number;
  87528. /**
  87529. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87530. * @param data defines the data to store
  87531. */
  87532. create(data?: DataArray): void;
  87533. /**
  87534. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87535. * This function will create a new buffer if the current one is not updatable
  87536. * @param data defines the data to store
  87537. */
  87538. update(data: DataArray): void;
  87539. /**
  87540. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87541. * Returns the directly updated WebGLBuffer.
  87542. * @param data the new data
  87543. * @param offset the new offset
  87544. * @param useBytes set to true if the offset is in bytes
  87545. */
  87546. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87547. /**
  87548. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87549. */
  87550. dispose(): void;
  87551. /**
  87552. * Enumerates each value of this vertex buffer as numbers.
  87553. * @param count the number of values to enumerate
  87554. * @param callback the callback function called for each value
  87555. */
  87556. forEach(count: number, callback: (value: number, index: number) => void): void;
  87557. /**
  87558. * Positions
  87559. */
  87560. static readonly PositionKind: string;
  87561. /**
  87562. * Normals
  87563. */
  87564. static readonly NormalKind: string;
  87565. /**
  87566. * Tangents
  87567. */
  87568. static readonly TangentKind: string;
  87569. /**
  87570. * Texture coordinates
  87571. */
  87572. static readonly UVKind: string;
  87573. /**
  87574. * Texture coordinates 2
  87575. */
  87576. static readonly UV2Kind: string;
  87577. /**
  87578. * Texture coordinates 3
  87579. */
  87580. static readonly UV3Kind: string;
  87581. /**
  87582. * Texture coordinates 4
  87583. */
  87584. static readonly UV4Kind: string;
  87585. /**
  87586. * Texture coordinates 5
  87587. */
  87588. static readonly UV5Kind: string;
  87589. /**
  87590. * Texture coordinates 6
  87591. */
  87592. static readonly UV6Kind: string;
  87593. /**
  87594. * Colors
  87595. */
  87596. static readonly ColorKind: string;
  87597. /**
  87598. * Matrix indices (for bones)
  87599. */
  87600. static readonly MatricesIndicesKind: string;
  87601. /**
  87602. * Matrix weights (for bones)
  87603. */
  87604. static readonly MatricesWeightsKind: string;
  87605. /**
  87606. * Additional matrix indices (for bones)
  87607. */
  87608. static readonly MatricesIndicesExtraKind: string;
  87609. /**
  87610. * Additional matrix weights (for bones)
  87611. */
  87612. static readonly MatricesWeightsExtraKind: string;
  87613. /**
  87614. * Deduces the stride given a kind.
  87615. * @param kind The kind string to deduce
  87616. * @returns The deduced stride
  87617. */
  87618. static DeduceStride(kind: string): number;
  87619. /**
  87620. * Gets the byte length of the given type.
  87621. * @param type the type
  87622. * @returns the number of bytes
  87623. */
  87624. static GetTypeByteLength(type: number): number;
  87625. /**
  87626. * Enumerates each value of the given parameters as numbers.
  87627. * @param data the data to enumerate
  87628. * @param byteOffset the byte offset of the data
  87629. * @param byteStride the byte stride of the data
  87630. * @param componentCount the number of components per element
  87631. * @param componentType the type of the component
  87632. * @param count the number of values to enumerate
  87633. * @param normalized whether the data is normalized
  87634. * @param callback the callback function called for each value
  87635. */
  87636. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87637. private static _GetFloatValue;
  87638. }
  87639. }
  87640. declare module BABYLON {
  87641. /**
  87642. * The options Interface for creating a Capsule Mesh
  87643. */
  87644. export interface ICreateCapsuleOptions {
  87645. /** The Orientation of the capsule. Default : Vector3.Up() */
  87646. orientation?: Vector3;
  87647. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87648. subdivisions: number;
  87649. /** Number of cylindrical segments on the capsule. */
  87650. tessellation: number;
  87651. /** Height or Length of the capsule. */
  87652. height: number;
  87653. /** Radius of the capsule. */
  87654. radius: number;
  87655. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87656. capSubdivisions: number;
  87657. /** Overwrite for the top radius. */
  87658. radiusTop?: number;
  87659. /** Overwrite for the bottom radius. */
  87660. radiusBottom?: number;
  87661. /** Overwrite for the top capSubdivisions. */
  87662. topCapSubdivisions?: number;
  87663. /** Overwrite for the bottom capSubdivisions. */
  87664. bottomCapSubdivisions?: number;
  87665. }
  87666. /**
  87667. * Class containing static functions to help procedurally build meshes
  87668. */
  87669. export class CapsuleBuilder {
  87670. /**
  87671. * Creates a capsule or a pill mesh
  87672. * @param name defines the name of the mesh
  87673. * @param options The constructors options.
  87674. * @param scene The scene the mesh is scoped to.
  87675. * @returns Capsule Mesh
  87676. */
  87677. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87678. }
  87679. }
  87680. declare module BABYLON {
  87681. /**
  87682. * @hidden
  87683. */
  87684. export class IntersectionInfo {
  87685. bu: Nullable<number>;
  87686. bv: Nullable<number>;
  87687. distance: number;
  87688. faceId: number;
  87689. subMeshId: number;
  87690. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87691. }
  87692. }
  87693. declare module BABYLON {
  87694. /**
  87695. * Class used to store bounding sphere information
  87696. */
  87697. export class BoundingSphere {
  87698. /**
  87699. * Gets the center of the bounding sphere in local space
  87700. */
  87701. readonly center: Vector3;
  87702. /**
  87703. * Radius of the bounding sphere in local space
  87704. */
  87705. radius: number;
  87706. /**
  87707. * Gets the center of the bounding sphere in world space
  87708. */
  87709. readonly centerWorld: Vector3;
  87710. /**
  87711. * Radius of the bounding sphere in world space
  87712. */
  87713. radiusWorld: number;
  87714. /**
  87715. * Gets the minimum vector in local space
  87716. */
  87717. readonly minimum: Vector3;
  87718. /**
  87719. * Gets the maximum vector in local space
  87720. */
  87721. readonly maximum: Vector3;
  87722. private _worldMatrix;
  87723. private static readonly TmpVector3;
  87724. /**
  87725. * Creates a new bounding sphere
  87726. * @param min defines the minimum vector (in local space)
  87727. * @param max defines the maximum vector (in local space)
  87728. * @param worldMatrix defines the new world matrix
  87729. */
  87730. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87731. /**
  87732. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87733. * @param min defines the new minimum vector (in local space)
  87734. * @param max defines the new maximum vector (in local space)
  87735. * @param worldMatrix defines the new world matrix
  87736. */
  87737. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87738. /**
  87739. * Scale the current bounding sphere by applying a scale factor
  87740. * @param factor defines the scale factor to apply
  87741. * @returns the current bounding box
  87742. */
  87743. scale(factor: number): BoundingSphere;
  87744. /**
  87745. * Gets the world matrix of the bounding box
  87746. * @returns a matrix
  87747. */
  87748. getWorldMatrix(): DeepImmutable<Matrix>;
  87749. /** @hidden */
  87750. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87751. /**
  87752. * Tests if the bounding sphere is intersecting the frustum planes
  87753. * @param frustumPlanes defines the frustum planes to test
  87754. * @returns true if there is an intersection
  87755. */
  87756. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87757. /**
  87758. * Tests if the bounding sphere center is in between the frustum planes.
  87759. * Used for optimistic fast inclusion.
  87760. * @param frustumPlanes defines the frustum planes to test
  87761. * @returns true if the sphere center is in between the frustum planes
  87762. */
  87763. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87764. /**
  87765. * Tests if a point is inside the bounding sphere
  87766. * @param point defines the point to test
  87767. * @returns true if the point is inside the bounding sphere
  87768. */
  87769. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87770. /**
  87771. * Checks if two sphere intersct
  87772. * @param sphere0 sphere 0
  87773. * @param sphere1 sphere 1
  87774. * @returns true if the speres intersect
  87775. */
  87776. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87777. }
  87778. }
  87779. declare module BABYLON {
  87780. /**
  87781. * Class used to store bounding box information
  87782. */
  87783. export class BoundingBox implements ICullable {
  87784. /**
  87785. * Gets the 8 vectors representing the bounding box in local space
  87786. */
  87787. readonly vectors: Vector3[];
  87788. /**
  87789. * Gets the center of the bounding box in local space
  87790. */
  87791. readonly center: Vector3;
  87792. /**
  87793. * Gets the center of the bounding box in world space
  87794. */
  87795. readonly centerWorld: Vector3;
  87796. /**
  87797. * Gets the extend size in local space
  87798. */
  87799. readonly extendSize: Vector3;
  87800. /**
  87801. * Gets the extend size in world space
  87802. */
  87803. readonly extendSizeWorld: Vector3;
  87804. /**
  87805. * Gets the OBB (object bounding box) directions
  87806. */
  87807. readonly directions: Vector3[];
  87808. /**
  87809. * Gets the 8 vectors representing the bounding box in world space
  87810. */
  87811. readonly vectorsWorld: Vector3[];
  87812. /**
  87813. * Gets the minimum vector in world space
  87814. */
  87815. readonly minimumWorld: Vector3;
  87816. /**
  87817. * Gets the maximum vector in world space
  87818. */
  87819. readonly maximumWorld: Vector3;
  87820. /**
  87821. * Gets the minimum vector in local space
  87822. */
  87823. readonly minimum: Vector3;
  87824. /**
  87825. * Gets the maximum vector in local space
  87826. */
  87827. readonly maximum: Vector3;
  87828. private _worldMatrix;
  87829. private static readonly TmpVector3;
  87830. /**
  87831. * @hidden
  87832. */
  87833. _tag: number;
  87834. /**
  87835. * Creates a new bounding box
  87836. * @param min defines the minimum vector (in local space)
  87837. * @param max defines the maximum vector (in local space)
  87838. * @param worldMatrix defines the new world matrix
  87839. */
  87840. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87841. /**
  87842. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87843. * @param min defines the new minimum vector (in local space)
  87844. * @param max defines the new maximum vector (in local space)
  87845. * @param worldMatrix defines the new world matrix
  87846. */
  87847. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87848. /**
  87849. * Scale the current bounding box by applying a scale factor
  87850. * @param factor defines the scale factor to apply
  87851. * @returns the current bounding box
  87852. */
  87853. scale(factor: number): BoundingBox;
  87854. /**
  87855. * Gets the world matrix of the bounding box
  87856. * @returns a matrix
  87857. */
  87858. getWorldMatrix(): DeepImmutable<Matrix>;
  87859. /** @hidden */
  87860. _update(world: DeepImmutable<Matrix>): void;
  87861. /**
  87862. * Tests if the bounding box is intersecting the frustum planes
  87863. * @param frustumPlanes defines the frustum planes to test
  87864. * @returns true if there is an intersection
  87865. */
  87866. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87867. /**
  87868. * Tests if the bounding box is entirely inside the frustum planes
  87869. * @param frustumPlanes defines the frustum planes to test
  87870. * @returns true if there is an inclusion
  87871. */
  87872. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87873. /**
  87874. * Tests if a point is inside the bounding box
  87875. * @param point defines the point to test
  87876. * @returns true if the point is inside the bounding box
  87877. */
  87878. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87879. /**
  87880. * Tests if the bounding box intersects with a bounding sphere
  87881. * @param sphere defines the sphere to test
  87882. * @returns true if there is an intersection
  87883. */
  87884. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87885. /**
  87886. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87887. * @param min defines the min vector to use
  87888. * @param max defines the max vector to use
  87889. * @returns true if there is an intersection
  87890. */
  87891. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87892. /**
  87893. * Tests if two bounding boxes are intersections
  87894. * @param box0 defines the first box to test
  87895. * @param box1 defines the second box to test
  87896. * @returns true if there is an intersection
  87897. */
  87898. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87899. /**
  87900. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87901. * @param minPoint defines the minimum vector of the bounding box
  87902. * @param maxPoint defines the maximum vector of the bounding box
  87903. * @param sphereCenter defines the sphere center
  87904. * @param sphereRadius defines the sphere radius
  87905. * @returns true if there is an intersection
  87906. */
  87907. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87908. /**
  87909. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87910. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87911. * @param frustumPlanes defines the frustum planes to test
  87912. * @return true if there is an inclusion
  87913. */
  87914. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87915. /**
  87916. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87917. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87918. * @param frustumPlanes defines the frustum planes to test
  87919. * @return true if there is an intersection
  87920. */
  87921. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87922. }
  87923. }
  87924. declare module BABYLON {
  87925. /** @hidden */
  87926. export class Collider {
  87927. /** Define if a collision was found */
  87928. collisionFound: boolean;
  87929. /**
  87930. * Define last intersection point in local space
  87931. */
  87932. intersectionPoint: Vector3;
  87933. /**
  87934. * Define last collided mesh
  87935. */
  87936. collidedMesh: Nullable<AbstractMesh>;
  87937. private _collisionPoint;
  87938. private _planeIntersectionPoint;
  87939. private _tempVector;
  87940. private _tempVector2;
  87941. private _tempVector3;
  87942. private _tempVector4;
  87943. private _edge;
  87944. private _baseToVertex;
  87945. private _destinationPoint;
  87946. private _slidePlaneNormal;
  87947. private _displacementVector;
  87948. /** @hidden */
  87949. _radius: Vector3;
  87950. /** @hidden */
  87951. _retry: number;
  87952. private _velocity;
  87953. private _basePoint;
  87954. private _epsilon;
  87955. /** @hidden */
  87956. _velocityWorldLength: number;
  87957. /** @hidden */
  87958. _basePointWorld: Vector3;
  87959. private _velocityWorld;
  87960. private _normalizedVelocity;
  87961. /** @hidden */
  87962. _initialVelocity: Vector3;
  87963. /** @hidden */
  87964. _initialPosition: Vector3;
  87965. private _nearestDistance;
  87966. private _collisionMask;
  87967. get collisionMask(): number;
  87968. set collisionMask(mask: number);
  87969. /**
  87970. * Gets the plane normal used to compute the sliding response (in local space)
  87971. */
  87972. get slidePlaneNormal(): Vector3;
  87973. /** @hidden */
  87974. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87975. /** @hidden */
  87976. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87977. /** @hidden */
  87978. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87979. /** @hidden */
  87980. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87981. /** @hidden */
  87982. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87983. /** @hidden */
  87984. _getResponse(pos: Vector3, vel: Vector3): void;
  87985. }
  87986. }
  87987. declare module BABYLON {
  87988. /**
  87989. * Interface for cullable objects
  87990. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87991. */
  87992. export interface ICullable {
  87993. /**
  87994. * Checks if the object or part of the object is in the frustum
  87995. * @param frustumPlanes Camera near/planes
  87996. * @returns true if the object is in frustum otherwise false
  87997. */
  87998. isInFrustum(frustumPlanes: Plane[]): boolean;
  87999. /**
  88000. * Checks if a cullable object (mesh...) is in the camera frustum
  88001. * Unlike isInFrustum this cheks the full bounding box
  88002. * @param frustumPlanes Camera near/planes
  88003. * @returns true if the object is in frustum otherwise false
  88004. */
  88005. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88006. }
  88007. /**
  88008. * Info for a bounding data of a mesh
  88009. */
  88010. export class BoundingInfo implements ICullable {
  88011. /**
  88012. * Bounding box for the mesh
  88013. */
  88014. readonly boundingBox: BoundingBox;
  88015. /**
  88016. * Bounding sphere for the mesh
  88017. */
  88018. readonly boundingSphere: BoundingSphere;
  88019. private _isLocked;
  88020. private static readonly TmpVector3;
  88021. /**
  88022. * Constructs bounding info
  88023. * @param minimum min vector of the bounding box/sphere
  88024. * @param maximum max vector of the bounding box/sphere
  88025. * @param worldMatrix defines the new world matrix
  88026. */
  88027. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88028. /**
  88029. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88030. * @param min defines the new minimum vector (in local space)
  88031. * @param max defines the new maximum vector (in local space)
  88032. * @param worldMatrix defines the new world matrix
  88033. */
  88034. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88035. /**
  88036. * min vector of the bounding box/sphere
  88037. */
  88038. get minimum(): Vector3;
  88039. /**
  88040. * max vector of the bounding box/sphere
  88041. */
  88042. get maximum(): Vector3;
  88043. /**
  88044. * If the info is locked and won't be updated to avoid perf overhead
  88045. */
  88046. get isLocked(): boolean;
  88047. set isLocked(value: boolean);
  88048. /**
  88049. * Updates the bounding sphere and box
  88050. * @param world world matrix to be used to update
  88051. */
  88052. update(world: DeepImmutable<Matrix>): void;
  88053. /**
  88054. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88055. * @param center New center of the bounding info
  88056. * @param extend New extend of the bounding info
  88057. * @returns the current bounding info
  88058. */
  88059. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88060. /**
  88061. * Scale the current bounding info by applying a scale factor
  88062. * @param factor defines the scale factor to apply
  88063. * @returns the current bounding info
  88064. */
  88065. scale(factor: number): BoundingInfo;
  88066. /**
  88067. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  88068. * @param frustumPlanes defines the frustum to test
  88069. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  88070. * @returns true if the bounding info is in the frustum planes
  88071. */
  88072. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  88073. /**
  88074. * Gets the world distance between the min and max points of the bounding box
  88075. */
  88076. get diagonalLength(): number;
  88077. /**
  88078. * Checks if a cullable object (mesh...) is in the camera frustum
  88079. * Unlike isInFrustum this cheks the full bounding box
  88080. * @param frustumPlanes Camera near/planes
  88081. * @returns true if the object is in frustum otherwise false
  88082. */
  88083. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88084. /** @hidden */
  88085. _checkCollision(collider: Collider): boolean;
  88086. /**
  88087. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  88088. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88089. * @param point the point to check intersection with
  88090. * @returns if the point intersects
  88091. */
  88092. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88093. /**
  88094. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88095. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88096. * @param boundingInfo the bounding info to check intersection with
  88097. * @param precise if the intersection should be done using OBB
  88098. * @returns if the bounding info intersects
  88099. */
  88100. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88101. }
  88102. }
  88103. declare module BABYLON {
  88104. /**
  88105. * Extracts minimum and maximum values from a list of indexed positions
  88106. * @param positions defines the positions to use
  88107. * @param indices defines the indices to the positions
  88108. * @param indexStart defines the start index
  88109. * @param indexCount defines the end index
  88110. * @param bias defines bias value to add to the result
  88111. * @return minimum and maximum values
  88112. */
  88113. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88114. minimum: Vector3;
  88115. maximum: Vector3;
  88116. };
  88117. /**
  88118. * Extracts minimum and maximum values from a list of positions
  88119. * @param positions defines the positions to use
  88120. * @param start defines the start index in the positions array
  88121. * @param count defines the number of positions to handle
  88122. * @param bias defines bias value to add to the result
  88123. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88124. * @return minimum and maximum values
  88125. */
  88126. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88127. minimum: Vector3;
  88128. maximum: Vector3;
  88129. };
  88130. }
  88131. declare module BABYLON {
  88132. /** @hidden */
  88133. export class WebGLDataBuffer extends DataBuffer {
  88134. private _buffer;
  88135. constructor(resource: WebGLBuffer);
  88136. get underlyingResource(): any;
  88137. }
  88138. }
  88139. declare module BABYLON {
  88140. /** @hidden */
  88141. export class WebGLPipelineContext implements IPipelineContext {
  88142. engine: ThinEngine;
  88143. program: Nullable<WebGLProgram>;
  88144. context?: WebGLRenderingContext;
  88145. vertexShader?: WebGLShader;
  88146. fragmentShader?: WebGLShader;
  88147. isParallelCompiled: boolean;
  88148. onCompiled?: () => void;
  88149. transformFeedback?: WebGLTransformFeedback | null;
  88150. vertexCompilationError: Nullable<string>;
  88151. fragmentCompilationError: Nullable<string>;
  88152. programLinkError: Nullable<string>;
  88153. programValidationError: Nullable<string>;
  88154. get isAsync(): boolean;
  88155. get isReady(): boolean;
  88156. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  88157. _getVertexShaderCode(): string | null;
  88158. _getFragmentShaderCode(): string | null;
  88159. }
  88160. }
  88161. declare module BABYLON {
  88162. interface ThinEngine {
  88163. /**
  88164. * Create an uniform buffer
  88165. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88166. * @param elements defines the content of the uniform buffer
  88167. * @returns the webGL uniform buffer
  88168. */
  88169. createUniformBuffer(elements: FloatArray): DataBuffer;
  88170. /**
  88171. * Create a dynamic uniform buffer
  88172. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88173. * @param elements defines the content of the uniform buffer
  88174. * @returns the webGL uniform buffer
  88175. */
  88176. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88177. /**
  88178. * Update an existing uniform buffer
  88179. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88180. * @param uniformBuffer defines the target uniform buffer
  88181. * @param elements defines the content to update
  88182. * @param offset defines the offset in the uniform buffer where update should start
  88183. * @param count defines the size of the data to update
  88184. */
  88185. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88186. /**
  88187. * Bind an uniform buffer to the current webGL context
  88188. * @param buffer defines the buffer to bind
  88189. */
  88190. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88191. /**
  88192. * Bind a buffer to the current webGL context at a given location
  88193. * @param buffer defines the buffer to bind
  88194. * @param location defines the index where to bind the buffer
  88195. */
  88196. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88197. /**
  88198. * Bind a specific block at a given index in a specific shader program
  88199. * @param pipelineContext defines the pipeline context to use
  88200. * @param blockName defines the block name
  88201. * @param index defines the index where to bind the block
  88202. */
  88203. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88204. }
  88205. }
  88206. declare module BABYLON {
  88207. /**
  88208. * Uniform buffer objects.
  88209. *
  88210. * Handles blocks of uniform on the GPU.
  88211. *
  88212. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88213. *
  88214. * For more information, please refer to :
  88215. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88216. */
  88217. export class UniformBuffer {
  88218. private _engine;
  88219. private _buffer;
  88220. private _data;
  88221. private _bufferData;
  88222. private _dynamic?;
  88223. private _uniformLocations;
  88224. private _uniformSizes;
  88225. private _uniformLocationPointer;
  88226. private _needSync;
  88227. private _noUBO;
  88228. private _currentEffect;
  88229. /** @hidden */
  88230. _alreadyBound: boolean;
  88231. private static _MAX_UNIFORM_SIZE;
  88232. private static _tempBuffer;
  88233. /**
  88234. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88235. * This is dynamic to allow compat with webgl 1 and 2.
  88236. * You will need to pass the name of the uniform as well as the value.
  88237. */
  88238. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88239. /**
  88240. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88241. * This is dynamic to allow compat with webgl 1 and 2.
  88242. * You will need to pass the name of the uniform as well as the value.
  88243. */
  88244. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88245. /**
  88246. * Lambda to Update a single float in a uniform buffer.
  88247. * This is dynamic to allow compat with webgl 1 and 2.
  88248. * You will need to pass the name of the uniform as well as the value.
  88249. */
  88250. updateFloat: (name: string, x: number) => void;
  88251. /**
  88252. * Lambda to Update a vec2 of float in a uniform buffer.
  88253. * This is dynamic to allow compat with webgl 1 and 2.
  88254. * You will need to pass the name of the uniform as well as the value.
  88255. */
  88256. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88257. /**
  88258. * Lambda to Update a vec3 of float in a uniform buffer.
  88259. * This is dynamic to allow compat with webgl 1 and 2.
  88260. * You will need to pass the name of the uniform as well as the value.
  88261. */
  88262. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88263. /**
  88264. * Lambda to Update a vec4 of float in a uniform buffer.
  88265. * This is dynamic to allow compat with webgl 1 and 2.
  88266. * You will need to pass the name of the uniform as well as the value.
  88267. */
  88268. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88269. /**
  88270. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88271. * This is dynamic to allow compat with webgl 1 and 2.
  88272. * You will need to pass the name of the uniform as well as the value.
  88273. */
  88274. updateMatrix: (name: string, mat: Matrix) => void;
  88275. /**
  88276. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88277. * This is dynamic to allow compat with webgl 1 and 2.
  88278. * You will need to pass the name of the uniform as well as the value.
  88279. */
  88280. updateVector3: (name: string, vector: Vector3) => void;
  88281. /**
  88282. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88283. * This is dynamic to allow compat with webgl 1 and 2.
  88284. * You will need to pass the name of the uniform as well as the value.
  88285. */
  88286. updateVector4: (name: string, vector: Vector4) => void;
  88287. /**
  88288. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88289. * This is dynamic to allow compat with webgl 1 and 2.
  88290. * You will need to pass the name of the uniform as well as the value.
  88291. */
  88292. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88293. /**
  88294. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88295. * This is dynamic to allow compat with webgl 1 and 2.
  88296. * You will need to pass the name of the uniform as well as the value.
  88297. */
  88298. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88299. /**
  88300. * Instantiates a new Uniform buffer objects.
  88301. *
  88302. * Handles blocks of uniform on the GPU.
  88303. *
  88304. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88305. *
  88306. * For more information, please refer to :
  88307. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88308. * @param engine Define the engine the buffer is associated with
  88309. * @param data Define the data contained in the buffer
  88310. * @param dynamic Define if the buffer is updatable
  88311. */
  88312. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88313. /**
  88314. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88315. * or just falling back on setUniformXXX calls.
  88316. */
  88317. get useUbo(): boolean;
  88318. /**
  88319. * Indicates if the WebGL underlying uniform buffer is in sync
  88320. * with the javascript cache data.
  88321. */
  88322. get isSync(): boolean;
  88323. /**
  88324. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88325. * Also, a dynamic UniformBuffer will disable cache verification and always
  88326. * update the underlying WebGL uniform buffer to the GPU.
  88327. * @returns if Dynamic, otherwise false
  88328. */
  88329. isDynamic(): boolean;
  88330. /**
  88331. * The data cache on JS side.
  88332. * @returns the underlying data as a float array
  88333. */
  88334. getData(): Float32Array;
  88335. /**
  88336. * The underlying WebGL Uniform buffer.
  88337. * @returns the webgl buffer
  88338. */
  88339. getBuffer(): Nullable<DataBuffer>;
  88340. /**
  88341. * std140 layout specifies how to align data within an UBO structure.
  88342. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88343. * for specs.
  88344. */
  88345. private _fillAlignment;
  88346. /**
  88347. * Adds an uniform in the buffer.
  88348. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88349. * for the layout to be correct !
  88350. * @param name Name of the uniform, as used in the uniform block in the shader.
  88351. * @param size Data size, or data directly.
  88352. */
  88353. addUniform(name: string, size: number | number[]): void;
  88354. /**
  88355. * Adds a Matrix 4x4 to the uniform buffer.
  88356. * @param name Name of the uniform, as used in the uniform block in the shader.
  88357. * @param mat A 4x4 matrix.
  88358. */
  88359. addMatrix(name: string, mat: Matrix): void;
  88360. /**
  88361. * Adds a vec2 to the uniform buffer.
  88362. * @param name Name of the uniform, as used in the uniform block in the shader.
  88363. * @param x Define the x component value of the vec2
  88364. * @param y Define the y component value of the vec2
  88365. */
  88366. addFloat2(name: string, x: number, y: number): void;
  88367. /**
  88368. * Adds a vec3 to the uniform buffer.
  88369. * @param name Name of the uniform, as used in the uniform block in the shader.
  88370. * @param x Define the x component value of the vec3
  88371. * @param y Define the y component value of the vec3
  88372. * @param z Define the z component value of the vec3
  88373. */
  88374. addFloat3(name: string, x: number, y: number, z: number): void;
  88375. /**
  88376. * Adds a vec3 to the uniform buffer.
  88377. * @param name Name of the uniform, as used in the uniform block in the shader.
  88378. * @param color Define the vec3 from a Color
  88379. */
  88380. addColor3(name: string, color: Color3): void;
  88381. /**
  88382. * Adds a vec4 to the uniform buffer.
  88383. * @param name Name of the uniform, as used in the uniform block in the shader.
  88384. * @param color Define the rgb components from a Color
  88385. * @param alpha Define the a component of the vec4
  88386. */
  88387. addColor4(name: string, color: Color3, alpha: number): void;
  88388. /**
  88389. * Adds a vec3 to the uniform buffer.
  88390. * @param name Name of the uniform, as used in the uniform block in the shader.
  88391. * @param vector Define the vec3 components from a Vector
  88392. */
  88393. addVector3(name: string, vector: Vector3): void;
  88394. /**
  88395. * Adds a Matrix 3x3 to the uniform buffer.
  88396. * @param name Name of the uniform, as used in the uniform block in the shader.
  88397. */
  88398. addMatrix3x3(name: string): void;
  88399. /**
  88400. * Adds a Matrix 2x2 to the uniform buffer.
  88401. * @param name Name of the uniform, as used in the uniform block in the shader.
  88402. */
  88403. addMatrix2x2(name: string): void;
  88404. /**
  88405. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88406. */
  88407. create(): void;
  88408. /** @hidden */
  88409. _rebuild(): void;
  88410. /**
  88411. * Updates the WebGL Uniform Buffer on the GPU.
  88412. * If the `dynamic` flag is set to true, no cache comparison is done.
  88413. * Otherwise, the buffer will be updated only if the cache differs.
  88414. */
  88415. update(): void;
  88416. /**
  88417. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88418. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88419. * @param data Define the flattened data
  88420. * @param size Define the size of the data.
  88421. */
  88422. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88423. private _valueCache;
  88424. private _cacheMatrix;
  88425. private _updateMatrix3x3ForUniform;
  88426. private _updateMatrix3x3ForEffect;
  88427. private _updateMatrix2x2ForEffect;
  88428. private _updateMatrix2x2ForUniform;
  88429. private _updateFloatForEffect;
  88430. private _updateFloatForUniform;
  88431. private _updateFloat2ForEffect;
  88432. private _updateFloat2ForUniform;
  88433. private _updateFloat3ForEffect;
  88434. private _updateFloat3ForUniform;
  88435. private _updateFloat4ForEffect;
  88436. private _updateFloat4ForUniform;
  88437. private _updateMatrixForEffect;
  88438. private _updateMatrixForUniform;
  88439. private _updateVector3ForEffect;
  88440. private _updateVector3ForUniform;
  88441. private _updateVector4ForEffect;
  88442. private _updateVector4ForUniform;
  88443. private _updateColor3ForEffect;
  88444. private _updateColor3ForUniform;
  88445. private _updateColor4ForEffect;
  88446. private _updateColor4ForUniform;
  88447. /**
  88448. * Sets a sampler uniform on the effect.
  88449. * @param name Define the name of the sampler.
  88450. * @param texture Define the texture to set in the sampler
  88451. */
  88452. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88453. /**
  88454. * Directly updates the value of the uniform in the cache AND on the GPU.
  88455. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88456. * @param data Define the flattened data
  88457. */
  88458. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88459. /**
  88460. * Binds this uniform buffer to an effect.
  88461. * @param effect Define the effect to bind the buffer to
  88462. * @param name Name of the uniform block in the shader.
  88463. */
  88464. bindToEffect(effect: Effect, name: string): void;
  88465. /**
  88466. * Disposes the uniform buffer.
  88467. */
  88468. dispose(): void;
  88469. }
  88470. }
  88471. declare module BABYLON {
  88472. /**
  88473. * Enum that determines the text-wrapping mode to use.
  88474. */
  88475. export enum InspectableType {
  88476. /**
  88477. * Checkbox for booleans
  88478. */
  88479. Checkbox = 0,
  88480. /**
  88481. * Sliders for numbers
  88482. */
  88483. Slider = 1,
  88484. /**
  88485. * Vector3
  88486. */
  88487. Vector3 = 2,
  88488. /**
  88489. * Quaternions
  88490. */
  88491. Quaternion = 3,
  88492. /**
  88493. * Color3
  88494. */
  88495. Color3 = 4,
  88496. /**
  88497. * String
  88498. */
  88499. String = 5
  88500. }
  88501. /**
  88502. * Interface used to define custom inspectable properties.
  88503. * This interface is used by the inspector to display custom property grids
  88504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88505. */
  88506. export interface IInspectable {
  88507. /**
  88508. * Gets the label to display
  88509. */
  88510. label: string;
  88511. /**
  88512. * Gets the name of the property to edit
  88513. */
  88514. propertyName: string;
  88515. /**
  88516. * Gets the type of the editor to use
  88517. */
  88518. type: InspectableType;
  88519. /**
  88520. * Gets the minimum value of the property when using in "slider" mode
  88521. */
  88522. min?: number;
  88523. /**
  88524. * Gets the maximum value of the property when using in "slider" mode
  88525. */
  88526. max?: number;
  88527. /**
  88528. * Gets the setp to use when using in "slider" mode
  88529. */
  88530. step?: number;
  88531. }
  88532. }
  88533. declare module BABYLON {
  88534. /**
  88535. * Class used to provide helper for timing
  88536. */
  88537. export class TimingTools {
  88538. /**
  88539. * Polyfill for setImmediate
  88540. * @param action defines the action to execute after the current execution block
  88541. */
  88542. static SetImmediate(action: () => void): void;
  88543. }
  88544. }
  88545. declare module BABYLON {
  88546. /**
  88547. * Class used to enable instatition of objects by class name
  88548. */
  88549. export class InstantiationTools {
  88550. /**
  88551. * Use this object to register external classes like custom textures or material
  88552. * to allow the laoders to instantiate them
  88553. */
  88554. static RegisteredExternalClasses: {
  88555. [key: string]: Object;
  88556. };
  88557. /**
  88558. * Tries to instantiate a new object from a given class name
  88559. * @param className defines the class name to instantiate
  88560. * @returns the new object or null if the system was not able to do the instantiation
  88561. */
  88562. static Instantiate(className: string): any;
  88563. }
  88564. }
  88565. declare module BABYLON {
  88566. /**
  88567. * Define options used to create a depth texture
  88568. */
  88569. export class DepthTextureCreationOptions {
  88570. /** Specifies whether or not a stencil should be allocated in the texture */
  88571. generateStencil?: boolean;
  88572. /** Specifies whether or not bilinear filtering is enable on the texture */
  88573. bilinearFiltering?: boolean;
  88574. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88575. comparisonFunction?: number;
  88576. /** Specifies if the created texture is a cube texture */
  88577. isCube?: boolean;
  88578. }
  88579. }
  88580. declare module BABYLON {
  88581. interface ThinEngine {
  88582. /**
  88583. * Creates a depth stencil cube texture.
  88584. * This is only available in WebGL 2.
  88585. * @param size The size of face edge in the cube texture.
  88586. * @param options The options defining the cube texture.
  88587. * @returns The cube texture
  88588. */
  88589. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88590. /**
  88591. * Creates a cube texture
  88592. * @param rootUrl defines the url where the files to load is located
  88593. * @param scene defines the current scene
  88594. * @param files defines the list of files to load (1 per face)
  88595. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88596. * @param onLoad defines an optional callback raised when the texture is loaded
  88597. * @param onError defines an optional callback raised if there is an issue to load the texture
  88598. * @param format defines the format of the data
  88599. * @param forcedExtension defines the extension to use to pick the right loader
  88600. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88601. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88602. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88603. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88604. * @param loaderOptions options to be passed to the loader
  88605. * @returns the cube texture as an InternalTexture
  88606. */
  88607. 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>, loaderOptions: any): InternalTexture;
  88608. /**
  88609. * Creates a cube texture
  88610. * @param rootUrl defines the url where the files to load is located
  88611. * @param scene defines the current scene
  88612. * @param files defines the list of files to load (1 per face)
  88613. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88614. * @param onLoad defines an optional callback raised when the texture is loaded
  88615. * @param onError defines an optional callback raised if there is an issue to load the texture
  88616. * @param format defines the format of the data
  88617. * @param forcedExtension defines the extension to use to pick the right loader
  88618. * @returns the cube texture as an InternalTexture
  88619. */
  88620. 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;
  88621. /**
  88622. * Creates a cube texture
  88623. * @param rootUrl defines the url where the files to load is located
  88624. * @param scene defines the current scene
  88625. * @param files defines the list of files to load (1 per face)
  88626. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88627. * @param onLoad defines an optional callback raised when the texture is loaded
  88628. * @param onError defines an optional callback raised if there is an issue to load the texture
  88629. * @param format defines the format of the data
  88630. * @param forcedExtension defines the extension to use to pick the right loader
  88631. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88634. * @returns the cube texture as an InternalTexture
  88635. */
  88636. 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;
  88637. /** @hidden */
  88638. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88639. /** @hidden */
  88640. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88641. /** @hidden */
  88642. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88643. /** @hidden */
  88644. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88645. /**
  88646. * @hidden
  88647. */
  88648. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  88649. }
  88650. }
  88651. declare module BABYLON {
  88652. /**
  88653. * Class for creating a cube texture
  88654. */
  88655. export class CubeTexture extends BaseTexture {
  88656. private _delayedOnLoad;
  88657. /**
  88658. * Observable triggered once the texture has been loaded.
  88659. */
  88660. onLoadObservable: Observable<CubeTexture>;
  88661. /**
  88662. * The url of the texture
  88663. */
  88664. url: string;
  88665. /**
  88666. * Gets or sets the center of the bounding box associated with the cube texture.
  88667. * It must define where the camera used to render the texture was set
  88668. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88669. */
  88670. boundingBoxPosition: Vector3;
  88671. private _boundingBoxSize;
  88672. /**
  88673. * Gets or sets the size of the bounding box associated with the cube texture
  88674. * When defined, the cubemap will switch to local mode
  88675. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88676. * @example https://www.babylonjs-playground.com/#RNASML
  88677. */
  88678. set boundingBoxSize(value: Vector3);
  88679. /**
  88680. * Returns the bounding box size
  88681. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88682. */
  88683. get boundingBoxSize(): Vector3;
  88684. protected _rotationY: number;
  88685. /**
  88686. * Sets texture matrix rotation angle around Y axis in radians.
  88687. */
  88688. set rotationY(value: number);
  88689. /**
  88690. * Gets texture matrix rotation angle around Y axis radians.
  88691. */
  88692. get rotationY(): number;
  88693. /**
  88694. * Are mip maps generated for this texture or not.
  88695. */
  88696. get noMipmap(): boolean;
  88697. private _noMipmap;
  88698. private _files;
  88699. protected _forcedExtension: Nullable<string>;
  88700. private _extensions;
  88701. private _textureMatrix;
  88702. private _format;
  88703. private _createPolynomials;
  88704. private _loaderOptions;
  88705. /**
  88706. * Creates a cube texture from an array of image urls
  88707. * @param files defines an array of image urls
  88708. * @param scene defines the hosting scene
  88709. * @param noMipmap specifies if mip maps are not used
  88710. * @returns a cube texture
  88711. */
  88712. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88713. /**
  88714. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88715. * @param url defines the url of the prefiltered texture
  88716. * @param scene defines the scene the texture is attached to
  88717. * @param forcedExtension defines the extension of the file if different from the url
  88718. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88719. * @return the prefiltered texture
  88720. */
  88721. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88722. /**
  88723. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88724. * as prefiltered data.
  88725. * @param rootUrl defines the url of the texture or the root name of the six images
  88726. * @param null defines the scene or engine the texture is attached to
  88727. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88728. * @param noMipmap defines if mipmaps should be created or not
  88729. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88730. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88731. * @param onError defines a callback triggered in case of error during load
  88732. * @param format defines the internal format to use for the texture once loaded
  88733. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88734. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88735. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88738. * @param loaderOptions options to be passed to the loader
  88739. * @return the cube texture
  88740. */
  88741. 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, loaderOptions?: any);
  88742. /**
  88743. * Get the current class name of the texture useful for serialization or dynamic coding.
  88744. * @returns "CubeTexture"
  88745. */
  88746. getClassName(): string;
  88747. /**
  88748. * Update the url (and optional buffer) of this texture if url was null during construction.
  88749. * @param url the url of the texture
  88750. * @param forcedExtension defines the extension to use
  88751. * @param onLoad callback called when the texture is loaded (defaults to null)
  88752. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88753. */
  88754. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88755. /**
  88756. * Delays loading of the cube texture
  88757. * @param forcedExtension defines the extension to use
  88758. */
  88759. delayLoad(forcedExtension?: string): void;
  88760. /**
  88761. * Returns the reflection texture matrix
  88762. * @returns the reflection texture matrix
  88763. */
  88764. getReflectionTextureMatrix(): Matrix;
  88765. /**
  88766. * Sets the reflection texture matrix
  88767. * @param value Reflection texture matrix
  88768. */
  88769. setReflectionTextureMatrix(value: Matrix): void;
  88770. /**
  88771. * Parses text to create a cube texture
  88772. * @param parsedTexture define the serialized text to read from
  88773. * @param scene defines the hosting scene
  88774. * @param rootUrl defines the root url of the cube texture
  88775. * @returns a cube texture
  88776. */
  88777. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88778. /**
  88779. * Makes a clone, or deep copy, of the cube texture
  88780. * @returns a new cube texture
  88781. */
  88782. clone(): CubeTexture;
  88783. }
  88784. }
  88785. declare module BABYLON {
  88786. /**
  88787. * Manages the defines for the Material
  88788. */
  88789. export class MaterialDefines {
  88790. /** @hidden */
  88791. protected _keys: string[];
  88792. private _isDirty;
  88793. /** @hidden */
  88794. _renderId: number;
  88795. /** @hidden */
  88796. _areLightsDirty: boolean;
  88797. /** @hidden */
  88798. _areLightsDisposed: boolean;
  88799. /** @hidden */
  88800. _areAttributesDirty: boolean;
  88801. /** @hidden */
  88802. _areTexturesDirty: boolean;
  88803. /** @hidden */
  88804. _areFresnelDirty: boolean;
  88805. /** @hidden */
  88806. _areMiscDirty: boolean;
  88807. /** @hidden */
  88808. _arePrePassDirty: boolean;
  88809. /** @hidden */
  88810. _areImageProcessingDirty: boolean;
  88811. /** @hidden */
  88812. _normals: boolean;
  88813. /** @hidden */
  88814. _uvs: boolean;
  88815. /** @hidden */
  88816. _needNormals: boolean;
  88817. /** @hidden */
  88818. _needUVs: boolean;
  88819. [id: string]: any;
  88820. /**
  88821. * Specifies if the material needs to be re-calculated
  88822. */
  88823. get isDirty(): boolean;
  88824. /**
  88825. * Marks the material to indicate that it has been re-calculated
  88826. */
  88827. markAsProcessed(): void;
  88828. /**
  88829. * Marks the material to indicate that it needs to be re-calculated
  88830. */
  88831. markAsUnprocessed(): void;
  88832. /**
  88833. * Marks the material to indicate all of its defines need to be re-calculated
  88834. */
  88835. markAllAsDirty(): void;
  88836. /**
  88837. * Marks the material to indicate that image processing needs to be re-calculated
  88838. */
  88839. markAsImageProcessingDirty(): void;
  88840. /**
  88841. * Marks the material to indicate the lights need to be re-calculated
  88842. * @param disposed Defines whether the light is dirty due to dispose or not
  88843. */
  88844. markAsLightDirty(disposed?: boolean): void;
  88845. /**
  88846. * Marks the attribute state as changed
  88847. */
  88848. markAsAttributesDirty(): void;
  88849. /**
  88850. * Marks the texture state as changed
  88851. */
  88852. markAsTexturesDirty(): void;
  88853. /**
  88854. * Marks the fresnel state as changed
  88855. */
  88856. markAsFresnelDirty(): void;
  88857. /**
  88858. * Marks the misc state as changed
  88859. */
  88860. markAsMiscDirty(): void;
  88861. /**
  88862. * Marks the prepass state as changed
  88863. */
  88864. markAsPrePassDirty(): void;
  88865. /**
  88866. * Rebuilds the material defines
  88867. */
  88868. rebuild(): void;
  88869. /**
  88870. * Specifies if two material defines are equal
  88871. * @param other - A material define instance to compare to
  88872. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88873. */
  88874. isEqual(other: MaterialDefines): boolean;
  88875. /**
  88876. * Clones this instance's defines to another instance
  88877. * @param other - material defines to clone values to
  88878. */
  88879. cloneTo(other: MaterialDefines): void;
  88880. /**
  88881. * Resets the material define values
  88882. */
  88883. reset(): void;
  88884. /**
  88885. * Converts the material define values to a string
  88886. * @returns - String of material define information
  88887. */
  88888. toString(): string;
  88889. }
  88890. }
  88891. declare module BABYLON {
  88892. /**
  88893. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88894. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88895. * 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;
  88896. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88897. */
  88898. export class ColorCurves {
  88899. private _dirty;
  88900. private _tempColor;
  88901. private _globalCurve;
  88902. private _highlightsCurve;
  88903. private _midtonesCurve;
  88904. private _shadowsCurve;
  88905. private _positiveCurve;
  88906. private _negativeCurve;
  88907. private _globalHue;
  88908. private _globalDensity;
  88909. private _globalSaturation;
  88910. private _globalExposure;
  88911. /**
  88912. * Gets the global Hue value.
  88913. * 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).
  88914. */
  88915. get globalHue(): number;
  88916. /**
  88917. * Sets the global Hue value.
  88918. * 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).
  88919. */
  88920. set globalHue(value: number);
  88921. /**
  88922. * Gets the global Density value.
  88923. * 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.
  88924. * Values less than zero provide a filter of opposite hue.
  88925. */
  88926. get globalDensity(): number;
  88927. /**
  88928. * Sets the global Density value.
  88929. * 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.
  88930. * Values less than zero provide a filter of opposite hue.
  88931. */
  88932. set globalDensity(value: number);
  88933. /**
  88934. * Gets the global Saturation value.
  88935. * 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.
  88936. */
  88937. get globalSaturation(): number;
  88938. /**
  88939. * Sets the global Saturation value.
  88940. * 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.
  88941. */
  88942. set globalSaturation(value: number);
  88943. /**
  88944. * Gets the global Exposure value.
  88945. * 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.
  88946. */
  88947. get globalExposure(): number;
  88948. /**
  88949. * Sets the global Exposure value.
  88950. * 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.
  88951. */
  88952. set globalExposure(value: number);
  88953. private _highlightsHue;
  88954. private _highlightsDensity;
  88955. private _highlightsSaturation;
  88956. private _highlightsExposure;
  88957. /**
  88958. * Gets the highlights Hue value.
  88959. * 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).
  88960. */
  88961. get highlightsHue(): number;
  88962. /**
  88963. * Sets the highlights Hue value.
  88964. * 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).
  88965. */
  88966. set highlightsHue(value: number);
  88967. /**
  88968. * Gets the highlights Density value.
  88969. * 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.
  88970. * Values less than zero provide a filter of opposite hue.
  88971. */
  88972. get highlightsDensity(): number;
  88973. /**
  88974. * Sets the highlights Density value.
  88975. * 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.
  88976. * Values less than zero provide a filter of opposite hue.
  88977. */
  88978. set highlightsDensity(value: number);
  88979. /**
  88980. * Gets the highlights Saturation value.
  88981. * 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.
  88982. */
  88983. get highlightsSaturation(): number;
  88984. /**
  88985. * Sets the highlights Saturation value.
  88986. * 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.
  88987. */
  88988. set highlightsSaturation(value: number);
  88989. /**
  88990. * Gets the highlights Exposure value.
  88991. * 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.
  88992. */
  88993. get highlightsExposure(): number;
  88994. /**
  88995. * Sets the highlights Exposure value.
  88996. * 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.
  88997. */
  88998. set highlightsExposure(value: number);
  88999. private _midtonesHue;
  89000. private _midtonesDensity;
  89001. private _midtonesSaturation;
  89002. private _midtonesExposure;
  89003. /**
  89004. * Gets the midtones Hue value.
  89005. * 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).
  89006. */
  89007. get midtonesHue(): number;
  89008. /**
  89009. * Sets the midtones Hue value.
  89010. * 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).
  89011. */
  89012. set midtonesHue(value: number);
  89013. /**
  89014. * Gets the midtones Density value.
  89015. * 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.
  89016. * Values less than zero provide a filter of opposite hue.
  89017. */
  89018. get midtonesDensity(): number;
  89019. /**
  89020. * Sets the midtones Density value.
  89021. * 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.
  89022. * Values less than zero provide a filter of opposite hue.
  89023. */
  89024. set midtonesDensity(value: number);
  89025. /**
  89026. * Gets the midtones Saturation value.
  89027. * 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.
  89028. */
  89029. get midtonesSaturation(): number;
  89030. /**
  89031. * Sets the midtones Saturation value.
  89032. * 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.
  89033. */
  89034. set midtonesSaturation(value: number);
  89035. /**
  89036. * Gets the midtones Exposure value.
  89037. * 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.
  89038. */
  89039. get midtonesExposure(): number;
  89040. /**
  89041. * Sets the midtones Exposure value.
  89042. * 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.
  89043. */
  89044. set midtonesExposure(value: number);
  89045. private _shadowsHue;
  89046. private _shadowsDensity;
  89047. private _shadowsSaturation;
  89048. private _shadowsExposure;
  89049. /**
  89050. * Gets the shadows Hue value.
  89051. * 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).
  89052. */
  89053. get shadowsHue(): number;
  89054. /**
  89055. * Sets the shadows Hue value.
  89056. * 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).
  89057. */
  89058. set shadowsHue(value: number);
  89059. /**
  89060. * Gets the shadows Density value.
  89061. * 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.
  89062. * Values less than zero provide a filter of opposite hue.
  89063. */
  89064. get shadowsDensity(): number;
  89065. /**
  89066. * Sets the shadows Density value.
  89067. * 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.
  89068. * Values less than zero provide a filter of opposite hue.
  89069. */
  89070. set shadowsDensity(value: number);
  89071. /**
  89072. * Gets the shadows Saturation value.
  89073. * 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.
  89074. */
  89075. get shadowsSaturation(): number;
  89076. /**
  89077. * Sets the shadows Saturation value.
  89078. * 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.
  89079. */
  89080. set shadowsSaturation(value: number);
  89081. /**
  89082. * Gets the shadows Exposure value.
  89083. * 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.
  89084. */
  89085. get shadowsExposure(): number;
  89086. /**
  89087. * Sets the shadows Exposure value.
  89088. * 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.
  89089. */
  89090. set shadowsExposure(value: number);
  89091. /**
  89092. * Returns the class name
  89093. * @returns The class name
  89094. */
  89095. getClassName(): string;
  89096. /**
  89097. * Binds the color curves to the shader.
  89098. * @param colorCurves The color curve to bind
  89099. * @param effect The effect to bind to
  89100. * @param positiveUniform The positive uniform shader parameter
  89101. * @param neutralUniform The neutral uniform shader parameter
  89102. * @param negativeUniform The negative uniform shader parameter
  89103. */
  89104. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89105. /**
  89106. * Prepare the list of uniforms associated with the ColorCurves effects.
  89107. * @param uniformsList The list of uniforms used in the effect
  89108. */
  89109. static PrepareUniforms(uniformsList: string[]): void;
  89110. /**
  89111. * Returns color grading data based on a hue, density, saturation and exposure value.
  89112. * @param filterHue The hue of the color filter.
  89113. * @param filterDensity The density of the color filter.
  89114. * @param saturation The saturation.
  89115. * @param exposure The exposure.
  89116. * @param result The result data container.
  89117. */
  89118. private getColorGradingDataToRef;
  89119. /**
  89120. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89121. * @param value The input slider value in range [-100,100].
  89122. * @returns Adjusted value.
  89123. */
  89124. private static applyColorGradingSliderNonlinear;
  89125. /**
  89126. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89127. * @param hue The hue (H) input.
  89128. * @param saturation The saturation (S) input.
  89129. * @param brightness The brightness (B) input.
  89130. * @result An RGBA color represented as Vector4.
  89131. */
  89132. private static fromHSBToRef;
  89133. /**
  89134. * Returns a value clamped between min and max
  89135. * @param value The value to clamp
  89136. * @param min The minimum of value
  89137. * @param max The maximum of value
  89138. * @returns The clamped value.
  89139. */
  89140. private static clamp;
  89141. /**
  89142. * Clones the current color curve instance.
  89143. * @return The cloned curves
  89144. */
  89145. clone(): ColorCurves;
  89146. /**
  89147. * Serializes the current color curve instance to a json representation.
  89148. * @return a JSON representation
  89149. */
  89150. serialize(): any;
  89151. /**
  89152. * Parses the color curve from a json representation.
  89153. * @param source the JSON source to parse
  89154. * @return The parsed curves
  89155. */
  89156. static Parse(source: any): ColorCurves;
  89157. }
  89158. }
  89159. declare module BABYLON {
  89160. /**
  89161. * Interface to follow in your material defines to integrate easily the
  89162. * Image proccessing functions.
  89163. * @hidden
  89164. */
  89165. export interface IImageProcessingConfigurationDefines {
  89166. IMAGEPROCESSING: boolean;
  89167. VIGNETTE: boolean;
  89168. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89169. VIGNETTEBLENDMODEOPAQUE: boolean;
  89170. TONEMAPPING: boolean;
  89171. TONEMAPPING_ACES: boolean;
  89172. CONTRAST: boolean;
  89173. EXPOSURE: boolean;
  89174. COLORCURVES: boolean;
  89175. COLORGRADING: boolean;
  89176. COLORGRADING3D: boolean;
  89177. SAMPLER3DGREENDEPTH: boolean;
  89178. SAMPLER3DBGRMAP: boolean;
  89179. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89180. }
  89181. /**
  89182. * @hidden
  89183. */
  89184. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89185. IMAGEPROCESSING: boolean;
  89186. VIGNETTE: boolean;
  89187. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89188. VIGNETTEBLENDMODEOPAQUE: boolean;
  89189. TONEMAPPING: boolean;
  89190. TONEMAPPING_ACES: boolean;
  89191. CONTRAST: boolean;
  89192. COLORCURVES: boolean;
  89193. COLORGRADING: boolean;
  89194. COLORGRADING3D: boolean;
  89195. SAMPLER3DGREENDEPTH: boolean;
  89196. SAMPLER3DBGRMAP: boolean;
  89197. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89198. EXPOSURE: boolean;
  89199. constructor();
  89200. }
  89201. /**
  89202. * This groups together the common properties used for image processing either in direct forward pass
  89203. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89204. * or not.
  89205. */
  89206. export class ImageProcessingConfiguration {
  89207. /**
  89208. * Default tone mapping applied in BabylonJS.
  89209. */
  89210. static readonly TONEMAPPING_STANDARD: number;
  89211. /**
  89212. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89213. * to other engines rendering to increase portability.
  89214. */
  89215. static readonly TONEMAPPING_ACES: number;
  89216. /**
  89217. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89218. */
  89219. colorCurves: Nullable<ColorCurves>;
  89220. private _colorCurvesEnabled;
  89221. /**
  89222. * Gets wether the color curves effect is enabled.
  89223. */
  89224. get colorCurvesEnabled(): boolean;
  89225. /**
  89226. * Sets wether the color curves effect is enabled.
  89227. */
  89228. set colorCurvesEnabled(value: boolean);
  89229. private _colorGradingTexture;
  89230. /**
  89231. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89232. */
  89233. get colorGradingTexture(): Nullable<BaseTexture>;
  89234. /**
  89235. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89236. */
  89237. set colorGradingTexture(value: Nullable<BaseTexture>);
  89238. private _colorGradingEnabled;
  89239. /**
  89240. * Gets wether the color grading effect is enabled.
  89241. */
  89242. get colorGradingEnabled(): boolean;
  89243. /**
  89244. * Sets wether the color grading effect is enabled.
  89245. */
  89246. set colorGradingEnabled(value: boolean);
  89247. private _colorGradingWithGreenDepth;
  89248. /**
  89249. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89250. */
  89251. get colorGradingWithGreenDepth(): boolean;
  89252. /**
  89253. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89254. */
  89255. set colorGradingWithGreenDepth(value: boolean);
  89256. private _colorGradingBGR;
  89257. /**
  89258. * Gets wether the color grading texture contains BGR values.
  89259. */
  89260. get colorGradingBGR(): boolean;
  89261. /**
  89262. * Sets wether the color grading texture contains BGR values.
  89263. */
  89264. set colorGradingBGR(value: boolean);
  89265. /** @hidden */
  89266. _exposure: number;
  89267. /**
  89268. * Gets the Exposure used in the effect.
  89269. */
  89270. get exposure(): number;
  89271. /**
  89272. * Sets the Exposure used in the effect.
  89273. */
  89274. set exposure(value: number);
  89275. private _toneMappingEnabled;
  89276. /**
  89277. * Gets wether the tone mapping effect is enabled.
  89278. */
  89279. get toneMappingEnabled(): boolean;
  89280. /**
  89281. * Sets wether the tone mapping effect is enabled.
  89282. */
  89283. set toneMappingEnabled(value: boolean);
  89284. private _toneMappingType;
  89285. /**
  89286. * Gets the type of tone mapping effect.
  89287. */
  89288. get toneMappingType(): number;
  89289. /**
  89290. * Sets the type of tone mapping effect used in BabylonJS.
  89291. */
  89292. set toneMappingType(value: number);
  89293. protected _contrast: number;
  89294. /**
  89295. * Gets the contrast used in the effect.
  89296. */
  89297. get contrast(): number;
  89298. /**
  89299. * Sets the contrast used in the effect.
  89300. */
  89301. set contrast(value: number);
  89302. /**
  89303. * Vignette stretch size.
  89304. */
  89305. vignetteStretch: number;
  89306. /**
  89307. * Vignette centre X Offset.
  89308. */
  89309. vignetteCentreX: number;
  89310. /**
  89311. * Vignette centre Y Offset.
  89312. */
  89313. vignetteCentreY: number;
  89314. /**
  89315. * Vignette weight or intensity of the vignette effect.
  89316. */
  89317. vignetteWeight: number;
  89318. /**
  89319. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89320. * if vignetteEnabled is set to true.
  89321. */
  89322. vignetteColor: Color4;
  89323. /**
  89324. * Camera field of view used by the Vignette effect.
  89325. */
  89326. vignetteCameraFov: number;
  89327. private _vignetteBlendMode;
  89328. /**
  89329. * Gets the vignette blend mode allowing different kind of effect.
  89330. */
  89331. get vignetteBlendMode(): number;
  89332. /**
  89333. * Sets the vignette blend mode allowing different kind of effect.
  89334. */
  89335. set vignetteBlendMode(value: number);
  89336. private _vignetteEnabled;
  89337. /**
  89338. * Gets wether the vignette effect is enabled.
  89339. */
  89340. get vignetteEnabled(): boolean;
  89341. /**
  89342. * Sets wether the vignette effect is enabled.
  89343. */
  89344. set vignetteEnabled(value: boolean);
  89345. private _applyByPostProcess;
  89346. /**
  89347. * Gets wether the image processing is applied through a post process or not.
  89348. */
  89349. get applyByPostProcess(): boolean;
  89350. /**
  89351. * Sets wether the image processing is applied through a post process or not.
  89352. */
  89353. set applyByPostProcess(value: boolean);
  89354. private _isEnabled;
  89355. /**
  89356. * Gets wether the image processing is enabled or not.
  89357. */
  89358. get isEnabled(): boolean;
  89359. /**
  89360. * Sets wether the image processing is enabled or not.
  89361. */
  89362. set isEnabled(value: boolean);
  89363. /**
  89364. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89365. */
  89366. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89367. /**
  89368. * Method called each time the image processing information changes requires to recompile the effect.
  89369. */
  89370. protected _updateParameters(): void;
  89371. /**
  89372. * Gets the current class name.
  89373. * @return "ImageProcessingConfiguration"
  89374. */
  89375. getClassName(): string;
  89376. /**
  89377. * Prepare the list of uniforms associated with the Image Processing effects.
  89378. * @param uniforms The list of uniforms used in the effect
  89379. * @param defines the list of defines currently in use
  89380. */
  89381. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89382. /**
  89383. * Prepare the list of samplers associated with the Image Processing effects.
  89384. * @param samplersList The list of uniforms used in the effect
  89385. * @param defines the list of defines currently in use
  89386. */
  89387. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89388. /**
  89389. * Prepare the list of defines associated to the shader.
  89390. * @param defines the list of defines to complete
  89391. * @param forPostProcess Define if we are currently in post process mode or not
  89392. */
  89393. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89394. /**
  89395. * Returns true if all the image processing information are ready.
  89396. * @returns True if ready, otherwise, false
  89397. */
  89398. isReady(): boolean;
  89399. /**
  89400. * Binds the image processing to the shader.
  89401. * @param effect The effect to bind to
  89402. * @param overrideAspectRatio Override the aspect ratio of the effect
  89403. */
  89404. bind(effect: Effect, overrideAspectRatio?: number): void;
  89405. /**
  89406. * Clones the current image processing instance.
  89407. * @return The cloned image processing
  89408. */
  89409. clone(): ImageProcessingConfiguration;
  89410. /**
  89411. * Serializes the current image processing instance to a json representation.
  89412. * @return a JSON representation
  89413. */
  89414. serialize(): any;
  89415. /**
  89416. * Parses the image processing from a json representation.
  89417. * @param source the JSON source to parse
  89418. * @return The parsed image processing
  89419. */
  89420. static Parse(source: any): ImageProcessingConfiguration;
  89421. private static _VIGNETTEMODE_MULTIPLY;
  89422. private static _VIGNETTEMODE_OPAQUE;
  89423. /**
  89424. * Used to apply the vignette as a mix with the pixel color.
  89425. */
  89426. static get VIGNETTEMODE_MULTIPLY(): number;
  89427. /**
  89428. * Used to apply the vignette as a replacement of the pixel color.
  89429. */
  89430. static get VIGNETTEMODE_OPAQUE(): number;
  89431. }
  89432. }
  89433. declare module BABYLON {
  89434. /** @hidden */
  89435. export var postprocessVertexShader: {
  89436. name: string;
  89437. shader: string;
  89438. };
  89439. }
  89440. declare module BABYLON {
  89441. /**
  89442. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89443. */
  89444. export type RenderTargetTextureSize = number | {
  89445. width: number;
  89446. height: number;
  89447. layers?: number;
  89448. };
  89449. interface ThinEngine {
  89450. /**
  89451. * Creates a new render target texture
  89452. * @param size defines the size of the texture
  89453. * @param options defines the options used to create the texture
  89454. * @returns a new render target texture stored in an InternalTexture
  89455. */
  89456. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89457. /**
  89458. * Creates a depth stencil texture.
  89459. * This is only available in WebGL 2 or with the depth texture extension available.
  89460. * @param size The size of face edge in the texture.
  89461. * @param options The options defining the texture.
  89462. * @returns The texture
  89463. */
  89464. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89465. /** @hidden */
  89466. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89467. }
  89468. }
  89469. declare module BABYLON {
  89470. /**
  89471. * Defines the kind of connection point for node based material
  89472. */
  89473. export enum NodeMaterialBlockConnectionPointTypes {
  89474. /** Float */
  89475. Float = 1,
  89476. /** Int */
  89477. Int = 2,
  89478. /** Vector2 */
  89479. Vector2 = 4,
  89480. /** Vector3 */
  89481. Vector3 = 8,
  89482. /** Vector4 */
  89483. Vector4 = 16,
  89484. /** Color3 */
  89485. Color3 = 32,
  89486. /** Color4 */
  89487. Color4 = 64,
  89488. /** Matrix */
  89489. Matrix = 128,
  89490. /** Custom object */
  89491. Object = 256,
  89492. /** Detect type based on connection */
  89493. AutoDetect = 1024,
  89494. /** Output type that will be defined by input type */
  89495. BasedOnInput = 2048
  89496. }
  89497. }
  89498. declare module BABYLON {
  89499. /**
  89500. * Enum used to define the target of a block
  89501. */
  89502. export enum NodeMaterialBlockTargets {
  89503. /** Vertex shader */
  89504. Vertex = 1,
  89505. /** Fragment shader */
  89506. Fragment = 2,
  89507. /** Neutral */
  89508. Neutral = 4,
  89509. /** Vertex and Fragment */
  89510. VertexAndFragment = 3
  89511. }
  89512. }
  89513. declare module BABYLON {
  89514. /**
  89515. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89516. */
  89517. export enum NodeMaterialBlockConnectionPointMode {
  89518. /** Value is an uniform */
  89519. Uniform = 0,
  89520. /** Value is a mesh attribute */
  89521. Attribute = 1,
  89522. /** Value is a varying between vertex and fragment shaders */
  89523. Varying = 2,
  89524. /** Mode is undefined */
  89525. Undefined = 3
  89526. }
  89527. }
  89528. declare module BABYLON {
  89529. /**
  89530. * Enum used to define system values e.g. values automatically provided by the system
  89531. */
  89532. export enum NodeMaterialSystemValues {
  89533. /** World */
  89534. World = 1,
  89535. /** View */
  89536. View = 2,
  89537. /** Projection */
  89538. Projection = 3,
  89539. /** ViewProjection */
  89540. ViewProjection = 4,
  89541. /** WorldView */
  89542. WorldView = 5,
  89543. /** WorldViewProjection */
  89544. WorldViewProjection = 6,
  89545. /** CameraPosition */
  89546. CameraPosition = 7,
  89547. /** Fog Color */
  89548. FogColor = 8,
  89549. /** Delta time */
  89550. DeltaTime = 9
  89551. }
  89552. }
  89553. declare module BABYLON {
  89554. /** Defines supported spaces */
  89555. export enum Space {
  89556. /** Local (object) space */
  89557. LOCAL = 0,
  89558. /** World space */
  89559. WORLD = 1,
  89560. /** Bone space */
  89561. BONE = 2
  89562. }
  89563. /** Defines the 3 main axes */
  89564. export class Axis {
  89565. /** X axis */
  89566. static X: Vector3;
  89567. /** Y axis */
  89568. static Y: Vector3;
  89569. /** Z axis */
  89570. static Z: Vector3;
  89571. }
  89572. }
  89573. declare module BABYLON {
  89574. /**
  89575. * Represents a camera frustum
  89576. */
  89577. export class Frustum {
  89578. /**
  89579. * Gets the planes representing the frustum
  89580. * @param transform matrix to be applied to the returned planes
  89581. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89582. */
  89583. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89584. /**
  89585. * Gets the near frustum plane transformed by the transform matrix
  89586. * @param transform transformation matrix to be applied to the resulting frustum plane
  89587. * @param frustumPlane the resuling frustum plane
  89588. */
  89589. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89590. /**
  89591. * Gets the far frustum plane transformed by the transform matrix
  89592. * @param transform transformation matrix to be applied to the resulting frustum plane
  89593. * @param frustumPlane the resuling frustum plane
  89594. */
  89595. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89596. /**
  89597. * Gets the left frustum plane transformed by the transform matrix
  89598. * @param transform transformation matrix to be applied to the resulting frustum plane
  89599. * @param frustumPlane the resuling frustum plane
  89600. */
  89601. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89602. /**
  89603. * Gets the right frustum plane transformed by the transform matrix
  89604. * @param transform transformation matrix to be applied to the resulting frustum plane
  89605. * @param frustumPlane the resuling frustum plane
  89606. */
  89607. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89608. /**
  89609. * Gets the top frustum plane transformed by the transform matrix
  89610. * @param transform transformation matrix to be applied to the resulting frustum plane
  89611. * @param frustumPlane the resuling frustum plane
  89612. */
  89613. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89614. /**
  89615. * Gets the bottom frustum plane transformed by the transform matrix
  89616. * @param transform transformation matrix to be applied to the resulting frustum plane
  89617. * @param frustumPlane the resuling frustum plane
  89618. */
  89619. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89620. /**
  89621. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89622. * @param transform transformation matrix to be applied to the resulting frustum planes
  89623. * @param frustumPlanes the resuling frustum planes
  89624. */
  89625. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89626. }
  89627. }
  89628. declare module BABYLON {
  89629. /**
  89630. * Interface for the size containing width and height
  89631. */
  89632. export interface ISize {
  89633. /**
  89634. * Width
  89635. */
  89636. width: number;
  89637. /**
  89638. * Heighht
  89639. */
  89640. height: number;
  89641. }
  89642. /**
  89643. * Size containing widht and height
  89644. */
  89645. export class Size implements ISize {
  89646. /**
  89647. * Width
  89648. */
  89649. width: number;
  89650. /**
  89651. * Height
  89652. */
  89653. height: number;
  89654. /**
  89655. * Creates a Size object from the given width and height (floats).
  89656. * @param width width of the new size
  89657. * @param height height of the new size
  89658. */
  89659. constructor(width: number, height: number);
  89660. /**
  89661. * Returns a string with the Size width and height
  89662. * @returns a string with the Size width and height
  89663. */
  89664. toString(): string;
  89665. /**
  89666. * "Size"
  89667. * @returns the string "Size"
  89668. */
  89669. getClassName(): string;
  89670. /**
  89671. * Returns the Size hash code.
  89672. * @returns a hash code for a unique width and height
  89673. */
  89674. getHashCode(): number;
  89675. /**
  89676. * Updates the current size from the given one.
  89677. * @param src the given size
  89678. */
  89679. copyFrom(src: Size): void;
  89680. /**
  89681. * Updates in place the current Size from the given floats.
  89682. * @param width width of the new size
  89683. * @param height height of the new size
  89684. * @returns the updated Size.
  89685. */
  89686. copyFromFloats(width: number, height: number): Size;
  89687. /**
  89688. * Updates in place the current Size from the given floats.
  89689. * @param width width to set
  89690. * @param height height to set
  89691. * @returns the updated Size.
  89692. */
  89693. set(width: number, height: number): Size;
  89694. /**
  89695. * Multiplies the width and height by numbers
  89696. * @param w factor to multiple the width by
  89697. * @param h factor to multiple the height by
  89698. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89699. */
  89700. multiplyByFloats(w: number, h: number): Size;
  89701. /**
  89702. * Clones the size
  89703. * @returns a new Size copied from the given one.
  89704. */
  89705. clone(): Size;
  89706. /**
  89707. * True if the current Size and the given one width and height are strictly equal.
  89708. * @param other the other size to compare against
  89709. * @returns True if the current Size and the given one width and height are strictly equal.
  89710. */
  89711. equals(other: Size): boolean;
  89712. /**
  89713. * The surface of the Size : width * height (float).
  89714. */
  89715. get surface(): number;
  89716. /**
  89717. * Create a new size of zero
  89718. * @returns a new Size set to (0.0, 0.0)
  89719. */
  89720. static Zero(): Size;
  89721. /**
  89722. * Sums the width and height of two sizes
  89723. * @param otherSize size to add to this size
  89724. * @returns a new Size set as the addition result of the current Size and the given one.
  89725. */
  89726. add(otherSize: Size): Size;
  89727. /**
  89728. * Subtracts the width and height of two
  89729. * @param otherSize size to subtract to this size
  89730. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89731. */
  89732. subtract(otherSize: Size): Size;
  89733. /**
  89734. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89735. * @param start starting size to lerp between
  89736. * @param end end size to lerp between
  89737. * @param amount amount to lerp between the start and end values
  89738. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89739. */
  89740. static Lerp(start: Size, end: Size, amount: number): Size;
  89741. }
  89742. }
  89743. declare module BABYLON {
  89744. /**
  89745. * Contains position and normal vectors for a vertex
  89746. */
  89747. export class PositionNormalVertex {
  89748. /** the position of the vertex (defaut: 0,0,0) */
  89749. position: Vector3;
  89750. /** the normal of the vertex (defaut: 0,1,0) */
  89751. normal: Vector3;
  89752. /**
  89753. * Creates a PositionNormalVertex
  89754. * @param position the position of the vertex (defaut: 0,0,0)
  89755. * @param normal the normal of the vertex (defaut: 0,1,0)
  89756. */
  89757. constructor(
  89758. /** the position of the vertex (defaut: 0,0,0) */
  89759. position?: Vector3,
  89760. /** the normal of the vertex (defaut: 0,1,0) */
  89761. normal?: Vector3);
  89762. /**
  89763. * Clones the PositionNormalVertex
  89764. * @returns the cloned PositionNormalVertex
  89765. */
  89766. clone(): PositionNormalVertex;
  89767. }
  89768. /**
  89769. * Contains position, normal and uv vectors for a vertex
  89770. */
  89771. export class PositionNormalTextureVertex {
  89772. /** the position of the vertex (defaut: 0,0,0) */
  89773. position: Vector3;
  89774. /** the normal of the vertex (defaut: 0,1,0) */
  89775. normal: Vector3;
  89776. /** the uv of the vertex (default: 0,0) */
  89777. uv: Vector2;
  89778. /**
  89779. * Creates a PositionNormalTextureVertex
  89780. * @param position the position of the vertex (defaut: 0,0,0)
  89781. * @param normal the normal of the vertex (defaut: 0,1,0)
  89782. * @param uv the uv of the vertex (default: 0,0)
  89783. */
  89784. constructor(
  89785. /** the position of the vertex (defaut: 0,0,0) */
  89786. position?: Vector3,
  89787. /** the normal of the vertex (defaut: 0,1,0) */
  89788. normal?: Vector3,
  89789. /** the uv of the vertex (default: 0,0) */
  89790. uv?: Vector2);
  89791. /**
  89792. * Clones the PositionNormalTextureVertex
  89793. * @returns the cloned PositionNormalTextureVertex
  89794. */
  89795. clone(): PositionNormalTextureVertex;
  89796. }
  89797. }
  89798. declare module BABYLON {
  89799. /**
  89800. * Enum defining the type of animations supported by InputBlock
  89801. */
  89802. export enum AnimatedInputBlockTypes {
  89803. /** No animation */
  89804. None = 0,
  89805. /** Time based animation. Will only work for floats */
  89806. Time = 1
  89807. }
  89808. }
  89809. declare module BABYLON {
  89810. /**
  89811. * Interface describing all the common properties and methods a shadow light needs to implement.
  89812. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89813. * as well as binding the different shadow properties to the effects.
  89814. */
  89815. export interface IShadowLight extends Light {
  89816. /**
  89817. * The light id in the scene (used in scene.findLighById for instance)
  89818. */
  89819. id: string;
  89820. /**
  89821. * The position the shdow will be casted from.
  89822. */
  89823. position: Vector3;
  89824. /**
  89825. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89826. */
  89827. direction: Vector3;
  89828. /**
  89829. * The transformed position. Position of the light in world space taking parenting in account.
  89830. */
  89831. transformedPosition: Vector3;
  89832. /**
  89833. * The transformed direction. Direction of the light in world space taking parenting in account.
  89834. */
  89835. transformedDirection: Vector3;
  89836. /**
  89837. * The friendly name of the light in the scene.
  89838. */
  89839. name: string;
  89840. /**
  89841. * Defines the shadow projection clipping minimum z value.
  89842. */
  89843. shadowMinZ: number;
  89844. /**
  89845. * Defines the shadow projection clipping maximum z value.
  89846. */
  89847. shadowMaxZ: number;
  89848. /**
  89849. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89850. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89851. */
  89852. computeTransformedInformation(): boolean;
  89853. /**
  89854. * Gets the scene the light belongs to.
  89855. * @returns The scene
  89856. */
  89857. getScene(): Scene;
  89858. /**
  89859. * Callback defining a custom Projection Matrix Builder.
  89860. * This can be used to override the default projection matrix computation.
  89861. */
  89862. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89863. /**
  89864. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89865. * @param matrix The materix to updated with the projection information
  89866. * @param viewMatrix The transform matrix of the light
  89867. * @param renderList The list of mesh to render in the map
  89868. * @returns The current light
  89869. */
  89870. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89871. /**
  89872. * Gets the current depth scale used in ESM.
  89873. * @returns The scale
  89874. */
  89875. getDepthScale(): number;
  89876. /**
  89877. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89878. * @returns true if a cube texture needs to be use
  89879. */
  89880. needCube(): boolean;
  89881. /**
  89882. * Detects if the projection matrix requires to be recomputed this frame.
  89883. * @returns true if it requires to be recomputed otherwise, false.
  89884. */
  89885. needProjectionMatrixCompute(): boolean;
  89886. /**
  89887. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89888. */
  89889. forceProjectionMatrixCompute(): void;
  89890. /**
  89891. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89892. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89893. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89894. */
  89895. getShadowDirection(faceIndex?: number): Vector3;
  89896. /**
  89897. * Gets the minZ used for shadow according to both the scene and the light.
  89898. * @param activeCamera The camera we are returning the min for
  89899. * @returns the depth min z
  89900. */
  89901. getDepthMinZ(activeCamera: Camera): number;
  89902. /**
  89903. * Gets the maxZ used for shadow according to both the scene and the light.
  89904. * @param activeCamera The camera we are returning the max for
  89905. * @returns the depth max z
  89906. */
  89907. getDepthMaxZ(activeCamera: Camera): number;
  89908. }
  89909. /**
  89910. * Base implementation IShadowLight
  89911. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89912. */
  89913. export abstract class ShadowLight extends Light implements IShadowLight {
  89914. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89915. protected _position: Vector3;
  89916. protected _setPosition(value: Vector3): void;
  89917. /**
  89918. * Sets the position the shadow will be casted from. Also use as the light position for both
  89919. * point and spot lights.
  89920. */
  89921. get position(): Vector3;
  89922. /**
  89923. * Sets the position the shadow will be casted from. Also use as the light position for both
  89924. * point and spot lights.
  89925. */
  89926. set position(value: Vector3);
  89927. protected _direction: Vector3;
  89928. protected _setDirection(value: Vector3): void;
  89929. /**
  89930. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89931. * Also use as the light direction on spot and directional lights.
  89932. */
  89933. get direction(): Vector3;
  89934. /**
  89935. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89936. * Also use as the light direction on spot and directional lights.
  89937. */
  89938. set direction(value: Vector3);
  89939. protected _shadowMinZ: number;
  89940. /**
  89941. * Gets the shadow projection clipping minimum z value.
  89942. */
  89943. get shadowMinZ(): number;
  89944. /**
  89945. * Sets the shadow projection clipping minimum z value.
  89946. */
  89947. set shadowMinZ(value: number);
  89948. protected _shadowMaxZ: number;
  89949. /**
  89950. * Sets the shadow projection clipping maximum z value.
  89951. */
  89952. get shadowMaxZ(): number;
  89953. /**
  89954. * Gets the shadow projection clipping maximum z value.
  89955. */
  89956. set shadowMaxZ(value: number);
  89957. /**
  89958. * Callback defining a custom Projection Matrix Builder.
  89959. * This can be used to override the default projection matrix computation.
  89960. */
  89961. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89962. /**
  89963. * The transformed position. Position of the light in world space taking parenting in account.
  89964. */
  89965. transformedPosition: Vector3;
  89966. /**
  89967. * The transformed direction. Direction of the light in world space taking parenting in account.
  89968. */
  89969. transformedDirection: Vector3;
  89970. private _needProjectionMatrixCompute;
  89971. /**
  89972. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89973. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89974. */
  89975. computeTransformedInformation(): boolean;
  89976. /**
  89977. * Return the depth scale used for the shadow map.
  89978. * @returns the depth scale.
  89979. */
  89980. getDepthScale(): number;
  89981. /**
  89982. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89983. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89984. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89985. */
  89986. getShadowDirection(faceIndex?: number): Vector3;
  89987. /**
  89988. * Returns the ShadowLight absolute position in the World.
  89989. * @returns the position vector in world space
  89990. */
  89991. getAbsolutePosition(): Vector3;
  89992. /**
  89993. * Sets the ShadowLight direction toward the passed target.
  89994. * @param target The point to target in local space
  89995. * @returns the updated ShadowLight direction
  89996. */
  89997. setDirectionToTarget(target: Vector3): Vector3;
  89998. /**
  89999. * Returns the light rotation in euler definition.
  90000. * @returns the x y z rotation in local space.
  90001. */
  90002. getRotation(): Vector3;
  90003. /**
  90004. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90005. * @returns true if a cube texture needs to be use
  90006. */
  90007. needCube(): boolean;
  90008. /**
  90009. * Detects if the projection matrix requires to be recomputed this frame.
  90010. * @returns true if it requires to be recomputed otherwise, false.
  90011. */
  90012. needProjectionMatrixCompute(): boolean;
  90013. /**
  90014. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90015. */
  90016. forceProjectionMatrixCompute(): void;
  90017. /** @hidden */
  90018. _initCache(): void;
  90019. /** @hidden */
  90020. _isSynchronized(): boolean;
  90021. /**
  90022. * Computes the world matrix of the node
  90023. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90024. * @returns the world matrix
  90025. */
  90026. computeWorldMatrix(force?: boolean): Matrix;
  90027. /**
  90028. * Gets the minZ used for shadow according to both the scene and the light.
  90029. * @param activeCamera The camera we are returning the min for
  90030. * @returns the depth min z
  90031. */
  90032. getDepthMinZ(activeCamera: Camera): number;
  90033. /**
  90034. * Gets the maxZ used for shadow according to both the scene and the light.
  90035. * @param activeCamera The camera we are returning the max for
  90036. * @returns the depth max z
  90037. */
  90038. getDepthMaxZ(activeCamera: Camera): number;
  90039. /**
  90040. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90041. * @param matrix The materix to updated with the projection information
  90042. * @param viewMatrix The transform matrix of the light
  90043. * @param renderList The list of mesh to render in the map
  90044. * @returns The current light
  90045. */
  90046. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90047. }
  90048. }
  90049. declare module BABYLON {
  90050. /** @hidden */
  90051. export var packingFunctions: {
  90052. name: string;
  90053. shader: string;
  90054. };
  90055. }
  90056. declare module BABYLON {
  90057. /** @hidden */
  90058. export var bayerDitherFunctions: {
  90059. name: string;
  90060. shader: string;
  90061. };
  90062. }
  90063. declare module BABYLON {
  90064. /** @hidden */
  90065. export var shadowMapFragmentDeclaration: {
  90066. name: string;
  90067. shader: string;
  90068. };
  90069. }
  90070. declare module BABYLON {
  90071. /** @hidden */
  90072. export var clipPlaneFragmentDeclaration: {
  90073. name: string;
  90074. shader: string;
  90075. };
  90076. }
  90077. declare module BABYLON {
  90078. /** @hidden */
  90079. export var clipPlaneFragment: {
  90080. name: string;
  90081. shader: string;
  90082. };
  90083. }
  90084. declare module BABYLON {
  90085. /** @hidden */
  90086. export var shadowMapFragment: {
  90087. name: string;
  90088. shader: string;
  90089. };
  90090. }
  90091. declare module BABYLON {
  90092. /** @hidden */
  90093. export var shadowMapPixelShader: {
  90094. name: string;
  90095. shader: string;
  90096. };
  90097. }
  90098. declare module BABYLON {
  90099. /** @hidden */
  90100. export var bonesDeclaration: {
  90101. name: string;
  90102. shader: string;
  90103. };
  90104. }
  90105. declare module BABYLON {
  90106. /** @hidden */
  90107. export var morphTargetsVertexGlobalDeclaration: {
  90108. name: string;
  90109. shader: string;
  90110. };
  90111. }
  90112. declare module BABYLON {
  90113. /** @hidden */
  90114. export var morphTargetsVertexDeclaration: {
  90115. name: string;
  90116. shader: string;
  90117. };
  90118. }
  90119. declare module BABYLON {
  90120. /** @hidden */
  90121. export var instancesDeclaration: {
  90122. name: string;
  90123. shader: string;
  90124. };
  90125. }
  90126. declare module BABYLON {
  90127. /** @hidden */
  90128. export var helperFunctions: {
  90129. name: string;
  90130. shader: string;
  90131. };
  90132. }
  90133. declare module BABYLON {
  90134. /** @hidden */
  90135. export var shadowMapVertexDeclaration: {
  90136. name: string;
  90137. shader: string;
  90138. };
  90139. }
  90140. declare module BABYLON {
  90141. /** @hidden */
  90142. export var clipPlaneVertexDeclaration: {
  90143. name: string;
  90144. shader: string;
  90145. };
  90146. }
  90147. declare module BABYLON {
  90148. /** @hidden */
  90149. export var morphTargetsVertex: {
  90150. name: string;
  90151. shader: string;
  90152. };
  90153. }
  90154. declare module BABYLON {
  90155. /** @hidden */
  90156. export var instancesVertex: {
  90157. name: string;
  90158. shader: string;
  90159. };
  90160. }
  90161. declare module BABYLON {
  90162. /** @hidden */
  90163. export var bonesVertex: {
  90164. name: string;
  90165. shader: string;
  90166. };
  90167. }
  90168. declare module BABYLON {
  90169. /** @hidden */
  90170. export var shadowMapVertexNormalBias: {
  90171. name: string;
  90172. shader: string;
  90173. };
  90174. }
  90175. declare module BABYLON {
  90176. /** @hidden */
  90177. export var shadowMapVertexMetric: {
  90178. name: string;
  90179. shader: string;
  90180. };
  90181. }
  90182. declare module BABYLON {
  90183. /** @hidden */
  90184. export var clipPlaneVertex: {
  90185. name: string;
  90186. shader: string;
  90187. };
  90188. }
  90189. declare module BABYLON {
  90190. /** @hidden */
  90191. export var shadowMapVertexShader: {
  90192. name: string;
  90193. shader: string;
  90194. };
  90195. }
  90196. declare module BABYLON {
  90197. /** @hidden */
  90198. export var depthBoxBlurPixelShader: {
  90199. name: string;
  90200. shader: string;
  90201. };
  90202. }
  90203. declare module BABYLON {
  90204. /** @hidden */
  90205. export var shadowMapFragmentSoftTransparentShadow: {
  90206. name: string;
  90207. shader: string;
  90208. };
  90209. }
  90210. declare module BABYLON {
  90211. /**
  90212. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90213. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90214. */
  90215. export class EffectFallbacks implements IEffectFallbacks {
  90216. private _defines;
  90217. private _currentRank;
  90218. private _maxRank;
  90219. private _mesh;
  90220. /**
  90221. * Removes the fallback from the bound mesh.
  90222. */
  90223. unBindMesh(): void;
  90224. /**
  90225. * Adds a fallback on the specified property.
  90226. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90227. * @param define The name of the define in the shader
  90228. */
  90229. addFallback(rank: number, define: string): void;
  90230. /**
  90231. * Sets the mesh to use CPU skinning when needing to fallback.
  90232. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90233. * @param mesh The mesh to use the fallbacks.
  90234. */
  90235. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90236. /**
  90237. * Checks to see if more fallbacks are still availible.
  90238. */
  90239. get hasMoreFallbacks(): boolean;
  90240. /**
  90241. * Removes the defines that should be removed when falling back.
  90242. * @param currentDefines defines the current define statements for the shader.
  90243. * @param effect defines the current effect we try to compile
  90244. * @returns The resulting defines with defines of the current rank removed.
  90245. */
  90246. reduce(currentDefines: string, effect: Effect): string;
  90247. }
  90248. }
  90249. declare module BABYLON {
  90250. /**
  90251. * Interface used to define Action
  90252. */
  90253. export interface IAction {
  90254. /**
  90255. * Trigger for the action
  90256. */
  90257. trigger: number;
  90258. /** Options of the trigger */
  90259. triggerOptions: any;
  90260. /**
  90261. * Gets the trigger parameters
  90262. * @returns the trigger parameters
  90263. */
  90264. getTriggerParameter(): any;
  90265. /**
  90266. * Internal only - executes current action event
  90267. * @hidden
  90268. */
  90269. _executeCurrent(evt?: ActionEvent): void;
  90270. /**
  90271. * Serialize placeholder for child classes
  90272. * @param parent of child
  90273. * @returns the serialized object
  90274. */
  90275. serialize(parent: any): any;
  90276. /**
  90277. * Internal only
  90278. * @hidden
  90279. */
  90280. _prepare(): void;
  90281. /**
  90282. * Internal only - manager for action
  90283. * @hidden
  90284. */
  90285. _actionManager: Nullable<AbstractActionManager>;
  90286. /**
  90287. * Adds action to chain of actions, may be a DoNothingAction
  90288. * @param action defines the next action to execute
  90289. * @returns The action passed in
  90290. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90291. */
  90292. then(action: IAction): IAction;
  90293. }
  90294. /**
  90295. * The action to be carried out following a trigger
  90296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90297. */
  90298. export class Action implements IAction {
  90299. /** the trigger, with or without parameters, for the action */
  90300. triggerOptions: any;
  90301. /**
  90302. * Trigger for the action
  90303. */
  90304. trigger: number;
  90305. /**
  90306. * Internal only - manager for action
  90307. * @hidden
  90308. */
  90309. _actionManager: ActionManager;
  90310. private _nextActiveAction;
  90311. private _child;
  90312. private _condition?;
  90313. private _triggerParameter;
  90314. /**
  90315. * An event triggered prior to action being executed.
  90316. */
  90317. onBeforeExecuteObservable: Observable<Action>;
  90318. /**
  90319. * Creates a new Action
  90320. * @param triggerOptions the trigger, with or without parameters, for the action
  90321. * @param condition an optional determinant of action
  90322. */
  90323. constructor(
  90324. /** the trigger, with or without parameters, for the action */
  90325. triggerOptions: any, condition?: Condition);
  90326. /**
  90327. * Internal only
  90328. * @hidden
  90329. */
  90330. _prepare(): void;
  90331. /**
  90332. * Gets the trigger parameters
  90333. * @returns the trigger parameters
  90334. */
  90335. getTriggerParameter(): any;
  90336. /**
  90337. * Internal only - executes current action event
  90338. * @hidden
  90339. */
  90340. _executeCurrent(evt?: ActionEvent): void;
  90341. /**
  90342. * Execute placeholder for child classes
  90343. * @param evt optional action event
  90344. */
  90345. execute(evt?: ActionEvent): void;
  90346. /**
  90347. * Skips to next active action
  90348. */
  90349. skipToNextActiveAction(): void;
  90350. /**
  90351. * Adds action to chain of actions, may be a DoNothingAction
  90352. * @param action defines the next action to execute
  90353. * @returns The action passed in
  90354. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90355. */
  90356. then(action: Action): Action;
  90357. /**
  90358. * Internal only
  90359. * @hidden
  90360. */
  90361. _getProperty(propertyPath: string): string;
  90362. /**
  90363. * Internal only
  90364. * @hidden
  90365. */
  90366. _getEffectiveTarget(target: any, propertyPath: string): any;
  90367. /**
  90368. * Serialize placeholder for child classes
  90369. * @param parent of child
  90370. * @returns the serialized object
  90371. */
  90372. serialize(parent: any): any;
  90373. /**
  90374. * Internal only called by serialize
  90375. * @hidden
  90376. */
  90377. protected _serialize(serializedAction: any, parent?: any): any;
  90378. /**
  90379. * Internal only
  90380. * @hidden
  90381. */
  90382. static _SerializeValueAsString: (value: any) => string;
  90383. /**
  90384. * Internal only
  90385. * @hidden
  90386. */
  90387. static _GetTargetProperty: (target: Scene | Node) => {
  90388. name: string;
  90389. targetType: string;
  90390. value: string;
  90391. };
  90392. }
  90393. }
  90394. declare module BABYLON {
  90395. /**
  90396. * A Condition applied to an Action
  90397. */
  90398. export class Condition {
  90399. /**
  90400. * Internal only - manager for action
  90401. * @hidden
  90402. */
  90403. _actionManager: ActionManager;
  90404. /**
  90405. * Internal only
  90406. * @hidden
  90407. */
  90408. _evaluationId: number;
  90409. /**
  90410. * Internal only
  90411. * @hidden
  90412. */
  90413. _currentResult: boolean;
  90414. /**
  90415. * Creates a new Condition
  90416. * @param actionManager the manager of the action the condition is applied to
  90417. */
  90418. constructor(actionManager: ActionManager);
  90419. /**
  90420. * Check if the current condition is valid
  90421. * @returns a boolean
  90422. */
  90423. isValid(): boolean;
  90424. /**
  90425. * Internal only
  90426. * @hidden
  90427. */
  90428. _getProperty(propertyPath: string): string;
  90429. /**
  90430. * Internal only
  90431. * @hidden
  90432. */
  90433. _getEffectiveTarget(target: any, propertyPath: string): any;
  90434. /**
  90435. * Serialize placeholder for child classes
  90436. * @returns the serialized object
  90437. */
  90438. serialize(): any;
  90439. /**
  90440. * Internal only
  90441. * @hidden
  90442. */
  90443. protected _serialize(serializedCondition: any): any;
  90444. }
  90445. /**
  90446. * Defines specific conditional operators as extensions of Condition
  90447. */
  90448. export class ValueCondition extends Condition {
  90449. /** path to specify the property of the target the conditional operator uses */
  90450. propertyPath: string;
  90451. /** the value compared by the conditional operator against the current value of the property */
  90452. value: any;
  90453. /** the conditional operator, default ValueCondition.IsEqual */
  90454. operator: number;
  90455. /**
  90456. * Internal only
  90457. * @hidden
  90458. */
  90459. private static _IsEqual;
  90460. /**
  90461. * Internal only
  90462. * @hidden
  90463. */
  90464. private static _IsDifferent;
  90465. /**
  90466. * Internal only
  90467. * @hidden
  90468. */
  90469. private static _IsGreater;
  90470. /**
  90471. * Internal only
  90472. * @hidden
  90473. */
  90474. private static _IsLesser;
  90475. /**
  90476. * returns the number for IsEqual
  90477. */
  90478. static get IsEqual(): number;
  90479. /**
  90480. * Returns the number for IsDifferent
  90481. */
  90482. static get IsDifferent(): number;
  90483. /**
  90484. * Returns the number for IsGreater
  90485. */
  90486. static get IsGreater(): number;
  90487. /**
  90488. * Returns the number for IsLesser
  90489. */
  90490. static get IsLesser(): number;
  90491. /**
  90492. * Internal only The action manager for the condition
  90493. * @hidden
  90494. */
  90495. _actionManager: ActionManager;
  90496. /**
  90497. * Internal only
  90498. * @hidden
  90499. */
  90500. private _target;
  90501. /**
  90502. * Internal only
  90503. * @hidden
  90504. */
  90505. private _effectiveTarget;
  90506. /**
  90507. * Internal only
  90508. * @hidden
  90509. */
  90510. private _property;
  90511. /**
  90512. * Creates a new ValueCondition
  90513. * @param actionManager manager for the action the condition applies to
  90514. * @param target for the action
  90515. * @param propertyPath path to specify the property of the target the conditional operator uses
  90516. * @param value the value compared by the conditional operator against the current value of the property
  90517. * @param operator the conditional operator, default ValueCondition.IsEqual
  90518. */
  90519. constructor(actionManager: ActionManager, target: any,
  90520. /** path to specify the property of the target the conditional operator uses */
  90521. propertyPath: string,
  90522. /** the value compared by the conditional operator against the current value of the property */
  90523. value: any,
  90524. /** the conditional operator, default ValueCondition.IsEqual */
  90525. operator?: number);
  90526. /**
  90527. * Compares the given value with the property value for the specified conditional operator
  90528. * @returns the result of the comparison
  90529. */
  90530. isValid(): boolean;
  90531. /**
  90532. * Serialize the ValueCondition into a JSON compatible object
  90533. * @returns serialization object
  90534. */
  90535. serialize(): any;
  90536. /**
  90537. * Gets the name of the conditional operator for the ValueCondition
  90538. * @param operator the conditional operator
  90539. * @returns the name
  90540. */
  90541. static GetOperatorName(operator: number): string;
  90542. }
  90543. /**
  90544. * Defines a predicate condition as an extension of Condition
  90545. */
  90546. export class PredicateCondition extends Condition {
  90547. /** defines the predicate function used to validate the condition */
  90548. predicate: () => boolean;
  90549. /**
  90550. * Internal only - manager for action
  90551. * @hidden
  90552. */
  90553. _actionManager: ActionManager;
  90554. /**
  90555. * Creates a new PredicateCondition
  90556. * @param actionManager manager for the action the condition applies to
  90557. * @param predicate defines the predicate function used to validate the condition
  90558. */
  90559. constructor(actionManager: ActionManager,
  90560. /** defines the predicate function used to validate the condition */
  90561. predicate: () => boolean);
  90562. /**
  90563. * @returns the validity of the predicate condition
  90564. */
  90565. isValid(): boolean;
  90566. }
  90567. /**
  90568. * Defines a state condition as an extension of Condition
  90569. */
  90570. export class StateCondition extends Condition {
  90571. /** Value to compare with target state */
  90572. value: string;
  90573. /**
  90574. * Internal only - manager for action
  90575. * @hidden
  90576. */
  90577. _actionManager: ActionManager;
  90578. /**
  90579. * Internal only
  90580. * @hidden
  90581. */
  90582. private _target;
  90583. /**
  90584. * Creates a new StateCondition
  90585. * @param actionManager manager for the action the condition applies to
  90586. * @param target of the condition
  90587. * @param value to compare with target state
  90588. */
  90589. constructor(actionManager: ActionManager, target: any,
  90590. /** Value to compare with target state */
  90591. value: string);
  90592. /**
  90593. * Gets a boolean indicating if the current condition is met
  90594. * @returns the validity of the state
  90595. */
  90596. isValid(): boolean;
  90597. /**
  90598. * Serialize the StateCondition into a JSON compatible object
  90599. * @returns serialization object
  90600. */
  90601. serialize(): any;
  90602. }
  90603. }
  90604. declare module BABYLON {
  90605. /**
  90606. * This defines an action responsible to toggle a boolean once triggered.
  90607. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90608. */
  90609. export class SwitchBooleanAction extends Action {
  90610. /**
  90611. * The path to the boolean property in the target object
  90612. */
  90613. propertyPath: string;
  90614. private _target;
  90615. private _effectiveTarget;
  90616. private _property;
  90617. /**
  90618. * Instantiate the action
  90619. * @param triggerOptions defines the trigger options
  90620. * @param target defines the object containing the boolean
  90621. * @param propertyPath defines the path to the boolean property in the target object
  90622. * @param condition defines the trigger related conditions
  90623. */
  90624. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90625. /** @hidden */
  90626. _prepare(): void;
  90627. /**
  90628. * Execute the action toggle the boolean value.
  90629. */
  90630. execute(): void;
  90631. /**
  90632. * Serializes the actions and its related information.
  90633. * @param parent defines the object to serialize in
  90634. * @returns the serialized object
  90635. */
  90636. serialize(parent: any): any;
  90637. }
  90638. /**
  90639. * This defines an action responsible to set a the state field of the target
  90640. * to a desired value once triggered.
  90641. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90642. */
  90643. export class SetStateAction extends Action {
  90644. /**
  90645. * The value to store in the state field.
  90646. */
  90647. value: string;
  90648. private _target;
  90649. /**
  90650. * Instantiate the action
  90651. * @param triggerOptions defines the trigger options
  90652. * @param target defines the object containing the state property
  90653. * @param value defines the value to store in the state field
  90654. * @param condition defines the trigger related conditions
  90655. */
  90656. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90657. /**
  90658. * Execute the action and store the value on the target state property.
  90659. */
  90660. execute(): void;
  90661. /**
  90662. * Serializes the actions and its related information.
  90663. * @param parent defines the object to serialize in
  90664. * @returns the serialized object
  90665. */
  90666. serialize(parent: any): any;
  90667. }
  90668. /**
  90669. * This defines an action responsible to set a property of the target
  90670. * to a desired value once triggered.
  90671. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90672. */
  90673. export class SetValueAction extends Action {
  90674. /**
  90675. * The path of the property to set in the target.
  90676. */
  90677. propertyPath: string;
  90678. /**
  90679. * The value to set in the property
  90680. */
  90681. value: any;
  90682. private _target;
  90683. private _effectiveTarget;
  90684. private _property;
  90685. /**
  90686. * Instantiate the action
  90687. * @param triggerOptions defines the trigger options
  90688. * @param target defines the object containing the property
  90689. * @param propertyPath defines the path of the property to set in the target
  90690. * @param value defines the value to set in the property
  90691. * @param condition defines the trigger related conditions
  90692. */
  90693. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90694. /** @hidden */
  90695. _prepare(): void;
  90696. /**
  90697. * Execute the action and set the targetted property to the desired value.
  90698. */
  90699. execute(): void;
  90700. /**
  90701. * Serializes the actions and its related information.
  90702. * @param parent defines the object to serialize in
  90703. * @returns the serialized object
  90704. */
  90705. serialize(parent: any): any;
  90706. }
  90707. /**
  90708. * This defines an action responsible to increment the target value
  90709. * to a desired value once triggered.
  90710. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90711. */
  90712. export class IncrementValueAction extends Action {
  90713. /**
  90714. * The path of the property to increment in the target.
  90715. */
  90716. propertyPath: string;
  90717. /**
  90718. * The value we should increment the property by.
  90719. */
  90720. value: any;
  90721. private _target;
  90722. private _effectiveTarget;
  90723. private _property;
  90724. /**
  90725. * Instantiate the action
  90726. * @param triggerOptions defines the trigger options
  90727. * @param target defines the object containing the property
  90728. * @param propertyPath defines the path of the property to increment in the target
  90729. * @param value defines the value value we should increment the property by
  90730. * @param condition defines the trigger related conditions
  90731. */
  90732. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90733. /** @hidden */
  90734. _prepare(): void;
  90735. /**
  90736. * Execute the action and increment the target of the value amount.
  90737. */
  90738. execute(): void;
  90739. /**
  90740. * Serializes the actions and its related information.
  90741. * @param parent defines the object to serialize in
  90742. * @returns the serialized object
  90743. */
  90744. serialize(parent: any): any;
  90745. }
  90746. /**
  90747. * This defines an action responsible to start an animation once triggered.
  90748. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90749. */
  90750. export class PlayAnimationAction extends Action {
  90751. /**
  90752. * Where the animation should start (animation frame)
  90753. */
  90754. from: number;
  90755. /**
  90756. * Where the animation should stop (animation frame)
  90757. */
  90758. to: number;
  90759. /**
  90760. * Define if the animation should loop or stop after the first play.
  90761. */
  90762. loop?: boolean;
  90763. private _target;
  90764. /**
  90765. * Instantiate the action
  90766. * @param triggerOptions defines the trigger options
  90767. * @param target defines the target animation or animation name
  90768. * @param from defines from where the animation should start (animation frame)
  90769. * @param end defines where the animation should stop (animation frame)
  90770. * @param loop defines if the animation should loop or stop after the first play
  90771. * @param condition defines the trigger related conditions
  90772. */
  90773. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90774. /** @hidden */
  90775. _prepare(): void;
  90776. /**
  90777. * Execute the action and play the animation.
  90778. */
  90779. execute(): void;
  90780. /**
  90781. * Serializes the actions and its related information.
  90782. * @param parent defines the object to serialize in
  90783. * @returns the serialized object
  90784. */
  90785. serialize(parent: any): any;
  90786. }
  90787. /**
  90788. * This defines an action responsible to stop an animation once triggered.
  90789. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90790. */
  90791. export class StopAnimationAction extends Action {
  90792. private _target;
  90793. /**
  90794. * Instantiate the action
  90795. * @param triggerOptions defines the trigger options
  90796. * @param target defines the target animation or animation name
  90797. * @param condition defines the trigger related conditions
  90798. */
  90799. constructor(triggerOptions: any, target: any, condition?: Condition);
  90800. /** @hidden */
  90801. _prepare(): void;
  90802. /**
  90803. * Execute the action and stop the animation.
  90804. */
  90805. execute(): void;
  90806. /**
  90807. * Serializes the actions and its related information.
  90808. * @param parent defines the object to serialize in
  90809. * @returns the serialized object
  90810. */
  90811. serialize(parent: any): any;
  90812. }
  90813. /**
  90814. * This defines an action responsible that does nothing once triggered.
  90815. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90816. */
  90817. export class DoNothingAction extends Action {
  90818. /**
  90819. * Instantiate the action
  90820. * @param triggerOptions defines the trigger options
  90821. * @param condition defines the trigger related conditions
  90822. */
  90823. constructor(triggerOptions?: any, condition?: Condition);
  90824. /**
  90825. * Execute the action and do nothing.
  90826. */
  90827. execute(): void;
  90828. /**
  90829. * Serializes the actions and its related information.
  90830. * @param parent defines the object to serialize in
  90831. * @returns the serialized object
  90832. */
  90833. serialize(parent: any): any;
  90834. }
  90835. /**
  90836. * This defines an action responsible to trigger several actions once triggered.
  90837. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90838. */
  90839. export class CombineAction extends Action {
  90840. /**
  90841. * The list of aggregated animations to run.
  90842. */
  90843. children: Action[];
  90844. /**
  90845. * Instantiate the action
  90846. * @param triggerOptions defines the trigger options
  90847. * @param children defines the list of aggregated animations to run
  90848. * @param condition defines the trigger related conditions
  90849. */
  90850. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90851. /** @hidden */
  90852. _prepare(): void;
  90853. /**
  90854. * Execute the action and executes all the aggregated actions.
  90855. */
  90856. execute(evt: ActionEvent): void;
  90857. /**
  90858. * Serializes the actions and its related information.
  90859. * @param parent defines the object to serialize in
  90860. * @returns the serialized object
  90861. */
  90862. serialize(parent: any): any;
  90863. }
  90864. /**
  90865. * This defines an action responsible to run code (external event) once triggered.
  90866. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90867. */
  90868. export class ExecuteCodeAction extends Action {
  90869. /**
  90870. * The callback function to run.
  90871. */
  90872. func: (evt: ActionEvent) => void;
  90873. /**
  90874. * Instantiate the action
  90875. * @param triggerOptions defines the trigger options
  90876. * @param func defines the callback function to run
  90877. * @param condition defines the trigger related conditions
  90878. */
  90879. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90880. /**
  90881. * Execute the action and run the attached code.
  90882. */
  90883. execute(evt: ActionEvent): void;
  90884. }
  90885. /**
  90886. * This defines an action responsible to set the parent property of the target once triggered.
  90887. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90888. */
  90889. export class SetParentAction extends Action {
  90890. private _parent;
  90891. private _target;
  90892. /**
  90893. * Instantiate the action
  90894. * @param triggerOptions defines the trigger options
  90895. * @param target defines the target containing the parent property
  90896. * @param parent defines from where the animation should start (animation frame)
  90897. * @param condition defines the trigger related conditions
  90898. */
  90899. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90900. /** @hidden */
  90901. _prepare(): void;
  90902. /**
  90903. * Execute the action and set the parent property.
  90904. */
  90905. execute(): void;
  90906. /**
  90907. * Serializes the actions and its related information.
  90908. * @param parent defines the object to serialize in
  90909. * @returns the serialized object
  90910. */
  90911. serialize(parent: any): any;
  90912. }
  90913. }
  90914. declare module BABYLON {
  90915. /**
  90916. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90917. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90918. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90919. */
  90920. export class ActionManager extends AbstractActionManager {
  90921. /**
  90922. * Nothing
  90923. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90924. */
  90925. static readonly NothingTrigger: number;
  90926. /**
  90927. * On pick
  90928. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90929. */
  90930. static readonly OnPickTrigger: number;
  90931. /**
  90932. * On left pick
  90933. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90934. */
  90935. static readonly OnLeftPickTrigger: number;
  90936. /**
  90937. * On right pick
  90938. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90939. */
  90940. static readonly OnRightPickTrigger: number;
  90941. /**
  90942. * On center pick
  90943. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90944. */
  90945. static readonly OnCenterPickTrigger: number;
  90946. /**
  90947. * On pick down
  90948. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90949. */
  90950. static readonly OnPickDownTrigger: number;
  90951. /**
  90952. * On double pick
  90953. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90954. */
  90955. static readonly OnDoublePickTrigger: number;
  90956. /**
  90957. * On pick up
  90958. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90959. */
  90960. static readonly OnPickUpTrigger: number;
  90961. /**
  90962. * On pick out.
  90963. * This trigger will only be raised if you also declared a OnPickDown
  90964. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90965. */
  90966. static readonly OnPickOutTrigger: number;
  90967. /**
  90968. * On long press
  90969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90970. */
  90971. static readonly OnLongPressTrigger: number;
  90972. /**
  90973. * On pointer over
  90974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90975. */
  90976. static readonly OnPointerOverTrigger: number;
  90977. /**
  90978. * On pointer out
  90979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90980. */
  90981. static readonly OnPointerOutTrigger: number;
  90982. /**
  90983. * On every frame
  90984. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90985. */
  90986. static readonly OnEveryFrameTrigger: number;
  90987. /**
  90988. * On intersection enter
  90989. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90990. */
  90991. static readonly OnIntersectionEnterTrigger: number;
  90992. /**
  90993. * On intersection exit
  90994. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90995. */
  90996. static readonly OnIntersectionExitTrigger: number;
  90997. /**
  90998. * On key down
  90999. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91000. */
  91001. static readonly OnKeyDownTrigger: number;
  91002. /**
  91003. * On key up
  91004. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91005. */
  91006. static readonly OnKeyUpTrigger: number;
  91007. private _scene;
  91008. /**
  91009. * Creates a new action manager
  91010. * @param scene defines the hosting scene
  91011. */
  91012. constructor(scene: Scene);
  91013. /**
  91014. * Releases all associated resources
  91015. */
  91016. dispose(): void;
  91017. /**
  91018. * Gets hosting scene
  91019. * @returns the hosting scene
  91020. */
  91021. getScene(): Scene;
  91022. /**
  91023. * Does this action manager handles actions of any of the given triggers
  91024. * @param triggers defines the triggers to be tested
  91025. * @return a boolean indicating whether one (or more) of the triggers is handled
  91026. */
  91027. hasSpecificTriggers(triggers: number[]): boolean;
  91028. /**
  91029. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91030. * speed.
  91031. * @param triggerA defines the trigger to be tested
  91032. * @param triggerB defines the trigger to be tested
  91033. * @return a boolean indicating whether one (or more) of the triggers is handled
  91034. */
  91035. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91036. /**
  91037. * Does this action manager handles actions of a given trigger
  91038. * @param trigger defines the trigger to be tested
  91039. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91040. * @return whether the trigger is handled
  91041. */
  91042. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91043. /**
  91044. * Does this action manager has pointer triggers
  91045. */
  91046. get hasPointerTriggers(): boolean;
  91047. /**
  91048. * Does this action manager has pick triggers
  91049. */
  91050. get hasPickTriggers(): boolean;
  91051. /**
  91052. * Registers an action to this action manager
  91053. * @param action defines the action to be registered
  91054. * @return the action amended (prepared) after registration
  91055. */
  91056. registerAction(action: IAction): Nullable<IAction>;
  91057. /**
  91058. * Unregisters an action to this action manager
  91059. * @param action defines the action to be unregistered
  91060. * @return a boolean indicating whether the action has been unregistered
  91061. */
  91062. unregisterAction(action: IAction): Boolean;
  91063. /**
  91064. * Process a specific trigger
  91065. * @param trigger defines the trigger to process
  91066. * @param evt defines the event details to be processed
  91067. */
  91068. processTrigger(trigger: number, evt?: IActionEvent): void;
  91069. /** @hidden */
  91070. _getEffectiveTarget(target: any, propertyPath: string): any;
  91071. /** @hidden */
  91072. _getProperty(propertyPath: string): string;
  91073. /**
  91074. * Serialize this manager to a JSON object
  91075. * @param name defines the property name to store this manager
  91076. * @returns a JSON representation of this manager
  91077. */
  91078. serialize(name: string): any;
  91079. /**
  91080. * Creates a new ActionManager from a JSON data
  91081. * @param parsedActions defines the JSON data to read from
  91082. * @param object defines the hosting mesh
  91083. * @param scene defines the hosting scene
  91084. */
  91085. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91086. /**
  91087. * Get a trigger name by index
  91088. * @param trigger defines the trigger index
  91089. * @returns a trigger name
  91090. */
  91091. static GetTriggerName(trigger: number): string;
  91092. }
  91093. }
  91094. declare module BABYLON {
  91095. /**
  91096. * Class used to represent a sprite
  91097. * @see https://doc.babylonjs.com/babylon101/sprites
  91098. */
  91099. export class Sprite implements IAnimatable {
  91100. /** defines the name */
  91101. name: string;
  91102. /** Gets or sets the current world position */
  91103. position: Vector3;
  91104. /** Gets or sets the main color */
  91105. color: Color4;
  91106. /** Gets or sets the width */
  91107. width: number;
  91108. /** Gets or sets the height */
  91109. height: number;
  91110. /** Gets or sets rotation angle */
  91111. angle: number;
  91112. /** Gets or sets the cell index in the sprite sheet */
  91113. cellIndex: number;
  91114. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91115. cellRef: string;
  91116. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91117. invertU: boolean;
  91118. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91119. invertV: boolean;
  91120. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91121. disposeWhenFinishedAnimating: boolean;
  91122. /** Gets the list of attached animations */
  91123. animations: Nullable<Array<Animation>>;
  91124. /** Gets or sets a boolean indicating if the sprite can be picked */
  91125. isPickable: boolean;
  91126. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  91127. useAlphaForPicking: boolean;
  91128. /** @hidden */
  91129. _xOffset: number;
  91130. /** @hidden */
  91131. _yOffset: number;
  91132. /** @hidden */
  91133. _xSize: number;
  91134. /** @hidden */
  91135. _ySize: number;
  91136. /**
  91137. * Gets or sets the associated action manager
  91138. */
  91139. actionManager: Nullable<ActionManager>;
  91140. /**
  91141. * An event triggered when the control has been disposed
  91142. */
  91143. onDisposeObservable: Observable<Sprite>;
  91144. private _animationStarted;
  91145. private _loopAnimation;
  91146. private _fromIndex;
  91147. private _toIndex;
  91148. private _delay;
  91149. private _direction;
  91150. private _manager;
  91151. private _time;
  91152. private _onAnimationEnd;
  91153. /**
  91154. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91155. */
  91156. isVisible: boolean;
  91157. /**
  91158. * Gets or sets the sprite size
  91159. */
  91160. get size(): number;
  91161. set size(value: number);
  91162. /**
  91163. * Returns a boolean indicating if the animation is started
  91164. */
  91165. get animationStarted(): boolean;
  91166. /**
  91167. * Gets or sets the unique id of the sprite
  91168. */
  91169. uniqueId: number;
  91170. /**
  91171. * Gets the manager of this sprite
  91172. */
  91173. get manager(): ISpriteManager;
  91174. /**
  91175. * Creates a new Sprite
  91176. * @param name defines the name
  91177. * @param manager defines the manager
  91178. */
  91179. constructor(
  91180. /** defines the name */
  91181. name: string, manager: ISpriteManager);
  91182. /**
  91183. * Returns the string "Sprite"
  91184. * @returns "Sprite"
  91185. */
  91186. getClassName(): string;
  91187. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91188. get fromIndex(): number;
  91189. set fromIndex(value: number);
  91190. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91191. get toIndex(): number;
  91192. set toIndex(value: number);
  91193. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91194. get loopAnimation(): boolean;
  91195. set loopAnimation(value: boolean);
  91196. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91197. get delay(): number;
  91198. set delay(value: number);
  91199. /**
  91200. * Starts an animation
  91201. * @param from defines the initial key
  91202. * @param to defines the end key
  91203. * @param loop defines if the animation must loop
  91204. * @param delay defines the start delay (in ms)
  91205. * @param onAnimationEnd defines a callback to call when animation ends
  91206. */
  91207. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91208. /** Stops current animation (if any) */
  91209. stopAnimation(): void;
  91210. /** @hidden */
  91211. _animate(deltaTime: number): void;
  91212. /** Release associated resources */
  91213. dispose(): void;
  91214. /**
  91215. * Serializes the sprite to a JSON object
  91216. * @returns the JSON object
  91217. */
  91218. serialize(): any;
  91219. /**
  91220. * Parses a JSON object to create a new sprite
  91221. * @param parsedSprite The JSON object to parse
  91222. * @param manager defines the hosting manager
  91223. * @returns the new sprite
  91224. */
  91225. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91226. }
  91227. }
  91228. declare module BABYLON {
  91229. /**
  91230. * Information about the result of picking within a scene
  91231. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91232. */
  91233. export class PickingInfo {
  91234. /** @hidden */
  91235. _pickingUnavailable: boolean;
  91236. /**
  91237. * If the pick collided with an object
  91238. */
  91239. hit: boolean;
  91240. /**
  91241. * Distance away where the pick collided
  91242. */
  91243. distance: number;
  91244. /**
  91245. * The location of pick collision
  91246. */
  91247. pickedPoint: Nullable<Vector3>;
  91248. /**
  91249. * The mesh corresponding the the pick collision
  91250. */
  91251. pickedMesh: Nullable<AbstractMesh>;
  91252. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91253. bu: number;
  91254. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91255. bv: number;
  91256. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91257. faceId: number;
  91258. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91259. subMeshFaceId: number;
  91260. /** Id of the the submesh that was picked */
  91261. subMeshId: number;
  91262. /** If a sprite was picked, this will be the sprite the pick collided with */
  91263. pickedSprite: Nullable<Sprite>;
  91264. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91265. thinInstanceIndex: number;
  91266. /**
  91267. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91268. */
  91269. originMesh: Nullable<AbstractMesh>;
  91270. /**
  91271. * The ray that was used to perform the picking.
  91272. */
  91273. ray: Nullable<Ray>;
  91274. /**
  91275. * Gets the normal correspodning to the face the pick collided with
  91276. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91277. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91278. * @returns The normal correspodning to the face the pick collided with
  91279. */
  91280. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91281. /**
  91282. * Gets the texture coordinates of where the pick occured
  91283. * @returns the vector containing the coordnates of the texture
  91284. */
  91285. getTextureCoordinates(): Nullable<Vector2>;
  91286. }
  91287. }
  91288. declare module BABYLON {
  91289. /**
  91290. * Class representing a ray with position and direction
  91291. */
  91292. export class Ray {
  91293. /** origin point */
  91294. origin: Vector3;
  91295. /** direction */
  91296. direction: Vector3;
  91297. /** length of the ray */
  91298. length: number;
  91299. private static readonly _TmpVector3;
  91300. private _tmpRay;
  91301. /**
  91302. * Creates a new ray
  91303. * @param origin origin point
  91304. * @param direction direction
  91305. * @param length length of the ray
  91306. */
  91307. constructor(
  91308. /** origin point */
  91309. origin: Vector3,
  91310. /** direction */
  91311. direction: Vector3,
  91312. /** length of the ray */
  91313. length?: number);
  91314. /**
  91315. * Checks if the ray intersects a box
  91316. * This does not account for the ray lenght by design to improve perfs.
  91317. * @param minimum bound of the box
  91318. * @param maximum bound of the box
  91319. * @param intersectionTreshold extra extend to be added to the box in all direction
  91320. * @returns if the box was hit
  91321. */
  91322. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91323. /**
  91324. * Checks if the ray intersects a box
  91325. * This does not account for the ray lenght by design to improve perfs.
  91326. * @param box the bounding box to check
  91327. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91328. * @returns if the box was hit
  91329. */
  91330. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91331. /**
  91332. * If the ray hits a sphere
  91333. * @param sphere the bounding sphere to check
  91334. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91335. * @returns true if it hits the sphere
  91336. */
  91337. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91338. /**
  91339. * If the ray hits a triange
  91340. * @param vertex0 triangle vertex
  91341. * @param vertex1 triangle vertex
  91342. * @param vertex2 triangle vertex
  91343. * @returns intersection information if hit
  91344. */
  91345. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91346. /**
  91347. * Checks if ray intersects a plane
  91348. * @param plane the plane to check
  91349. * @returns the distance away it was hit
  91350. */
  91351. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91352. /**
  91353. * Calculate the intercept of a ray on a given axis
  91354. * @param axis to check 'x' | 'y' | 'z'
  91355. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91356. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91357. */
  91358. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91359. /**
  91360. * Checks if ray intersects a mesh
  91361. * @param mesh the mesh to check
  91362. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91363. * @returns picking info of the intersecton
  91364. */
  91365. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91366. /**
  91367. * Checks if ray intersects a mesh
  91368. * @param meshes the meshes to check
  91369. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91370. * @param results array to store result in
  91371. * @returns Array of picking infos
  91372. */
  91373. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91374. private _comparePickingInfo;
  91375. private static smallnum;
  91376. private static rayl;
  91377. /**
  91378. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91379. * @param sega the first point of the segment to test the intersection against
  91380. * @param segb the second point of the segment to test the intersection against
  91381. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91382. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91383. */
  91384. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91385. /**
  91386. * Update the ray from viewport position
  91387. * @param x position
  91388. * @param y y position
  91389. * @param viewportWidth viewport width
  91390. * @param viewportHeight viewport height
  91391. * @param world world matrix
  91392. * @param view view matrix
  91393. * @param projection projection matrix
  91394. * @returns this ray updated
  91395. */
  91396. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91397. /**
  91398. * Creates a ray with origin and direction of 0,0,0
  91399. * @returns the new ray
  91400. */
  91401. static Zero(): Ray;
  91402. /**
  91403. * Creates a new ray from screen space and viewport
  91404. * @param x position
  91405. * @param y y position
  91406. * @param viewportWidth viewport width
  91407. * @param viewportHeight viewport height
  91408. * @param world world matrix
  91409. * @param view view matrix
  91410. * @param projection projection matrix
  91411. * @returns new ray
  91412. */
  91413. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91414. /**
  91415. * 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
  91416. * transformed to the given world matrix.
  91417. * @param origin The origin point
  91418. * @param end The end point
  91419. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91420. * @returns the new ray
  91421. */
  91422. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91423. /**
  91424. * Transforms a ray by a matrix
  91425. * @param ray ray to transform
  91426. * @param matrix matrix to apply
  91427. * @returns the resulting new ray
  91428. */
  91429. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91430. /**
  91431. * Transforms a ray by a matrix
  91432. * @param ray ray to transform
  91433. * @param matrix matrix to apply
  91434. * @param result ray to store result in
  91435. */
  91436. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91437. /**
  91438. * Unproject a ray from screen space to object space
  91439. * @param sourceX defines the screen space x coordinate to use
  91440. * @param sourceY defines the screen space y coordinate to use
  91441. * @param viewportWidth defines the current width of the viewport
  91442. * @param viewportHeight defines the current height of the viewport
  91443. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91444. * @param view defines the view matrix to use
  91445. * @param projection defines the projection matrix to use
  91446. */
  91447. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91448. }
  91449. /**
  91450. * Type used to define predicate used to select faces when a mesh intersection is detected
  91451. */
  91452. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91453. interface Scene {
  91454. /** @hidden */
  91455. _tempPickingRay: Nullable<Ray>;
  91456. /** @hidden */
  91457. _cachedRayForTransform: Ray;
  91458. /** @hidden */
  91459. _pickWithRayInverseMatrix: Matrix;
  91460. /** @hidden */
  91461. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91462. /** @hidden */
  91463. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91464. /** @hidden */
  91465. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91466. }
  91467. }
  91468. declare module BABYLON {
  91469. /**
  91470. * Groups all the scene component constants in one place to ease maintenance.
  91471. * @hidden
  91472. */
  91473. export class SceneComponentConstants {
  91474. static readonly NAME_EFFECTLAYER: string;
  91475. static readonly NAME_LAYER: string;
  91476. static readonly NAME_LENSFLARESYSTEM: string;
  91477. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91478. static readonly NAME_PARTICLESYSTEM: string;
  91479. static readonly NAME_GAMEPAD: string;
  91480. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91481. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91482. static readonly NAME_PREPASSRENDERER: string;
  91483. static readonly NAME_DEPTHRENDERER: string;
  91484. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91485. static readonly NAME_SPRITE: string;
  91486. static readonly NAME_SUBSURFACE: string;
  91487. static readonly NAME_OUTLINERENDERER: string;
  91488. static readonly NAME_PROCEDURALTEXTURE: string;
  91489. static readonly NAME_SHADOWGENERATOR: string;
  91490. static readonly NAME_OCTREE: string;
  91491. static readonly NAME_PHYSICSENGINE: string;
  91492. static readonly NAME_AUDIO: string;
  91493. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91494. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91495. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91496. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91497. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91498. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91499. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91500. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91501. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91502. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91503. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91504. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91505. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91506. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91507. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91508. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91509. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91510. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91511. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91512. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91513. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91514. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91515. static readonly STEP_AFTERRENDER_AUDIO: number;
  91516. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91517. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91518. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91519. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91520. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91521. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91522. static readonly STEP_POINTERMOVE_SPRITE: number;
  91523. static readonly STEP_POINTERDOWN_SPRITE: number;
  91524. static readonly STEP_POINTERUP_SPRITE: number;
  91525. }
  91526. /**
  91527. * This represents a scene component.
  91528. *
  91529. * This is used to decouple the dependency the scene is having on the different workloads like
  91530. * layers, post processes...
  91531. */
  91532. export interface ISceneComponent {
  91533. /**
  91534. * The name of the component. Each component must have a unique name.
  91535. */
  91536. name: string;
  91537. /**
  91538. * The scene the component belongs to.
  91539. */
  91540. scene: Scene;
  91541. /**
  91542. * Register the component to one instance of a scene.
  91543. */
  91544. register(): void;
  91545. /**
  91546. * Rebuilds the elements related to this component in case of
  91547. * context lost for instance.
  91548. */
  91549. rebuild(): void;
  91550. /**
  91551. * Disposes the component and the associated ressources.
  91552. */
  91553. dispose(): void;
  91554. }
  91555. /**
  91556. * This represents a SERIALIZABLE scene component.
  91557. *
  91558. * This extends Scene Component to add Serialization methods on top.
  91559. */
  91560. export interface ISceneSerializableComponent extends ISceneComponent {
  91561. /**
  91562. * Adds all the elements from the container to the scene
  91563. * @param container the container holding the elements
  91564. */
  91565. addFromContainer(container: AbstractScene): void;
  91566. /**
  91567. * Removes all the elements in the container from the scene
  91568. * @param container contains the elements to remove
  91569. * @param dispose if the removed element should be disposed (default: false)
  91570. */
  91571. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91572. /**
  91573. * Serializes the component data to the specified json object
  91574. * @param serializationObject The object to serialize to
  91575. */
  91576. serialize(serializationObject: any): void;
  91577. }
  91578. /**
  91579. * Strong typing of a Mesh related stage step action
  91580. */
  91581. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91582. /**
  91583. * Strong typing of a Evaluate Sub Mesh related stage step action
  91584. */
  91585. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91586. /**
  91587. * Strong typing of a Active Mesh related stage step action
  91588. */
  91589. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91590. /**
  91591. * Strong typing of a Camera related stage step action
  91592. */
  91593. export type CameraStageAction = (camera: Camera) => void;
  91594. /**
  91595. * Strong typing of a Camera Frame buffer related stage step action
  91596. */
  91597. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91598. /**
  91599. * Strong typing of a Render Target related stage step action
  91600. */
  91601. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91602. /**
  91603. * Strong typing of a RenderingGroup related stage step action
  91604. */
  91605. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91606. /**
  91607. * Strong typing of a Mesh Render related stage step action
  91608. */
  91609. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91610. /**
  91611. * Strong typing of a simple stage step action
  91612. */
  91613. export type SimpleStageAction = () => void;
  91614. /**
  91615. * Strong typing of a render target action.
  91616. */
  91617. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91618. /**
  91619. * Strong typing of a pointer move action.
  91620. */
  91621. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91622. /**
  91623. * Strong typing of a pointer up/down action.
  91624. */
  91625. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91626. /**
  91627. * Representation of a stage in the scene (Basically a list of ordered steps)
  91628. * @hidden
  91629. */
  91630. export class Stage<T extends Function> extends Array<{
  91631. index: number;
  91632. component: ISceneComponent;
  91633. action: T;
  91634. }> {
  91635. /**
  91636. * Hide ctor from the rest of the world.
  91637. * @param items The items to add.
  91638. */
  91639. private constructor();
  91640. /**
  91641. * Creates a new Stage.
  91642. * @returns A new instance of a Stage
  91643. */
  91644. static Create<T extends Function>(): Stage<T>;
  91645. /**
  91646. * Registers a step in an ordered way in the targeted stage.
  91647. * @param index Defines the position to register the step in
  91648. * @param component Defines the component attached to the step
  91649. * @param action Defines the action to launch during the step
  91650. */
  91651. registerStep(index: number, component: ISceneComponent, action: T): void;
  91652. /**
  91653. * Clears all the steps from the stage.
  91654. */
  91655. clear(): void;
  91656. }
  91657. }
  91658. declare module BABYLON {
  91659. interface Scene {
  91660. /** @hidden */
  91661. _pointerOverSprite: Nullable<Sprite>;
  91662. /** @hidden */
  91663. _pickedDownSprite: Nullable<Sprite>;
  91664. /** @hidden */
  91665. _tempSpritePickingRay: Nullable<Ray>;
  91666. /**
  91667. * All of the sprite managers added to this scene
  91668. * @see https://doc.babylonjs.com/babylon101/sprites
  91669. */
  91670. spriteManagers: Array<ISpriteManager>;
  91671. /**
  91672. * An event triggered when sprites rendering is about to start
  91673. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91674. */
  91675. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91676. /**
  91677. * An event triggered when sprites rendering is done
  91678. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91679. */
  91680. onAfterSpritesRenderingObservable: Observable<Scene>;
  91681. /** @hidden */
  91682. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91683. /** Launch a ray to try to pick a sprite in the scene
  91684. * @param x position on screen
  91685. * @param y position on screen
  91686. * @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
  91687. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91688. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91689. * @returns a PickingInfo
  91690. */
  91691. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91692. /** Use the given ray to pick a sprite in the scene
  91693. * @param ray The ray (in world space) to use to pick meshes
  91694. * @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
  91695. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91696. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91697. * @returns a PickingInfo
  91698. */
  91699. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91700. /** @hidden */
  91701. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91702. /** Launch a ray to try to pick sprites in the scene
  91703. * @param x position on screen
  91704. * @param y position on screen
  91705. * @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
  91706. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91707. * @returns a PickingInfo array
  91708. */
  91709. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91710. /** Use the given ray to pick sprites in the scene
  91711. * @param ray The ray (in world space) to use to pick meshes
  91712. * @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
  91713. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91714. * @returns a PickingInfo array
  91715. */
  91716. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91717. /**
  91718. * Force the sprite under the pointer
  91719. * @param sprite defines the sprite to use
  91720. */
  91721. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91722. /**
  91723. * Gets the sprite under the pointer
  91724. * @returns a Sprite or null if no sprite is under the pointer
  91725. */
  91726. getPointerOverSprite(): Nullable<Sprite>;
  91727. }
  91728. /**
  91729. * Defines the sprite scene component responsible to manage sprites
  91730. * in a given scene.
  91731. */
  91732. export class SpriteSceneComponent implements ISceneComponent {
  91733. /**
  91734. * The component name helpfull to identify the component in the list of scene components.
  91735. */
  91736. readonly name: string;
  91737. /**
  91738. * The scene the component belongs to.
  91739. */
  91740. scene: Scene;
  91741. /** @hidden */
  91742. private _spritePredicate;
  91743. /**
  91744. * Creates a new instance of the component for the given scene
  91745. * @param scene Defines the scene to register the component in
  91746. */
  91747. constructor(scene: Scene);
  91748. /**
  91749. * Registers the component in a given scene
  91750. */
  91751. register(): void;
  91752. /**
  91753. * Rebuilds the elements related to this component in case of
  91754. * context lost for instance.
  91755. */
  91756. rebuild(): void;
  91757. /**
  91758. * Disposes the component and the associated ressources.
  91759. */
  91760. dispose(): void;
  91761. private _pickSpriteButKeepRay;
  91762. private _pointerMove;
  91763. private _pointerDown;
  91764. private _pointerUp;
  91765. }
  91766. }
  91767. declare module BABYLON {
  91768. /** @hidden */
  91769. export var fogFragmentDeclaration: {
  91770. name: string;
  91771. shader: string;
  91772. };
  91773. }
  91774. declare module BABYLON {
  91775. /** @hidden */
  91776. export var fogFragment: {
  91777. name: string;
  91778. shader: string;
  91779. };
  91780. }
  91781. declare module BABYLON {
  91782. /** @hidden */
  91783. export var imageProcessingCompatibility: {
  91784. name: string;
  91785. shader: string;
  91786. };
  91787. }
  91788. declare module BABYLON {
  91789. /** @hidden */
  91790. export var spritesPixelShader: {
  91791. name: string;
  91792. shader: string;
  91793. };
  91794. }
  91795. declare module BABYLON {
  91796. /** @hidden */
  91797. export var fogVertexDeclaration: {
  91798. name: string;
  91799. shader: string;
  91800. };
  91801. }
  91802. declare module BABYLON {
  91803. /** @hidden */
  91804. export var spritesVertexShader: {
  91805. name: string;
  91806. shader: string;
  91807. };
  91808. }
  91809. declare module BABYLON {
  91810. /**
  91811. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91812. */
  91813. export interface ISpriteManager extends IDisposable {
  91814. /**
  91815. * Gets manager's name
  91816. */
  91817. name: string;
  91818. /**
  91819. * Restricts the camera to viewing objects with the same layerMask.
  91820. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91821. */
  91822. layerMask: number;
  91823. /**
  91824. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91825. */
  91826. isPickable: boolean;
  91827. /**
  91828. * Gets the hosting scene
  91829. */
  91830. scene: Scene;
  91831. /**
  91832. * Specifies the rendering group id for this mesh (0 by default)
  91833. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91834. */
  91835. renderingGroupId: number;
  91836. /**
  91837. * Defines the list of sprites managed by the manager.
  91838. */
  91839. sprites: Array<Sprite>;
  91840. /**
  91841. * Gets or sets the spritesheet texture
  91842. */
  91843. texture: Texture;
  91844. /** Defines the default width of a cell in the spritesheet */
  91845. cellWidth: number;
  91846. /** Defines the default height of a cell in the spritesheet */
  91847. cellHeight: number;
  91848. /**
  91849. * Tests the intersection of a sprite with a specific ray.
  91850. * @param ray The ray we are sending to test the collision
  91851. * @param camera The camera space we are sending rays in
  91852. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91853. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91854. * @returns picking info or null.
  91855. */
  91856. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91857. /**
  91858. * Intersects the sprites with a ray
  91859. * @param ray defines the ray to intersect with
  91860. * @param camera defines the current active camera
  91861. * @param predicate defines a predicate used to select candidate sprites
  91862. * @returns null if no hit or a PickingInfo array
  91863. */
  91864. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91865. /**
  91866. * Renders the list of sprites on screen.
  91867. */
  91868. render(): void;
  91869. }
  91870. /**
  91871. * Class used to manage multiple sprites on the same spritesheet
  91872. * @see https://doc.babylonjs.com/babylon101/sprites
  91873. */
  91874. export class SpriteManager implements ISpriteManager {
  91875. /** defines the manager's name */
  91876. name: string;
  91877. /** Define the Url to load snippets */
  91878. static SnippetUrl: string;
  91879. /** Snippet ID if the manager was created from the snippet server */
  91880. snippetId: string;
  91881. /** Gets the list of sprites */
  91882. sprites: Sprite[];
  91883. /** Gets or sets the rendering group id (0 by default) */
  91884. renderingGroupId: number;
  91885. /** Gets or sets camera layer mask */
  91886. layerMask: number;
  91887. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91888. fogEnabled: boolean;
  91889. /** Gets or sets a boolean indicating if the sprites are pickable */
  91890. isPickable: boolean;
  91891. /** Defines the default width of a cell in the spritesheet */
  91892. cellWidth: number;
  91893. /** Defines the default height of a cell in the spritesheet */
  91894. cellHeight: number;
  91895. /** Associative array from JSON sprite data file */
  91896. private _cellData;
  91897. /** Array of sprite names from JSON sprite data file */
  91898. private _spriteMap;
  91899. /** True when packed cell data from JSON file is ready*/
  91900. private _packedAndReady;
  91901. private _textureContent;
  91902. private _useInstancing;
  91903. /**
  91904. * An event triggered when the manager is disposed.
  91905. */
  91906. onDisposeObservable: Observable<SpriteManager>;
  91907. private _onDisposeObserver;
  91908. /**
  91909. * Callback called when the manager is disposed
  91910. */
  91911. set onDispose(callback: () => void);
  91912. private _capacity;
  91913. private _fromPacked;
  91914. private _spriteTexture;
  91915. private _epsilon;
  91916. private _scene;
  91917. private _vertexData;
  91918. private _buffer;
  91919. private _vertexBuffers;
  91920. private _spriteBuffer;
  91921. private _indexBuffer;
  91922. private _effectBase;
  91923. private _effectFog;
  91924. private _vertexBufferSize;
  91925. /**
  91926. * Gets or sets the unique id of the sprite
  91927. */
  91928. uniqueId: number;
  91929. /**
  91930. * Gets the array of sprites
  91931. */
  91932. get children(): Sprite[];
  91933. /**
  91934. * Gets the hosting scene
  91935. */
  91936. get scene(): Scene;
  91937. /**
  91938. * Gets the capacity of the manager
  91939. */
  91940. get capacity(): number;
  91941. /**
  91942. * Gets or sets the spritesheet texture
  91943. */
  91944. get texture(): Texture;
  91945. set texture(value: Texture);
  91946. private _blendMode;
  91947. /**
  91948. * Blend mode use to render the particle, it can be any of
  91949. * the static Constants.ALPHA_x properties provided in this class.
  91950. * Default value is Constants.ALPHA_COMBINE
  91951. */
  91952. get blendMode(): number;
  91953. set blendMode(blendMode: number);
  91954. /** Disables writing to the depth buffer when rendering the sprites.
  91955. * It can be handy to disable depth writing when using textures without alpha channel
  91956. * and setting some specific blend modes.
  91957. */
  91958. disableDepthWrite: boolean;
  91959. /**
  91960. * Creates a new sprite manager
  91961. * @param name defines the manager's name
  91962. * @param imgUrl defines the sprite sheet url
  91963. * @param capacity defines the maximum allowed number of sprites
  91964. * @param cellSize defines the size of a sprite cell
  91965. * @param scene defines the hosting scene
  91966. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91967. * @param samplingMode defines the smapling mode to use with spritesheet
  91968. * @param fromPacked set to false; do not alter
  91969. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91970. */
  91971. constructor(
  91972. /** defines the manager's name */
  91973. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91974. /**
  91975. * Returns the string "SpriteManager"
  91976. * @returns "SpriteManager"
  91977. */
  91978. getClassName(): string;
  91979. private _makePacked;
  91980. private _appendSpriteVertex;
  91981. private _checkTextureAlpha;
  91982. /**
  91983. * Intersects the sprites with a ray
  91984. * @param ray defines the ray to intersect with
  91985. * @param camera defines the current active camera
  91986. * @param predicate defines a predicate used to select candidate sprites
  91987. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91988. * @returns null if no hit or a PickingInfo
  91989. */
  91990. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91991. /**
  91992. * Intersects the sprites with a ray
  91993. * @param ray defines the ray to intersect with
  91994. * @param camera defines the current active camera
  91995. * @param predicate defines a predicate used to select candidate sprites
  91996. * @returns null if no hit or a PickingInfo array
  91997. */
  91998. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91999. /**
  92000. * Render all child sprites
  92001. */
  92002. render(): void;
  92003. /**
  92004. * Release associated resources
  92005. */
  92006. dispose(): void;
  92007. /**
  92008. * Serializes the sprite manager to a JSON object
  92009. * @param serializeTexture defines if the texture must be serialized as well
  92010. * @returns the JSON object
  92011. */
  92012. serialize(serializeTexture?: boolean): any;
  92013. /**
  92014. * Parses a JSON object to create a new sprite manager.
  92015. * @param parsedManager The JSON object to parse
  92016. * @param scene The scene to create the sprite managerin
  92017. * @param rootUrl The root url to use to load external dependencies like texture
  92018. * @returns the new sprite manager
  92019. */
  92020. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  92021. /**
  92022. * Creates a sprite manager from a snippet saved in a remote file
  92023. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  92024. * @param url defines the url to load from
  92025. * @param scene defines the hosting scene
  92026. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92027. * @returns a promise that will resolve to the new sprite manager
  92028. */
  92029. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92030. /**
  92031. * Creates a sprite manager from a snippet saved by the sprite editor
  92032. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  92033. * @param scene defines the hosting scene
  92034. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92035. * @returns a promise that will resolve to the new sprite manager
  92036. */
  92037. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92038. }
  92039. }
  92040. declare module BABYLON {
  92041. /** Interface used by value gradients (color, factor, ...) */
  92042. export interface IValueGradient {
  92043. /**
  92044. * Gets or sets the gradient value (between 0 and 1)
  92045. */
  92046. gradient: number;
  92047. }
  92048. /** Class used to store color4 gradient */
  92049. export class ColorGradient implements IValueGradient {
  92050. /**
  92051. * Gets or sets the gradient value (between 0 and 1)
  92052. */
  92053. gradient: number;
  92054. /**
  92055. * Gets or sets first associated color
  92056. */
  92057. color1: Color4;
  92058. /**
  92059. * Gets or sets second associated color
  92060. */
  92061. color2?: Color4 | undefined;
  92062. /**
  92063. * Creates a new color4 gradient
  92064. * @param gradient gets or sets the gradient value (between 0 and 1)
  92065. * @param color1 gets or sets first associated color
  92066. * @param color2 gets or sets first second color
  92067. */
  92068. constructor(
  92069. /**
  92070. * Gets or sets the gradient value (between 0 and 1)
  92071. */
  92072. gradient: number,
  92073. /**
  92074. * Gets or sets first associated color
  92075. */
  92076. color1: Color4,
  92077. /**
  92078. * Gets or sets second associated color
  92079. */
  92080. color2?: Color4 | undefined);
  92081. /**
  92082. * Will get a color picked randomly between color1 and color2.
  92083. * If color2 is undefined then color1 will be used
  92084. * @param result defines the target Color4 to store the result in
  92085. */
  92086. getColorToRef(result: Color4): void;
  92087. }
  92088. /** Class used to store color 3 gradient */
  92089. export class Color3Gradient implements IValueGradient {
  92090. /**
  92091. * Gets or sets the gradient value (between 0 and 1)
  92092. */
  92093. gradient: number;
  92094. /**
  92095. * Gets or sets the associated color
  92096. */
  92097. color: Color3;
  92098. /**
  92099. * Creates a new color3 gradient
  92100. * @param gradient gets or sets the gradient value (between 0 and 1)
  92101. * @param color gets or sets associated color
  92102. */
  92103. constructor(
  92104. /**
  92105. * Gets or sets the gradient value (between 0 and 1)
  92106. */
  92107. gradient: number,
  92108. /**
  92109. * Gets or sets the associated color
  92110. */
  92111. color: Color3);
  92112. }
  92113. /** Class used to store factor gradient */
  92114. export class FactorGradient implements IValueGradient {
  92115. /**
  92116. * Gets or sets the gradient value (between 0 and 1)
  92117. */
  92118. gradient: number;
  92119. /**
  92120. * Gets or sets first associated factor
  92121. */
  92122. factor1: number;
  92123. /**
  92124. * Gets or sets second associated factor
  92125. */
  92126. factor2?: number | undefined;
  92127. /**
  92128. * Creates a new factor gradient
  92129. * @param gradient gets or sets the gradient value (between 0 and 1)
  92130. * @param factor1 gets or sets first associated factor
  92131. * @param factor2 gets or sets second associated factor
  92132. */
  92133. constructor(
  92134. /**
  92135. * Gets or sets the gradient value (between 0 and 1)
  92136. */
  92137. gradient: number,
  92138. /**
  92139. * Gets or sets first associated factor
  92140. */
  92141. factor1: number,
  92142. /**
  92143. * Gets or sets second associated factor
  92144. */
  92145. factor2?: number | undefined);
  92146. /**
  92147. * Will get a number picked randomly between factor1 and factor2.
  92148. * If factor2 is undefined then factor1 will be used
  92149. * @returns the picked number
  92150. */
  92151. getFactor(): number;
  92152. }
  92153. /**
  92154. * Helper used to simplify some generic gradient tasks
  92155. */
  92156. export class GradientHelper {
  92157. /**
  92158. * Gets the current gradient from an array of IValueGradient
  92159. * @param ratio defines the current ratio to get
  92160. * @param gradients defines the array of IValueGradient
  92161. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  92162. */
  92163. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  92164. }
  92165. }
  92166. declare module BABYLON {
  92167. interface ThinEngine {
  92168. /**
  92169. * Creates a raw texture
  92170. * @param data defines the data to store in the texture
  92171. * @param width defines the width of the texture
  92172. * @param height defines the height of the texture
  92173. * @param format defines the format of the data
  92174. * @param generateMipMaps defines if the engine should generate the mip levels
  92175. * @param invertY defines if data must be stored with Y axis inverted
  92176. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92177. * @param compression defines the compression used (null by default)
  92178. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92179. * @returns the raw texture inside an InternalTexture
  92180. */
  92181. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92182. /**
  92183. * Update a raw texture
  92184. * @param texture defines the texture to update
  92185. * @param data defines the data to store in the texture
  92186. * @param format defines the format of the data
  92187. * @param invertY defines if data must be stored with Y axis inverted
  92188. */
  92189. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92190. /**
  92191. * Update a raw texture
  92192. * @param texture defines the texture to update
  92193. * @param data defines the data to store in the texture
  92194. * @param format defines the format of the data
  92195. * @param invertY defines if data must be stored with Y axis inverted
  92196. * @param compression defines the compression used (null by default)
  92197. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92198. */
  92199. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92200. /**
  92201. * Creates a new raw cube texture
  92202. * @param data defines the array of data to use to create each face
  92203. * @param size defines the size of the textures
  92204. * @param format defines the format of the data
  92205. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92206. * @param generateMipMaps defines if the engine should generate the mip levels
  92207. * @param invertY defines if data must be stored with Y axis inverted
  92208. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92209. * @param compression defines the compression used (null by default)
  92210. * @returns the cube texture as an InternalTexture
  92211. */
  92212. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92213. /**
  92214. * Update a raw cube texture
  92215. * @param texture defines the texture to udpdate
  92216. * @param data defines the data to store
  92217. * @param format defines the data format
  92218. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92219. * @param invertY defines if data must be stored with Y axis inverted
  92220. */
  92221. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92222. /**
  92223. * Update a raw cube texture
  92224. * @param texture defines the texture to udpdate
  92225. * @param data defines the data to store
  92226. * @param format defines the data format
  92227. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92228. * @param invertY defines if data must be stored with Y axis inverted
  92229. * @param compression defines the compression used (null by default)
  92230. */
  92231. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92232. /**
  92233. * Update a raw cube texture
  92234. * @param texture defines the texture to udpdate
  92235. * @param data defines the data to store
  92236. * @param format defines the data format
  92237. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92238. * @param invertY defines if data must be stored with Y axis inverted
  92239. * @param compression defines the compression used (null by default)
  92240. * @param level defines which level of the texture to update
  92241. */
  92242. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92243. /**
  92244. * Creates a new raw cube texture from a specified url
  92245. * @param url defines the url where the data is located
  92246. * @param scene defines the current scene
  92247. * @param size defines the size of the textures
  92248. * @param format defines the format of the data
  92249. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92250. * @param noMipmap defines if the engine should avoid generating the mip levels
  92251. * @param callback defines a callback used to extract texture data from loaded data
  92252. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92253. * @param onLoad defines a callback called when texture is loaded
  92254. * @param onError defines a callback called if there is an error
  92255. * @returns the cube texture as an InternalTexture
  92256. */
  92257. 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;
  92258. /**
  92259. * Creates a new raw cube texture from a specified url
  92260. * @param url defines the url where the data is located
  92261. * @param scene defines the current scene
  92262. * @param size defines the size of the textures
  92263. * @param format defines the format of the data
  92264. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92265. * @param noMipmap defines if the engine should avoid generating the mip levels
  92266. * @param callback defines a callback used to extract texture data from loaded data
  92267. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92268. * @param onLoad defines a callback called when texture is loaded
  92269. * @param onError defines a callback called if there is an error
  92270. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92271. * @param invertY defines if data must be stored with Y axis inverted
  92272. * @returns the cube texture as an InternalTexture
  92273. */
  92274. 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;
  92275. /**
  92276. * Creates a new raw 3D texture
  92277. * @param data defines the data used to create the texture
  92278. * @param width defines the width of the texture
  92279. * @param height defines the height of the texture
  92280. * @param depth defines the depth of the texture
  92281. * @param format defines the format of the texture
  92282. * @param generateMipMaps defines if the engine must generate mip levels
  92283. * @param invertY defines if data must be stored with Y axis inverted
  92284. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92285. * @param compression defines the compressed used (can be null)
  92286. * @param textureType defines the compressed used (can be null)
  92287. * @returns a new raw 3D texture (stored in an InternalTexture)
  92288. */
  92289. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92290. /**
  92291. * Update a raw 3D texture
  92292. * @param texture defines the texture to update
  92293. * @param data defines the data to store
  92294. * @param format defines the data format
  92295. * @param invertY defines if data must be stored with Y axis inverted
  92296. */
  92297. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92298. /**
  92299. * Update a raw 3D texture
  92300. * @param texture defines the texture to update
  92301. * @param data defines the data to store
  92302. * @param format defines the data format
  92303. * @param invertY defines if data must be stored with Y axis inverted
  92304. * @param compression defines the used compression (can be null)
  92305. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92306. */
  92307. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92308. /**
  92309. * Creates a new raw 2D array texture
  92310. * @param data defines the data used to create the texture
  92311. * @param width defines the width of the texture
  92312. * @param height defines the height of the texture
  92313. * @param depth defines the number of layers of the texture
  92314. * @param format defines the format of the texture
  92315. * @param generateMipMaps defines if the engine must generate mip levels
  92316. * @param invertY defines if data must be stored with Y axis inverted
  92317. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92318. * @param compression defines the compressed used (can be null)
  92319. * @param textureType defines the compressed used (can be null)
  92320. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92321. */
  92322. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92323. /**
  92324. * Update a raw 2D array texture
  92325. * @param texture defines the texture to update
  92326. * @param data defines the data to store
  92327. * @param format defines the data format
  92328. * @param invertY defines if data must be stored with Y axis inverted
  92329. */
  92330. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92331. /**
  92332. * Update a raw 2D array texture
  92333. * @param texture defines the texture to update
  92334. * @param data defines the data to store
  92335. * @param format defines the data format
  92336. * @param invertY defines if data must be stored with Y axis inverted
  92337. * @param compression defines the used compression (can be null)
  92338. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92339. */
  92340. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92341. }
  92342. }
  92343. declare module BABYLON {
  92344. /**
  92345. * Raw texture can help creating a texture directly from an array of data.
  92346. * This can be super useful if you either get the data from an uncompressed source or
  92347. * if you wish to create your texture pixel by pixel.
  92348. */
  92349. export class RawTexture extends Texture {
  92350. /**
  92351. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92352. */
  92353. format: number;
  92354. /**
  92355. * Instantiates a new RawTexture.
  92356. * Raw texture can help creating a texture directly from an array of data.
  92357. * This can be super useful if you either get the data from an uncompressed source or
  92358. * if you wish to create your texture pixel by pixel.
  92359. * @param data define the array of data to use to create the texture
  92360. * @param width define the width of the texture
  92361. * @param height define the height of the texture
  92362. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92363. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92364. * @param generateMipMaps define whether mip maps should be generated or not
  92365. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92366. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92367. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92368. */
  92369. constructor(data: ArrayBufferView, width: number, height: number,
  92370. /**
  92371. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92372. */
  92373. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92374. /**
  92375. * Updates the texture underlying data.
  92376. * @param data Define the new data of the texture
  92377. */
  92378. update(data: ArrayBufferView): void;
  92379. /**
  92380. * Creates a luminance texture from some data.
  92381. * @param data Define the texture data
  92382. * @param width Define the width of the texture
  92383. * @param height Define the height of the texture
  92384. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92385. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92386. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92387. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92388. * @returns the luminance texture
  92389. */
  92390. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92391. /**
  92392. * Creates a luminance alpha texture from some data.
  92393. * @param data Define the texture data
  92394. * @param width Define the width of the texture
  92395. * @param height Define the height of the texture
  92396. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92397. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92398. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92399. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92400. * @returns the luminance alpha texture
  92401. */
  92402. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92403. /**
  92404. * Creates an alpha texture from some data.
  92405. * @param data Define the texture data
  92406. * @param width Define the width of the texture
  92407. * @param height Define the height of the texture
  92408. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92409. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92410. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92411. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92412. * @returns the alpha texture
  92413. */
  92414. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92415. /**
  92416. * Creates a RGB texture from some data.
  92417. * @param data Define the texture data
  92418. * @param width Define the width of the texture
  92419. * @param height Define the height of the texture
  92420. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92421. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92422. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92423. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92424. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92425. * @returns the RGB alpha texture
  92426. */
  92427. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92428. /**
  92429. * Creates a RGBA texture from some data.
  92430. * @param data Define the texture data
  92431. * @param width Define the width of the texture
  92432. * @param height Define the height of the texture
  92433. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92434. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92435. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92436. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92437. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92438. * @returns the RGBA texture
  92439. */
  92440. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92441. /**
  92442. * Creates a R texture from some data.
  92443. * @param data Define the texture data
  92444. * @param width Define the width of the texture
  92445. * @param height Define the height of the texture
  92446. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92447. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92448. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92449. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92450. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92451. * @returns the R texture
  92452. */
  92453. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92454. }
  92455. }
  92456. declare module BABYLON {
  92457. interface ThinEngine {
  92458. /**
  92459. * Update a dynamic index buffer
  92460. * @param indexBuffer defines the target index buffer
  92461. * @param indices defines the data to update
  92462. * @param offset defines the offset in the target index buffer where update should start
  92463. */
  92464. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92465. /**
  92466. * Updates a dynamic vertex buffer.
  92467. * @param vertexBuffer the vertex buffer to update
  92468. * @param data the data used to update the vertex buffer
  92469. * @param byteOffset the byte offset of the data
  92470. * @param byteLength the byte length of the data
  92471. */
  92472. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92473. }
  92474. }
  92475. declare module BABYLON {
  92476. interface AbstractScene {
  92477. /**
  92478. * The list of procedural textures added to the scene
  92479. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92480. */
  92481. proceduralTextures: Array<ProceduralTexture>;
  92482. }
  92483. /**
  92484. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92485. * in a given scene.
  92486. */
  92487. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92488. /**
  92489. * The component name helpfull to identify the component in the list of scene components.
  92490. */
  92491. readonly name: string;
  92492. /**
  92493. * The scene the component belongs to.
  92494. */
  92495. scene: Scene;
  92496. /**
  92497. * Creates a new instance of the component for the given scene
  92498. * @param scene Defines the scene to register the component in
  92499. */
  92500. constructor(scene: Scene);
  92501. /**
  92502. * Registers the component in a given scene
  92503. */
  92504. register(): void;
  92505. /**
  92506. * Rebuilds the elements related to this component in case of
  92507. * context lost for instance.
  92508. */
  92509. rebuild(): void;
  92510. /**
  92511. * Disposes the component and the associated ressources.
  92512. */
  92513. dispose(): void;
  92514. private _beforeClear;
  92515. }
  92516. }
  92517. declare module BABYLON {
  92518. interface ThinEngine {
  92519. /**
  92520. * Creates a new render target cube texture
  92521. * @param size defines the size of the texture
  92522. * @param options defines the options used to create the texture
  92523. * @returns a new render target cube texture stored in an InternalTexture
  92524. */
  92525. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92526. }
  92527. }
  92528. declare module BABYLON {
  92529. /** @hidden */
  92530. export var proceduralVertexShader: {
  92531. name: string;
  92532. shader: string;
  92533. };
  92534. }
  92535. declare module BABYLON {
  92536. /**
  92537. * 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.
  92538. * This is the base class of any Procedural texture and contains most of the shareable code.
  92539. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92540. */
  92541. export class ProceduralTexture extends Texture {
  92542. /**
  92543. * Define if the texture is enabled or not (disabled texture will not render)
  92544. */
  92545. isEnabled: boolean;
  92546. /**
  92547. * Define if the texture must be cleared before rendering (default is true)
  92548. */
  92549. autoClear: boolean;
  92550. /**
  92551. * Callback called when the texture is generated
  92552. */
  92553. onGenerated: () => void;
  92554. /**
  92555. * Event raised when the texture is generated
  92556. */
  92557. onGeneratedObservable: Observable<ProceduralTexture>;
  92558. /**
  92559. * Event raised before the texture is generated
  92560. */
  92561. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92562. /**
  92563. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92564. */
  92565. nodeMaterialSource: Nullable<NodeMaterial>;
  92566. /** @hidden */
  92567. _generateMipMaps: boolean;
  92568. /** @hidden **/
  92569. _effect: Effect;
  92570. /** @hidden */
  92571. _textures: {
  92572. [key: string]: Texture;
  92573. };
  92574. /** @hidden */
  92575. protected _fallbackTexture: Nullable<Texture>;
  92576. private _size;
  92577. private _currentRefreshId;
  92578. private _frameId;
  92579. private _refreshRate;
  92580. private _vertexBuffers;
  92581. private _indexBuffer;
  92582. private _uniforms;
  92583. private _samplers;
  92584. private _fragment;
  92585. private _floats;
  92586. private _ints;
  92587. private _floatsArrays;
  92588. private _colors3;
  92589. private _colors4;
  92590. private _vectors2;
  92591. private _vectors3;
  92592. private _matrices;
  92593. private _fallbackTextureUsed;
  92594. private _fullEngine;
  92595. private _cachedDefines;
  92596. private _contentUpdateId;
  92597. private _contentData;
  92598. /**
  92599. * Instantiates a new procedural texture.
  92600. * 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.
  92601. * This is the base class of any Procedural texture and contains most of the shareable code.
  92602. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92603. * @param name Define the name of the texture
  92604. * @param size Define the size of the texture to create
  92605. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92606. * @param scene Define the scene the texture belongs to
  92607. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92608. * @param generateMipMaps Define if the texture should creates mip maps or not
  92609. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92610. * @param textureType The FBO internal texture type
  92611. */
  92612. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92613. /**
  92614. * The effect that is created when initializing the post process.
  92615. * @returns The created effect corresponding the the postprocess.
  92616. */
  92617. getEffect(): Effect;
  92618. /**
  92619. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92620. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92621. */
  92622. getContent(): Nullable<ArrayBufferView>;
  92623. private _createIndexBuffer;
  92624. /** @hidden */
  92625. _rebuild(): void;
  92626. /**
  92627. * Resets the texture in order to recreate its associated resources.
  92628. * This can be called in case of context loss
  92629. */
  92630. reset(): void;
  92631. protected _getDefines(): string;
  92632. /**
  92633. * Is the texture ready to be used ? (rendered at least once)
  92634. * @returns true if ready, otherwise, false.
  92635. */
  92636. isReady(): boolean;
  92637. /**
  92638. * Resets the refresh counter of the texture and start bak from scratch.
  92639. * Could be useful to regenerate the texture if it is setup to render only once.
  92640. */
  92641. resetRefreshCounter(): void;
  92642. /**
  92643. * Set the fragment shader to use in order to render the texture.
  92644. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92645. */
  92646. setFragment(fragment: any): void;
  92647. /**
  92648. * Define the refresh rate of the texture or the rendering frequency.
  92649. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92650. */
  92651. get refreshRate(): number;
  92652. set refreshRate(value: number);
  92653. /** @hidden */
  92654. _shouldRender(): boolean;
  92655. /**
  92656. * Get the size the texture is rendering at.
  92657. * @returns the size (on cube texture it is always squared)
  92658. */
  92659. getRenderSize(): RenderTargetTextureSize;
  92660. /**
  92661. * Resize the texture to new value.
  92662. * @param size Define the new size the texture should have
  92663. * @param generateMipMaps Define whether the new texture should create mip maps
  92664. */
  92665. resize(size: number, generateMipMaps: boolean): void;
  92666. private _checkUniform;
  92667. /**
  92668. * Set a texture in the shader program used to render.
  92669. * @param name Define the name of the uniform samplers as defined in the shader
  92670. * @param texture Define the texture to bind to this sampler
  92671. * @return the texture itself allowing "fluent" like uniform updates
  92672. */
  92673. setTexture(name: string, texture: Texture): ProceduralTexture;
  92674. /**
  92675. * Set a float in the shader.
  92676. * @param name Define the name of the uniform as defined in the shader
  92677. * @param value Define the value to give to the uniform
  92678. * @return the texture itself allowing "fluent" like uniform updates
  92679. */
  92680. setFloat(name: string, value: number): ProceduralTexture;
  92681. /**
  92682. * Set a int in the shader.
  92683. * @param name Define the name of the uniform as defined in the shader
  92684. * @param value Define the value to give to the uniform
  92685. * @return the texture itself allowing "fluent" like uniform updates
  92686. */
  92687. setInt(name: string, value: number): ProceduralTexture;
  92688. /**
  92689. * Set an array of floats in the shader.
  92690. * @param name Define the name of the uniform as defined in the shader
  92691. * @param value Define the value to give to the uniform
  92692. * @return the texture itself allowing "fluent" like uniform updates
  92693. */
  92694. setFloats(name: string, value: number[]): ProceduralTexture;
  92695. /**
  92696. * Set a vec3 in the shader from a Color3.
  92697. * @param name Define the name of the uniform as defined in the shader
  92698. * @param value Define the value to give to the uniform
  92699. * @return the texture itself allowing "fluent" like uniform updates
  92700. */
  92701. setColor3(name: string, value: Color3): ProceduralTexture;
  92702. /**
  92703. * Set a vec4 in the shader from a Color4.
  92704. * @param name Define the name of the uniform as defined in the shader
  92705. * @param value Define the value to give to the uniform
  92706. * @return the texture itself allowing "fluent" like uniform updates
  92707. */
  92708. setColor4(name: string, value: Color4): ProceduralTexture;
  92709. /**
  92710. * Set a vec2 in the shader from a Vector2.
  92711. * @param name Define the name of the uniform as defined in the shader
  92712. * @param value Define the value to give to the uniform
  92713. * @return the texture itself allowing "fluent" like uniform updates
  92714. */
  92715. setVector2(name: string, value: Vector2): ProceduralTexture;
  92716. /**
  92717. * Set a vec3 in the shader from a Vector3.
  92718. * @param name Define the name of the uniform as defined in the shader
  92719. * @param value Define the value to give to the uniform
  92720. * @return the texture itself allowing "fluent" like uniform updates
  92721. */
  92722. setVector3(name: string, value: Vector3): ProceduralTexture;
  92723. /**
  92724. * Set a mat4 in the shader from a MAtrix.
  92725. * @param name Define the name of the uniform as defined in the shader
  92726. * @param value Define the value to give to the uniform
  92727. * @return the texture itself allowing "fluent" like uniform updates
  92728. */
  92729. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92730. /**
  92731. * Render the texture to its associated render target.
  92732. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92733. */
  92734. render(useCameraPostProcess?: boolean): void;
  92735. /**
  92736. * Clone the texture.
  92737. * @returns the cloned texture
  92738. */
  92739. clone(): ProceduralTexture;
  92740. /**
  92741. * Dispose the texture and release its asoociated resources.
  92742. */
  92743. dispose(): void;
  92744. }
  92745. }
  92746. declare module BABYLON {
  92747. /**
  92748. * This represents the base class for particle system in Babylon.
  92749. * 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.
  92750. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92751. * @example https://doc.babylonjs.com/babylon101/particles
  92752. */
  92753. export class BaseParticleSystem {
  92754. /**
  92755. * Source color is added to the destination color without alpha affecting the result
  92756. */
  92757. static BLENDMODE_ONEONE: number;
  92758. /**
  92759. * Blend current color and particle color using particle’s alpha
  92760. */
  92761. static BLENDMODE_STANDARD: number;
  92762. /**
  92763. * Add current color and particle color multiplied by particle’s alpha
  92764. */
  92765. static BLENDMODE_ADD: number;
  92766. /**
  92767. * Multiply current color with particle color
  92768. */
  92769. static BLENDMODE_MULTIPLY: number;
  92770. /**
  92771. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92772. */
  92773. static BLENDMODE_MULTIPLYADD: number;
  92774. /**
  92775. * List of animations used by the particle system.
  92776. */
  92777. animations: Animation[];
  92778. /**
  92779. * Gets or sets the unique id of the particle system
  92780. */
  92781. uniqueId: number;
  92782. /**
  92783. * The id of the Particle system.
  92784. */
  92785. id: string;
  92786. /**
  92787. * The friendly name of the Particle system.
  92788. */
  92789. name: string;
  92790. /**
  92791. * Snippet ID if the particle system was created from the snippet server
  92792. */
  92793. snippetId: string;
  92794. /**
  92795. * The rendering group used by the Particle system to chose when to render.
  92796. */
  92797. renderingGroupId: number;
  92798. /**
  92799. * The emitter represents the Mesh or position we are attaching the particle system to.
  92800. */
  92801. emitter: Nullable<AbstractMesh | Vector3>;
  92802. /**
  92803. * The maximum number of particles to emit per frame
  92804. */
  92805. emitRate: number;
  92806. /**
  92807. * If you want to launch only a few particles at once, that can be done, as well.
  92808. */
  92809. manualEmitCount: number;
  92810. /**
  92811. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92812. */
  92813. updateSpeed: number;
  92814. /**
  92815. * The amount of time the particle system is running (depends of the overall update speed).
  92816. */
  92817. targetStopDuration: number;
  92818. /**
  92819. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92820. */
  92821. disposeOnStop: boolean;
  92822. /**
  92823. * Minimum power of emitting particles.
  92824. */
  92825. minEmitPower: number;
  92826. /**
  92827. * Maximum power of emitting particles.
  92828. */
  92829. maxEmitPower: number;
  92830. /**
  92831. * Minimum life time of emitting particles.
  92832. */
  92833. minLifeTime: number;
  92834. /**
  92835. * Maximum life time of emitting particles.
  92836. */
  92837. maxLifeTime: number;
  92838. /**
  92839. * Minimum Size of emitting particles.
  92840. */
  92841. minSize: number;
  92842. /**
  92843. * Maximum Size of emitting particles.
  92844. */
  92845. maxSize: number;
  92846. /**
  92847. * Minimum scale of emitting particles on X axis.
  92848. */
  92849. minScaleX: number;
  92850. /**
  92851. * Maximum scale of emitting particles on X axis.
  92852. */
  92853. maxScaleX: number;
  92854. /**
  92855. * Minimum scale of emitting particles on Y axis.
  92856. */
  92857. minScaleY: number;
  92858. /**
  92859. * Maximum scale of emitting particles on Y axis.
  92860. */
  92861. maxScaleY: number;
  92862. /**
  92863. * Gets or sets the minimal initial rotation in radians.
  92864. */
  92865. minInitialRotation: number;
  92866. /**
  92867. * Gets or sets the maximal initial rotation in radians.
  92868. */
  92869. maxInitialRotation: number;
  92870. /**
  92871. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92872. */
  92873. minAngularSpeed: number;
  92874. /**
  92875. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92876. */
  92877. maxAngularSpeed: number;
  92878. /**
  92879. * The texture used to render each particle. (this can be a spritesheet)
  92880. */
  92881. particleTexture: Nullable<BaseTexture>;
  92882. /**
  92883. * The layer mask we are rendering the particles through.
  92884. */
  92885. layerMask: number;
  92886. /**
  92887. * This can help using your own shader to render the particle system.
  92888. * The according effect will be created
  92889. */
  92890. customShader: any;
  92891. /**
  92892. * By default particle system starts as soon as they are created. This prevents the
  92893. * automatic start to happen and let you decide when to start emitting particles.
  92894. */
  92895. preventAutoStart: boolean;
  92896. private _noiseTexture;
  92897. /**
  92898. * Gets or sets a texture used to add random noise to particle positions
  92899. */
  92900. get noiseTexture(): Nullable<ProceduralTexture>;
  92901. set noiseTexture(value: Nullable<ProceduralTexture>);
  92902. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92903. noiseStrength: Vector3;
  92904. /**
  92905. * Callback triggered when the particle animation is ending.
  92906. */
  92907. onAnimationEnd: Nullable<() => void>;
  92908. /**
  92909. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92910. */
  92911. blendMode: number;
  92912. /**
  92913. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92914. * to override the particles.
  92915. */
  92916. forceDepthWrite: boolean;
  92917. /** 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 */
  92918. preWarmCycles: number;
  92919. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92920. preWarmStepOffset: number;
  92921. /**
  92922. * 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)
  92923. */
  92924. spriteCellChangeSpeed: number;
  92925. /**
  92926. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92927. */
  92928. startSpriteCellID: number;
  92929. /**
  92930. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92931. */
  92932. endSpriteCellID: number;
  92933. /**
  92934. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92935. */
  92936. spriteCellWidth: number;
  92937. /**
  92938. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92939. */
  92940. spriteCellHeight: number;
  92941. /**
  92942. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92943. */
  92944. spriteRandomStartCell: boolean;
  92945. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92946. translationPivot: Vector2;
  92947. /** @hidden */
  92948. protected _isAnimationSheetEnabled: boolean;
  92949. /**
  92950. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92951. */
  92952. beginAnimationOnStart: boolean;
  92953. /**
  92954. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92955. */
  92956. beginAnimationFrom: number;
  92957. /**
  92958. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92959. */
  92960. beginAnimationTo: number;
  92961. /**
  92962. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92963. */
  92964. beginAnimationLoop: boolean;
  92965. /**
  92966. * Gets or sets a world offset applied to all particles
  92967. */
  92968. worldOffset: Vector3;
  92969. /**
  92970. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92971. */
  92972. get isAnimationSheetEnabled(): boolean;
  92973. set isAnimationSheetEnabled(value: boolean);
  92974. /**
  92975. * Get hosting scene
  92976. * @returns the scene
  92977. */
  92978. getScene(): Nullable<Scene>;
  92979. /**
  92980. * You can use gravity if you want to give an orientation to your particles.
  92981. */
  92982. gravity: Vector3;
  92983. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92984. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92985. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92986. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92987. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92988. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92989. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92990. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92991. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92992. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92993. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92994. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92995. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92996. /**
  92997. * Defines the delay in milliseconds before starting the system (0 by default)
  92998. */
  92999. startDelay: number;
  93000. /**
  93001. * Gets the current list of drag gradients.
  93002. * You must use addDragGradient and removeDragGradient to udpate this list
  93003. * @returns the list of drag gradients
  93004. */
  93005. getDragGradients(): Nullable<Array<FactorGradient>>;
  93006. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93007. limitVelocityDamping: number;
  93008. /**
  93009. * Gets the current list of limit velocity gradients.
  93010. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93011. * @returns the list of limit velocity gradients
  93012. */
  93013. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93014. /**
  93015. * Gets the current list of color gradients.
  93016. * You must use addColorGradient and removeColorGradient to udpate this list
  93017. * @returns the list of color gradients
  93018. */
  93019. getColorGradients(): Nullable<Array<ColorGradient>>;
  93020. /**
  93021. * Gets the current list of size gradients.
  93022. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93023. * @returns the list of size gradients
  93024. */
  93025. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93026. /**
  93027. * Gets the current list of color remap gradients.
  93028. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93029. * @returns the list of color remap gradients
  93030. */
  93031. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93032. /**
  93033. * Gets the current list of alpha remap gradients.
  93034. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93035. * @returns the list of alpha remap gradients
  93036. */
  93037. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93038. /**
  93039. * Gets the current list of life time gradients.
  93040. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93041. * @returns the list of life time gradients
  93042. */
  93043. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93044. /**
  93045. * Gets the current list of angular speed gradients.
  93046. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93047. * @returns the list of angular speed gradients
  93048. */
  93049. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93050. /**
  93051. * Gets the current list of velocity gradients.
  93052. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93053. * @returns the list of velocity gradients
  93054. */
  93055. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93056. /**
  93057. * Gets the current list of start size gradients.
  93058. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93059. * @returns the list of start size gradients
  93060. */
  93061. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93062. /**
  93063. * Gets the current list of emit rate gradients.
  93064. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93065. * @returns the list of emit rate gradients
  93066. */
  93067. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93068. /**
  93069. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93070. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93071. */
  93072. get direction1(): Vector3;
  93073. set direction1(value: Vector3);
  93074. /**
  93075. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93076. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93077. */
  93078. get direction2(): Vector3;
  93079. set direction2(value: Vector3);
  93080. /**
  93081. * 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.
  93082. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93083. */
  93084. get minEmitBox(): Vector3;
  93085. set minEmitBox(value: Vector3);
  93086. /**
  93087. * 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.
  93088. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93089. */
  93090. get maxEmitBox(): Vector3;
  93091. set maxEmitBox(value: Vector3);
  93092. /**
  93093. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93094. */
  93095. color1: Color4;
  93096. /**
  93097. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93098. */
  93099. color2: Color4;
  93100. /**
  93101. * Color the particle will have at the end of its lifetime
  93102. */
  93103. colorDead: Color4;
  93104. /**
  93105. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  93106. */
  93107. textureMask: Color4;
  93108. /**
  93109. * The particle emitter type defines the emitter used by the particle system.
  93110. * It can be for example box, sphere, or cone...
  93111. */
  93112. particleEmitterType: IParticleEmitterType;
  93113. /** @hidden */
  93114. _isSubEmitter: boolean;
  93115. /**
  93116. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93117. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93118. */
  93119. billboardMode: number;
  93120. protected _isBillboardBased: boolean;
  93121. /**
  93122. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93123. */
  93124. get isBillboardBased(): boolean;
  93125. set isBillboardBased(value: boolean);
  93126. /**
  93127. * The scene the particle system belongs to.
  93128. */
  93129. protected _scene: Nullable<Scene>;
  93130. /**
  93131. * The engine the particle system belongs to.
  93132. */
  93133. protected _engine: ThinEngine;
  93134. /**
  93135. * Local cache of defines for image processing.
  93136. */
  93137. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  93138. /**
  93139. * Default configuration related to image processing available in the standard Material.
  93140. */
  93141. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  93142. /**
  93143. * Gets the image processing configuration used either in this material.
  93144. */
  93145. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  93146. /**
  93147. * Sets the Default image processing configuration used either in the this material.
  93148. *
  93149. * If sets to null, the scene one is in use.
  93150. */
  93151. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  93152. /**
  93153. * Attaches a new image processing configuration to the Standard Material.
  93154. * @param configuration
  93155. */
  93156. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93157. /** @hidden */
  93158. protected _reset(): void;
  93159. /** @hidden */
  93160. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  93161. /**
  93162. * Instantiates a particle system.
  93163. * 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.
  93164. * @param name The name of the particle system
  93165. */
  93166. constructor(name: string);
  93167. /**
  93168. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93169. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93170. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93171. * @returns the emitter
  93172. */
  93173. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93174. /**
  93175. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93176. * @param radius The radius of the hemisphere to emit from
  93177. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93178. * @returns the emitter
  93179. */
  93180. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  93181. /**
  93182. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93183. * @param radius The radius of the sphere to emit from
  93184. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93185. * @returns the emitter
  93186. */
  93187. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93188. /**
  93189. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93190. * @param radius The radius of the sphere to emit from
  93191. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93192. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93193. * @returns the emitter
  93194. */
  93195. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93196. /**
  93197. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93198. * @param radius The radius of the emission cylinder
  93199. * @param height The height of the emission cylinder
  93200. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93201. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93202. * @returns the emitter
  93203. */
  93204. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93205. /**
  93206. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93207. * @param radius The radius of the cylinder to emit from
  93208. * @param height The height of the emission cylinder
  93209. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93210. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93211. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93212. * @returns the emitter
  93213. */
  93214. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93215. /**
  93216. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93217. * @param radius The radius of the cone to emit from
  93218. * @param angle The base angle of the cone
  93219. * @returns the emitter
  93220. */
  93221. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93222. /**
  93223. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93224. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93225. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93226. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93227. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93228. * @returns the emitter
  93229. */
  93230. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93231. }
  93232. }
  93233. declare module BABYLON {
  93234. /**
  93235. * Type of sub emitter
  93236. */
  93237. export enum SubEmitterType {
  93238. /**
  93239. * Attached to the particle over it's lifetime
  93240. */
  93241. ATTACHED = 0,
  93242. /**
  93243. * Created when the particle dies
  93244. */
  93245. END = 1
  93246. }
  93247. /**
  93248. * Sub emitter class used to emit particles from an existing particle
  93249. */
  93250. export class SubEmitter {
  93251. /**
  93252. * the particle system to be used by the sub emitter
  93253. */
  93254. particleSystem: ParticleSystem;
  93255. /**
  93256. * Type of the submitter (Default: END)
  93257. */
  93258. type: SubEmitterType;
  93259. /**
  93260. * 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)
  93261. * Note: This only is supported when using an emitter of type Mesh
  93262. */
  93263. inheritDirection: boolean;
  93264. /**
  93265. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93266. */
  93267. inheritedVelocityAmount: number;
  93268. /**
  93269. * Creates a sub emitter
  93270. * @param particleSystem the particle system to be used by the sub emitter
  93271. */
  93272. constructor(
  93273. /**
  93274. * the particle system to be used by the sub emitter
  93275. */
  93276. particleSystem: ParticleSystem);
  93277. /**
  93278. * Clones the sub emitter
  93279. * @returns the cloned sub emitter
  93280. */
  93281. clone(): SubEmitter;
  93282. /**
  93283. * Serialize current object to a JSON object
  93284. * @returns the serialized object
  93285. */
  93286. serialize(): any;
  93287. /** @hidden */
  93288. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93289. /**
  93290. * Creates a new SubEmitter from a serialized JSON version
  93291. * @param serializationObject defines the JSON object to read from
  93292. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93293. * @param rootUrl defines the rootUrl for data loading
  93294. * @returns a new SubEmitter
  93295. */
  93296. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93297. /** Release associated resources */
  93298. dispose(): void;
  93299. }
  93300. }
  93301. declare module BABYLON {
  93302. /** @hidden */
  93303. export var imageProcessingDeclaration: {
  93304. name: string;
  93305. shader: string;
  93306. };
  93307. }
  93308. declare module BABYLON {
  93309. /** @hidden */
  93310. export var imageProcessingFunctions: {
  93311. name: string;
  93312. shader: string;
  93313. };
  93314. }
  93315. declare module BABYLON {
  93316. /** @hidden */
  93317. export var particlesPixelShader: {
  93318. name: string;
  93319. shader: string;
  93320. };
  93321. }
  93322. declare module BABYLON {
  93323. /** @hidden */
  93324. export var particlesVertexShader: {
  93325. name: string;
  93326. shader: string;
  93327. };
  93328. }
  93329. declare module BABYLON {
  93330. /**
  93331. * Interface used to define entities containing multiple clip planes
  93332. */
  93333. export interface IClipPlanesHolder {
  93334. /**
  93335. * Gets or sets the active clipplane 1
  93336. */
  93337. clipPlane: Nullable<Plane>;
  93338. /**
  93339. * Gets or sets the active clipplane 2
  93340. */
  93341. clipPlane2: Nullable<Plane>;
  93342. /**
  93343. * Gets or sets the active clipplane 3
  93344. */
  93345. clipPlane3: Nullable<Plane>;
  93346. /**
  93347. * Gets or sets the active clipplane 4
  93348. */
  93349. clipPlane4: Nullable<Plane>;
  93350. /**
  93351. * Gets or sets the active clipplane 5
  93352. */
  93353. clipPlane5: Nullable<Plane>;
  93354. /**
  93355. * Gets or sets the active clipplane 6
  93356. */
  93357. clipPlane6: Nullable<Plane>;
  93358. }
  93359. }
  93360. declare module BABYLON {
  93361. /**
  93362. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93363. *
  93364. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93365. *
  93366. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93367. */
  93368. export class ThinMaterialHelper {
  93369. /**
  93370. * Binds the clip plane information from the holder to the effect.
  93371. * @param effect The effect we are binding the data to
  93372. * @param holder The entity containing the clip plane information
  93373. */
  93374. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93375. }
  93376. }
  93377. declare module BABYLON {
  93378. interface ThinEngine {
  93379. /**
  93380. * Sets alpha constants used by some alpha blending modes
  93381. * @param r defines the red component
  93382. * @param g defines the green component
  93383. * @param b defines the blue component
  93384. * @param a defines the alpha component
  93385. */
  93386. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93387. /**
  93388. * Sets the current alpha mode
  93389. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93390. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93391. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93392. */
  93393. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93394. /**
  93395. * Gets the current alpha mode
  93396. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93397. * @returns the current alpha mode
  93398. */
  93399. getAlphaMode(): number;
  93400. /**
  93401. * Sets the current alpha equation
  93402. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93403. */
  93404. setAlphaEquation(equation: number): void;
  93405. /**
  93406. * Gets the current alpha equation.
  93407. * @returns the current alpha equation
  93408. */
  93409. getAlphaEquation(): number;
  93410. }
  93411. }
  93412. declare module BABYLON {
  93413. /**
  93414. * This represents a particle system in Babylon.
  93415. * 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.
  93416. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93417. * @example https://doc.babylonjs.com/babylon101/particles
  93418. */
  93419. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93420. /**
  93421. * Billboard mode will only apply to Y axis
  93422. */
  93423. static readonly BILLBOARDMODE_Y: number;
  93424. /**
  93425. * Billboard mode will apply to all axes
  93426. */
  93427. static readonly BILLBOARDMODE_ALL: number;
  93428. /**
  93429. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93430. */
  93431. static readonly BILLBOARDMODE_STRETCHED: number;
  93432. /**
  93433. * This function can be defined to provide custom update for active particles.
  93434. * This function will be called instead of regular update (age, position, color, etc.).
  93435. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93436. */
  93437. updateFunction: (particles: Particle[]) => void;
  93438. private _emitterWorldMatrix;
  93439. /**
  93440. * This function can be defined to specify initial direction for every new particle.
  93441. * It by default use the emitterType defined function
  93442. */
  93443. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93444. /**
  93445. * This function can be defined to specify initial position for every new particle.
  93446. * It by default use the emitterType defined function
  93447. */
  93448. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93449. /**
  93450. * @hidden
  93451. */
  93452. _inheritedVelocityOffset: Vector3;
  93453. /**
  93454. * An event triggered when the system is disposed
  93455. */
  93456. onDisposeObservable: Observable<IParticleSystem>;
  93457. /**
  93458. * An event triggered when the system is stopped
  93459. */
  93460. onStoppedObservable: Observable<IParticleSystem>;
  93461. private _onDisposeObserver;
  93462. /**
  93463. * Sets a callback that will be triggered when the system is disposed
  93464. */
  93465. set onDispose(callback: () => void);
  93466. private _particles;
  93467. private _epsilon;
  93468. private _capacity;
  93469. private _stockParticles;
  93470. private _newPartsExcess;
  93471. private _vertexData;
  93472. private _vertexBuffer;
  93473. private _vertexBuffers;
  93474. private _spriteBuffer;
  93475. private _indexBuffer;
  93476. private _effect;
  93477. private _customEffect;
  93478. private _cachedDefines;
  93479. private _scaledColorStep;
  93480. private _colorDiff;
  93481. private _scaledDirection;
  93482. private _scaledGravity;
  93483. private _currentRenderId;
  93484. private _alive;
  93485. private _useInstancing;
  93486. private _vertexArrayObject;
  93487. private _started;
  93488. private _stopped;
  93489. private _actualFrame;
  93490. private _scaledUpdateSpeed;
  93491. private _vertexBufferSize;
  93492. /** @hidden */
  93493. _currentEmitRateGradient: Nullable<FactorGradient>;
  93494. /** @hidden */
  93495. _currentEmitRate1: number;
  93496. /** @hidden */
  93497. _currentEmitRate2: number;
  93498. /** @hidden */
  93499. _currentStartSizeGradient: Nullable<FactorGradient>;
  93500. /** @hidden */
  93501. _currentStartSize1: number;
  93502. /** @hidden */
  93503. _currentStartSize2: number;
  93504. private readonly _rawTextureWidth;
  93505. private _rampGradientsTexture;
  93506. private _useRampGradients;
  93507. /** Gets or sets a matrix to use to compute projection */
  93508. defaultProjectionMatrix: Matrix;
  93509. /** Gets or sets a matrix to use to compute view */
  93510. defaultViewMatrix: Matrix;
  93511. /** Gets or sets a boolean indicating that ramp gradients must be used
  93512. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93513. */
  93514. get useRampGradients(): boolean;
  93515. set useRampGradients(value: boolean);
  93516. /**
  93517. * 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.
  93518. * 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: [])
  93519. */
  93520. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93521. private _subEmitters;
  93522. /**
  93523. * @hidden
  93524. * If the particle systems emitter should be disposed when the particle system is disposed
  93525. */
  93526. _disposeEmitterOnDispose: boolean;
  93527. /**
  93528. * The current active Sub-systems, this property is used by the root particle system only.
  93529. */
  93530. activeSubSystems: Array<ParticleSystem>;
  93531. /**
  93532. * Specifies if the particles are updated in emitter local space or world space
  93533. */
  93534. isLocal: boolean;
  93535. private _rootParticleSystem;
  93536. /**
  93537. * Gets the current list of active particles
  93538. */
  93539. get particles(): Particle[];
  93540. /**
  93541. * Gets the number of particles active at the same time.
  93542. * @returns The number of active particles.
  93543. */
  93544. getActiveCount(): number;
  93545. /**
  93546. * Returns the string "ParticleSystem"
  93547. * @returns a string containing the class name
  93548. */
  93549. getClassName(): string;
  93550. /**
  93551. * Gets a boolean indicating that the system is stopping
  93552. * @returns true if the system is currently stopping
  93553. */
  93554. isStopping(): boolean;
  93555. /**
  93556. * Gets the custom effect used to render the particles
  93557. * @param blendMode Blend mode for which the effect should be retrieved
  93558. * @returns The effect
  93559. */
  93560. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93561. /**
  93562. * Sets the custom effect used to render the particles
  93563. * @param effect The effect to set
  93564. * @param blendMode Blend mode for which the effect should be set
  93565. */
  93566. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93567. /** @hidden */
  93568. private _onBeforeDrawParticlesObservable;
  93569. /**
  93570. * Observable that will be called just before the particles are drawn
  93571. */
  93572. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93573. /**
  93574. * Gets the name of the particle vertex shader
  93575. */
  93576. get vertexShaderName(): string;
  93577. /**
  93578. * Instantiates a particle system.
  93579. * 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.
  93580. * @param name The name of the particle system
  93581. * @param capacity The max number of particles alive at the same time
  93582. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93583. * @param customEffect a custom effect used to change the way particles are rendered by default
  93584. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93585. * @param epsilon Offset used to render the particles
  93586. */
  93587. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93588. private _addFactorGradient;
  93589. private _removeFactorGradient;
  93590. /**
  93591. * Adds a new life time gradient
  93592. * @param gradient defines the gradient to use (between 0 and 1)
  93593. * @param factor defines the life time factor to affect to the specified gradient
  93594. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93595. * @returns the current particle system
  93596. */
  93597. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93598. /**
  93599. * Remove a specific life time gradient
  93600. * @param gradient defines the gradient to remove
  93601. * @returns the current particle system
  93602. */
  93603. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93604. /**
  93605. * Adds a new size gradient
  93606. * @param gradient defines the gradient to use (between 0 and 1)
  93607. * @param factor defines the size factor to affect to the specified gradient
  93608. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93609. * @returns the current particle system
  93610. */
  93611. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93612. /**
  93613. * Remove a specific size gradient
  93614. * @param gradient defines the gradient to remove
  93615. * @returns the current particle system
  93616. */
  93617. removeSizeGradient(gradient: number): IParticleSystem;
  93618. /**
  93619. * Adds a new color remap gradient
  93620. * @param gradient defines the gradient to use (between 0 and 1)
  93621. * @param min defines the color remap minimal range
  93622. * @param max defines the color remap maximal range
  93623. * @returns the current particle system
  93624. */
  93625. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93626. /**
  93627. * Remove a specific color remap gradient
  93628. * @param gradient defines the gradient to remove
  93629. * @returns the current particle system
  93630. */
  93631. removeColorRemapGradient(gradient: number): IParticleSystem;
  93632. /**
  93633. * Adds a new alpha remap gradient
  93634. * @param gradient defines the gradient to use (between 0 and 1)
  93635. * @param min defines the alpha remap minimal range
  93636. * @param max defines the alpha remap maximal range
  93637. * @returns the current particle system
  93638. */
  93639. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93640. /**
  93641. * Remove a specific alpha remap gradient
  93642. * @param gradient defines the gradient to remove
  93643. * @returns the current particle system
  93644. */
  93645. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93646. /**
  93647. * Adds a new angular speed gradient
  93648. * @param gradient defines the gradient to use (between 0 and 1)
  93649. * @param factor defines the angular speed to affect to the specified gradient
  93650. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93651. * @returns the current particle system
  93652. */
  93653. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93654. /**
  93655. * Remove a specific angular speed gradient
  93656. * @param gradient defines the gradient to remove
  93657. * @returns the current particle system
  93658. */
  93659. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93660. /**
  93661. * Adds a new velocity gradient
  93662. * @param gradient defines the gradient to use (between 0 and 1)
  93663. * @param factor defines the velocity to affect to the specified gradient
  93664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93665. * @returns the current particle system
  93666. */
  93667. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93668. /**
  93669. * Remove a specific velocity gradient
  93670. * @param gradient defines the gradient to remove
  93671. * @returns the current particle system
  93672. */
  93673. removeVelocityGradient(gradient: number): IParticleSystem;
  93674. /**
  93675. * Adds a new limit velocity gradient
  93676. * @param gradient defines the gradient to use (between 0 and 1)
  93677. * @param factor defines the limit velocity value to affect to the specified gradient
  93678. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93679. * @returns the current particle system
  93680. */
  93681. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93682. /**
  93683. * Remove a specific limit velocity gradient
  93684. * @param gradient defines the gradient to remove
  93685. * @returns the current particle system
  93686. */
  93687. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93688. /**
  93689. * Adds a new drag gradient
  93690. * @param gradient defines the gradient to use (between 0 and 1)
  93691. * @param factor defines the drag value to affect to the specified gradient
  93692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93693. * @returns the current particle system
  93694. */
  93695. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93696. /**
  93697. * Remove a specific drag gradient
  93698. * @param gradient defines the gradient to remove
  93699. * @returns the current particle system
  93700. */
  93701. removeDragGradient(gradient: number): IParticleSystem;
  93702. /**
  93703. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93704. * @param gradient defines the gradient to use (between 0 and 1)
  93705. * @param factor defines the emit rate value to affect to the specified gradient
  93706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93707. * @returns the current particle system
  93708. */
  93709. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93710. /**
  93711. * Remove a specific emit rate gradient
  93712. * @param gradient defines the gradient to remove
  93713. * @returns the current particle system
  93714. */
  93715. removeEmitRateGradient(gradient: number): IParticleSystem;
  93716. /**
  93717. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93718. * @param gradient defines the gradient to use (between 0 and 1)
  93719. * @param factor defines the start size value to affect to the specified gradient
  93720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93721. * @returns the current particle system
  93722. */
  93723. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93724. /**
  93725. * Remove a specific start size gradient
  93726. * @param gradient defines the gradient to remove
  93727. * @returns the current particle system
  93728. */
  93729. removeStartSizeGradient(gradient: number): IParticleSystem;
  93730. private _createRampGradientTexture;
  93731. /**
  93732. * Gets the current list of ramp gradients.
  93733. * You must use addRampGradient and removeRampGradient to udpate this list
  93734. * @returns the list of ramp gradients
  93735. */
  93736. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93737. /** Force the system to rebuild all gradients that need to be resync */
  93738. forceRefreshGradients(): void;
  93739. private _syncRampGradientTexture;
  93740. /**
  93741. * Adds a new ramp gradient used to remap particle colors
  93742. * @param gradient defines the gradient to use (between 0 and 1)
  93743. * @param color defines the color to affect to the specified gradient
  93744. * @returns the current particle system
  93745. */
  93746. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93747. /**
  93748. * Remove a specific ramp gradient
  93749. * @param gradient defines the gradient to remove
  93750. * @returns the current particle system
  93751. */
  93752. removeRampGradient(gradient: number): ParticleSystem;
  93753. /**
  93754. * Adds a new color gradient
  93755. * @param gradient defines the gradient to use (between 0 and 1)
  93756. * @param color1 defines the color to affect to the specified gradient
  93757. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93758. * @returns this particle system
  93759. */
  93760. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93761. /**
  93762. * Remove a specific color gradient
  93763. * @param gradient defines the gradient to remove
  93764. * @returns this particle system
  93765. */
  93766. removeColorGradient(gradient: number): IParticleSystem;
  93767. private _fetchR;
  93768. protected _reset(): void;
  93769. private _resetEffect;
  93770. private _createVertexBuffers;
  93771. private _createIndexBuffer;
  93772. /**
  93773. * Gets the maximum number of particles active at the same time.
  93774. * @returns The max number of active particles.
  93775. */
  93776. getCapacity(): number;
  93777. /**
  93778. * Gets whether there are still active particles in the system.
  93779. * @returns True if it is alive, otherwise false.
  93780. */
  93781. isAlive(): boolean;
  93782. /**
  93783. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93784. * @returns True if it has been started, otherwise false.
  93785. */
  93786. isStarted(): boolean;
  93787. private _prepareSubEmitterInternalArray;
  93788. /**
  93789. * Starts the particle system and begins to emit
  93790. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93791. */
  93792. start(delay?: number): void;
  93793. /**
  93794. * Stops the particle system.
  93795. * @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.
  93796. */
  93797. stop(stopSubEmitters?: boolean): void;
  93798. /**
  93799. * Remove all active particles
  93800. */
  93801. reset(): void;
  93802. /**
  93803. * @hidden (for internal use only)
  93804. */
  93805. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93806. /**
  93807. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93808. * Its lifetime will start back at 0.
  93809. */
  93810. recycleParticle: (particle: Particle) => void;
  93811. private _stopSubEmitters;
  93812. private _createParticle;
  93813. private _removeFromRoot;
  93814. private _emitFromParticle;
  93815. private _update;
  93816. /** @hidden */
  93817. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93818. /** @hidden */
  93819. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93820. /**
  93821. * Fill the defines array according to the current settings of the particle system
  93822. * @param defines Array to be updated
  93823. * @param blendMode blend mode to take into account when updating the array
  93824. */
  93825. fillDefines(defines: Array<string>, blendMode: number): void;
  93826. /**
  93827. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93828. * @param uniforms Uniforms array to fill
  93829. * @param attributes Attributes array to fill
  93830. * @param samplers Samplers array to fill
  93831. */
  93832. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93833. /** @hidden */
  93834. private _getEffect;
  93835. /**
  93836. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93837. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93838. */
  93839. animate(preWarmOnly?: boolean): void;
  93840. private _appendParticleVertices;
  93841. /**
  93842. * Rebuilds the particle system.
  93843. */
  93844. rebuild(): void;
  93845. /**
  93846. * Is this system ready to be used/rendered
  93847. * @return true if the system is ready
  93848. */
  93849. isReady(): boolean;
  93850. private _render;
  93851. /**
  93852. * Renders the particle system in its current state.
  93853. * @returns the current number of particles
  93854. */
  93855. render(): number;
  93856. /**
  93857. * Disposes the particle system and free the associated resources
  93858. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93859. */
  93860. dispose(disposeTexture?: boolean): void;
  93861. /**
  93862. * Clones the particle system.
  93863. * @param name The name of the cloned object
  93864. * @param newEmitter The new emitter to use
  93865. * @returns the cloned particle system
  93866. */
  93867. clone(name: string, newEmitter: any): ParticleSystem;
  93868. /**
  93869. * Serializes the particle system to a JSON object
  93870. * @param serializeTexture defines if the texture must be serialized as well
  93871. * @returns the JSON object
  93872. */
  93873. serialize(serializeTexture?: boolean): any;
  93874. /** @hidden */
  93875. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93876. /** @hidden */
  93877. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93878. /**
  93879. * Parses a JSON object to create a particle system.
  93880. * @param parsedParticleSystem The JSON object to parse
  93881. * @param sceneOrEngine The scene or the engine to create the particle system in
  93882. * @param rootUrl The root url to use to load external dependencies like texture
  93883. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93884. * @returns the Parsed particle system
  93885. */
  93886. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93887. }
  93888. }
  93889. declare module BABYLON {
  93890. /**
  93891. * A particle represents one of the element emitted by a particle system.
  93892. * This is mainly define by its coordinates, direction, velocity and age.
  93893. */
  93894. export class Particle {
  93895. /**
  93896. * The particle system the particle belongs to.
  93897. */
  93898. particleSystem: ParticleSystem;
  93899. private static _Count;
  93900. /**
  93901. * Unique ID of the particle
  93902. */
  93903. id: number;
  93904. /**
  93905. * The world position of the particle in the scene.
  93906. */
  93907. position: Vector3;
  93908. /**
  93909. * The world direction of the particle in the scene.
  93910. */
  93911. direction: Vector3;
  93912. /**
  93913. * The color of the particle.
  93914. */
  93915. color: Color4;
  93916. /**
  93917. * The color change of the particle per step.
  93918. */
  93919. colorStep: Color4;
  93920. /**
  93921. * Defines how long will the life of the particle be.
  93922. */
  93923. lifeTime: number;
  93924. /**
  93925. * The current age of the particle.
  93926. */
  93927. age: number;
  93928. /**
  93929. * The current size of the particle.
  93930. */
  93931. size: number;
  93932. /**
  93933. * The current scale of the particle.
  93934. */
  93935. scale: Vector2;
  93936. /**
  93937. * The current angle of the particle.
  93938. */
  93939. angle: number;
  93940. /**
  93941. * Defines how fast is the angle changing.
  93942. */
  93943. angularSpeed: number;
  93944. /**
  93945. * Defines the cell index used by the particle to be rendered from a sprite.
  93946. */
  93947. cellIndex: number;
  93948. /**
  93949. * The information required to support color remapping
  93950. */
  93951. remapData: Vector4;
  93952. /** @hidden */
  93953. _randomCellOffset?: number;
  93954. /** @hidden */
  93955. _initialDirection: Nullable<Vector3>;
  93956. /** @hidden */
  93957. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93958. /** @hidden */
  93959. _initialStartSpriteCellID: number;
  93960. /** @hidden */
  93961. _initialEndSpriteCellID: number;
  93962. /** @hidden */
  93963. _currentColorGradient: Nullable<ColorGradient>;
  93964. /** @hidden */
  93965. _currentColor1: Color4;
  93966. /** @hidden */
  93967. _currentColor2: Color4;
  93968. /** @hidden */
  93969. _currentSizeGradient: Nullable<FactorGradient>;
  93970. /** @hidden */
  93971. _currentSize1: number;
  93972. /** @hidden */
  93973. _currentSize2: number;
  93974. /** @hidden */
  93975. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93976. /** @hidden */
  93977. _currentAngularSpeed1: number;
  93978. /** @hidden */
  93979. _currentAngularSpeed2: number;
  93980. /** @hidden */
  93981. _currentVelocityGradient: Nullable<FactorGradient>;
  93982. /** @hidden */
  93983. _currentVelocity1: number;
  93984. /** @hidden */
  93985. _currentVelocity2: number;
  93986. /** @hidden */
  93987. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93988. /** @hidden */
  93989. _currentLimitVelocity1: number;
  93990. /** @hidden */
  93991. _currentLimitVelocity2: number;
  93992. /** @hidden */
  93993. _currentDragGradient: Nullable<FactorGradient>;
  93994. /** @hidden */
  93995. _currentDrag1: number;
  93996. /** @hidden */
  93997. _currentDrag2: number;
  93998. /** @hidden */
  93999. _randomNoiseCoordinates1: Vector3;
  94000. /** @hidden */
  94001. _randomNoiseCoordinates2: Vector3;
  94002. /** @hidden */
  94003. _localPosition?: Vector3;
  94004. /**
  94005. * Creates a new instance Particle
  94006. * @param particleSystem the particle system the particle belongs to
  94007. */
  94008. constructor(
  94009. /**
  94010. * The particle system the particle belongs to.
  94011. */
  94012. particleSystem: ParticleSystem);
  94013. private updateCellInfoFromSystem;
  94014. /**
  94015. * Defines how the sprite cell index is updated for the particle
  94016. */
  94017. updateCellIndex(): void;
  94018. /** @hidden */
  94019. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  94020. /** @hidden */
  94021. _inheritParticleInfoToSubEmitters(): void;
  94022. /** @hidden */
  94023. _reset(): void;
  94024. /**
  94025. * Copy the properties of particle to another one.
  94026. * @param other the particle to copy the information to.
  94027. */
  94028. copyTo(other: Particle): void;
  94029. }
  94030. }
  94031. declare module BABYLON {
  94032. /**
  94033. * Particle emitter represents a volume emitting particles.
  94034. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  94035. */
  94036. export interface IParticleEmitterType {
  94037. /**
  94038. * Called by the particle System when the direction is computed for the created particle.
  94039. * @param worldMatrix is the world matrix of the particle system
  94040. * @param directionToUpdate is the direction vector to update with the result
  94041. * @param particle is the particle we are computed the direction for
  94042. * @param isLocal defines if the direction should be set in local space
  94043. */
  94044. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94045. /**
  94046. * Called by the particle System when the position is computed for the created particle.
  94047. * @param worldMatrix is the world matrix of the particle system
  94048. * @param positionToUpdate is the position vector to update with the result
  94049. * @param particle is the particle we are computed the position for
  94050. * @param isLocal defines if the position should be set in local space
  94051. */
  94052. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94053. /**
  94054. * Clones the current emitter and returns a copy of it
  94055. * @returns the new emitter
  94056. */
  94057. clone(): IParticleEmitterType;
  94058. /**
  94059. * Called by the GPUParticleSystem to setup the update shader
  94060. * @param effect defines the update shader
  94061. */
  94062. applyToShader(effect: Effect): void;
  94063. /**
  94064. * Returns a string to use to update the GPU particles update shader
  94065. * @returns the effect defines string
  94066. */
  94067. getEffectDefines(): string;
  94068. /**
  94069. * Returns a string representing the class name
  94070. * @returns a string containing the class name
  94071. */
  94072. getClassName(): string;
  94073. /**
  94074. * Serializes the particle system to a JSON object.
  94075. * @returns the JSON object
  94076. */
  94077. serialize(): any;
  94078. /**
  94079. * Parse properties from a JSON object
  94080. * @param serializationObject defines the JSON object
  94081. * @param scene defines the hosting scene
  94082. */
  94083. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94084. }
  94085. }
  94086. declare module BABYLON {
  94087. /**
  94088. * Particle emitter emitting particles from the inside of a box.
  94089. * It emits the particles randomly between 2 given directions.
  94090. */
  94091. export class BoxParticleEmitter implements IParticleEmitterType {
  94092. /**
  94093. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94094. */
  94095. direction1: Vector3;
  94096. /**
  94097. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94098. */
  94099. direction2: Vector3;
  94100. /**
  94101. * 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.
  94102. */
  94103. minEmitBox: Vector3;
  94104. /**
  94105. * 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.
  94106. */
  94107. maxEmitBox: Vector3;
  94108. /**
  94109. * Creates a new instance BoxParticleEmitter
  94110. */
  94111. constructor();
  94112. /**
  94113. * Called by the particle System when the direction is computed for the created particle.
  94114. * @param worldMatrix is the world matrix of the particle system
  94115. * @param directionToUpdate is the direction vector to update with the result
  94116. * @param particle is the particle we are computed the direction for
  94117. * @param isLocal defines if the direction should be set in local space
  94118. */
  94119. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94120. /**
  94121. * Called by the particle System when the position is computed for the created particle.
  94122. * @param worldMatrix is the world matrix of the particle system
  94123. * @param positionToUpdate is the position vector to update with the result
  94124. * @param particle is the particle we are computed the position for
  94125. * @param isLocal defines if the position should be set in local space
  94126. */
  94127. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94128. /**
  94129. * Clones the current emitter and returns a copy of it
  94130. * @returns the new emitter
  94131. */
  94132. clone(): BoxParticleEmitter;
  94133. /**
  94134. * Called by the GPUParticleSystem to setup the update shader
  94135. * @param effect defines the update shader
  94136. */
  94137. applyToShader(effect: Effect): void;
  94138. /**
  94139. * Returns a string to use to update the GPU particles update shader
  94140. * @returns a string containng the defines string
  94141. */
  94142. getEffectDefines(): string;
  94143. /**
  94144. * Returns the string "BoxParticleEmitter"
  94145. * @returns a string containing the class name
  94146. */
  94147. getClassName(): string;
  94148. /**
  94149. * Serializes the particle system to a JSON object.
  94150. * @returns the JSON object
  94151. */
  94152. serialize(): any;
  94153. /**
  94154. * Parse properties from a JSON object
  94155. * @param serializationObject defines the JSON object
  94156. */
  94157. parse(serializationObject: any): void;
  94158. }
  94159. }
  94160. declare module BABYLON {
  94161. /**
  94162. * Particle emitter emitting particles from the inside of a cone.
  94163. * It emits the particles alongside the cone volume from the base to the particle.
  94164. * The emission direction might be randomized.
  94165. */
  94166. export class ConeParticleEmitter implements IParticleEmitterType {
  94167. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94168. directionRandomizer: number;
  94169. private _radius;
  94170. private _angle;
  94171. private _height;
  94172. /**
  94173. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  94174. */
  94175. radiusRange: number;
  94176. /**
  94177. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  94178. */
  94179. heightRange: number;
  94180. /**
  94181. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  94182. */
  94183. emitFromSpawnPointOnly: boolean;
  94184. /**
  94185. * Gets or sets the radius of the emission cone
  94186. */
  94187. get radius(): number;
  94188. set radius(value: number);
  94189. /**
  94190. * Gets or sets the angle of the emission cone
  94191. */
  94192. get angle(): number;
  94193. set angle(value: number);
  94194. private _buildHeight;
  94195. /**
  94196. * Creates a new instance ConeParticleEmitter
  94197. * @param radius the radius of the emission cone (1 by default)
  94198. * @param angle the cone base angle (PI by default)
  94199. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94200. */
  94201. constructor(radius?: number, angle?: number,
  94202. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94203. directionRandomizer?: number);
  94204. /**
  94205. * Called by the particle System when the direction is computed for the created particle.
  94206. * @param worldMatrix is the world matrix of the particle system
  94207. * @param directionToUpdate is the direction vector to update with the result
  94208. * @param particle is the particle we are computed the direction for
  94209. * @param isLocal defines if the direction should be set in local space
  94210. */
  94211. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94212. /**
  94213. * Called by the particle System when the position is computed for the created particle.
  94214. * @param worldMatrix is the world matrix of the particle system
  94215. * @param positionToUpdate is the position vector to update with the result
  94216. * @param particle is the particle we are computed the position for
  94217. * @param isLocal defines if the position should be set in local space
  94218. */
  94219. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94220. /**
  94221. * Clones the current emitter and returns a copy of it
  94222. * @returns the new emitter
  94223. */
  94224. clone(): ConeParticleEmitter;
  94225. /**
  94226. * Called by the GPUParticleSystem to setup the update shader
  94227. * @param effect defines the update shader
  94228. */
  94229. applyToShader(effect: Effect): void;
  94230. /**
  94231. * Returns a string to use to update the GPU particles update shader
  94232. * @returns a string containng the defines string
  94233. */
  94234. getEffectDefines(): string;
  94235. /**
  94236. * Returns the string "ConeParticleEmitter"
  94237. * @returns a string containing the class name
  94238. */
  94239. getClassName(): string;
  94240. /**
  94241. * Serializes the particle system to a JSON object.
  94242. * @returns the JSON object
  94243. */
  94244. serialize(): any;
  94245. /**
  94246. * Parse properties from a JSON object
  94247. * @param serializationObject defines the JSON object
  94248. */
  94249. parse(serializationObject: any): void;
  94250. }
  94251. }
  94252. declare module BABYLON {
  94253. /**
  94254. * Particle emitter emitting particles from the inside of a cylinder.
  94255. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94256. */
  94257. export class CylinderParticleEmitter implements IParticleEmitterType {
  94258. /**
  94259. * The radius of the emission cylinder.
  94260. */
  94261. radius: number;
  94262. /**
  94263. * The height of the emission cylinder.
  94264. */
  94265. height: number;
  94266. /**
  94267. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94268. */
  94269. radiusRange: number;
  94270. /**
  94271. * How much to randomize the particle direction [0-1].
  94272. */
  94273. directionRandomizer: number;
  94274. /**
  94275. * Creates a new instance CylinderParticleEmitter
  94276. * @param radius the radius of the emission cylinder (1 by default)
  94277. * @param height the height of the emission cylinder (1 by default)
  94278. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94279. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94280. */
  94281. constructor(
  94282. /**
  94283. * The radius of the emission cylinder.
  94284. */
  94285. radius?: number,
  94286. /**
  94287. * The height of the emission cylinder.
  94288. */
  94289. height?: number,
  94290. /**
  94291. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94292. */
  94293. radiusRange?: number,
  94294. /**
  94295. * How much to randomize the particle direction [0-1].
  94296. */
  94297. directionRandomizer?: number);
  94298. /**
  94299. * Called by the particle System when the direction is computed for the created particle.
  94300. * @param worldMatrix is the world matrix of the particle system
  94301. * @param directionToUpdate is the direction vector to update with the result
  94302. * @param particle is the particle we are computed the direction for
  94303. * @param isLocal defines if the direction should be set in local space
  94304. */
  94305. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94306. /**
  94307. * Called by the particle System when the position is computed for the created particle.
  94308. * @param worldMatrix is the world matrix of the particle system
  94309. * @param positionToUpdate is the position vector to update with the result
  94310. * @param particle is the particle we are computed the position for
  94311. * @param isLocal defines if the position should be set in local space
  94312. */
  94313. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94314. /**
  94315. * Clones the current emitter and returns a copy of it
  94316. * @returns the new emitter
  94317. */
  94318. clone(): CylinderParticleEmitter;
  94319. /**
  94320. * Called by the GPUParticleSystem to setup the update shader
  94321. * @param effect defines the update shader
  94322. */
  94323. applyToShader(effect: Effect): void;
  94324. /**
  94325. * Returns a string to use to update the GPU particles update shader
  94326. * @returns a string containng the defines string
  94327. */
  94328. getEffectDefines(): string;
  94329. /**
  94330. * Returns the string "CylinderParticleEmitter"
  94331. * @returns a string containing the class name
  94332. */
  94333. getClassName(): string;
  94334. /**
  94335. * Serializes the particle system to a JSON object.
  94336. * @returns the JSON object
  94337. */
  94338. serialize(): any;
  94339. /**
  94340. * Parse properties from a JSON object
  94341. * @param serializationObject defines the JSON object
  94342. */
  94343. parse(serializationObject: any): void;
  94344. }
  94345. /**
  94346. * Particle emitter emitting particles from the inside of a cylinder.
  94347. * It emits the particles randomly between two vectors.
  94348. */
  94349. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94350. /**
  94351. * The min limit of the emission direction.
  94352. */
  94353. direction1: Vector3;
  94354. /**
  94355. * The max limit of the emission direction.
  94356. */
  94357. direction2: Vector3;
  94358. /**
  94359. * Creates a new instance CylinderDirectedParticleEmitter
  94360. * @param radius the radius of the emission cylinder (1 by default)
  94361. * @param height the height of the emission cylinder (1 by default)
  94362. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94363. * @param direction1 the min limit of the emission direction (up vector by default)
  94364. * @param direction2 the max limit of the emission direction (up vector by default)
  94365. */
  94366. constructor(radius?: number, height?: number, radiusRange?: number,
  94367. /**
  94368. * The min limit of the emission direction.
  94369. */
  94370. direction1?: Vector3,
  94371. /**
  94372. * The max limit of the emission direction.
  94373. */
  94374. direction2?: Vector3);
  94375. /**
  94376. * Called by the particle System when the direction is computed for the created particle.
  94377. * @param worldMatrix is the world matrix of the particle system
  94378. * @param directionToUpdate is the direction vector to update with the result
  94379. * @param particle is the particle we are computed the direction for
  94380. */
  94381. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94382. /**
  94383. * Clones the current emitter and returns a copy of it
  94384. * @returns the new emitter
  94385. */
  94386. clone(): CylinderDirectedParticleEmitter;
  94387. /**
  94388. * Called by the GPUParticleSystem to setup the update shader
  94389. * @param effect defines the update shader
  94390. */
  94391. applyToShader(effect: Effect): void;
  94392. /**
  94393. * Returns a string to use to update the GPU particles update shader
  94394. * @returns a string containng the defines string
  94395. */
  94396. getEffectDefines(): string;
  94397. /**
  94398. * Returns the string "CylinderDirectedParticleEmitter"
  94399. * @returns a string containing the class name
  94400. */
  94401. getClassName(): string;
  94402. /**
  94403. * Serializes the particle system to a JSON object.
  94404. * @returns the JSON object
  94405. */
  94406. serialize(): any;
  94407. /**
  94408. * Parse properties from a JSON object
  94409. * @param serializationObject defines the JSON object
  94410. */
  94411. parse(serializationObject: any): void;
  94412. }
  94413. }
  94414. declare module BABYLON {
  94415. /**
  94416. * Particle emitter emitting particles from the inside of a hemisphere.
  94417. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94418. */
  94419. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94420. /**
  94421. * The radius of the emission hemisphere.
  94422. */
  94423. radius: number;
  94424. /**
  94425. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94426. */
  94427. radiusRange: number;
  94428. /**
  94429. * How much to randomize the particle direction [0-1].
  94430. */
  94431. directionRandomizer: number;
  94432. /**
  94433. * Creates a new instance HemisphericParticleEmitter
  94434. * @param radius the radius of the emission hemisphere (1 by default)
  94435. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94436. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94437. */
  94438. constructor(
  94439. /**
  94440. * The radius of the emission hemisphere.
  94441. */
  94442. radius?: number,
  94443. /**
  94444. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94445. */
  94446. radiusRange?: number,
  94447. /**
  94448. * How much to randomize the particle direction [0-1].
  94449. */
  94450. directionRandomizer?: number);
  94451. /**
  94452. * Called by the particle System when the direction is computed for the created particle.
  94453. * @param worldMatrix is the world matrix of the particle system
  94454. * @param directionToUpdate is the direction vector to update with the result
  94455. * @param particle is the particle we are computed the direction for
  94456. * @param isLocal defines if the direction should be set in local space
  94457. */
  94458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94459. /**
  94460. * Called by the particle System when the position is computed for the created particle.
  94461. * @param worldMatrix is the world matrix of the particle system
  94462. * @param positionToUpdate is the position vector to update with the result
  94463. * @param particle is the particle we are computed the position for
  94464. * @param isLocal defines if the position should be set in local space
  94465. */
  94466. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94467. /**
  94468. * Clones the current emitter and returns a copy of it
  94469. * @returns the new emitter
  94470. */
  94471. clone(): HemisphericParticleEmitter;
  94472. /**
  94473. * Called by the GPUParticleSystem to setup the update shader
  94474. * @param effect defines the update shader
  94475. */
  94476. applyToShader(effect: Effect): void;
  94477. /**
  94478. * Returns a string to use to update the GPU particles update shader
  94479. * @returns a string containng the defines string
  94480. */
  94481. getEffectDefines(): string;
  94482. /**
  94483. * Returns the string "HemisphericParticleEmitter"
  94484. * @returns a string containing the class name
  94485. */
  94486. getClassName(): string;
  94487. /**
  94488. * Serializes the particle system to a JSON object.
  94489. * @returns the JSON object
  94490. */
  94491. serialize(): any;
  94492. /**
  94493. * Parse properties from a JSON object
  94494. * @param serializationObject defines the JSON object
  94495. */
  94496. parse(serializationObject: any): void;
  94497. }
  94498. }
  94499. declare module BABYLON {
  94500. /**
  94501. * Particle emitter emitting particles from a point.
  94502. * It emits the particles randomly between 2 given directions.
  94503. */
  94504. export class PointParticleEmitter implements IParticleEmitterType {
  94505. /**
  94506. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94507. */
  94508. direction1: Vector3;
  94509. /**
  94510. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94511. */
  94512. direction2: Vector3;
  94513. /**
  94514. * Creates a new instance PointParticleEmitter
  94515. */
  94516. constructor();
  94517. /**
  94518. * Called by the particle System when the direction is computed for the created particle.
  94519. * @param worldMatrix is the world matrix of the particle system
  94520. * @param directionToUpdate is the direction vector to update with the result
  94521. * @param particle is the particle we are computed the direction for
  94522. * @param isLocal defines if the direction should be set in local space
  94523. */
  94524. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94525. /**
  94526. * Called by the particle System when the position is computed for the created particle.
  94527. * @param worldMatrix is the world matrix of the particle system
  94528. * @param positionToUpdate is the position vector to update with the result
  94529. * @param particle is the particle we are computed the position for
  94530. * @param isLocal defines if the position should be set in local space
  94531. */
  94532. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94533. /**
  94534. * Clones the current emitter and returns a copy of it
  94535. * @returns the new emitter
  94536. */
  94537. clone(): PointParticleEmitter;
  94538. /**
  94539. * Called by the GPUParticleSystem to setup the update shader
  94540. * @param effect defines the update shader
  94541. */
  94542. applyToShader(effect: Effect): void;
  94543. /**
  94544. * Returns a string to use to update the GPU particles update shader
  94545. * @returns a string containng the defines string
  94546. */
  94547. getEffectDefines(): string;
  94548. /**
  94549. * Returns the string "PointParticleEmitter"
  94550. * @returns a string containing the class name
  94551. */
  94552. getClassName(): string;
  94553. /**
  94554. * Serializes the particle system to a JSON object.
  94555. * @returns the JSON object
  94556. */
  94557. serialize(): any;
  94558. /**
  94559. * Parse properties from a JSON object
  94560. * @param serializationObject defines the JSON object
  94561. */
  94562. parse(serializationObject: any): void;
  94563. }
  94564. }
  94565. declare module BABYLON {
  94566. /**
  94567. * Particle emitter emitting particles from the inside of a sphere.
  94568. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94569. */
  94570. export class SphereParticleEmitter implements IParticleEmitterType {
  94571. /**
  94572. * The radius of the emission sphere.
  94573. */
  94574. radius: number;
  94575. /**
  94576. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94577. */
  94578. radiusRange: number;
  94579. /**
  94580. * How much to randomize the particle direction [0-1].
  94581. */
  94582. directionRandomizer: number;
  94583. /**
  94584. * Creates a new instance SphereParticleEmitter
  94585. * @param radius the radius of the emission sphere (1 by default)
  94586. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94587. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94588. */
  94589. constructor(
  94590. /**
  94591. * The radius of the emission sphere.
  94592. */
  94593. radius?: number,
  94594. /**
  94595. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94596. */
  94597. radiusRange?: number,
  94598. /**
  94599. * How much to randomize the particle direction [0-1].
  94600. */
  94601. directionRandomizer?: number);
  94602. /**
  94603. * Called by the particle System when the direction is computed for the created particle.
  94604. * @param worldMatrix is the world matrix of the particle system
  94605. * @param directionToUpdate is the direction vector to update with the result
  94606. * @param particle is the particle we are computed the direction for
  94607. * @param isLocal defines if the direction should be set in local space
  94608. */
  94609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94610. /**
  94611. * Called by the particle System when the position is computed for the created particle.
  94612. * @param worldMatrix is the world matrix of the particle system
  94613. * @param positionToUpdate is the position vector to update with the result
  94614. * @param particle is the particle we are computed the position for
  94615. * @param isLocal defines if the position should be set in local space
  94616. */
  94617. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94618. /**
  94619. * Clones the current emitter and returns a copy of it
  94620. * @returns the new emitter
  94621. */
  94622. clone(): SphereParticleEmitter;
  94623. /**
  94624. * Called by the GPUParticleSystem to setup the update shader
  94625. * @param effect defines the update shader
  94626. */
  94627. applyToShader(effect: Effect): void;
  94628. /**
  94629. * Returns a string to use to update the GPU particles update shader
  94630. * @returns a string containng the defines string
  94631. */
  94632. getEffectDefines(): string;
  94633. /**
  94634. * Returns the string "SphereParticleEmitter"
  94635. * @returns a string containing the class name
  94636. */
  94637. getClassName(): string;
  94638. /**
  94639. * Serializes the particle system to a JSON object.
  94640. * @returns the JSON object
  94641. */
  94642. serialize(): any;
  94643. /**
  94644. * Parse properties from a JSON object
  94645. * @param serializationObject defines the JSON object
  94646. */
  94647. parse(serializationObject: any): void;
  94648. }
  94649. /**
  94650. * Particle emitter emitting particles from the inside of a sphere.
  94651. * It emits the particles randomly between two vectors.
  94652. */
  94653. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94654. /**
  94655. * The min limit of the emission direction.
  94656. */
  94657. direction1: Vector3;
  94658. /**
  94659. * The max limit of the emission direction.
  94660. */
  94661. direction2: Vector3;
  94662. /**
  94663. * Creates a new instance SphereDirectedParticleEmitter
  94664. * @param radius the radius of the emission sphere (1 by default)
  94665. * @param direction1 the min limit of the emission direction (up vector by default)
  94666. * @param direction2 the max limit of the emission direction (up vector by default)
  94667. */
  94668. constructor(radius?: number,
  94669. /**
  94670. * The min limit of the emission direction.
  94671. */
  94672. direction1?: Vector3,
  94673. /**
  94674. * The max limit of the emission direction.
  94675. */
  94676. direction2?: Vector3);
  94677. /**
  94678. * Called by the particle System when the direction is computed for the created particle.
  94679. * @param worldMatrix is the world matrix of the particle system
  94680. * @param directionToUpdate is the direction vector to update with the result
  94681. * @param particle is the particle we are computed the direction for
  94682. */
  94683. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94684. /**
  94685. * Clones the current emitter and returns a copy of it
  94686. * @returns the new emitter
  94687. */
  94688. clone(): SphereDirectedParticleEmitter;
  94689. /**
  94690. * Called by the GPUParticleSystem to setup the update shader
  94691. * @param effect defines the update shader
  94692. */
  94693. applyToShader(effect: Effect): void;
  94694. /**
  94695. * Returns a string to use to update the GPU particles update shader
  94696. * @returns a string containng the defines string
  94697. */
  94698. getEffectDefines(): string;
  94699. /**
  94700. * Returns the string "SphereDirectedParticleEmitter"
  94701. * @returns a string containing the class name
  94702. */
  94703. getClassName(): string;
  94704. /**
  94705. * Serializes the particle system to a JSON object.
  94706. * @returns the JSON object
  94707. */
  94708. serialize(): any;
  94709. /**
  94710. * Parse properties from a JSON object
  94711. * @param serializationObject defines the JSON object
  94712. */
  94713. parse(serializationObject: any): void;
  94714. }
  94715. }
  94716. declare module BABYLON {
  94717. /**
  94718. * Particle emitter emitting particles from a custom list of positions.
  94719. */
  94720. export class CustomParticleEmitter implements IParticleEmitterType {
  94721. /**
  94722. * Gets or sets the position generator that will create the inital position of each particle.
  94723. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94724. */
  94725. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94726. /**
  94727. * Gets or sets the destination generator that will create the final destination of each particle.
  94728. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94729. */
  94730. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94731. /**
  94732. * Creates a new instance CustomParticleEmitter
  94733. */
  94734. constructor();
  94735. /**
  94736. * Called by the particle System when the direction is computed for the created particle.
  94737. * @param worldMatrix is the world matrix of the particle system
  94738. * @param directionToUpdate is the direction vector to update with the result
  94739. * @param particle is the particle we are computed the direction for
  94740. * @param isLocal defines if the direction should be set in local space
  94741. */
  94742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94743. /**
  94744. * Called by the particle System when the position is computed for the created particle.
  94745. * @param worldMatrix is the world matrix of the particle system
  94746. * @param positionToUpdate is the position vector to update with the result
  94747. * @param particle is the particle we are computed the position for
  94748. * @param isLocal defines if the position should be set in local space
  94749. */
  94750. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94751. /**
  94752. * Clones the current emitter and returns a copy of it
  94753. * @returns the new emitter
  94754. */
  94755. clone(): CustomParticleEmitter;
  94756. /**
  94757. * Called by the GPUParticleSystem to setup the update shader
  94758. * @param effect defines the update shader
  94759. */
  94760. applyToShader(effect: Effect): void;
  94761. /**
  94762. * Returns a string to use to update the GPU particles update shader
  94763. * @returns a string containng the defines string
  94764. */
  94765. getEffectDefines(): string;
  94766. /**
  94767. * Returns the string "PointParticleEmitter"
  94768. * @returns a string containing the class name
  94769. */
  94770. getClassName(): string;
  94771. /**
  94772. * Serializes the particle system to a JSON object.
  94773. * @returns the JSON object
  94774. */
  94775. serialize(): any;
  94776. /**
  94777. * Parse properties from a JSON object
  94778. * @param serializationObject defines the JSON object
  94779. */
  94780. parse(serializationObject: any): void;
  94781. }
  94782. }
  94783. declare module BABYLON {
  94784. /**
  94785. * Particle emitter emitting particles from the inside of a box.
  94786. * It emits the particles randomly between 2 given directions.
  94787. */
  94788. export class MeshParticleEmitter implements IParticleEmitterType {
  94789. private _indices;
  94790. private _positions;
  94791. private _normals;
  94792. private _storedNormal;
  94793. private _mesh;
  94794. /**
  94795. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94796. */
  94797. direction1: Vector3;
  94798. /**
  94799. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94800. */
  94801. direction2: Vector3;
  94802. /**
  94803. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94804. */
  94805. useMeshNormalsForDirection: boolean;
  94806. /** Defines the mesh to use as source */
  94807. get mesh(): Nullable<AbstractMesh>;
  94808. set mesh(value: Nullable<AbstractMesh>);
  94809. /**
  94810. * Creates a new instance MeshParticleEmitter
  94811. * @param mesh defines the mesh to use as source
  94812. */
  94813. constructor(mesh?: Nullable<AbstractMesh>);
  94814. /**
  94815. * Called by the particle System when the direction is computed for the created particle.
  94816. * @param worldMatrix is the world matrix of the particle system
  94817. * @param directionToUpdate is the direction vector to update with the result
  94818. * @param particle is the particle we are computed the direction for
  94819. * @param isLocal defines if the direction should be set in local space
  94820. */
  94821. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94822. /**
  94823. * Called by the particle System when the position is computed for the created particle.
  94824. * @param worldMatrix is the world matrix of the particle system
  94825. * @param positionToUpdate is the position vector to update with the result
  94826. * @param particle is the particle we are computed the position for
  94827. * @param isLocal defines if the position should be set in local space
  94828. */
  94829. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94830. /**
  94831. * Clones the current emitter and returns a copy of it
  94832. * @returns the new emitter
  94833. */
  94834. clone(): MeshParticleEmitter;
  94835. /**
  94836. * Called by the GPUParticleSystem to setup the update shader
  94837. * @param effect defines the update shader
  94838. */
  94839. applyToShader(effect: Effect): void;
  94840. /**
  94841. * Returns a string to use to update the GPU particles update shader
  94842. * @returns a string containng the defines string
  94843. */
  94844. getEffectDefines(): string;
  94845. /**
  94846. * Returns the string "BoxParticleEmitter"
  94847. * @returns a string containing the class name
  94848. */
  94849. getClassName(): string;
  94850. /**
  94851. * Serializes the particle system to a JSON object.
  94852. * @returns the JSON object
  94853. */
  94854. serialize(): any;
  94855. /**
  94856. * Parse properties from a JSON object
  94857. * @param serializationObject defines the JSON object
  94858. * @param scene defines the hosting scene
  94859. */
  94860. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94861. }
  94862. }
  94863. declare module BABYLON {
  94864. /**
  94865. * Interface representing a particle system in Babylon.js.
  94866. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94867. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94868. */
  94869. export interface IParticleSystem {
  94870. /**
  94871. * List of animations used by the particle system.
  94872. */
  94873. animations: Animation[];
  94874. /**
  94875. * The id of the Particle system.
  94876. */
  94877. id: string;
  94878. /**
  94879. * The name of the Particle system.
  94880. */
  94881. name: string;
  94882. /**
  94883. * The emitter represents the Mesh or position we are attaching the particle system to.
  94884. */
  94885. emitter: Nullable<AbstractMesh | Vector3>;
  94886. /**
  94887. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94888. */
  94889. isBillboardBased: boolean;
  94890. /**
  94891. * The rendering group used by the Particle system to chose when to render.
  94892. */
  94893. renderingGroupId: number;
  94894. /**
  94895. * The layer mask we are rendering the particles through.
  94896. */
  94897. layerMask: number;
  94898. /**
  94899. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94900. */
  94901. updateSpeed: number;
  94902. /**
  94903. * The amount of time the particle system is running (depends of the overall update speed).
  94904. */
  94905. targetStopDuration: number;
  94906. /**
  94907. * The texture used to render each particle. (this can be a spritesheet)
  94908. */
  94909. particleTexture: Nullable<BaseTexture>;
  94910. /**
  94911. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94912. */
  94913. blendMode: number;
  94914. /**
  94915. * Minimum life time of emitting particles.
  94916. */
  94917. minLifeTime: number;
  94918. /**
  94919. * Maximum life time of emitting particles.
  94920. */
  94921. maxLifeTime: number;
  94922. /**
  94923. * Minimum Size of emitting particles.
  94924. */
  94925. minSize: number;
  94926. /**
  94927. * Maximum Size of emitting particles.
  94928. */
  94929. maxSize: number;
  94930. /**
  94931. * Minimum scale of emitting particles on X axis.
  94932. */
  94933. minScaleX: number;
  94934. /**
  94935. * Maximum scale of emitting particles on X axis.
  94936. */
  94937. maxScaleX: number;
  94938. /**
  94939. * Minimum scale of emitting particles on Y axis.
  94940. */
  94941. minScaleY: number;
  94942. /**
  94943. * Maximum scale of emitting particles on Y axis.
  94944. */
  94945. maxScaleY: number;
  94946. /**
  94947. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94948. */
  94949. color1: Color4;
  94950. /**
  94951. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94952. */
  94953. color2: Color4;
  94954. /**
  94955. * Color the particle will have at the end of its lifetime.
  94956. */
  94957. colorDead: Color4;
  94958. /**
  94959. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94960. */
  94961. emitRate: number;
  94962. /**
  94963. * You can use gravity if you want to give an orientation to your particles.
  94964. */
  94965. gravity: Vector3;
  94966. /**
  94967. * Minimum power of emitting particles.
  94968. */
  94969. minEmitPower: number;
  94970. /**
  94971. * Maximum power of emitting particles.
  94972. */
  94973. maxEmitPower: number;
  94974. /**
  94975. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94976. */
  94977. minAngularSpeed: number;
  94978. /**
  94979. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94980. */
  94981. maxAngularSpeed: number;
  94982. /**
  94983. * Gets or sets the minimal initial rotation in radians.
  94984. */
  94985. minInitialRotation: number;
  94986. /**
  94987. * Gets or sets the maximal initial rotation in radians.
  94988. */
  94989. maxInitialRotation: number;
  94990. /**
  94991. * The particle emitter type defines the emitter used by the particle system.
  94992. * It can be for example box, sphere, or cone...
  94993. */
  94994. particleEmitterType: Nullable<IParticleEmitterType>;
  94995. /**
  94996. * Defines the delay in milliseconds before starting the system (0 by default)
  94997. */
  94998. startDelay: number;
  94999. /**
  95000. * 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
  95001. */
  95002. preWarmCycles: number;
  95003. /**
  95004. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  95005. */
  95006. preWarmStepOffset: number;
  95007. /**
  95008. * 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)
  95009. */
  95010. spriteCellChangeSpeed: number;
  95011. /**
  95012. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  95013. */
  95014. startSpriteCellID: number;
  95015. /**
  95016. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  95017. */
  95018. endSpriteCellID: number;
  95019. /**
  95020. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  95021. */
  95022. spriteCellWidth: number;
  95023. /**
  95024. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  95025. */
  95026. spriteCellHeight: number;
  95027. /**
  95028. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  95029. */
  95030. spriteRandomStartCell: boolean;
  95031. /**
  95032. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  95033. */
  95034. isAnimationSheetEnabled: boolean;
  95035. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  95036. translationPivot: Vector2;
  95037. /**
  95038. * Gets or sets a texture used to add random noise to particle positions
  95039. */
  95040. noiseTexture: Nullable<BaseTexture>;
  95041. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  95042. noiseStrength: Vector3;
  95043. /**
  95044. * Gets or sets the billboard mode to use when isBillboardBased = true.
  95045. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  95046. */
  95047. billboardMode: number;
  95048. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  95049. limitVelocityDamping: number;
  95050. /**
  95051. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  95052. */
  95053. beginAnimationOnStart: boolean;
  95054. /**
  95055. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  95056. */
  95057. beginAnimationFrom: number;
  95058. /**
  95059. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  95060. */
  95061. beginAnimationTo: number;
  95062. /**
  95063. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  95064. */
  95065. beginAnimationLoop: boolean;
  95066. /**
  95067. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  95068. */
  95069. disposeOnStop: boolean;
  95070. /**
  95071. * Specifies if the particles are updated in emitter local space or world space
  95072. */
  95073. isLocal: boolean;
  95074. /** Snippet ID if the particle system was created from the snippet server */
  95075. snippetId: string;
  95076. /** Gets or sets a matrix to use to compute projection */
  95077. defaultProjectionMatrix: Matrix;
  95078. /**
  95079. * Gets the maximum number of particles active at the same time.
  95080. * @returns The max number of active particles.
  95081. */
  95082. getCapacity(): number;
  95083. /**
  95084. * Gets the number of particles active at the same time.
  95085. * @returns The number of active particles.
  95086. */
  95087. getActiveCount(): number;
  95088. /**
  95089. * Gets if the system has been started. (Note: this will still be true after stop is called)
  95090. * @returns True if it has been started, otherwise false.
  95091. */
  95092. isStarted(): boolean;
  95093. /**
  95094. * Animates the particle system for this frame.
  95095. */
  95096. animate(): void;
  95097. /**
  95098. * Renders the particle system in its current state.
  95099. * @returns the current number of particles
  95100. */
  95101. render(): number;
  95102. /**
  95103. * Dispose the particle system and frees its associated resources.
  95104. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  95105. */
  95106. dispose(disposeTexture?: boolean): void;
  95107. /**
  95108. * An event triggered when the system is disposed
  95109. */
  95110. onDisposeObservable: Observable<IParticleSystem>;
  95111. /**
  95112. * An event triggered when the system is stopped
  95113. */
  95114. onStoppedObservable: Observable<IParticleSystem>;
  95115. /**
  95116. * Clones the particle system.
  95117. * @param name The name of the cloned object
  95118. * @param newEmitter The new emitter to use
  95119. * @returns the cloned particle system
  95120. */
  95121. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  95122. /**
  95123. * Serializes the particle system to a JSON object
  95124. * @param serializeTexture defines if the texture must be serialized as well
  95125. * @returns the JSON object
  95126. */
  95127. serialize(serializeTexture: boolean): any;
  95128. /**
  95129. * Rebuild the particle system
  95130. */
  95131. rebuild(): void;
  95132. /** Force the system to rebuild all gradients that need to be resync */
  95133. forceRefreshGradients(): void;
  95134. /**
  95135. * Starts the particle system and begins to emit
  95136. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  95137. */
  95138. start(delay?: number): void;
  95139. /**
  95140. * Stops the particle system.
  95141. */
  95142. stop(): void;
  95143. /**
  95144. * Remove all active particles
  95145. */
  95146. reset(): void;
  95147. /**
  95148. * Gets a boolean indicating that the system is stopping
  95149. * @returns true if the system is currently stopping
  95150. */
  95151. isStopping(): boolean;
  95152. /**
  95153. * Is this system ready to be used/rendered
  95154. * @return true if the system is ready
  95155. */
  95156. isReady(): boolean;
  95157. /**
  95158. * Returns the string "ParticleSystem"
  95159. * @returns a string containing the class name
  95160. */
  95161. getClassName(): string;
  95162. /**
  95163. * Gets the custom effect used to render the particles
  95164. * @param blendMode Blend mode for which the effect should be retrieved
  95165. * @returns The effect
  95166. */
  95167. getCustomEffect(blendMode: number): Nullable<Effect>;
  95168. /**
  95169. * Sets the custom effect used to render the particles
  95170. * @param effect The effect to set
  95171. * @param blendMode Blend mode for which the effect should be set
  95172. */
  95173. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  95174. /**
  95175. * Fill the defines array according to the current settings of the particle system
  95176. * @param defines Array to be updated
  95177. * @param blendMode blend mode to take into account when updating the array
  95178. */
  95179. fillDefines(defines: Array<string>, blendMode: number): void;
  95180. /**
  95181. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  95182. * @param uniforms Uniforms array to fill
  95183. * @param attributes Attributes array to fill
  95184. * @param samplers Samplers array to fill
  95185. */
  95186. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95187. /**
  95188. * Observable that will be called just before the particles are drawn
  95189. */
  95190. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95191. /**
  95192. * Gets the name of the particle vertex shader
  95193. */
  95194. vertexShaderName: string;
  95195. /**
  95196. * Adds a new color gradient
  95197. * @param gradient defines the gradient to use (between 0 and 1)
  95198. * @param color1 defines the color to affect to the specified gradient
  95199. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95200. * @returns the current particle system
  95201. */
  95202. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95203. /**
  95204. * Remove a specific color gradient
  95205. * @param gradient defines the gradient to remove
  95206. * @returns the current particle system
  95207. */
  95208. removeColorGradient(gradient: number): IParticleSystem;
  95209. /**
  95210. * Adds a new size gradient
  95211. * @param gradient defines the gradient to use (between 0 and 1)
  95212. * @param factor defines the size factor to affect to the specified gradient
  95213. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95214. * @returns the current particle system
  95215. */
  95216. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95217. /**
  95218. * Remove a specific size gradient
  95219. * @param gradient defines the gradient to remove
  95220. * @returns the current particle system
  95221. */
  95222. removeSizeGradient(gradient: number): IParticleSystem;
  95223. /**
  95224. * Gets the current list of color gradients.
  95225. * You must use addColorGradient and removeColorGradient to udpate this list
  95226. * @returns the list of color gradients
  95227. */
  95228. getColorGradients(): Nullable<Array<ColorGradient>>;
  95229. /**
  95230. * Gets the current list of size gradients.
  95231. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95232. * @returns the list of size gradients
  95233. */
  95234. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95235. /**
  95236. * Gets the current list of angular speed gradients.
  95237. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95238. * @returns the list of angular speed gradients
  95239. */
  95240. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95241. /**
  95242. * Adds a new angular speed gradient
  95243. * @param gradient defines the gradient to use (between 0 and 1)
  95244. * @param factor defines the angular speed to affect to the specified gradient
  95245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95246. * @returns the current particle system
  95247. */
  95248. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95249. /**
  95250. * Remove a specific angular speed gradient
  95251. * @param gradient defines the gradient to remove
  95252. * @returns the current particle system
  95253. */
  95254. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95255. /**
  95256. * Gets the current list of velocity gradients.
  95257. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95258. * @returns the list of velocity gradients
  95259. */
  95260. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95261. /**
  95262. * Adds a new velocity gradient
  95263. * @param gradient defines the gradient to use (between 0 and 1)
  95264. * @param factor defines the velocity to affect to the specified gradient
  95265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95266. * @returns the current particle system
  95267. */
  95268. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95269. /**
  95270. * Remove a specific velocity gradient
  95271. * @param gradient defines the gradient to remove
  95272. * @returns the current particle system
  95273. */
  95274. removeVelocityGradient(gradient: number): IParticleSystem;
  95275. /**
  95276. * Gets the current list of limit velocity gradients.
  95277. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95278. * @returns the list of limit velocity gradients
  95279. */
  95280. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95281. /**
  95282. * Adds a new limit velocity gradient
  95283. * @param gradient defines the gradient to use (between 0 and 1)
  95284. * @param factor defines the limit velocity to affect to the specified gradient
  95285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95286. * @returns the current particle system
  95287. */
  95288. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95289. /**
  95290. * Remove a specific limit velocity gradient
  95291. * @param gradient defines the gradient to remove
  95292. * @returns the current particle system
  95293. */
  95294. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95295. /**
  95296. * Adds a new drag gradient
  95297. * @param gradient defines the gradient to use (between 0 and 1)
  95298. * @param factor defines the drag to affect to the specified gradient
  95299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95300. * @returns the current particle system
  95301. */
  95302. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95303. /**
  95304. * Remove a specific drag gradient
  95305. * @param gradient defines the gradient to remove
  95306. * @returns the current particle system
  95307. */
  95308. removeDragGradient(gradient: number): IParticleSystem;
  95309. /**
  95310. * Gets the current list of drag gradients.
  95311. * You must use addDragGradient and removeDragGradient to udpate this list
  95312. * @returns the list of drag gradients
  95313. */
  95314. getDragGradients(): Nullable<Array<FactorGradient>>;
  95315. /**
  95316. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95317. * @param gradient defines the gradient to use (between 0 and 1)
  95318. * @param factor defines the emit rate to affect to the specified gradient
  95319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95320. * @returns the current particle system
  95321. */
  95322. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95323. /**
  95324. * Remove a specific emit rate gradient
  95325. * @param gradient defines the gradient to remove
  95326. * @returns the current particle system
  95327. */
  95328. removeEmitRateGradient(gradient: number): IParticleSystem;
  95329. /**
  95330. * Gets the current list of emit rate gradients.
  95331. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95332. * @returns the list of emit rate gradients
  95333. */
  95334. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95335. /**
  95336. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95337. * @param gradient defines the gradient to use (between 0 and 1)
  95338. * @param factor defines the start size to affect to the specified gradient
  95339. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95340. * @returns the current particle system
  95341. */
  95342. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95343. /**
  95344. * Remove a specific start size gradient
  95345. * @param gradient defines the gradient to remove
  95346. * @returns the current particle system
  95347. */
  95348. removeStartSizeGradient(gradient: number): IParticleSystem;
  95349. /**
  95350. * Gets the current list of start size gradients.
  95351. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95352. * @returns the list of start size gradients
  95353. */
  95354. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95355. /**
  95356. * Adds a new life time gradient
  95357. * @param gradient defines the gradient to use (between 0 and 1)
  95358. * @param factor defines the life time factor to affect to the specified gradient
  95359. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95360. * @returns the current particle system
  95361. */
  95362. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95363. /**
  95364. * Remove a specific life time gradient
  95365. * @param gradient defines the gradient to remove
  95366. * @returns the current particle system
  95367. */
  95368. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95369. /**
  95370. * Gets the current list of life time gradients.
  95371. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95372. * @returns the list of life time gradients
  95373. */
  95374. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95375. /**
  95376. * Gets the current list of color gradients.
  95377. * You must use addColorGradient and removeColorGradient to udpate this list
  95378. * @returns the list of color gradients
  95379. */
  95380. getColorGradients(): Nullable<Array<ColorGradient>>;
  95381. /**
  95382. * Adds a new ramp gradient used to remap particle colors
  95383. * @param gradient defines the gradient to use (between 0 and 1)
  95384. * @param color defines the color to affect to the specified gradient
  95385. * @returns the current particle system
  95386. */
  95387. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95388. /**
  95389. * Gets the current list of ramp gradients.
  95390. * You must use addRampGradient and removeRampGradient to udpate this list
  95391. * @returns the list of ramp gradients
  95392. */
  95393. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95394. /** Gets or sets a boolean indicating that ramp gradients must be used
  95395. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95396. */
  95397. useRampGradients: boolean;
  95398. /**
  95399. * Adds a new color remap gradient
  95400. * @param gradient defines the gradient to use (between 0 and 1)
  95401. * @param min defines the color remap minimal range
  95402. * @param max defines the color remap maximal range
  95403. * @returns the current particle system
  95404. */
  95405. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95406. /**
  95407. * Gets the current list of color remap gradients.
  95408. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95409. * @returns the list of color remap gradients
  95410. */
  95411. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95412. /**
  95413. * Adds a new alpha remap gradient
  95414. * @param gradient defines the gradient to use (between 0 and 1)
  95415. * @param min defines the alpha remap minimal range
  95416. * @param max defines the alpha remap maximal range
  95417. * @returns the current particle system
  95418. */
  95419. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95420. /**
  95421. * Gets the current list of alpha remap gradients.
  95422. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95423. * @returns the list of alpha remap gradients
  95424. */
  95425. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95426. /**
  95427. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95428. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95429. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95430. * @returns the emitter
  95431. */
  95432. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95433. /**
  95434. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95435. * @param radius The radius of the hemisphere to emit from
  95436. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95437. * @returns the emitter
  95438. */
  95439. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95440. /**
  95441. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95442. * @param radius The radius of the sphere to emit from
  95443. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95444. * @returns the emitter
  95445. */
  95446. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95447. /**
  95448. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95449. * @param radius The radius of the sphere to emit from
  95450. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95451. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95452. * @returns the emitter
  95453. */
  95454. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95455. /**
  95456. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95457. * @param radius The radius of the emission cylinder
  95458. * @param height The height of the emission cylinder
  95459. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95460. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95461. * @returns the emitter
  95462. */
  95463. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95464. /**
  95465. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95466. * @param radius The radius of the cylinder to emit from
  95467. * @param height The height of the emission cylinder
  95468. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95471. * @returns the emitter
  95472. */
  95473. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95474. /**
  95475. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95476. * @param radius The radius of the cone to emit from
  95477. * @param angle The base angle of the cone
  95478. * @returns the emitter
  95479. */
  95480. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95481. /**
  95482. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95483. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95484. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95485. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95486. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95487. * @returns the emitter
  95488. */
  95489. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95490. /**
  95491. * Get hosting scene
  95492. * @returns the scene
  95493. */
  95494. getScene(): Nullable<Scene>;
  95495. }
  95496. }
  95497. declare module BABYLON {
  95498. /**
  95499. * 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.
  95500. * @see https://doc.babylonjs.com/how_to/transformnode
  95501. */
  95502. export class TransformNode extends Node {
  95503. /**
  95504. * Object will not rotate to face the camera
  95505. */
  95506. static BILLBOARDMODE_NONE: number;
  95507. /**
  95508. * Object will rotate to face the camera but only on the x axis
  95509. */
  95510. static BILLBOARDMODE_X: number;
  95511. /**
  95512. * Object will rotate to face the camera but only on the y axis
  95513. */
  95514. static BILLBOARDMODE_Y: number;
  95515. /**
  95516. * Object will rotate to face the camera but only on the z axis
  95517. */
  95518. static BILLBOARDMODE_Z: number;
  95519. /**
  95520. * Object will rotate to face the camera
  95521. */
  95522. static BILLBOARDMODE_ALL: number;
  95523. /**
  95524. * Object will rotate to face the camera's position instead of orientation
  95525. */
  95526. static BILLBOARDMODE_USE_POSITION: number;
  95527. private static _TmpRotation;
  95528. private static _TmpScaling;
  95529. private static _TmpTranslation;
  95530. private _forward;
  95531. private _forwardInverted;
  95532. private _up;
  95533. private _right;
  95534. private _rightInverted;
  95535. private _position;
  95536. private _rotation;
  95537. private _rotationQuaternion;
  95538. protected _scaling: Vector3;
  95539. protected _isDirty: boolean;
  95540. private _transformToBoneReferal;
  95541. private _isAbsoluteSynced;
  95542. private _billboardMode;
  95543. /**
  95544. * Gets or sets the billboard mode. Default is 0.
  95545. *
  95546. * | Value | Type | Description |
  95547. * | --- | --- | --- |
  95548. * | 0 | BILLBOARDMODE_NONE | |
  95549. * | 1 | BILLBOARDMODE_X | |
  95550. * | 2 | BILLBOARDMODE_Y | |
  95551. * | 4 | BILLBOARDMODE_Z | |
  95552. * | 7 | BILLBOARDMODE_ALL | |
  95553. *
  95554. */
  95555. get billboardMode(): number;
  95556. set billboardMode(value: number);
  95557. private _preserveParentRotationForBillboard;
  95558. /**
  95559. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95560. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95561. */
  95562. get preserveParentRotationForBillboard(): boolean;
  95563. set preserveParentRotationForBillboard(value: boolean);
  95564. /**
  95565. * 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
  95566. */
  95567. scalingDeterminant: number;
  95568. private _infiniteDistance;
  95569. /**
  95570. * Gets or sets the distance of the object to max, often used by skybox
  95571. */
  95572. get infiniteDistance(): boolean;
  95573. set infiniteDistance(value: boolean);
  95574. /**
  95575. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95576. * By default the system will update normals to compensate
  95577. */
  95578. ignoreNonUniformScaling: boolean;
  95579. /**
  95580. * 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
  95581. */
  95582. reIntegrateRotationIntoRotationQuaternion: boolean;
  95583. /** @hidden */
  95584. _poseMatrix: Nullable<Matrix>;
  95585. /** @hidden */
  95586. _localMatrix: Matrix;
  95587. private _usePivotMatrix;
  95588. private _absolutePosition;
  95589. private _absoluteScaling;
  95590. private _absoluteRotationQuaternion;
  95591. private _pivotMatrix;
  95592. private _pivotMatrixInverse;
  95593. /** @hidden */
  95594. _postMultiplyPivotMatrix: boolean;
  95595. protected _isWorldMatrixFrozen: boolean;
  95596. /** @hidden */
  95597. _indexInSceneTransformNodesArray: number;
  95598. /**
  95599. * An event triggered after the world matrix is updated
  95600. */
  95601. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95602. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95603. /**
  95604. * Gets a string identifying the name of the class
  95605. * @returns "TransformNode" string
  95606. */
  95607. getClassName(): string;
  95608. /**
  95609. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95610. */
  95611. get position(): Vector3;
  95612. set position(newPosition: Vector3);
  95613. /**
  95614. * 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)).
  95615. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95616. */
  95617. get rotation(): Vector3;
  95618. set rotation(newRotation: Vector3);
  95619. /**
  95620. * 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)).
  95621. */
  95622. get scaling(): Vector3;
  95623. set scaling(newScaling: Vector3);
  95624. /**
  95625. * 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).
  95626. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95627. */
  95628. get rotationQuaternion(): Nullable<Quaternion>;
  95629. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95630. /**
  95631. * The forward direction of that transform in world space.
  95632. */
  95633. get forward(): Vector3;
  95634. /**
  95635. * The up direction of that transform in world space.
  95636. */
  95637. get up(): Vector3;
  95638. /**
  95639. * The right direction of that transform in world space.
  95640. */
  95641. get right(): Vector3;
  95642. /**
  95643. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95644. * @param matrix the matrix to copy the pose from
  95645. * @returns this TransformNode.
  95646. */
  95647. updatePoseMatrix(matrix: Matrix): TransformNode;
  95648. /**
  95649. * Returns the mesh Pose matrix.
  95650. * @returns the pose matrix
  95651. */
  95652. getPoseMatrix(): Matrix;
  95653. /** @hidden */
  95654. _isSynchronized(): boolean;
  95655. /** @hidden */
  95656. _initCache(): void;
  95657. /**
  95658. * Flag the transform node as dirty (Forcing it to update everything)
  95659. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95660. * @returns this transform node
  95661. */
  95662. markAsDirty(property: string): TransformNode;
  95663. /**
  95664. * Returns the current mesh absolute position.
  95665. * Returns a Vector3.
  95666. */
  95667. get absolutePosition(): Vector3;
  95668. /**
  95669. * Returns the current mesh absolute scaling.
  95670. * Returns a Vector3.
  95671. */
  95672. get absoluteScaling(): Vector3;
  95673. /**
  95674. * Returns the current mesh absolute rotation.
  95675. * Returns a Quaternion.
  95676. */
  95677. get absoluteRotationQuaternion(): Quaternion;
  95678. /**
  95679. * Sets a new matrix to apply before all other transformation
  95680. * @param matrix defines the transform matrix
  95681. * @returns the current TransformNode
  95682. */
  95683. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95684. /**
  95685. * Sets a new pivot matrix to the current node
  95686. * @param matrix defines the new pivot matrix to use
  95687. * @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
  95688. * @returns the current TransformNode
  95689. */
  95690. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95691. /**
  95692. * Returns the mesh pivot matrix.
  95693. * Default : Identity.
  95694. * @returns the matrix
  95695. */
  95696. getPivotMatrix(): Matrix;
  95697. /**
  95698. * Instantiate (when possible) or clone that node with its hierarchy
  95699. * @param newParent defines the new parent to use for the instance (or clone)
  95700. * @param options defines options to configure how copy is done
  95701. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95702. * @returns an instance (or a clone) of the current node with its hiearchy
  95703. */
  95704. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95705. doNotInstantiate: boolean;
  95706. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95707. /**
  95708. * Prevents the World matrix to be computed any longer
  95709. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95710. * @returns the TransformNode.
  95711. */
  95712. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95713. /**
  95714. * Allows back the World matrix computation.
  95715. * @returns the TransformNode.
  95716. */
  95717. unfreezeWorldMatrix(): this;
  95718. /**
  95719. * True if the World matrix has been frozen.
  95720. */
  95721. get isWorldMatrixFrozen(): boolean;
  95722. /**
  95723. * Retuns the mesh absolute position in the World.
  95724. * @returns a Vector3.
  95725. */
  95726. getAbsolutePosition(): Vector3;
  95727. /**
  95728. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95729. * @param absolutePosition the absolute position to set
  95730. * @returns the TransformNode.
  95731. */
  95732. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95733. /**
  95734. * Sets the mesh position in its local space.
  95735. * @param vector3 the position to set in localspace
  95736. * @returns the TransformNode.
  95737. */
  95738. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95739. /**
  95740. * Returns the mesh position in the local space from the current World matrix values.
  95741. * @returns a new Vector3.
  95742. */
  95743. getPositionExpressedInLocalSpace(): Vector3;
  95744. /**
  95745. * Translates the mesh along the passed Vector3 in its local space.
  95746. * @param vector3 the distance to translate in localspace
  95747. * @returns the TransformNode.
  95748. */
  95749. locallyTranslate(vector3: Vector3): TransformNode;
  95750. private static _lookAtVectorCache;
  95751. /**
  95752. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95753. * @param targetPoint the position (must be in same space as current mesh) to look at
  95754. * @param yawCor optional yaw (y-axis) correction in radians
  95755. * @param pitchCor optional pitch (x-axis) correction in radians
  95756. * @param rollCor optional roll (z-axis) correction in radians
  95757. * @param space the choosen space of the target
  95758. * @returns the TransformNode.
  95759. */
  95760. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95761. /**
  95762. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95763. * This Vector3 is expressed in the World space.
  95764. * @param localAxis axis to rotate
  95765. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95766. */
  95767. getDirection(localAxis: Vector3): Vector3;
  95768. /**
  95769. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95770. * localAxis is expressed in the mesh local space.
  95771. * result is computed in the Wordl space from the mesh World matrix.
  95772. * @param localAxis axis to rotate
  95773. * @param result the resulting transformnode
  95774. * @returns this TransformNode.
  95775. */
  95776. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95777. /**
  95778. * Sets this transform node rotation to the given local axis.
  95779. * @param localAxis the axis in local space
  95780. * @param yawCor optional yaw (y-axis) correction in radians
  95781. * @param pitchCor optional pitch (x-axis) correction in radians
  95782. * @param rollCor optional roll (z-axis) correction in radians
  95783. * @returns this TransformNode
  95784. */
  95785. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95786. /**
  95787. * Sets a new pivot point to the current node
  95788. * @param point defines the new pivot point to use
  95789. * @param space defines if the point is in world or local space (local by default)
  95790. * @returns the current TransformNode
  95791. */
  95792. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95793. /**
  95794. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95795. * @returns the pivot point
  95796. */
  95797. getPivotPoint(): Vector3;
  95798. /**
  95799. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95800. * @param result the vector3 to store the result
  95801. * @returns this TransformNode.
  95802. */
  95803. getPivotPointToRef(result: Vector3): TransformNode;
  95804. /**
  95805. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95806. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95807. */
  95808. getAbsolutePivotPoint(): Vector3;
  95809. /**
  95810. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95811. * @param result vector3 to store the result
  95812. * @returns this TransformNode.
  95813. */
  95814. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95815. /**
  95816. * Defines the passed node as the parent of the current node.
  95817. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95818. * @see https://doc.babylonjs.com/how_to/parenting
  95819. * @param node the node ot set as the parent
  95820. * @returns this TransformNode.
  95821. */
  95822. setParent(node: Nullable<Node>): TransformNode;
  95823. private _nonUniformScaling;
  95824. /**
  95825. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95826. */
  95827. get nonUniformScaling(): boolean;
  95828. /** @hidden */
  95829. _updateNonUniformScalingState(value: boolean): boolean;
  95830. /**
  95831. * Attach the current TransformNode to another TransformNode associated with a bone
  95832. * @param bone Bone affecting the TransformNode
  95833. * @param affectedTransformNode TransformNode associated with the bone
  95834. * @returns this object
  95835. */
  95836. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95837. /**
  95838. * Detach the transform node if its associated with a bone
  95839. * @returns this object
  95840. */
  95841. detachFromBone(): TransformNode;
  95842. private static _rotationAxisCache;
  95843. /**
  95844. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95845. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95846. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95847. * The passed axis is also normalized.
  95848. * @param axis the axis to rotate around
  95849. * @param amount the amount to rotate in radians
  95850. * @param space Space to rotate in (Default: local)
  95851. * @returns the TransformNode.
  95852. */
  95853. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95854. /**
  95855. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95856. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95857. * The passed axis is also normalized. .
  95858. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95859. * @param point the point to rotate around
  95860. * @param axis the axis to rotate around
  95861. * @param amount the amount to rotate in radians
  95862. * @returns the TransformNode
  95863. */
  95864. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95865. /**
  95866. * Translates the mesh along the axis vector for the passed distance in the given space.
  95867. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95868. * @param axis the axis to translate in
  95869. * @param distance the distance to translate
  95870. * @param space Space to rotate in (Default: local)
  95871. * @returns the TransformNode.
  95872. */
  95873. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95874. /**
  95875. * Adds a rotation step to the mesh current rotation.
  95876. * x, y, z are Euler angles expressed in radians.
  95877. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95878. * This means this rotation is made in the mesh local space only.
  95879. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95880. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95881. * ```javascript
  95882. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95883. * ```
  95884. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95885. * 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.
  95886. * @param x Rotation to add
  95887. * @param y Rotation to add
  95888. * @param z Rotation to add
  95889. * @returns the TransformNode.
  95890. */
  95891. addRotation(x: number, y: number, z: number): TransformNode;
  95892. /**
  95893. * @hidden
  95894. */
  95895. protected _getEffectiveParent(): Nullable<Node>;
  95896. /**
  95897. * Computes the world matrix of the node
  95898. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95899. * @returns the world matrix
  95900. */
  95901. computeWorldMatrix(force?: boolean): Matrix;
  95902. /**
  95903. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95904. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95905. */
  95906. resetLocalMatrix(independentOfChildren?: boolean): void;
  95907. protected _afterComputeWorldMatrix(): void;
  95908. /**
  95909. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95910. * @param func callback function to add
  95911. *
  95912. * @returns the TransformNode.
  95913. */
  95914. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95915. /**
  95916. * Removes a registered callback function.
  95917. * @param func callback function to remove
  95918. * @returns the TransformNode.
  95919. */
  95920. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95921. /**
  95922. * Gets the position of the current mesh in camera space
  95923. * @param camera defines the camera to use
  95924. * @returns a position
  95925. */
  95926. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95927. /**
  95928. * Returns the distance from the mesh to the active camera
  95929. * @param camera defines the camera to use
  95930. * @returns the distance
  95931. */
  95932. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95933. /**
  95934. * Clone the current transform node
  95935. * @param name Name of the new clone
  95936. * @param newParent New parent for the clone
  95937. * @param doNotCloneChildren Do not clone children hierarchy
  95938. * @returns the new transform node
  95939. */
  95940. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95941. /**
  95942. * Serializes the objects information.
  95943. * @param currentSerializationObject defines the object to serialize in
  95944. * @returns the serialized object
  95945. */
  95946. serialize(currentSerializationObject?: any): any;
  95947. /**
  95948. * Returns a new TransformNode object parsed from the source provided.
  95949. * @param parsedTransformNode is the source.
  95950. * @param scene the scne the object belongs to
  95951. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95952. * @returns a new TransformNode object parsed from the source provided.
  95953. */
  95954. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95955. /**
  95956. * Get all child-transformNodes of this node
  95957. * @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
  95958. * @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
  95959. * @returns an array of TransformNode
  95960. */
  95961. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95962. /**
  95963. * Releases resources associated with this transform node.
  95964. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95965. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95966. */
  95967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95968. /**
  95969. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95970. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95971. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95972. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95973. * @returns the current mesh
  95974. */
  95975. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95976. private _syncAbsoluteScalingAndRotation;
  95977. }
  95978. }
  95979. declare module BABYLON {
  95980. /**
  95981. * Class used to override all child animations of a given target
  95982. */
  95983. export class AnimationPropertiesOverride {
  95984. /**
  95985. * Gets or sets a value indicating if animation blending must be used
  95986. */
  95987. enableBlending: boolean;
  95988. /**
  95989. * Gets or sets the blending speed to use when enableBlending is true
  95990. */
  95991. blendingSpeed: number;
  95992. /**
  95993. * Gets or sets the default loop mode to use
  95994. */
  95995. loopMode: number;
  95996. }
  95997. }
  95998. declare module BABYLON {
  95999. /**
  96000. * Class used to store bone information
  96001. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96002. */
  96003. export class Bone extends Node {
  96004. /**
  96005. * defines the bone name
  96006. */
  96007. name: string;
  96008. private static _tmpVecs;
  96009. private static _tmpQuat;
  96010. private static _tmpMats;
  96011. /**
  96012. * Gets the list of child bones
  96013. */
  96014. children: Bone[];
  96015. /** Gets the animations associated with this bone */
  96016. animations: Animation[];
  96017. /**
  96018. * Gets or sets bone length
  96019. */
  96020. length: number;
  96021. /**
  96022. * @hidden Internal only
  96023. * Set this value to map this bone to a different index in the transform matrices
  96024. * Set this value to -1 to exclude the bone from the transform matrices
  96025. */
  96026. _index: Nullable<number>;
  96027. private _skeleton;
  96028. private _localMatrix;
  96029. private _restPose;
  96030. private _bindPose;
  96031. private _baseMatrix;
  96032. private _absoluteTransform;
  96033. private _invertedAbsoluteTransform;
  96034. private _parent;
  96035. private _scalingDeterminant;
  96036. private _worldTransform;
  96037. private _localScaling;
  96038. private _localRotation;
  96039. private _localPosition;
  96040. private _needToDecompose;
  96041. private _needToCompose;
  96042. /** @hidden */
  96043. _linkedTransformNode: Nullable<TransformNode>;
  96044. /** @hidden */
  96045. _waitingTransformNodeId: Nullable<string>;
  96046. /** @hidden */
  96047. get _matrix(): Matrix;
  96048. /** @hidden */
  96049. set _matrix(value: Matrix);
  96050. /**
  96051. * Create a new bone
  96052. * @param name defines the bone name
  96053. * @param skeleton defines the parent skeleton
  96054. * @param parentBone defines the parent (can be null if the bone is the root)
  96055. * @param localMatrix defines the local matrix
  96056. * @param restPose defines the rest pose matrix
  96057. * @param baseMatrix defines the base matrix
  96058. * @param index defines index of the bone in the hiearchy
  96059. */
  96060. constructor(
  96061. /**
  96062. * defines the bone name
  96063. */
  96064. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  96065. /**
  96066. * Gets the current object class name.
  96067. * @return the class name
  96068. */
  96069. getClassName(): string;
  96070. /**
  96071. * Gets the parent skeleton
  96072. * @returns a skeleton
  96073. */
  96074. getSkeleton(): Skeleton;
  96075. /**
  96076. * Gets parent bone
  96077. * @returns a bone or null if the bone is the root of the bone hierarchy
  96078. */
  96079. getParent(): Nullable<Bone>;
  96080. /**
  96081. * Returns an array containing the root bones
  96082. * @returns an array containing the root bones
  96083. */
  96084. getChildren(): Array<Bone>;
  96085. /**
  96086. * Gets the node index in matrix array generated for rendering
  96087. * @returns the node index
  96088. */
  96089. getIndex(): number;
  96090. /**
  96091. * Sets the parent bone
  96092. * @param parent defines the parent (can be null if the bone is the root)
  96093. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96094. */
  96095. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  96096. /**
  96097. * Gets the local matrix
  96098. * @returns a matrix
  96099. */
  96100. getLocalMatrix(): Matrix;
  96101. /**
  96102. * Gets the base matrix (initial matrix which remains unchanged)
  96103. * @returns a matrix
  96104. */
  96105. getBaseMatrix(): Matrix;
  96106. /**
  96107. * Gets the rest pose matrix
  96108. * @returns a matrix
  96109. */
  96110. getRestPose(): Matrix;
  96111. /**
  96112. * Sets the rest pose matrix
  96113. * @param matrix the local-space rest pose to set for this bone
  96114. */
  96115. setRestPose(matrix: Matrix): void;
  96116. /**
  96117. * Gets the bind pose matrix
  96118. * @returns the bind pose matrix
  96119. */
  96120. getBindPose(): Matrix;
  96121. /**
  96122. * Sets the bind pose matrix
  96123. * @param matrix the local-space bind pose to set for this bone
  96124. */
  96125. setBindPose(matrix: Matrix): void;
  96126. /**
  96127. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  96128. */
  96129. getWorldMatrix(): Matrix;
  96130. /**
  96131. * Sets the local matrix to rest pose matrix
  96132. */
  96133. returnToRest(): void;
  96134. /**
  96135. * Gets the inverse of the absolute transform matrix.
  96136. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  96137. * @returns a matrix
  96138. */
  96139. getInvertedAbsoluteTransform(): Matrix;
  96140. /**
  96141. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  96142. * @returns a matrix
  96143. */
  96144. getAbsoluteTransform(): Matrix;
  96145. /**
  96146. * Links with the given transform node.
  96147. * The local matrix of this bone is copied from the transform node every frame.
  96148. * @param transformNode defines the transform node to link to
  96149. */
  96150. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  96151. /**
  96152. * Gets the node used to drive the bone's transformation
  96153. * @returns a transform node or null
  96154. */
  96155. getTransformNode(): Nullable<TransformNode>;
  96156. /** Gets or sets current position (in local space) */
  96157. get position(): Vector3;
  96158. set position(newPosition: Vector3);
  96159. /** Gets or sets current rotation (in local space) */
  96160. get rotation(): Vector3;
  96161. set rotation(newRotation: Vector3);
  96162. /** Gets or sets current rotation quaternion (in local space) */
  96163. get rotationQuaternion(): Quaternion;
  96164. set rotationQuaternion(newRotation: Quaternion);
  96165. /** Gets or sets current scaling (in local space) */
  96166. get scaling(): Vector3;
  96167. set scaling(newScaling: Vector3);
  96168. /**
  96169. * Gets the animation properties override
  96170. */
  96171. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96172. private _decompose;
  96173. private _compose;
  96174. /**
  96175. * Update the base and local matrices
  96176. * @param matrix defines the new base or local matrix
  96177. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96178. * @param updateLocalMatrix defines if the local matrix should be updated
  96179. */
  96180. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  96181. /** @hidden */
  96182. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96183. /**
  96184. * Flag the bone as dirty (Forcing it to update everything)
  96185. */
  96186. markAsDirty(): void;
  96187. /** @hidden */
  96188. _markAsDirtyAndCompose(): void;
  96189. private _markAsDirtyAndDecompose;
  96190. /**
  96191. * Translate the bone in local or world space
  96192. * @param vec The amount to translate the bone
  96193. * @param space The space that the translation is in
  96194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96195. */
  96196. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96197. /**
  96198. * Set the postion of the bone in local or world space
  96199. * @param position The position to set the bone
  96200. * @param space The space that the position is in
  96201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96202. */
  96203. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96204. /**
  96205. * Set the absolute position of the bone (world space)
  96206. * @param position The position to set the bone
  96207. * @param mesh The mesh that this bone is attached to
  96208. */
  96209. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96210. /**
  96211. * Scale the bone on the x, y and z axes (in local space)
  96212. * @param x The amount to scale the bone on the x axis
  96213. * @param y The amount to scale the bone on the y axis
  96214. * @param z The amount to scale the bone on the z axis
  96215. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96216. */
  96217. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96218. /**
  96219. * Set the bone scaling in local space
  96220. * @param scale defines the scaling vector
  96221. */
  96222. setScale(scale: Vector3): void;
  96223. /**
  96224. * Gets the current scaling in local space
  96225. * @returns the current scaling vector
  96226. */
  96227. getScale(): Vector3;
  96228. /**
  96229. * Gets the current scaling in local space and stores it in a target vector
  96230. * @param result defines the target vector
  96231. */
  96232. getScaleToRef(result: Vector3): void;
  96233. /**
  96234. * Set the yaw, pitch, and roll of the bone in local or world space
  96235. * @param yaw The rotation of the bone on the y axis
  96236. * @param pitch The rotation of the bone on the x axis
  96237. * @param roll The rotation of the bone on the z axis
  96238. * @param space The space that the axes of rotation are in
  96239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96240. */
  96241. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96242. /**
  96243. * Add a rotation to the bone on an axis in local or world space
  96244. * @param axis The axis to rotate the bone on
  96245. * @param amount The amount to rotate the bone
  96246. * @param space The space that the axis is in
  96247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96248. */
  96249. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96250. /**
  96251. * Set the rotation of the bone to a particular axis angle in local or world space
  96252. * @param axis The axis to rotate the bone on
  96253. * @param angle The angle that the bone should be rotated to
  96254. * @param space The space that the axis is in
  96255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96256. */
  96257. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96258. /**
  96259. * Set the euler rotation of the bone in local or world space
  96260. * @param rotation The euler rotation that the bone should be set to
  96261. * @param space The space that the rotation is in
  96262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96263. */
  96264. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96265. /**
  96266. * Set the quaternion rotation of the bone in local or world space
  96267. * @param quat The quaternion rotation that the bone should be set to
  96268. * @param space The space that the rotation is in
  96269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96270. */
  96271. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96272. /**
  96273. * Set the rotation matrix of the bone in local or world space
  96274. * @param rotMat The rotation matrix that the bone should be set to
  96275. * @param space The space that the rotation is in
  96276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96277. */
  96278. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96279. private _rotateWithMatrix;
  96280. private _getNegativeRotationToRef;
  96281. /**
  96282. * Get the position of the bone in local or world space
  96283. * @param space The space that the returned position is in
  96284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96285. * @returns The position of the bone
  96286. */
  96287. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96288. /**
  96289. * Copy the position of the bone to a vector3 in local or world space
  96290. * @param space The space that the returned position is in
  96291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96292. * @param result The vector3 to copy the position to
  96293. */
  96294. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96295. /**
  96296. * Get the absolute position of the bone (world space)
  96297. * @param mesh The mesh that this bone is attached to
  96298. * @returns The absolute position of the bone
  96299. */
  96300. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96301. /**
  96302. * Copy the absolute position of the bone (world space) to the result param
  96303. * @param mesh The mesh that this bone is attached to
  96304. * @param result The vector3 to copy the absolute position to
  96305. */
  96306. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96307. /**
  96308. * Compute the absolute transforms of this bone and its children
  96309. */
  96310. computeAbsoluteTransforms(): void;
  96311. /**
  96312. * Get the world direction from an axis that is in the local space of the bone
  96313. * @param localAxis The local direction that is used to compute the world direction
  96314. * @param mesh The mesh that this bone is attached to
  96315. * @returns The world direction
  96316. */
  96317. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96318. /**
  96319. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96320. * @param localAxis The local direction that is used to compute the world direction
  96321. * @param mesh The mesh that this bone is attached to
  96322. * @param result The vector3 that the world direction will be copied to
  96323. */
  96324. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96325. /**
  96326. * Get the euler rotation of the bone in local or world space
  96327. * @param space The space that the rotation should be in
  96328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96329. * @returns The euler rotation
  96330. */
  96331. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96332. /**
  96333. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96334. * @param space The space that the rotation should be in
  96335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96336. * @param result The vector3 that the rotation should be copied to
  96337. */
  96338. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96339. /**
  96340. * Get the quaternion rotation of the bone in either local or world space
  96341. * @param space The space that the rotation should be in
  96342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96343. * @returns The quaternion rotation
  96344. */
  96345. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96346. /**
  96347. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96348. * @param space The space that the rotation should be in
  96349. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96350. * @param result The quaternion that the rotation should be copied to
  96351. */
  96352. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96353. /**
  96354. * Get the rotation matrix of the bone in local or world space
  96355. * @param space The space that the rotation should be in
  96356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96357. * @returns The rotation matrix
  96358. */
  96359. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96360. /**
  96361. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96362. * @param space The space that the rotation should be in
  96363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96364. * @param result The quaternion that the rotation should be copied to
  96365. */
  96366. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96367. /**
  96368. * Get the world position of a point that is in the local space of the bone
  96369. * @param position The local position
  96370. * @param mesh The mesh that this bone is attached to
  96371. * @returns The world position
  96372. */
  96373. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96374. /**
  96375. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96376. * @param position The local position
  96377. * @param mesh The mesh that this bone is attached to
  96378. * @param result The vector3 that the world position should be copied to
  96379. */
  96380. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96381. /**
  96382. * Get the local position of a point that is in world space
  96383. * @param position The world position
  96384. * @param mesh The mesh that this bone is attached to
  96385. * @returns The local position
  96386. */
  96387. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96388. /**
  96389. * Get the local position of a point that is in world space and copy it to the result param
  96390. * @param position The world position
  96391. * @param mesh The mesh that this bone is attached to
  96392. * @param result The vector3 that the local position should be copied to
  96393. */
  96394. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96395. /**
  96396. * Set the current local matrix as the restPose for this bone.
  96397. */
  96398. setCurrentPoseAsRest(): void;
  96399. }
  96400. }
  96401. declare module BABYLON {
  96402. /**
  96403. * Defines a runtime animation
  96404. */
  96405. export class RuntimeAnimation {
  96406. private _events;
  96407. /**
  96408. * The current frame of the runtime animation
  96409. */
  96410. private _currentFrame;
  96411. /**
  96412. * The animation used by the runtime animation
  96413. */
  96414. private _animation;
  96415. /**
  96416. * The target of the runtime animation
  96417. */
  96418. private _target;
  96419. /**
  96420. * The initiating animatable
  96421. */
  96422. private _host;
  96423. /**
  96424. * The original value of the runtime animation
  96425. */
  96426. private _originalValue;
  96427. /**
  96428. * The original blend value of the runtime animation
  96429. */
  96430. private _originalBlendValue;
  96431. /**
  96432. * The offsets cache of the runtime animation
  96433. */
  96434. private _offsetsCache;
  96435. /**
  96436. * The high limits cache of the runtime animation
  96437. */
  96438. private _highLimitsCache;
  96439. /**
  96440. * Specifies if the runtime animation has been stopped
  96441. */
  96442. private _stopped;
  96443. /**
  96444. * The blending factor of the runtime animation
  96445. */
  96446. private _blendingFactor;
  96447. /**
  96448. * The BabylonJS scene
  96449. */
  96450. private _scene;
  96451. /**
  96452. * The current value of the runtime animation
  96453. */
  96454. private _currentValue;
  96455. /** @hidden */
  96456. _animationState: _IAnimationState;
  96457. /**
  96458. * The active target of the runtime animation
  96459. */
  96460. private _activeTargets;
  96461. private _currentActiveTarget;
  96462. private _directTarget;
  96463. /**
  96464. * The target path of the runtime animation
  96465. */
  96466. private _targetPath;
  96467. /**
  96468. * The weight of the runtime animation
  96469. */
  96470. private _weight;
  96471. /**
  96472. * The ratio offset of the runtime animation
  96473. */
  96474. private _ratioOffset;
  96475. /**
  96476. * The previous delay of the runtime animation
  96477. */
  96478. private _previousDelay;
  96479. /**
  96480. * The previous ratio of the runtime animation
  96481. */
  96482. private _previousRatio;
  96483. private _enableBlending;
  96484. private _keys;
  96485. private _minFrame;
  96486. private _maxFrame;
  96487. private _minValue;
  96488. private _maxValue;
  96489. private _targetIsArray;
  96490. /**
  96491. * Gets the current frame of the runtime animation
  96492. */
  96493. get currentFrame(): number;
  96494. /**
  96495. * Gets the weight of the runtime animation
  96496. */
  96497. get weight(): number;
  96498. /**
  96499. * Gets the current value of the runtime animation
  96500. */
  96501. get currentValue(): any;
  96502. /**
  96503. * Gets the target path of the runtime animation
  96504. */
  96505. get targetPath(): string;
  96506. /**
  96507. * Gets the actual target of the runtime animation
  96508. */
  96509. get target(): any;
  96510. /**
  96511. * Gets the additive state of the runtime animation
  96512. */
  96513. get isAdditive(): boolean;
  96514. /** @hidden */
  96515. _onLoop: () => void;
  96516. /**
  96517. * Create a new RuntimeAnimation object
  96518. * @param target defines the target of the animation
  96519. * @param animation defines the source animation object
  96520. * @param scene defines the hosting scene
  96521. * @param host defines the initiating Animatable
  96522. */
  96523. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96524. private _preparePath;
  96525. /**
  96526. * Gets the animation from the runtime animation
  96527. */
  96528. get animation(): Animation;
  96529. /**
  96530. * Resets the runtime animation to the beginning
  96531. * @param restoreOriginal defines whether to restore the target property to the original value
  96532. */
  96533. reset(restoreOriginal?: boolean): void;
  96534. /**
  96535. * Specifies if the runtime animation is stopped
  96536. * @returns Boolean specifying if the runtime animation is stopped
  96537. */
  96538. isStopped(): boolean;
  96539. /**
  96540. * Disposes of the runtime animation
  96541. */
  96542. dispose(): void;
  96543. /**
  96544. * Apply the interpolated value to the target
  96545. * @param currentValue defines the value computed by the animation
  96546. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96547. */
  96548. setValue(currentValue: any, weight: number): void;
  96549. private _getOriginalValues;
  96550. private _setValue;
  96551. /**
  96552. * Gets the loop pmode of the runtime animation
  96553. * @returns Loop Mode
  96554. */
  96555. private _getCorrectLoopMode;
  96556. /**
  96557. * Move the current animation to a given frame
  96558. * @param frame defines the frame to move to
  96559. */
  96560. goToFrame(frame: number): void;
  96561. /**
  96562. * @hidden Internal use only
  96563. */
  96564. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96565. /**
  96566. * Execute the current animation
  96567. * @param delay defines the delay to add to the current frame
  96568. * @param from defines the lower bound of the animation range
  96569. * @param to defines the upper bound of the animation range
  96570. * @param loop defines if the current animation must loop
  96571. * @param speedRatio defines the current speed ratio
  96572. * @param weight defines the weight of the animation (default is -1 so no weight)
  96573. * @param onLoop optional callback called when animation loops
  96574. * @returns a boolean indicating if the animation is running
  96575. */
  96576. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96577. }
  96578. }
  96579. declare module BABYLON {
  96580. /**
  96581. * Class used to store an actual running animation
  96582. */
  96583. export class Animatable {
  96584. /** defines the target object */
  96585. target: any;
  96586. /** defines the starting frame number (default is 0) */
  96587. fromFrame: number;
  96588. /** defines the ending frame number (default is 100) */
  96589. toFrame: number;
  96590. /** defines if the animation must loop (default is false) */
  96591. loopAnimation: boolean;
  96592. /** defines a callback to call when animation ends if it is not looping */
  96593. onAnimationEnd?: (() => void) | null | undefined;
  96594. /** defines a callback to call when animation loops */
  96595. onAnimationLoop?: (() => void) | null | undefined;
  96596. /** defines whether the animation should be evaluated additively */
  96597. isAdditive: boolean;
  96598. private _localDelayOffset;
  96599. private _pausedDelay;
  96600. private _runtimeAnimations;
  96601. private _paused;
  96602. private _scene;
  96603. private _speedRatio;
  96604. private _weight;
  96605. private _syncRoot;
  96606. /**
  96607. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96608. * This will only apply for non looping animation (default is true)
  96609. */
  96610. disposeOnEnd: boolean;
  96611. /**
  96612. * Gets a boolean indicating if the animation has started
  96613. */
  96614. animationStarted: boolean;
  96615. /**
  96616. * Observer raised when the animation ends
  96617. */
  96618. onAnimationEndObservable: Observable<Animatable>;
  96619. /**
  96620. * Observer raised when the animation loops
  96621. */
  96622. onAnimationLoopObservable: Observable<Animatable>;
  96623. /**
  96624. * Gets the root Animatable used to synchronize and normalize animations
  96625. */
  96626. get syncRoot(): Nullable<Animatable>;
  96627. /**
  96628. * Gets the current frame of the first RuntimeAnimation
  96629. * Used to synchronize Animatables
  96630. */
  96631. get masterFrame(): number;
  96632. /**
  96633. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96634. */
  96635. get weight(): number;
  96636. set weight(value: number);
  96637. /**
  96638. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96639. */
  96640. get speedRatio(): number;
  96641. set speedRatio(value: number);
  96642. /**
  96643. * Creates a new Animatable
  96644. * @param scene defines the hosting scene
  96645. * @param target defines the target object
  96646. * @param fromFrame defines the starting frame number (default is 0)
  96647. * @param toFrame defines the ending frame number (default is 100)
  96648. * @param loopAnimation defines if the animation must loop (default is false)
  96649. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96650. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96651. * @param animations defines a group of animation to add to the new Animatable
  96652. * @param onAnimationLoop defines a callback to call when animation loops
  96653. * @param isAdditive defines whether the animation should be evaluated additively
  96654. */
  96655. constructor(scene: Scene,
  96656. /** defines the target object */
  96657. target: any,
  96658. /** defines the starting frame number (default is 0) */
  96659. fromFrame?: number,
  96660. /** defines the ending frame number (default is 100) */
  96661. toFrame?: number,
  96662. /** defines if the animation must loop (default is false) */
  96663. loopAnimation?: boolean, speedRatio?: number,
  96664. /** defines a callback to call when animation ends if it is not looping */
  96665. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96666. /** defines a callback to call when animation loops */
  96667. onAnimationLoop?: (() => void) | null | undefined,
  96668. /** defines whether the animation should be evaluated additively */
  96669. isAdditive?: boolean);
  96670. /**
  96671. * Synchronize and normalize current Animatable with a source Animatable
  96672. * This is useful when using animation weights and when animations are not of the same length
  96673. * @param root defines the root Animatable to synchronize with
  96674. * @returns the current Animatable
  96675. */
  96676. syncWith(root: Animatable): Animatable;
  96677. /**
  96678. * Gets the list of runtime animations
  96679. * @returns an array of RuntimeAnimation
  96680. */
  96681. getAnimations(): RuntimeAnimation[];
  96682. /**
  96683. * Adds more animations to the current animatable
  96684. * @param target defines the target of the animations
  96685. * @param animations defines the new animations to add
  96686. */
  96687. appendAnimations(target: any, animations: Animation[]): void;
  96688. /**
  96689. * Gets the source animation for a specific property
  96690. * @param property defines the propertyu to look for
  96691. * @returns null or the source animation for the given property
  96692. */
  96693. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96694. /**
  96695. * Gets the runtime animation for a specific property
  96696. * @param property defines the propertyu to look for
  96697. * @returns null or the runtime animation for the given property
  96698. */
  96699. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96700. /**
  96701. * Resets the animatable to its original state
  96702. */
  96703. reset(): void;
  96704. /**
  96705. * Allows the animatable to blend with current running animations
  96706. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96707. * @param blendingSpeed defines the blending speed to use
  96708. */
  96709. enableBlending(blendingSpeed: number): void;
  96710. /**
  96711. * Disable animation blending
  96712. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96713. */
  96714. disableBlending(): void;
  96715. /**
  96716. * Jump directly to a given frame
  96717. * @param frame defines the frame to jump to
  96718. */
  96719. goToFrame(frame: number): void;
  96720. /**
  96721. * Pause the animation
  96722. */
  96723. pause(): void;
  96724. /**
  96725. * Restart the animation
  96726. */
  96727. restart(): void;
  96728. private _raiseOnAnimationEnd;
  96729. /**
  96730. * Stop and delete the current animation
  96731. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96732. * @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)
  96733. */
  96734. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96735. /**
  96736. * Wait asynchronously for the animation to end
  96737. * @returns a promise which will be fullfilled when the animation ends
  96738. */
  96739. waitAsync(): Promise<Animatable>;
  96740. /** @hidden */
  96741. _animate(delay: number): boolean;
  96742. }
  96743. interface Scene {
  96744. /** @hidden */
  96745. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96746. /** @hidden */
  96747. _processLateAnimationBindingsForMatrices(holder: {
  96748. totalWeight: number;
  96749. totalAdditiveWeight: number;
  96750. animations: RuntimeAnimation[];
  96751. additiveAnimations: RuntimeAnimation[];
  96752. originalValue: Matrix;
  96753. }): any;
  96754. /** @hidden */
  96755. _processLateAnimationBindingsForQuaternions(holder: {
  96756. totalWeight: number;
  96757. totalAdditiveWeight: number;
  96758. animations: RuntimeAnimation[];
  96759. additiveAnimations: RuntimeAnimation[];
  96760. originalValue: Quaternion;
  96761. }, refQuaternion: Quaternion): Quaternion;
  96762. /** @hidden */
  96763. _processLateAnimationBindings(): void;
  96764. /**
  96765. * Will start the animation sequence of a given target
  96766. * @param target defines the target
  96767. * @param from defines from which frame should animation start
  96768. * @param to defines until which frame should animation run.
  96769. * @param weight defines the weight to apply to the animation (1.0 by default)
  96770. * @param loop defines if the animation loops
  96771. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96772. * @param onAnimationEnd defines the function to be executed when the animation ends
  96773. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96774. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96775. * @param onAnimationLoop defines the callback to call when an animation loops
  96776. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96777. * @returns the animatable object created for this animation
  96778. */
  96779. 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;
  96780. /**
  96781. * Will start the animation sequence of a given target
  96782. * @param target defines the target
  96783. * @param from defines from which frame should animation start
  96784. * @param to defines until which frame should animation run.
  96785. * @param loop defines if the animation loops
  96786. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96787. * @param onAnimationEnd defines the function to be executed when the animation ends
  96788. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96789. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96790. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96791. * @param onAnimationLoop defines the callback to call when an animation loops
  96792. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96793. * @returns the animatable object created for this animation
  96794. */
  96795. 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;
  96796. /**
  96797. * Will start the animation sequence of a given target and its hierarchy
  96798. * @param target defines the target
  96799. * @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.
  96800. * @param from defines from which frame should animation start
  96801. * @param to defines until which frame should animation run.
  96802. * @param loop defines if the animation loops
  96803. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96804. * @param onAnimationEnd defines the function to be executed when the animation ends
  96805. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96806. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96807. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96808. * @param onAnimationLoop defines the callback to call when an animation loops
  96809. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96810. * @returns the list of created animatables
  96811. */
  96812. 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[];
  96813. /**
  96814. * Begin a new animation on a given node
  96815. * @param target defines the target where the animation will take place
  96816. * @param animations defines the list of animations to start
  96817. * @param from defines the initial value
  96818. * @param to defines the final value
  96819. * @param loop defines if you want animation to loop (off by default)
  96820. * @param speedRatio defines the speed ratio to apply to all animations
  96821. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96822. * @param onAnimationLoop defines the callback to call when an animation loops
  96823. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96824. * @returns the list of created animatables
  96825. */
  96826. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96827. /**
  96828. * Begin a new animation on a given node and its hierarchy
  96829. * @param target defines the root node where the animation will take place
  96830. * @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.
  96831. * @param animations defines the list of animations to start
  96832. * @param from defines the initial value
  96833. * @param to defines the final value
  96834. * @param loop defines if you want animation to loop (off by default)
  96835. * @param speedRatio defines the speed ratio to apply to all animations
  96836. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96837. * @param onAnimationLoop defines the callback to call when an animation loops
  96838. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96839. * @returns the list of animatables created for all nodes
  96840. */
  96841. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96842. /**
  96843. * Gets the animatable associated with a specific target
  96844. * @param target defines the target of the animatable
  96845. * @returns the required animatable if found
  96846. */
  96847. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96848. /**
  96849. * Gets all animatables associated with a given target
  96850. * @param target defines the target to look animatables for
  96851. * @returns an array of Animatables
  96852. */
  96853. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96854. /**
  96855. * Stops and removes all animations that have been applied to the scene
  96856. */
  96857. stopAllAnimations(): void;
  96858. /**
  96859. * Gets the current delta time used by animation engine
  96860. */
  96861. deltaTime: number;
  96862. }
  96863. interface Bone {
  96864. /**
  96865. * Copy an animation range from another bone
  96866. * @param source defines the source bone
  96867. * @param rangeName defines the range name to copy
  96868. * @param frameOffset defines the frame offset
  96869. * @param rescaleAsRequired defines if rescaling must be applied if required
  96870. * @param skelDimensionsRatio defines the scaling ratio
  96871. * @returns true if operation was successful
  96872. */
  96873. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96874. }
  96875. }
  96876. declare module BABYLON {
  96877. /**
  96878. * Class used to handle skinning animations
  96879. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96880. */
  96881. export class Skeleton implements IAnimatable {
  96882. /** defines the skeleton name */
  96883. name: string;
  96884. /** defines the skeleton Id */
  96885. id: string;
  96886. /**
  96887. * Defines the list of child bones
  96888. */
  96889. bones: Bone[];
  96890. /**
  96891. * Defines an estimate of the dimension of the skeleton at rest
  96892. */
  96893. dimensionsAtRest: Vector3;
  96894. /**
  96895. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96896. */
  96897. needInitialSkinMatrix: boolean;
  96898. /**
  96899. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96900. */
  96901. overrideMesh: Nullable<AbstractMesh>;
  96902. /**
  96903. * Gets the list of animations attached to this skeleton
  96904. */
  96905. animations: Array<Animation>;
  96906. private _scene;
  96907. private _isDirty;
  96908. private _transformMatrices;
  96909. private _transformMatrixTexture;
  96910. private _meshesWithPoseMatrix;
  96911. private _animatables;
  96912. private _identity;
  96913. private _synchronizedWithMesh;
  96914. private _ranges;
  96915. private _lastAbsoluteTransformsUpdateId;
  96916. private _canUseTextureForBones;
  96917. private _uniqueId;
  96918. /** @hidden */
  96919. _numBonesWithLinkedTransformNode: number;
  96920. /** @hidden */
  96921. _hasWaitingData: Nullable<boolean>;
  96922. /** @hidden */
  96923. _waitingOverrideMeshId: Nullable<string>;
  96924. /**
  96925. * Specifies if the skeleton should be serialized
  96926. */
  96927. doNotSerialize: boolean;
  96928. private _useTextureToStoreBoneMatrices;
  96929. /**
  96930. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96931. * Please note that this option is not available if the hardware does not support it
  96932. */
  96933. get useTextureToStoreBoneMatrices(): boolean;
  96934. set useTextureToStoreBoneMatrices(value: boolean);
  96935. private _animationPropertiesOverride;
  96936. /**
  96937. * Gets or sets the animation properties override
  96938. */
  96939. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96940. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96941. /**
  96942. * List of inspectable custom properties (used by the Inspector)
  96943. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96944. */
  96945. inspectableCustomProperties: IInspectable[];
  96946. /**
  96947. * An observable triggered before computing the skeleton's matrices
  96948. */
  96949. onBeforeComputeObservable: Observable<Skeleton>;
  96950. /**
  96951. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96952. */
  96953. get isUsingTextureForMatrices(): boolean;
  96954. /**
  96955. * Gets the unique ID of this skeleton
  96956. */
  96957. get uniqueId(): number;
  96958. /**
  96959. * Creates a new skeleton
  96960. * @param name defines the skeleton name
  96961. * @param id defines the skeleton Id
  96962. * @param scene defines the hosting scene
  96963. */
  96964. constructor(
  96965. /** defines the skeleton name */
  96966. name: string,
  96967. /** defines the skeleton Id */
  96968. id: string, scene: Scene);
  96969. /**
  96970. * Gets the current object class name.
  96971. * @return the class name
  96972. */
  96973. getClassName(): string;
  96974. /**
  96975. * Returns an array containing the root bones
  96976. * @returns an array containing the root bones
  96977. */
  96978. getChildren(): Array<Bone>;
  96979. /**
  96980. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96981. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96982. * @returns a Float32Array containing matrices data
  96983. */
  96984. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96985. /**
  96986. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96987. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96988. * @returns a raw texture containing the data
  96989. */
  96990. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96991. /**
  96992. * Gets the current hosting scene
  96993. * @returns a scene object
  96994. */
  96995. getScene(): Scene;
  96996. /**
  96997. * Gets a string representing the current skeleton data
  96998. * @param fullDetails defines a boolean indicating if we want a verbose version
  96999. * @returns a string representing the current skeleton data
  97000. */
  97001. toString(fullDetails?: boolean): string;
  97002. /**
  97003. * Get bone's index searching by name
  97004. * @param name defines bone's name to search for
  97005. * @return the indice of the bone. Returns -1 if not found
  97006. */
  97007. getBoneIndexByName(name: string): number;
  97008. /**
  97009. * Creater a new animation range
  97010. * @param name defines the name of the range
  97011. * @param from defines the start key
  97012. * @param to defines the end key
  97013. */
  97014. createAnimationRange(name: string, from: number, to: number): void;
  97015. /**
  97016. * Delete a specific animation range
  97017. * @param name defines the name of the range
  97018. * @param deleteFrames defines if frames must be removed as well
  97019. */
  97020. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97021. /**
  97022. * Gets a specific animation range
  97023. * @param name defines the name of the range to look for
  97024. * @returns the requested animation range or null if not found
  97025. */
  97026. getAnimationRange(name: string): Nullable<AnimationRange>;
  97027. /**
  97028. * Gets the list of all animation ranges defined on this skeleton
  97029. * @returns an array
  97030. */
  97031. getAnimationRanges(): Nullable<AnimationRange>[];
  97032. /**
  97033. * Copy animation range from a source skeleton.
  97034. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  97035. * @param source defines the source skeleton
  97036. * @param name defines the name of the range to copy
  97037. * @param rescaleAsRequired defines if rescaling must be applied if required
  97038. * @returns true if operation was successful
  97039. */
  97040. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  97041. /**
  97042. * Forces the skeleton to go to rest pose
  97043. */
  97044. returnToRest(): void;
  97045. private _getHighestAnimationFrame;
  97046. /**
  97047. * Begin a specific animation range
  97048. * @param name defines the name of the range to start
  97049. * @param loop defines if looping must be turned on (false by default)
  97050. * @param speedRatio defines the speed ratio to apply (1 by default)
  97051. * @param onAnimationEnd defines a callback which will be called when animation will end
  97052. * @returns a new animatable
  97053. */
  97054. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97055. /**
  97056. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  97057. * @param skeleton defines the Skeleton containing the animation range to convert
  97058. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  97059. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  97060. * @returns the original skeleton
  97061. */
  97062. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  97063. /** @hidden */
  97064. _markAsDirty(): void;
  97065. /** @hidden */
  97066. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97067. /** @hidden */
  97068. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97069. private _computeTransformMatrices;
  97070. /**
  97071. * Build all resources required to render a skeleton
  97072. */
  97073. prepare(): void;
  97074. /**
  97075. * Gets the list of animatables currently running for this skeleton
  97076. * @returns an array of animatables
  97077. */
  97078. getAnimatables(): IAnimatable[];
  97079. /**
  97080. * Clone the current skeleton
  97081. * @param name defines the name of the new skeleton
  97082. * @param id defines the id of the new skeleton
  97083. * @returns the new skeleton
  97084. */
  97085. clone(name: string, id?: string): Skeleton;
  97086. /**
  97087. * Enable animation blending for this skeleton
  97088. * @param blendingSpeed defines the blending speed to apply
  97089. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97090. */
  97091. enableBlending(blendingSpeed?: number): void;
  97092. /**
  97093. * Releases all resources associated with the current skeleton
  97094. */
  97095. dispose(): void;
  97096. /**
  97097. * Serialize the skeleton in a JSON object
  97098. * @returns a JSON object
  97099. */
  97100. serialize(): any;
  97101. /**
  97102. * Creates a new skeleton from serialized data
  97103. * @param parsedSkeleton defines the serialized data
  97104. * @param scene defines the hosting scene
  97105. * @returns a new skeleton
  97106. */
  97107. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  97108. /**
  97109. * Compute all node absolute transforms
  97110. * @param forceUpdate defines if computation must be done even if cache is up to date
  97111. */
  97112. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  97113. /**
  97114. * Gets the root pose matrix
  97115. * @returns a matrix
  97116. */
  97117. getPoseMatrix(): Nullable<Matrix>;
  97118. /**
  97119. * Sorts bones per internal index
  97120. */
  97121. sortBones(): void;
  97122. private _sortBones;
  97123. /**
  97124. * Set the current local matrix as the restPose for all bones in the skeleton.
  97125. */
  97126. setCurrentPoseAsRest(): void;
  97127. }
  97128. }
  97129. declare module BABYLON {
  97130. /**
  97131. * Creates an instance based on a source mesh.
  97132. */
  97133. export class InstancedMesh extends AbstractMesh {
  97134. private _sourceMesh;
  97135. private _currentLOD;
  97136. /** @hidden */
  97137. _indexInSourceMeshInstanceArray: number;
  97138. constructor(name: string, source: Mesh);
  97139. /**
  97140. * Returns the string "InstancedMesh".
  97141. */
  97142. getClassName(): string;
  97143. /** Gets the list of lights affecting that mesh */
  97144. get lightSources(): Light[];
  97145. _resyncLightSources(): void;
  97146. _resyncLightSource(light: Light): void;
  97147. _removeLightSource(light: Light, dispose: boolean): void;
  97148. /**
  97149. * If the source mesh receives shadows
  97150. */
  97151. get receiveShadows(): boolean;
  97152. /**
  97153. * The material of the source mesh
  97154. */
  97155. get material(): Nullable<Material>;
  97156. /**
  97157. * Visibility of the source mesh
  97158. */
  97159. get visibility(): number;
  97160. /**
  97161. * Skeleton of the source mesh
  97162. */
  97163. get skeleton(): Nullable<Skeleton>;
  97164. /**
  97165. * Rendering ground id of the source mesh
  97166. */
  97167. get renderingGroupId(): number;
  97168. set renderingGroupId(value: number);
  97169. /**
  97170. * Returns the total number of vertices (integer).
  97171. */
  97172. getTotalVertices(): number;
  97173. /**
  97174. * Returns a positive integer : the total number of indices in this mesh geometry.
  97175. * @returns the numner of indices or zero if the mesh has no geometry.
  97176. */
  97177. getTotalIndices(): number;
  97178. /**
  97179. * The source mesh of the instance
  97180. */
  97181. get sourceMesh(): Mesh;
  97182. /**
  97183. * Creates a new InstancedMesh object from the mesh model.
  97184. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97185. * @param name defines the name of the new instance
  97186. * @returns a new InstancedMesh
  97187. */
  97188. createInstance(name: string): InstancedMesh;
  97189. /**
  97190. * Is this node ready to be used/rendered
  97191. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97192. * @return {boolean} is it ready
  97193. */
  97194. isReady(completeCheck?: boolean): boolean;
  97195. /**
  97196. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97197. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97198. * @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.
  97199. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97200. */
  97201. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97202. /**
  97203. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97204. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97205. * The `data` are either a numeric array either a Float32Array.
  97206. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97207. * 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).
  97208. * Note that a new underlying VertexBuffer object is created each call.
  97209. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97210. *
  97211. * Possible `kind` values :
  97212. * - VertexBuffer.PositionKind
  97213. * - VertexBuffer.UVKind
  97214. * - VertexBuffer.UV2Kind
  97215. * - VertexBuffer.UV3Kind
  97216. * - VertexBuffer.UV4Kind
  97217. * - VertexBuffer.UV5Kind
  97218. * - VertexBuffer.UV6Kind
  97219. * - VertexBuffer.ColorKind
  97220. * - VertexBuffer.MatricesIndicesKind
  97221. * - VertexBuffer.MatricesIndicesExtraKind
  97222. * - VertexBuffer.MatricesWeightsKind
  97223. * - VertexBuffer.MatricesWeightsExtraKind
  97224. *
  97225. * Returns the Mesh.
  97226. */
  97227. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97228. /**
  97229. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97230. * If the mesh has no geometry, it is simply returned as it is.
  97231. * The `data` are either a numeric array either a Float32Array.
  97232. * No new underlying VertexBuffer object is created.
  97233. * 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.
  97234. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97235. *
  97236. * Possible `kind` values :
  97237. * - VertexBuffer.PositionKind
  97238. * - VertexBuffer.UVKind
  97239. * - VertexBuffer.UV2Kind
  97240. * - VertexBuffer.UV3Kind
  97241. * - VertexBuffer.UV4Kind
  97242. * - VertexBuffer.UV5Kind
  97243. * - VertexBuffer.UV6Kind
  97244. * - VertexBuffer.ColorKind
  97245. * - VertexBuffer.MatricesIndicesKind
  97246. * - VertexBuffer.MatricesIndicesExtraKind
  97247. * - VertexBuffer.MatricesWeightsKind
  97248. * - VertexBuffer.MatricesWeightsExtraKind
  97249. *
  97250. * Returns the Mesh.
  97251. */
  97252. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97253. /**
  97254. * Sets the mesh indices.
  97255. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97256. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97257. * This method creates a new index buffer each call.
  97258. * Returns the Mesh.
  97259. */
  97260. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97261. /**
  97262. * Boolean : True if the mesh owns the requested kind of data.
  97263. */
  97264. isVerticesDataPresent(kind: string): boolean;
  97265. /**
  97266. * Returns an array of indices (IndicesArray).
  97267. */
  97268. getIndices(): Nullable<IndicesArray>;
  97269. get _positions(): Nullable<Vector3[]>;
  97270. /**
  97271. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97272. * This means the mesh underlying bounding box and sphere are recomputed.
  97273. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97274. * @returns the current mesh
  97275. */
  97276. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97277. /** @hidden */
  97278. _preActivate(): InstancedMesh;
  97279. /** @hidden */
  97280. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97281. /** @hidden */
  97282. _postActivate(): void;
  97283. getWorldMatrix(): Matrix;
  97284. get isAnInstance(): boolean;
  97285. /**
  97286. * Returns the current associated LOD AbstractMesh.
  97287. */
  97288. getLOD(camera: Camera): AbstractMesh;
  97289. /** @hidden */
  97290. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97291. /** @hidden */
  97292. _syncSubMeshes(): InstancedMesh;
  97293. /** @hidden */
  97294. _generatePointsArray(): boolean;
  97295. /** @hidden */
  97296. _updateBoundingInfo(): AbstractMesh;
  97297. /**
  97298. * Creates a new InstancedMesh from the current mesh.
  97299. * - name (string) : the cloned mesh name
  97300. * - newParent (optional Node) : the optional Node to parent the clone to.
  97301. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97302. *
  97303. * Returns the clone.
  97304. */
  97305. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97306. /**
  97307. * Disposes the InstancedMesh.
  97308. * Returns nothing.
  97309. */
  97310. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97311. }
  97312. interface Mesh {
  97313. /**
  97314. * Register a custom buffer that will be instanced
  97315. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97316. * @param kind defines the buffer kind
  97317. * @param stride defines the stride in floats
  97318. */
  97319. registerInstancedBuffer(kind: string, stride: number): void;
  97320. /**
  97321. * true to use the edge renderer for all instances of this mesh
  97322. */
  97323. edgesShareWithInstances: boolean;
  97324. /** @hidden */
  97325. _userInstancedBuffersStorage: {
  97326. data: {
  97327. [key: string]: Float32Array;
  97328. };
  97329. sizes: {
  97330. [key: string]: number;
  97331. };
  97332. vertexBuffers: {
  97333. [key: string]: Nullable<VertexBuffer>;
  97334. };
  97335. strides: {
  97336. [key: string]: number;
  97337. };
  97338. };
  97339. }
  97340. interface AbstractMesh {
  97341. /**
  97342. * Object used to store instanced buffers defined by user
  97343. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97344. */
  97345. instancedBuffers: {
  97346. [key: string]: any;
  97347. };
  97348. }
  97349. }
  97350. declare module BABYLON {
  97351. /**
  97352. * Defines the options associated with the creation of a shader material.
  97353. */
  97354. export interface IShaderMaterialOptions {
  97355. /**
  97356. * Does the material work in alpha blend mode
  97357. */
  97358. needAlphaBlending: boolean;
  97359. /**
  97360. * Does the material work in alpha test mode
  97361. */
  97362. needAlphaTesting: boolean;
  97363. /**
  97364. * The list of attribute names used in the shader
  97365. */
  97366. attributes: string[];
  97367. /**
  97368. * The list of unifrom names used in the shader
  97369. */
  97370. uniforms: string[];
  97371. /**
  97372. * The list of UBO names used in the shader
  97373. */
  97374. uniformBuffers: string[];
  97375. /**
  97376. * The list of sampler names used in the shader
  97377. */
  97378. samplers: string[];
  97379. /**
  97380. * The list of defines used in the shader
  97381. */
  97382. defines: string[];
  97383. }
  97384. /**
  97385. * 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.
  97386. *
  97387. * This returned material effects how the mesh will look based on the code in the shaders.
  97388. *
  97389. * @see https://doc.babylonjs.com/how_to/shader_material
  97390. */
  97391. export class ShaderMaterial extends Material {
  97392. private _shaderPath;
  97393. private _options;
  97394. private _textures;
  97395. private _textureArrays;
  97396. private _floats;
  97397. private _ints;
  97398. private _floatsArrays;
  97399. private _colors3;
  97400. private _colors3Arrays;
  97401. private _colors4;
  97402. private _colors4Arrays;
  97403. private _vectors2;
  97404. private _vectors3;
  97405. private _vectors4;
  97406. private _matrices;
  97407. private _matrixArrays;
  97408. private _matrices3x3;
  97409. private _matrices2x2;
  97410. private _vectors2Arrays;
  97411. private _vectors3Arrays;
  97412. private _vectors4Arrays;
  97413. private _cachedWorldViewMatrix;
  97414. private _cachedWorldViewProjectionMatrix;
  97415. private _renderId;
  97416. private _multiview;
  97417. private _cachedDefines;
  97418. /** Define the Url to load snippets */
  97419. static SnippetUrl: string;
  97420. /** Snippet ID if the material was created from the snippet server */
  97421. snippetId: string;
  97422. /**
  97423. * Instantiate a new shader material.
  97424. * 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.
  97425. * This returned material effects how the mesh will look based on the code in the shaders.
  97426. * @see https://doc.babylonjs.com/how_to/shader_material
  97427. * @param name Define the name of the material in the scene
  97428. * @param scene Define the scene the material belongs to
  97429. * @param shaderPath Defines the route to the shader code in one of three ways:
  97430. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97431. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97432. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97433. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97434. * @param options Define the options used to create the shader
  97435. */
  97436. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97437. /**
  97438. * Gets the shader path used to define the shader code
  97439. * It can be modified to trigger a new compilation
  97440. */
  97441. get shaderPath(): any;
  97442. /**
  97443. * Sets the shader path used to define the shader code
  97444. * It can be modified to trigger a new compilation
  97445. */
  97446. set shaderPath(shaderPath: any);
  97447. /**
  97448. * Gets the options used to compile the shader.
  97449. * They can be modified to trigger a new compilation
  97450. */
  97451. get options(): IShaderMaterialOptions;
  97452. /**
  97453. * Gets the current class name of the material e.g. "ShaderMaterial"
  97454. * Mainly use in serialization.
  97455. * @returns the class name
  97456. */
  97457. getClassName(): string;
  97458. /**
  97459. * Specifies if the material will require alpha blending
  97460. * @returns a boolean specifying if alpha blending is needed
  97461. */
  97462. needAlphaBlending(): boolean;
  97463. /**
  97464. * Specifies if this material should be rendered in alpha test mode
  97465. * @returns a boolean specifying if an alpha test is needed.
  97466. */
  97467. needAlphaTesting(): boolean;
  97468. private _checkUniform;
  97469. /**
  97470. * Set a texture in the shader.
  97471. * @param name Define the name of the uniform samplers as defined in the shader
  97472. * @param texture Define the texture to bind to this sampler
  97473. * @return the material itself allowing "fluent" like uniform updates
  97474. */
  97475. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97476. /**
  97477. * Set a texture array in the shader.
  97478. * @param name Define the name of the uniform sampler array as defined in the shader
  97479. * @param textures Define the list of textures to bind to this sampler
  97480. * @return the material itself allowing "fluent" like uniform updates
  97481. */
  97482. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97483. /**
  97484. * Set a float in the shader.
  97485. * @param name Define the name of the uniform as defined in the shader
  97486. * @param value Define the value to give to the uniform
  97487. * @return the material itself allowing "fluent" like uniform updates
  97488. */
  97489. setFloat(name: string, value: number): ShaderMaterial;
  97490. /**
  97491. * Set a int in the shader.
  97492. * @param name Define the name of the uniform as defined in the shader
  97493. * @param value Define the value to give to the uniform
  97494. * @return the material itself allowing "fluent" like uniform updates
  97495. */
  97496. setInt(name: string, value: number): ShaderMaterial;
  97497. /**
  97498. * Set an array of floats in the shader.
  97499. * @param name Define the name of the uniform as defined in the shader
  97500. * @param value Define the value to give to the uniform
  97501. * @return the material itself allowing "fluent" like uniform updates
  97502. */
  97503. setFloats(name: string, value: number[]): ShaderMaterial;
  97504. /**
  97505. * Set a vec3 in the shader from a Color3.
  97506. * @param name Define the name of the uniform as defined in the shader
  97507. * @param value Define the value to give to the uniform
  97508. * @return the material itself allowing "fluent" like uniform updates
  97509. */
  97510. setColor3(name: string, value: Color3): ShaderMaterial;
  97511. /**
  97512. * Set a vec3 array in the shader from a Color3 array.
  97513. * @param name Define the name of the uniform as defined in the shader
  97514. * @param value Define the value to give to the uniform
  97515. * @return the material itself allowing "fluent" like uniform updates
  97516. */
  97517. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97518. /**
  97519. * Set a vec4 in the shader from a Color4.
  97520. * @param name Define the name of the uniform as defined in the shader
  97521. * @param value Define the value to give to the uniform
  97522. * @return the material itself allowing "fluent" like uniform updates
  97523. */
  97524. setColor4(name: string, value: Color4): ShaderMaterial;
  97525. /**
  97526. * Set a vec4 array in the shader from a Color4 array.
  97527. * @param name Define the name of the uniform as defined in the shader
  97528. * @param value Define the value to give to the uniform
  97529. * @return the material itself allowing "fluent" like uniform updates
  97530. */
  97531. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97532. /**
  97533. * Set a vec2 in the shader from a Vector2.
  97534. * @param name Define the name of the uniform as defined in the shader
  97535. * @param value Define the value to give to the uniform
  97536. * @return the material itself allowing "fluent" like uniform updates
  97537. */
  97538. setVector2(name: string, value: Vector2): ShaderMaterial;
  97539. /**
  97540. * Set a vec3 in the shader from a Vector3.
  97541. * @param name Define the name of the uniform as defined in the shader
  97542. * @param value Define the value to give to the uniform
  97543. * @return the material itself allowing "fluent" like uniform updates
  97544. */
  97545. setVector3(name: string, value: Vector3): ShaderMaterial;
  97546. /**
  97547. * Set a vec4 in the shader from a Vector4.
  97548. * @param name Define the name of the uniform as defined in the shader
  97549. * @param value Define the value to give to the uniform
  97550. * @return the material itself allowing "fluent" like uniform updates
  97551. */
  97552. setVector4(name: string, value: Vector4): ShaderMaterial;
  97553. /**
  97554. * Set a mat4 in the shader from a Matrix.
  97555. * @param name Define the name of the uniform as defined in the shader
  97556. * @param value Define the value to give to the uniform
  97557. * @return the material itself allowing "fluent" like uniform updates
  97558. */
  97559. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97560. /**
  97561. * Set a float32Array in the shader from a matrix array.
  97562. * @param name Define the name of the uniform as defined in the shader
  97563. * @param value Define the value to give to the uniform
  97564. * @return the material itself allowing "fluent" like uniform updates
  97565. */
  97566. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97567. /**
  97568. * Set a mat3 in the shader from a Float32Array.
  97569. * @param name Define the name of the uniform as defined in the shader
  97570. * @param value Define the value to give to the uniform
  97571. * @return the material itself allowing "fluent" like uniform updates
  97572. */
  97573. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97574. /**
  97575. * Set a mat2 in the shader from a Float32Array.
  97576. * @param name Define the name of the uniform as defined in the shader
  97577. * @param value Define the value to give to the uniform
  97578. * @return the material itself allowing "fluent" like uniform updates
  97579. */
  97580. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97581. /**
  97582. * Set a vec2 array in the shader from a number array.
  97583. * @param name Define the name of the uniform as defined in the shader
  97584. * @param value Define the value to give to the uniform
  97585. * @return the material itself allowing "fluent" like uniform updates
  97586. */
  97587. setArray2(name: string, value: number[]): ShaderMaterial;
  97588. /**
  97589. * Set a vec3 array in the shader from a number array.
  97590. * @param name Define the name of the uniform as defined in the shader
  97591. * @param value Define the value to give to the uniform
  97592. * @return the material itself allowing "fluent" like uniform updates
  97593. */
  97594. setArray3(name: string, value: number[]): ShaderMaterial;
  97595. /**
  97596. * Set a vec4 array in the shader from a number array.
  97597. * @param name Define the name of the uniform as defined in the shader
  97598. * @param value Define the value to give to the uniform
  97599. * @return the material itself allowing "fluent" like uniform updates
  97600. */
  97601. setArray4(name: string, value: number[]): ShaderMaterial;
  97602. private _checkCache;
  97603. /**
  97604. * Specifies that the submesh is ready to be used
  97605. * @param mesh defines the mesh to check
  97606. * @param subMesh defines which submesh to check
  97607. * @param useInstances specifies that instances should be used
  97608. * @returns a boolean indicating that the submesh is ready or not
  97609. */
  97610. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97611. /**
  97612. * Checks if the material is ready to render the requested mesh
  97613. * @param mesh Define the mesh to render
  97614. * @param useInstances Define whether or not the material is used with instances
  97615. * @returns true if ready, otherwise false
  97616. */
  97617. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97618. /**
  97619. * Binds the world matrix to the material
  97620. * @param world defines the world transformation matrix
  97621. * @param effectOverride - If provided, use this effect instead of internal effect
  97622. */
  97623. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97624. /**
  97625. * Binds the submesh to this material by preparing the effect and shader to draw
  97626. * @param world defines the world transformation matrix
  97627. * @param mesh defines the mesh containing the submesh
  97628. * @param subMesh defines the submesh to bind the material to
  97629. */
  97630. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97631. /**
  97632. * Binds the material to the mesh
  97633. * @param world defines the world transformation matrix
  97634. * @param mesh defines the mesh to bind the material to
  97635. * @param effectOverride - If provided, use this effect instead of internal effect
  97636. */
  97637. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97638. protected _afterBind(mesh?: Mesh): void;
  97639. /**
  97640. * Gets the active textures from the material
  97641. * @returns an array of textures
  97642. */
  97643. getActiveTextures(): BaseTexture[];
  97644. /**
  97645. * Specifies if the material uses a texture
  97646. * @param texture defines the texture to check against the material
  97647. * @returns a boolean specifying if the material uses the texture
  97648. */
  97649. hasTexture(texture: BaseTexture): boolean;
  97650. /**
  97651. * Makes a duplicate of the material, and gives it a new name
  97652. * @param name defines the new name for the duplicated material
  97653. * @returns the cloned material
  97654. */
  97655. clone(name: string): ShaderMaterial;
  97656. /**
  97657. * Disposes the material
  97658. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97659. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97660. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97661. */
  97662. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97663. /**
  97664. * Serializes this material in a JSON representation
  97665. * @returns the serialized material object
  97666. */
  97667. serialize(): any;
  97668. /**
  97669. * Creates a shader material from parsed shader material data
  97670. * @param source defines the JSON represnetation of the material
  97671. * @param scene defines the hosting scene
  97672. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97673. * @returns a new material
  97674. */
  97675. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97676. /**
  97677. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97678. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97679. * @param url defines the url to load from
  97680. * @param scene defines the hosting scene
  97681. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97682. * @returns a promise that will resolve to the new ShaderMaterial
  97683. */
  97684. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97685. /**
  97686. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97687. * @param snippetId defines the snippet to load
  97688. * @param scene defines the hosting scene
  97689. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97690. * @returns a promise that will resolve to the new ShaderMaterial
  97691. */
  97692. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97693. }
  97694. }
  97695. declare module BABYLON {
  97696. /** @hidden */
  97697. export var colorPixelShader: {
  97698. name: string;
  97699. shader: string;
  97700. };
  97701. }
  97702. declare module BABYLON {
  97703. /** @hidden */
  97704. export var colorVertexShader: {
  97705. name: string;
  97706. shader: string;
  97707. };
  97708. }
  97709. declare module BABYLON {
  97710. /**
  97711. * Line mesh
  97712. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97713. */
  97714. export class LinesMesh extends Mesh {
  97715. /**
  97716. * If vertex color should be applied to the mesh
  97717. */
  97718. readonly useVertexColor?: boolean | undefined;
  97719. /**
  97720. * If vertex alpha should be applied to the mesh
  97721. */
  97722. readonly useVertexAlpha?: boolean | undefined;
  97723. /**
  97724. * Color of the line (Default: White)
  97725. */
  97726. color: Color3;
  97727. /**
  97728. * Alpha of the line (Default: 1)
  97729. */
  97730. alpha: number;
  97731. /**
  97732. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97733. * This margin is expressed in world space coordinates, so its value may vary.
  97734. * Default value is 0.1
  97735. */
  97736. intersectionThreshold: number;
  97737. private _colorShader;
  97738. private color4;
  97739. /**
  97740. * Creates a new LinesMesh
  97741. * @param name defines the name
  97742. * @param scene defines the hosting scene
  97743. * @param parent defines the parent mesh if any
  97744. * @param source defines the optional source LinesMesh used to clone data from
  97745. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97746. * When false, achieved by calling a clone(), also passing False.
  97747. * This will make creation of children, recursive.
  97748. * @param useVertexColor defines if this LinesMesh supports vertex color
  97749. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97750. */
  97751. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97752. /**
  97753. * If vertex color should be applied to the mesh
  97754. */
  97755. useVertexColor?: boolean | undefined,
  97756. /**
  97757. * If vertex alpha should be applied to the mesh
  97758. */
  97759. useVertexAlpha?: boolean | undefined);
  97760. private _addClipPlaneDefine;
  97761. private _removeClipPlaneDefine;
  97762. isReady(): boolean;
  97763. /**
  97764. * Returns the string "LineMesh"
  97765. */
  97766. getClassName(): string;
  97767. /**
  97768. * @hidden
  97769. */
  97770. get material(): Material;
  97771. /**
  97772. * @hidden
  97773. */
  97774. set material(value: Material);
  97775. /**
  97776. * @hidden
  97777. */
  97778. get checkCollisions(): boolean;
  97779. /** @hidden */
  97780. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97781. /** @hidden */
  97782. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97783. /**
  97784. * Disposes of the line mesh
  97785. * @param doNotRecurse If children should be disposed
  97786. */
  97787. dispose(doNotRecurse?: boolean): void;
  97788. /**
  97789. * Returns a new LineMesh object cloned from the current one.
  97790. */
  97791. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97792. /**
  97793. * Creates a new InstancedLinesMesh object from the mesh model.
  97794. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97795. * @param name defines the name of the new instance
  97796. * @returns a new InstancedLinesMesh
  97797. */
  97798. createInstance(name: string): InstancedLinesMesh;
  97799. }
  97800. /**
  97801. * Creates an instance based on a source LinesMesh
  97802. */
  97803. export class InstancedLinesMesh extends InstancedMesh {
  97804. /**
  97805. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97806. * This margin is expressed in world space coordinates, so its value may vary.
  97807. * Initilized with the intersectionThreshold value of the source LinesMesh
  97808. */
  97809. intersectionThreshold: number;
  97810. constructor(name: string, source: LinesMesh);
  97811. /**
  97812. * Returns the string "InstancedLinesMesh".
  97813. */
  97814. getClassName(): string;
  97815. }
  97816. }
  97817. declare module BABYLON {
  97818. /** @hidden */
  97819. export var linePixelShader: {
  97820. name: string;
  97821. shader: string;
  97822. };
  97823. }
  97824. declare module BABYLON {
  97825. /** @hidden */
  97826. export var lineVertexShader: {
  97827. name: string;
  97828. shader: string;
  97829. };
  97830. }
  97831. declare module BABYLON {
  97832. interface Scene {
  97833. /** @hidden */
  97834. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97835. }
  97836. interface AbstractMesh {
  97837. /**
  97838. * Gets the edgesRenderer associated with the mesh
  97839. */
  97840. edgesRenderer: Nullable<EdgesRenderer>;
  97841. }
  97842. interface LinesMesh {
  97843. /**
  97844. * Enables the edge rendering mode on the mesh.
  97845. * This mode makes the mesh edges visible
  97846. * @param epsilon defines the maximal distance between two angles to detect a face
  97847. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97848. * @returns the currentAbstractMesh
  97849. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97850. */
  97851. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97852. }
  97853. interface InstancedLinesMesh {
  97854. /**
  97855. * Enables the edge rendering mode on the mesh.
  97856. * This mode makes the mesh edges visible
  97857. * @param epsilon defines the maximal distance between two angles to detect a face
  97858. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97859. * @returns the current InstancedLinesMesh
  97860. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97861. */
  97862. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97863. }
  97864. /**
  97865. * Defines the minimum contract an Edges renderer should follow.
  97866. */
  97867. export interface IEdgesRenderer extends IDisposable {
  97868. /**
  97869. * Gets or sets a boolean indicating if the edgesRenderer is active
  97870. */
  97871. isEnabled: boolean;
  97872. /**
  97873. * Renders the edges of the attached mesh,
  97874. */
  97875. render(): void;
  97876. /**
  97877. * Checks wether or not the edges renderer is ready to render.
  97878. * @return true if ready, otherwise false.
  97879. */
  97880. isReady(): boolean;
  97881. /**
  97882. * List of instances to render in case the source mesh has instances
  97883. */
  97884. customInstances: SmartArray<Matrix>;
  97885. }
  97886. /**
  97887. * Defines the additional options of the edges renderer
  97888. */
  97889. export interface IEdgesRendererOptions {
  97890. /**
  97891. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97892. * If not defined, the default value is true
  97893. */
  97894. useAlternateEdgeFinder?: boolean;
  97895. /**
  97896. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97897. * If not defined, the default value is true.
  97898. * 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)
  97899. * This option is used only if useAlternateEdgeFinder = true
  97900. */
  97901. useFastVertexMerger?: boolean;
  97902. /**
  97903. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97904. * The default value is 1e-6
  97905. * This option is used only if useAlternateEdgeFinder = true
  97906. */
  97907. epsilonVertexMerge?: number;
  97908. /**
  97909. * 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
  97910. * 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.
  97911. * This option is used only if useAlternateEdgeFinder = true
  97912. */
  97913. applyTessellation?: boolean;
  97914. /**
  97915. * 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
  97916. * The default value is 1e-6
  97917. * This option is used only if useAlternateEdgeFinder = true
  97918. */
  97919. epsilonVertexAligned?: number;
  97920. }
  97921. /**
  97922. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97923. */
  97924. export class EdgesRenderer implements IEdgesRenderer {
  97925. /**
  97926. * Define the size of the edges with an orthographic camera
  97927. */
  97928. edgesWidthScalerForOrthographic: number;
  97929. /**
  97930. * Define the size of the edges with a perspective camera
  97931. */
  97932. edgesWidthScalerForPerspective: number;
  97933. protected _source: AbstractMesh;
  97934. protected _linesPositions: number[];
  97935. protected _linesNormals: number[];
  97936. protected _linesIndices: number[];
  97937. protected _epsilon: number;
  97938. protected _indicesCount: number;
  97939. protected _lineShader: ShaderMaterial;
  97940. protected _ib: DataBuffer;
  97941. protected _buffers: {
  97942. [key: string]: Nullable<VertexBuffer>;
  97943. };
  97944. protected _buffersForInstances: {
  97945. [key: string]: Nullable<VertexBuffer>;
  97946. };
  97947. protected _checkVerticesInsteadOfIndices: boolean;
  97948. protected _options: Nullable<IEdgesRendererOptions>;
  97949. private _meshRebuildObserver;
  97950. private _meshDisposeObserver;
  97951. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97952. isEnabled: boolean;
  97953. /**
  97954. * List of instances to render in case the source mesh has instances
  97955. */
  97956. customInstances: SmartArray<Matrix>;
  97957. private static GetShader;
  97958. /**
  97959. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97960. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97961. * @param source Mesh used to create edges
  97962. * @param epsilon sum of angles in adjacency to check for edge
  97963. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97964. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97965. * @param options The options to apply when generating the edges
  97966. */
  97967. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97968. protected _prepareRessources(): void;
  97969. /** @hidden */
  97970. _rebuild(): void;
  97971. /**
  97972. * Releases the required resources for the edges renderer
  97973. */
  97974. dispose(): void;
  97975. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97976. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97977. /**
  97978. * Checks if the pair of p0 and p1 is en edge
  97979. * @param faceIndex
  97980. * @param edge
  97981. * @param faceNormals
  97982. * @param p0
  97983. * @param p1
  97984. * @private
  97985. */
  97986. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97987. /**
  97988. * push line into the position, normal and index buffer
  97989. * @protected
  97990. */
  97991. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97992. /**
  97993. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97994. */
  97995. private _tessellateTriangle;
  97996. private _generateEdgesLinesAlternate;
  97997. /**
  97998. * Generates lines edges from adjacencjes
  97999. * @private
  98000. */
  98001. _generateEdgesLines(): void;
  98002. /**
  98003. * Checks wether or not the edges renderer is ready to render.
  98004. * @return true if ready, otherwise false.
  98005. */
  98006. isReady(): boolean;
  98007. /**
  98008. * Renders the edges of the attached mesh,
  98009. */
  98010. render(): void;
  98011. }
  98012. /**
  98013. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  98014. */
  98015. export class LineEdgesRenderer extends EdgesRenderer {
  98016. /**
  98017. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  98018. * @param source LineMesh used to generate edges
  98019. * @param epsilon not important (specified angle for edge detection)
  98020. * @param checkVerticesInsteadOfIndices not important for LineMesh
  98021. */
  98022. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  98023. /**
  98024. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  98025. */
  98026. _generateEdgesLines(): void;
  98027. }
  98028. }
  98029. declare module BABYLON {
  98030. /**
  98031. * This represents the object necessary to create a rendering group.
  98032. * This is exclusively used and created by the rendering manager.
  98033. * To modify the behavior, you use the available helpers in your scene or meshes.
  98034. * @hidden
  98035. */
  98036. export class RenderingGroup {
  98037. index: number;
  98038. private static _zeroVector;
  98039. private _scene;
  98040. private _opaqueSubMeshes;
  98041. private _transparentSubMeshes;
  98042. private _alphaTestSubMeshes;
  98043. private _depthOnlySubMeshes;
  98044. private _particleSystems;
  98045. private _spriteManagers;
  98046. private _opaqueSortCompareFn;
  98047. private _alphaTestSortCompareFn;
  98048. private _transparentSortCompareFn;
  98049. private _renderOpaque;
  98050. private _renderAlphaTest;
  98051. private _renderTransparent;
  98052. /** @hidden */
  98053. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  98054. onBeforeTransparentRendering: () => void;
  98055. /**
  98056. * Set the opaque sort comparison function.
  98057. * If null the sub meshes will be render in the order they were created
  98058. */
  98059. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98060. /**
  98061. * Set the alpha test sort comparison function.
  98062. * If null the sub meshes will be render in the order they were created
  98063. */
  98064. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98065. /**
  98066. * Set the transparent sort comparison function.
  98067. * If null the sub meshes will be render in the order they were created
  98068. */
  98069. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98070. /**
  98071. * Creates a new rendering group.
  98072. * @param index The rendering group index
  98073. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  98074. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  98075. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  98076. */
  98077. 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>);
  98078. /**
  98079. * Render all the sub meshes contained in the group.
  98080. * @param customRenderFunction Used to override the default render behaviour of the group.
  98081. * @returns true if rendered some submeshes.
  98082. */
  98083. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  98084. /**
  98085. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  98086. * @param subMeshes The submeshes to render
  98087. */
  98088. private renderOpaqueSorted;
  98089. /**
  98090. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  98091. * @param subMeshes The submeshes to render
  98092. */
  98093. private renderAlphaTestSorted;
  98094. /**
  98095. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  98096. * @param subMeshes The submeshes to render
  98097. */
  98098. private renderTransparentSorted;
  98099. /**
  98100. * Renders the submeshes in a specified order.
  98101. * @param subMeshes The submeshes to sort before render
  98102. * @param sortCompareFn The comparison function use to sort
  98103. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  98104. * @param transparent Specifies to activate blending if true
  98105. */
  98106. private static renderSorted;
  98107. /**
  98108. * Renders the submeshes in the order they were dispatched (no sort applied).
  98109. * @param subMeshes The submeshes to render
  98110. */
  98111. private static renderUnsorted;
  98112. /**
  98113. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98114. * are rendered back to front if in the same alpha index.
  98115. *
  98116. * @param a The first submesh
  98117. * @param b The second submesh
  98118. * @returns The result of the comparison
  98119. */
  98120. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  98121. /**
  98122. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98123. * are rendered back to front.
  98124. *
  98125. * @param a The first submesh
  98126. * @param b The second submesh
  98127. * @returns The result of the comparison
  98128. */
  98129. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  98130. /**
  98131. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98132. * are rendered front to back (prevent overdraw).
  98133. *
  98134. * @param a The first submesh
  98135. * @param b The second submesh
  98136. * @returns The result of the comparison
  98137. */
  98138. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  98139. /**
  98140. * Resets the different lists of submeshes to prepare a new frame.
  98141. */
  98142. prepare(): void;
  98143. dispose(): void;
  98144. /**
  98145. * Inserts the submesh in its correct queue depending on its material.
  98146. * @param subMesh The submesh to dispatch
  98147. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98148. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98149. */
  98150. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98151. dispatchSprites(spriteManager: ISpriteManager): void;
  98152. dispatchParticles(particleSystem: IParticleSystem): void;
  98153. private _renderParticles;
  98154. private _renderSprites;
  98155. }
  98156. }
  98157. declare module BABYLON {
  98158. /**
  98159. * Interface describing the different options available in the rendering manager
  98160. * regarding Auto Clear between groups.
  98161. */
  98162. export interface IRenderingManagerAutoClearSetup {
  98163. /**
  98164. * Defines whether or not autoclear is enable.
  98165. */
  98166. autoClear: boolean;
  98167. /**
  98168. * Defines whether or not to autoclear the depth buffer.
  98169. */
  98170. depth: boolean;
  98171. /**
  98172. * Defines whether or not to autoclear the stencil buffer.
  98173. */
  98174. stencil: boolean;
  98175. }
  98176. /**
  98177. * This class is used by the onRenderingGroupObservable
  98178. */
  98179. export class RenderingGroupInfo {
  98180. /**
  98181. * The Scene that being rendered
  98182. */
  98183. scene: Scene;
  98184. /**
  98185. * The camera currently used for the rendering pass
  98186. */
  98187. camera: Nullable<Camera>;
  98188. /**
  98189. * The ID of the renderingGroup being processed
  98190. */
  98191. renderingGroupId: number;
  98192. }
  98193. /**
  98194. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98195. * It is enable to manage the different groups as well as the different necessary sort functions.
  98196. * This should not be used directly aside of the few static configurations
  98197. */
  98198. export class RenderingManager {
  98199. /**
  98200. * The max id used for rendering groups (not included)
  98201. */
  98202. static MAX_RENDERINGGROUPS: number;
  98203. /**
  98204. * The min id used for rendering groups (included)
  98205. */
  98206. static MIN_RENDERINGGROUPS: number;
  98207. /**
  98208. * Used to globally prevent autoclearing scenes.
  98209. */
  98210. static AUTOCLEAR: boolean;
  98211. /**
  98212. * @hidden
  98213. */
  98214. _useSceneAutoClearSetup: boolean;
  98215. private _scene;
  98216. private _renderingGroups;
  98217. private _depthStencilBufferAlreadyCleaned;
  98218. private _autoClearDepthStencil;
  98219. private _customOpaqueSortCompareFn;
  98220. private _customAlphaTestSortCompareFn;
  98221. private _customTransparentSortCompareFn;
  98222. private _renderingGroupInfo;
  98223. /**
  98224. * Instantiates a new rendering group for a particular scene
  98225. * @param scene Defines the scene the groups belongs to
  98226. */
  98227. constructor(scene: Scene);
  98228. private _clearDepthStencilBuffer;
  98229. /**
  98230. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98231. * @hidden
  98232. */
  98233. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98234. /**
  98235. * Resets the different information of the group to prepare a new frame
  98236. * @hidden
  98237. */
  98238. reset(): void;
  98239. /**
  98240. * Dispose and release the group and its associated resources.
  98241. * @hidden
  98242. */
  98243. dispose(): void;
  98244. /**
  98245. * Clear the info related to rendering groups preventing retention points during dispose.
  98246. */
  98247. freeRenderingGroups(): void;
  98248. private _prepareRenderingGroup;
  98249. /**
  98250. * Add a sprite manager to the rendering manager in order to render it this frame.
  98251. * @param spriteManager Define the sprite manager to render
  98252. */
  98253. dispatchSprites(spriteManager: ISpriteManager): void;
  98254. /**
  98255. * Add a particle system to the rendering manager in order to render it this frame.
  98256. * @param particleSystem Define the particle system to render
  98257. */
  98258. dispatchParticles(particleSystem: IParticleSystem): void;
  98259. /**
  98260. * Add a submesh to the manager in order to render it this frame
  98261. * @param subMesh The submesh to dispatch
  98262. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98263. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98264. */
  98265. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98266. /**
  98267. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98268. * This allowed control for front to back rendering or reversly depending of the special needs.
  98269. *
  98270. * @param renderingGroupId The rendering group id corresponding to its index
  98271. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98272. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98273. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98274. */
  98275. 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;
  98276. /**
  98277. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98278. *
  98279. * @param renderingGroupId The rendering group id corresponding to its index
  98280. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98281. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98282. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98283. */
  98284. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98285. /**
  98286. * Gets the current auto clear configuration for one rendering group of the rendering
  98287. * manager.
  98288. * @param index the rendering group index to get the information for
  98289. * @returns The auto clear setup for the requested rendering group
  98290. */
  98291. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98292. }
  98293. }
  98294. declare module BABYLON {
  98295. /**
  98296. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98297. */
  98298. export interface ICustomShaderOptions {
  98299. /**
  98300. * Gets or sets the custom shader name to use
  98301. */
  98302. shaderName: string;
  98303. /**
  98304. * The list of attribute names used in the shader
  98305. */
  98306. attributes?: string[];
  98307. /**
  98308. * The list of unifrom names used in the shader
  98309. */
  98310. uniforms?: string[];
  98311. /**
  98312. * The list of sampler names used in the shader
  98313. */
  98314. samplers?: string[];
  98315. /**
  98316. * The list of defines used in the shader
  98317. */
  98318. defines?: string[];
  98319. }
  98320. /**
  98321. * Interface to implement to create a shadow generator compatible with BJS.
  98322. */
  98323. export interface IShadowGenerator {
  98324. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98325. id: string;
  98326. /**
  98327. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98328. * @returns The render target texture if present otherwise, null
  98329. */
  98330. getShadowMap(): Nullable<RenderTargetTexture>;
  98331. /**
  98332. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98333. * @param subMesh The submesh we want to render in the shadow map
  98334. * @param useInstances Defines wether will draw in the map using instances
  98335. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98336. * @returns true if ready otherwise, false
  98337. */
  98338. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98339. /**
  98340. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98341. * @param defines Defines of the material we want to update
  98342. * @param lightIndex Index of the light in the enabled light list of the material
  98343. */
  98344. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98345. /**
  98346. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98347. * defined in the generator but impacting the effect).
  98348. * It implies the unifroms available on the materials are the standard BJS ones.
  98349. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98350. * @param effect The effect we are binfing the information for
  98351. */
  98352. bindShadowLight(lightIndex: string, effect: Effect): void;
  98353. /**
  98354. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98355. * (eq to shadow prjection matrix * light transform matrix)
  98356. * @returns The transform matrix used to create the shadow map
  98357. */
  98358. getTransformMatrix(): Matrix;
  98359. /**
  98360. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98361. * Cube and 2D textures for instance.
  98362. */
  98363. recreateShadowMap(): void;
  98364. /**
  98365. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98366. * @param onCompiled Callback triggered at the and of the effects compilation
  98367. * @param options Sets of optional options forcing the compilation with different modes
  98368. */
  98369. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98370. useInstances: boolean;
  98371. }>): void;
  98372. /**
  98373. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98374. * @param options Sets of optional options forcing the compilation with different modes
  98375. * @returns A promise that resolves when the compilation completes
  98376. */
  98377. forceCompilationAsync(options?: Partial<{
  98378. useInstances: boolean;
  98379. }>): Promise<void>;
  98380. /**
  98381. * Serializes the shadow generator setup to a json object.
  98382. * @returns The serialized JSON object
  98383. */
  98384. serialize(): any;
  98385. /**
  98386. * Disposes the Shadow map and related Textures and effects.
  98387. */
  98388. dispose(): void;
  98389. }
  98390. /**
  98391. * Default implementation IShadowGenerator.
  98392. * This is the main object responsible of generating shadows in the framework.
  98393. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98394. */
  98395. export class ShadowGenerator implements IShadowGenerator {
  98396. /**
  98397. * Name of the shadow generator class
  98398. */
  98399. static CLASSNAME: string;
  98400. /**
  98401. * Shadow generator mode None: no filtering applied.
  98402. */
  98403. static readonly FILTER_NONE: number;
  98404. /**
  98405. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98406. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98407. */
  98408. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98409. /**
  98410. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98411. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98412. */
  98413. static readonly FILTER_POISSONSAMPLING: number;
  98414. /**
  98415. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98416. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98417. */
  98418. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98419. /**
  98420. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98421. * edge artifacts on steep falloff.
  98422. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98423. */
  98424. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98425. /**
  98426. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98427. * edge artifacts on steep falloff.
  98428. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98429. */
  98430. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98431. /**
  98432. * Shadow generator mode PCF: Percentage Closer Filtering
  98433. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98434. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98435. */
  98436. static readonly FILTER_PCF: number;
  98437. /**
  98438. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98439. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98440. * Contact Hardening
  98441. */
  98442. static readonly FILTER_PCSS: number;
  98443. /**
  98444. * Reserved for PCF and PCSS
  98445. * Highest Quality.
  98446. *
  98447. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98448. *
  98449. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98450. */
  98451. static readonly QUALITY_HIGH: number;
  98452. /**
  98453. * Reserved for PCF and PCSS
  98454. * Good tradeoff for quality/perf cross devices
  98455. *
  98456. * Execute PCF on a 3*3 kernel.
  98457. *
  98458. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98459. */
  98460. static readonly QUALITY_MEDIUM: number;
  98461. /**
  98462. * Reserved for PCF and PCSS
  98463. * The lowest quality but the fastest.
  98464. *
  98465. * Execute PCF on a 1*1 kernel.
  98466. *
  98467. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98468. */
  98469. static readonly QUALITY_LOW: number;
  98470. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98471. id: string;
  98472. /** Gets or sets the custom shader name to use */
  98473. customShaderOptions: ICustomShaderOptions;
  98474. /**
  98475. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98476. */
  98477. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98478. /**
  98479. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98480. */
  98481. onAfterShadowMapRenderObservable: Observable<Effect>;
  98482. /**
  98483. * Observable triggered before a mesh is rendered in the shadow map.
  98484. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98485. */
  98486. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98487. /**
  98488. * Observable triggered after a mesh is rendered in the shadow map.
  98489. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98490. */
  98491. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98492. protected _bias: number;
  98493. /**
  98494. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98495. */
  98496. get bias(): number;
  98497. /**
  98498. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98499. */
  98500. set bias(bias: number);
  98501. protected _normalBias: number;
  98502. /**
  98503. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98504. */
  98505. get normalBias(): number;
  98506. /**
  98507. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98508. */
  98509. set normalBias(normalBias: number);
  98510. protected _blurBoxOffset: number;
  98511. /**
  98512. * Gets the blur box offset: offset applied during the blur pass.
  98513. * Only useful if useKernelBlur = false
  98514. */
  98515. get blurBoxOffset(): number;
  98516. /**
  98517. * Sets the blur box offset: offset applied during the blur pass.
  98518. * Only useful if useKernelBlur = false
  98519. */
  98520. set blurBoxOffset(value: number);
  98521. protected _blurScale: number;
  98522. /**
  98523. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98524. * 2 means half of the size.
  98525. */
  98526. get blurScale(): number;
  98527. /**
  98528. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98529. * 2 means half of the size.
  98530. */
  98531. set blurScale(value: number);
  98532. protected _blurKernel: number;
  98533. /**
  98534. * Gets the blur kernel: kernel size of the blur pass.
  98535. * Only useful if useKernelBlur = true
  98536. */
  98537. get blurKernel(): number;
  98538. /**
  98539. * Sets the blur kernel: kernel size of the blur pass.
  98540. * Only useful if useKernelBlur = true
  98541. */
  98542. set blurKernel(value: number);
  98543. protected _useKernelBlur: boolean;
  98544. /**
  98545. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98546. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98547. */
  98548. get useKernelBlur(): boolean;
  98549. /**
  98550. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98551. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98552. */
  98553. set useKernelBlur(value: boolean);
  98554. protected _depthScale: number;
  98555. /**
  98556. * Gets the depth scale used in ESM mode.
  98557. */
  98558. get depthScale(): number;
  98559. /**
  98560. * Sets the depth scale used in ESM mode.
  98561. * This can override the scale stored on the light.
  98562. */
  98563. set depthScale(value: number);
  98564. protected _validateFilter(filter: number): number;
  98565. protected _filter: number;
  98566. /**
  98567. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98568. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98569. */
  98570. get filter(): number;
  98571. /**
  98572. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98573. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98574. */
  98575. set filter(value: number);
  98576. /**
  98577. * Gets if the current filter is set to Poisson Sampling.
  98578. */
  98579. get usePoissonSampling(): boolean;
  98580. /**
  98581. * Sets the current filter to Poisson Sampling.
  98582. */
  98583. set usePoissonSampling(value: boolean);
  98584. /**
  98585. * Gets if the current filter is set to ESM.
  98586. */
  98587. get useExponentialShadowMap(): boolean;
  98588. /**
  98589. * Sets the current filter is to ESM.
  98590. */
  98591. set useExponentialShadowMap(value: boolean);
  98592. /**
  98593. * Gets if the current filter is set to filtered ESM.
  98594. */
  98595. get useBlurExponentialShadowMap(): boolean;
  98596. /**
  98597. * Gets if the current filter is set to filtered ESM.
  98598. */
  98599. set useBlurExponentialShadowMap(value: boolean);
  98600. /**
  98601. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98602. * exponential to prevent steep falloff artifacts).
  98603. */
  98604. get useCloseExponentialShadowMap(): boolean;
  98605. /**
  98606. * Sets the current filter to "close ESM" (using the inverse of the
  98607. * exponential to prevent steep falloff artifacts).
  98608. */
  98609. set useCloseExponentialShadowMap(value: boolean);
  98610. /**
  98611. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98612. * exponential to prevent steep falloff artifacts).
  98613. */
  98614. get useBlurCloseExponentialShadowMap(): boolean;
  98615. /**
  98616. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98617. * exponential to prevent steep falloff artifacts).
  98618. */
  98619. set useBlurCloseExponentialShadowMap(value: boolean);
  98620. /**
  98621. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98622. */
  98623. get usePercentageCloserFiltering(): boolean;
  98624. /**
  98625. * Sets the current filter to "PCF" (percentage closer filtering).
  98626. */
  98627. set usePercentageCloserFiltering(value: boolean);
  98628. protected _filteringQuality: number;
  98629. /**
  98630. * Gets the PCF or PCSS Quality.
  98631. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98632. */
  98633. get filteringQuality(): number;
  98634. /**
  98635. * Sets the PCF or PCSS Quality.
  98636. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98637. */
  98638. set filteringQuality(filteringQuality: number);
  98639. /**
  98640. * Gets if the current filter is set to "PCSS" (contact hardening).
  98641. */
  98642. get useContactHardeningShadow(): boolean;
  98643. /**
  98644. * Sets the current filter to "PCSS" (contact hardening).
  98645. */
  98646. set useContactHardeningShadow(value: boolean);
  98647. protected _contactHardeningLightSizeUVRatio: number;
  98648. /**
  98649. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98650. * Using a ratio helps keeping shape stability independently of the map size.
  98651. *
  98652. * It does not account for the light projection as it was having too much
  98653. * instability during the light setup or during light position changes.
  98654. *
  98655. * Only valid if useContactHardeningShadow is true.
  98656. */
  98657. get contactHardeningLightSizeUVRatio(): number;
  98658. /**
  98659. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98660. * Using a ratio helps keeping shape stability independently of the map size.
  98661. *
  98662. * It does not account for the light projection as it was having too much
  98663. * instability during the light setup or during light position changes.
  98664. *
  98665. * Only valid if useContactHardeningShadow is true.
  98666. */
  98667. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98668. protected _darkness: number;
  98669. /** Gets or sets the actual darkness of a shadow */
  98670. get darkness(): number;
  98671. set darkness(value: number);
  98672. /**
  98673. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98674. * 0 means strongest and 1 would means no shadow.
  98675. * @returns the darkness.
  98676. */
  98677. getDarkness(): number;
  98678. /**
  98679. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98680. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98681. * @returns the shadow generator allowing fluent coding.
  98682. */
  98683. setDarkness(darkness: number): ShadowGenerator;
  98684. protected _transparencyShadow: boolean;
  98685. /** Gets or sets the ability to have transparent shadow */
  98686. get transparencyShadow(): boolean;
  98687. set transparencyShadow(value: boolean);
  98688. /**
  98689. * Sets the ability to have transparent shadow (boolean).
  98690. * @param transparent True if transparent else False
  98691. * @returns the shadow generator allowing fluent coding
  98692. */
  98693. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98694. /**
  98695. * Enables or disables shadows with varying strength based on the transparency
  98696. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98697. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98698. * mesh.visibility * alphaTexture.a
  98699. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98700. */
  98701. enableSoftTransparentShadow: boolean;
  98702. protected _shadowMap: Nullable<RenderTargetTexture>;
  98703. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98704. /**
  98705. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98706. * @returns The render target texture if present otherwise, null
  98707. */
  98708. getShadowMap(): Nullable<RenderTargetTexture>;
  98709. /**
  98710. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98711. * @returns The render target texture if the shadow map is present otherwise, null
  98712. */
  98713. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98714. /**
  98715. * Gets the class name of that object
  98716. * @returns "ShadowGenerator"
  98717. */
  98718. getClassName(): string;
  98719. /**
  98720. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98721. * @param mesh Mesh to add
  98722. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98723. * @returns the Shadow Generator itself
  98724. */
  98725. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98726. /**
  98727. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98728. * @param mesh Mesh to remove
  98729. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98730. * @returns the Shadow Generator itself
  98731. */
  98732. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98733. /**
  98734. * Controls the extent to which the shadows fade out at the edge of the frustum
  98735. */
  98736. frustumEdgeFalloff: number;
  98737. protected _light: IShadowLight;
  98738. /**
  98739. * Returns the associated light object.
  98740. * @returns the light generating the shadow
  98741. */
  98742. getLight(): IShadowLight;
  98743. /**
  98744. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98745. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98746. * It might on the other hand introduce peter panning.
  98747. */
  98748. forceBackFacesOnly: boolean;
  98749. protected _scene: Scene;
  98750. protected _lightDirection: Vector3;
  98751. protected _effect: Effect;
  98752. protected _viewMatrix: Matrix;
  98753. protected _projectionMatrix: Matrix;
  98754. protected _transformMatrix: Matrix;
  98755. protected _cachedPosition: Vector3;
  98756. protected _cachedDirection: Vector3;
  98757. protected _cachedDefines: string;
  98758. protected _currentRenderID: number;
  98759. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98760. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98761. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98762. protected _blurPostProcesses: PostProcess[];
  98763. protected _mapSize: number;
  98764. protected _currentFaceIndex: number;
  98765. protected _currentFaceIndexCache: number;
  98766. protected _textureType: number;
  98767. protected _defaultTextureMatrix: Matrix;
  98768. protected _storedUniqueId: Nullable<number>;
  98769. /** @hidden */
  98770. static _SceneComponentInitialization: (scene: Scene) => void;
  98771. /**
  98772. * Gets or sets the size of the texture what stores the shadows
  98773. */
  98774. get mapSize(): number;
  98775. set mapSize(size: number);
  98776. /**
  98777. * Creates a ShadowGenerator object.
  98778. * A ShadowGenerator is the required tool to use the shadows.
  98779. * Each light casting shadows needs to use its own ShadowGenerator.
  98780. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98781. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98782. * @param light The light object generating the shadows.
  98783. * @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.
  98784. */
  98785. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98786. protected _initializeGenerator(): void;
  98787. protected _createTargetRenderTexture(): void;
  98788. protected _initializeShadowMap(): void;
  98789. protected _initializeBlurRTTAndPostProcesses(): void;
  98790. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98791. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98792. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98793. protected _applyFilterValues(): void;
  98794. /**
  98795. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98796. * @param onCompiled Callback triggered at the and of the effects compilation
  98797. * @param options Sets of optional options forcing the compilation with different modes
  98798. */
  98799. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98800. useInstances: boolean;
  98801. }>): void;
  98802. /**
  98803. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98804. * @param options Sets of optional options forcing the compilation with different modes
  98805. * @returns A promise that resolves when the compilation completes
  98806. */
  98807. forceCompilationAsync(options?: Partial<{
  98808. useInstances: boolean;
  98809. }>): Promise<void>;
  98810. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98811. private _prepareShadowDefines;
  98812. /**
  98813. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98814. * @param subMesh The submesh we want to render in the shadow map
  98815. * @param useInstances Defines wether will draw in the map using instances
  98816. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98817. * @returns true if ready otherwise, false
  98818. */
  98819. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98820. /**
  98821. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98822. * @param defines Defines of the material we want to update
  98823. * @param lightIndex Index of the light in the enabled light list of the material
  98824. */
  98825. prepareDefines(defines: any, lightIndex: number): void;
  98826. /**
  98827. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98828. * defined in the generator but impacting the effect).
  98829. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98830. * @param effect The effect we are binfing the information for
  98831. */
  98832. bindShadowLight(lightIndex: string, effect: Effect): void;
  98833. /**
  98834. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98835. * (eq to shadow prjection matrix * light transform matrix)
  98836. * @returns The transform matrix used to create the shadow map
  98837. */
  98838. getTransformMatrix(): Matrix;
  98839. /**
  98840. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98841. * Cube and 2D textures for instance.
  98842. */
  98843. recreateShadowMap(): void;
  98844. protected _disposeBlurPostProcesses(): void;
  98845. protected _disposeRTTandPostProcesses(): void;
  98846. /**
  98847. * Disposes the ShadowGenerator.
  98848. * Returns nothing.
  98849. */
  98850. dispose(): void;
  98851. /**
  98852. * Serializes the shadow generator setup to a json object.
  98853. * @returns The serialized JSON object
  98854. */
  98855. serialize(): any;
  98856. /**
  98857. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98858. * @param parsedShadowGenerator The JSON object to parse
  98859. * @param scene The scene to create the shadow map for
  98860. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98861. * @returns The parsed shadow generator
  98862. */
  98863. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98864. }
  98865. }
  98866. declare module BABYLON {
  98867. /**
  98868. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98869. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98870. * 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.
  98871. */
  98872. export abstract class Light extends Node {
  98873. /**
  98874. * Falloff Default: light is falling off following the material specification:
  98875. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98876. */
  98877. static readonly FALLOFF_DEFAULT: number;
  98878. /**
  98879. * Falloff Physical: light is falling off following the inverse squared distance law.
  98880. */
  98881. static readonly FALLOFF_PHYSICAL: number;
  98882. /**
  98883. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98884. * to enhance interoperability with other engines.
  98885. */
  98886. static readonly FALLOFF_GLTF: number;
  98887. /**
  98888. * Falloff Standard: light is falling off like in the standard material
  98889. * to enhance interoperability with other materials.
  98890. */
  98891. static readonly FALLOFF_STANDARD: number;
  98892. /**
  98893. * If every light affecting the material is in this lightmapMode,
  98894. * material.lightmapTexture adds or multiplies
  98895. * (depends on material.useLightmapAsShadowmap)
  98896. * after every other light calculations.
  98897. */
  98898. static readonly LIGHTMAP_DEFAULT: number;
  98899. /**
  98900. * material.lightmapTexture as only diffuse lighting from this light
  98901. * adds only specular lighting from this light
  98902. * adds dynamic shadows
  98903. */
  98904. static readonly LIGHTMAP_SPECULAR: number;
  98905. /**
  98906. * material.lightmapTexture as only lighting
  98907. * no light calculation from this light
  98908. * only adds dynamic shadows from this light
  98909. */
  98910. static readonly LIGHTMAP_SHADOWSONLY: number;
  98911. /**
  98912. * Each light type uses the default quantity according to its type:
  98913. * point/spot lights use luminous intensity
  98914. * directional lights use illuminance
  98915. */
  98916. static readonly INTENSITYMODE_AUTOMATIC: number;
  98917. /**
  98918. * lumen (lm)
  98919. */
  98920. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98921. /**
  98922. * candela (lm/sr)
  98923. */
  98924. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98925. /**
  98926. * lux (lm/m^2)
  98927. */
  98928. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98929. /**
  98930. * nit (cd/m^2)
  98931. */
  98932. static readonly INTENSITYMODE_LUMINANCE: number;
  98933. /**
  98934. * Light type const id of the point light.
  98935. */
  98936. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98937. /**
  98938. * Light type const id of the directional light.
  98939. */
  98940. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98941. /**
  98942. * Light type const id of the spot light.
  98943. */
  98944. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98945. /**
  98946. * Light type const id of the hemispheric light.
  98947. */
  98948. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98949. /**
  98950. * Diffuse gives the basic color to an object.
  98951. */
  98952. diffuse: Color3;
  98953. /**
  98954. * Specular produces a highlight color on an object.
  98955. * Note: This is note affecting PBR materials.
  98956. */
  98957. specular: Color3;
  98958. /**
  98959. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98960. * falling off base on range or angle.
  98961. * This can be set to any values in Light.FALLOFF_x.
  98962. *
  98963. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98964. * other types of materials.
  98965. */
  98966. falloffType: number;
  98967. /**
  98968. * Strength of the light.
  98969. * Note: By default it is define in the framework own unit.
  98970. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98971. */
  98972. intensity: number;
  98973. private _range;
  98974. protected _inverseSquaredRange: number;
  98975. /**
  98976. * Defines how far from the source the light is impacting in scene units.
  98977. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98978. */
  98979. get range(): number;
  98980. /**
  98981. * Defines how far from the source the light is impacting in scene units.
  98982. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98983. */
  98984. set range(value: number);
  98985. /**
  98986. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98987. * of light.
  98988. */
  98989. private _photometricScale;
  98990. private _intensityMode;
  98991. /**
  98992. * Gets the photometric scale used to interpret the intensity.
  98993. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98994. */
  98995. get intensityMode(): number;
  98996. /**
  98997. * Sets the photometric scale used to interpret the intensity.
  98998. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98999. */
  99000. set intensityMode(value: number);
  99001. private _radius;
  99002. /**
  99003. * Gets the light radius used by PBR Materials to simulate soft area lights.
  99004. */
  99005. get radius(): number;
  99006. /**
  99007. * sets the light radius used by PBR Materials to simulate soft area lights.
  99008. */
  99009. set radius(value: number);
  99010. private _renderPriority;
  99011. /**
  99012. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  99013. * exceeding the number allowed of the materials.
  99014. */
  99015. renderPriority: number;
  99016. private _shadowEnabled;
  99017. /**
  99018. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99019. * the current shadow generator.
  99020. */
  99021. get shadowEnabled(): boolean;
  99022. /**
  99023. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99024. * the current shadow generator.
  99025. */
  99026. set shadowEnabled(value: boolean);
  99027. private _includedOnlyMeshes;
  99028. /**
  99029. * Gets the only meshes impacted by this light.
  99030. */
  99031. get includedOnlyMeshes(): AbstractMesh[];
  99032. /**
  99033. * Sets the only meshes impacted by this light.
  99034. */
  99035. set includedOnlyMeshes(value: AbstractMesh[]);
  99036. private _excludedMeshes;
  99037. /**
  99038. * Gets the meshes not impacted by this light.
  99039. */
  99040. get excludedMeshes(): AbstractMesh[];
  99041. /**
  99042. * Sets the meshes not impacted by this light.
  99043. */
  99044. set excludedMeshes(value: AbstractMesh[]);
  99045. private _excludeWithLayerMask;
  99046. /**
  99047. * Gets the layer id use to find what meshes are not impacted by the light.
  99048. * Inactive if 0
  99049. */
  99050. get excludeWithLayerMask(): number;
  99051. /**
  99052. * Sets the layer id use to find what meshes are not impacted by the light.
  99053. * Inactive if 0
  99054. */
  99055. set excludeWithLayerMask(value: number);
  99056. private _includeOnlyWithLayerMask;
  99057. /**
  99058. * Gets the layer id use to find what meshes are impacted by the light.
  99059. * Inactive if 0
  99060. */
  99061. get includeOnlyWithLayerMask(): number;
  99062. /**
  99063. * Sets the layer id use to find what meshes are impacted by the light.
  99064. * Inactive if 0
  99065. */
  99066. set includeOnlyWithLayerMask(value: number);
  99067. private _lightmapMode;
  99068. /**
  99069. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99070. */
  99071. get lightmapMode(): number;
  99072. /**
  99073. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99074. */
  99075. set lightmapMode(value: number);
  99076. /**
  99077. * Shadow generator associted to the light.
  99078. * @hidden Internal use only.
  99079. */
  99080. _shadowGenerator: Nullable<IShadowGenerator>;
  99081. /**
  99082. * @hidden Internal use only.
  99083. */
  99084. _excludedMeshesIds: string[];
  99085. /**
  99086. * @hidden Internal use only.
  99087. */
  99088. _includedOnlyMeshesIds: string[];
  99089. /**
  99090. * The current light unifom buffer.
  99091. * @hidden Internal use only.
  99092. */
  99093. _uniformBuffer: UniformBuffer;
  99094. /** @hidden */
  99095. _renderId: number;
  99096. /**
  99097. * Creates a Light object in the scene.
  99098. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99099. * @param name The firendly name of the light
  99100. * @param scene The scene the light belongs too
  99101. */
  99102. constructor(name: string, scene: Scene);
  99103. protected abstract _buildUniformLayout(): void;
  99104. /**
  99105. * Sets the passed Effect "effect" with the Light information.
  99106. * @param effect The effect to update
  99107. * @param lightIndex The index of the light in the effect to update
  99108. * @returns The light
  99109. */
  99110. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  99111. /**
  99112. * Sets the passed Effect "effect" with the Light textures.
  99113. * @param effect The effect to update
  99114. * @param lightIndex The index of the light in the effect to update
  99115. * @returns The light
  99116. */
  99117. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  99118. /**
  99119. * Binds the lights information from the scene to the effect for the given mesh.
  99120. * @param lightIndex Light index
  99121. * @param scene The scene where the light belongs to
  99122. * @param effect The effect we are binding the data to
  99123. * @param useSpecular Defines if specular is supported
  99124. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99125. */
  99126. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99127. /**
  99128. * Sets the passed Effect "effect" with the Light information.
  99129. * @param effect The effect to update
  99130. * @param lightDataUniformName The uniform used to store light data (position or direction)
  99131. * @returns The light
  99132. */
  99133. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  99134. /**
  99135. * Returns the string "Light".
  99136. * @returns the class name
  99137. */
  99138. getClassName(): string;
  99139. /** @hidden */
  99140. readonly _isLight: boolean;
  99141. /**
  99142. * Converts the light information to a readable string for debug purpose.
  99143. * @param fullDetails Supports for multiple levels of logging within scene loading
  99144. * @returns the human readable light info
  99145. */
  99146. toString(fullDetails?: boolean): string;
  99147. /** @hidden */
  99148. protected _syncParentEnabledState(): void;
  99149. /**
  99150. * Set the enabled state of this node.
  99151. * @param value - the new enabled state
  99152. */
  99153. setEnabled(value: boolean): void;
  99154. /**
  99155. * Returns the Light associated shadow generator if any.
  99156. * @return the associated shadow generator.
  99157. */
  99158. getShadowGenerator(): Nullable<IShadowGenerator>;
  99159. /**
  99160. * Returns a Vector3, the absolute light position in the World.
  99161. * @returns the world space position of the light
  99162. */
  99163. getAbsolutePosition(): Vector3;
  99164. /**
  99165. * Specifies if the light will affect the passed mesh.
  99166. * @param mesh The mesh to test against the light
  99167. * @return true the mesh is affected otherwise, false.
  99168. */
  99169. canAffectMesh(mesh: AbstractMesh): boolean;
  99170. /**
  99171. * Sort function to order lights for rendering.
  99172. * @param a First Light object to compare to second.
  99173. * @param b Second Light object to compare first.
  99174. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  99175. */
  99176. static CompareLightsPriority(a: Light, b: Light): number;
  99177. /**
  99178. * Releases resources associated with this node.
  99179. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99180. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99181. */
  99182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99183. /**
  99184. * Returns the light type ID (integer).
  99185. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99186. */
  99187. getTypeID(): number;
  99188. /**
  99189. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99190. * @returns the scaled intensity in intensity mode unit
  99191. */
  99192. getScaledIntensity(): number;
  99193. /**
  99194. * Returns a new Light object, named "name", from the current one.
  99195. * @param name The name of the cloned light
  99196. * @param newParent The parent of this light, if it has one
  99197. * @returns the new created light
  99198. */
  99199. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99200. /**
  99201. * Serializes the current light into a Serialization object.
  99202. * @returns the serialized object.
  99203. */
  99204. serialize(): any;
  99205. /**
  99206. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99207. * This new light is named "name" and added to the passed scene.
  99208. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99209. * @param name The friendly name of the light
  99210. * @param scene The scene the new light will belong to
  99211. * @returns the constructor function
  99212. */
  99213. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99214. /**
  99215. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99216. * @param parsedLight The JSON representation of the light
  99217. * @param scene The scene to create the parsed light in
  99218. * @returns the created light after parsing
  99219. */
  99220. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99221. private _hookArrayForExcluded;
  99222. private _hookArrayForIncludedOnly;
  99223. private _resyncMeshes;
  99224. /**
  99225. * Forces the meshes to update their light related information in their rendering used effects
  99226. * @hidden Internal Use Only
  99227. */
  99228. _markMeshesAsLightDirty(): void;
  99229. /**
  99230. * Recomputes the cached photometric scale if needed.
  99231. */
  99232. private _computePhotometricScale;
  99233. /**
  99234. * Returns the Photometric Scale according to the light type and intensity mode.
  99235. */
  99236. private _getPhotometricScale;
  99237. /**
  99238. * Reorder the light in the scene according to their defined priority.
  99239. * @hidden Internal Use Only
  99240. */
  99241. _reorderLightsInScene(): void;
  99242. /**
  99243. * Prepares the list of defines specific to the light type.
  99244. * @param defines the list of defines
  99245. * @param lightIndex defines the index of the light for the effect
  99246. */
  99247. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99248. }
  99249. }
  99250. declare module BABYLON {
  99251. /**
  99252. * Configuration needed for prepass-capable materials
  99253. */
  99254. export class PrePassConfiguration {
  99255. /**
  99256. * Previous world matrices of meshes carrying this material
  99257. * Used for computing velocity
  99258. */
  99259. previousWorldMatrices: {
  99260. [index: number]: Matrix;
  99261. };
  99262. /**
  99263. * Previous view project matrix
  99264. * Used for computing velocity
  99265. */
  99266. previousViewProjection: Matrix;
  99267. /**
  99268. * Previous bones of meshes carrying this material
  99269. * Used for computing velocity
  99270. */
  99271. previousBones: {
  99272. [index: number]: Float32Array;
  99273. };
  99274. /**
  99275. * Add the required uniforms to the current list.
  99276. * @param uniforms defines the current uniform list.
  99277. */
  99278. static AddUniforms(uniforms: string[]): void;
  99279. /**
  99280. * Add the required samplers to the current list.
  99281. * @param samplers defines the current sampler list.
  99282. */
  99283. static AddSamplers(samplers: string[]): void;
  99284. /**
  99285. * Binds the material data.
  99286. * @param effect defines the effect to update
  99287. * @param scene defines the scene the material belongs to.
  99288. * @param mesh The mesh
  99289. * @param world World matrix of this mesh
  99290. * @param isFrozen Is the material frozen
  99291. */
  99292. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99293. }
  99294. }
  99295. declare module BABYLON {
  99296. /**
  99297. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99298. * This is the base of the follow, arc rotate cameras and Free camera
  99299. * @see https://doc.babylonjs.com/features/cameras
  99300. */
  99301. export class TargetCamera extends Camera {
  99302. private static _RigCamTransformMatrix;
  99303. private static _TargetTransformMatrix;
  99304. private static _TargetFocalPoint;
  99305. private _tmpUpVector;
  99306. private _tmpTargetVector;
  99307. /**
  99308. * Define the current direction the camera is moving to
  99309. */
  99310. cameraDirection: Vector3;
  99311. /**
  99312. * Define the current rotation the camera is rotating to
  99313. */
  99314. cameraRotation: Vector2;
  99315. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99316. ignoreParentScaling: boolean;
  99317. /**
  99318. * When set, the up vector of the camera will be updated by the rotation of the camera
  99319. */
  99320. updateUpVectorFromRotation: boolean;
  99321. private _tmpQuaternion;
  99322. /**
  99323. * Define the current rotation of the camera
  99324. */
  99325. rotation: Vector3;
  99326. /**
  99327. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99328. */
  99329. rotationQuaternion: Quaternion;
  99330. /**
  99331. * Define the current speed of the camera
  99332. */
  99333. speed: number;
  99334. /**
  99335. * Add constraint to the camera to prevent it to move freely in all directions and
  99336. * around all axis.
  99337. */
  99338. noRotationConstraint: boolean;
  99339. /**
  99340. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99341. * panning
  99342. */
  99343. invertRotation: boolean;
  99344. /**
  99345. * Speed multiplier for inverse camera panning
  99346. */
  99347. inverseRotationSpeed: number;
  99348. /**
  99349. * Define the current target of the camera as an object or a position.
  99350. */
  99351. lockedTarget: any;
  99352. /** @hidden */
  99353. _currentTarget: Vector3;
  99354. /** @hidden */
  99355. _initialFocalDistance: number;
  99356. /** @hidden */
  99357. _viewMatrix: Matrix;
  99358. /** @hidden */
  99359. _camMatrix: Matrix;
  99360. /** @hidden */
  99361. _cameraTransformMatrix: Matrix;
  99362. /** @hidden */
  99363. _cameraRotationMatrix: Matrix;
  99364. /** @hidden */
  99365. _referencePoint: Vector3;
  99366. /** @hidden */
  99367. _transformedReferencePoint: Vector3;
  99368. /** @hidden */
  99369. _reset: () => void;
  99370. private _defaultUp;
  99371. /**
  99372. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99373. * This is the base of the follow, arc rotate cameras and Free camera
  99374. * @see https://doc.babylonjs.com/features/cameras
  99375. * @param name Defines the name of the camera in the scene
  99376. * @param position Defines the start position of the camera in the scene
  99377. * @param scene Defines the scene the camera belongs to
  99378. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99379. */
  99380. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99381. /**
  99382. * Gets the position in front of the camera at a given distance.
  99383. * @param distance The distance from the camera we want the position to be
  99384. * @returns the position
  99385. */
  99386. getFrontPosition(distance: number): Vector3;
  99387. /** @hidden */
  99388. _getLockedTargetPosition(): Nullable<Vector3>;
  99389. private _storedPosition;
  99390. private _storedRotation;
  99391. private _storedRotationQuaternion;
  99392. /**
  99393. * Store current camera state of the camera (fov, position, rotation, etc..)
  99394. * @returns the camera
  99395. */
  99396. storeState(): Camera;
  99397. /**
  99398. * Restored camera state. You must call storeState() first
  99399. * @returns whether it was successful or not
  99400. * @hidden
  99401. */
  99402. _restoreStateValues(): boolean;
  99403. /** @hidden */
  99404. _initCache(): void;
  99405. /** @hidden */
  99406. _updateCache(ignoreParentClass?: boolean): void;
  99407. /** @hidden */
  99408. _isSynchronizedViewMatrix(): boolean;
  99409. /** @hidden */
  99410. _computeLocalCameraSpeed(): number;
  99411. /**
  99412. * Defines the target the camera should look at.
  99413. * @param target Defines the new target as a Vector or a mesh
  99414. */
  99415. setTarget(target: Vector3): void;
  99416. /**
  99417. * Defines the target point of the camera.
  99418. * The camera looks towards it form the radius distance.
  99419. */
  99420. get target(): Vector3;
  99421. set target(value: Vector3);
  99422. /**
  99423. * Return the current target position of the camera. This value is expressed in local space.
  99424. * @returns the target position
  99425. */
  99426. getTarget(): Vector3;
  99427. /** @hidden */
  99428. _decideIfNeedsToMove(): boolean;
  99429. /** @hidden */
  99430. _updatePosition(): void;
  99431. /** @hidden */
  99432. _checkInputs(): void;
  99433. protected _updateCameraRotationMatrix(): void;
  99434. /**
  99435. * 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)
  99436. * @returns the current camera
  99437. */
  99438. private _rotateUpVectorWithCameraRotationMatrix;
  99439. private _cachedRotationZ;
  99440. private _cachedQuaternionRotationZ;
  99441. /** @hidden */
  99442. _getViewMatrix(): Matrix;
  99443. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99444. /**
  99445. * @hidden
  99446. */
  99447. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99448. /**
  99449. * @hidden
  99450. */
  99451. _updateRigCameras(): void;
  99452. private _getRigCamPositionAndTarget;
  99453. /**
  99454. * Gets the current object class name.
  99455. * @return the class name
  99456. */
  99457. getClassName(): string;
  99458. }
  99459. }
  99460. declare module BABYLON {
  99461. /**
  99462. * Gather the list of keyboard event types as constants.
  99463. */
  99464. export class KeyboardEventTypes {
  99465. /**
  99466. * The keydown event is fired when a key becomes active (pressed).
  99467. */
  99468. static readonly KEYDOWN: number;
  99469. /**
  99470. * The keyup event is fired when a key has been released.
  99471. */
  99472. static readonly KEYUP: number;
  99473. }
  99474. /**
  99475. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99476. */
  99477. export class KeyboardInfo {
  99478. /**
  99479. * Defines the type of event (KeyboardEventTypes)
  99480. */
  99481. type: number;
  99482. /**
  99483. * Defines the related dom event
  99484. */
  99485. event: KeyboardEvent;
  99486. /**
  99487. * Instantiates a new keyboard info.
  99488. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99489. * @param type Defines the type of event (KeyboardEventTypes)
  99490. * @param event Defines the related dom event
  99491. */
  99492. constructor(
  99493. /**
  99494. * Defines the type of event (KeyboardEventTypes)
  99495. */
  99496. type: number,
  99497. /**
  99498. * Defines the related dom event
  99499. */
  99500. event: KeyboardEvent);
  99501. }
  99502. /**
  99503. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99504. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99505. */
  99506. export class KeyboardInfoPre extends KeyboardInfo {
  99507. /**
  99508. * Defines the type of event (KeyboardEventTypes)
  99509. */
  99510. type: number;
  99511. /**
  99512. * Defines the related dom event
  99513. */
  99514. event: KeyboardEvent;
  99515. /**
  99516. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99517. */
  99518. skipOnPointerObservable: boolean;
  99519. /**
  99520. * Instantiates a new keyboard pre info.
  99521. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99522. * @param type Defines the type of event (KeyboardEventTypes)
  99523. * @param event Defines the related dom event
  99524. */
  99525. constructor(
  99526. /**
  99527. * Defines the type of event (KeyboardEventTypes)
  99528. */
  99529. type: number,
  99530. /**
  99531. * Defines the related dom event
  99532. */
  99533. event: KeyboardEvent);
  99534. }
  99535. }
  99536. declare module BABYLON {
  99537. /**
  99538. * Manage the keyboard inputs to control the movement of a free camera.
  99539. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99540. */
  99541. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99542. /**
  99543. * Defines the camera the input is attached to.
  99544. */
  99545. camera: FreeCamera;
  99546. /**
  99547. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99548. */
  99549. keysUp: number[];
  99550. /**
  99551. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99552. */
  99553. keysUpward: number[];
  99554. /**
  99555. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99556. */
  99557. keysDown: number[];
  99558. /**
  99559. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99560. */
  99561. keysDownward: number[];
  99562. /**
  99563. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99564. */
  99565. keysLeft: number[];
  99566. /**
  99567. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99568. */
  99569. keysRight: number[];
  99570. private _keys;
  99571. private _onCanvasBlurObserver;
  99572. private _onKeyboardObserver;
  99573. private _engine;
  99574. private _scene;
  99575. /**
  99576. * Attach the input controls to a specific dom element to get the input from.
  99577. * @param element Defines the element the controls should be listened from
  99578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99579. */
  99580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99581. /**
  99582. * Detach the current controls from the specified dom element.
  99583. * @param element Defines the element to stop listening the inputs from
  99584. */
  99585. detachControl(element: Nullable<HTMLElement>): void;
  99586. /**
  99587. * Update the current camera state depending on the inputs that have been used this frame.
  99588. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99589. */
  99590. checkInputs(): void;
  99591. /**
  99592. * Gets the class name of the current intput.
  99593. * @returns the class name
  99594. */
  99595. getClassName(): string;
  99596. /** @hidden */
  99597. _onLostFocus(): void;
  99598. /**
  99599. * Get the friendly name associated with the input class.
  99600. * @returns the input friendly name
  99601. */
  99602. getSimpleName(): string;
  99603. }
  99604. }
  99605. declare module BABYLON {
  99606. /**
  99607. * Gather the list of pointer event types as constants.
  99608. */
  99609. export class PointerEventTypes {
  99610. /**
  99611. * 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.
  99612. */
  99613. static readonly POINTERDOWN: number;
  99614. /**
  99615. * The pointerup event is fired when a pointer is no longer active.
  99616. */
  99617. static readonly POINTERUP: number;
  99618. /**
  99619. * The pointermove event is fired when a pointer changes coordinates.
  99620. */
  99621. static readonly POINTERMOVE: number;
  99622. /**
  99623. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99624. */
  99625. static readonly POINTERWHEEL: number;
  99626. /**
  99627. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99628. */
  99629. static readonly POINTERPICK: number;
  99630. /**
  99631. * The pointertap event is fired when a the object has been touched and released without drag.
  99632. */
  99633. static readonly POINTERTAP: number;
  99634. /**
  99635. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99636. */
  99637. static readonly POINTERDOUBLETAP: number;
  99638. }
  99639. /**
  99640. * Base class of pointer info types.
  99641. */
  99642. export class PointerInfoBase {
  99643. /**
  99644. * Defines the type of event (PointerEventTypes)
  99645. */
  99646. type: number;
  99647. /**
  99648. * Defines the related dom event
  99649. */
  99650. event: PointerEvent | MouseWheelEvent;
  99651. /**
  99652. * Instantiates the base class of pointers info.
  99653. * @param type Defines the type of event (PointerEventTypes)
  99654. * @param event Defines the related dom event
  99655. */
  99656. constructor(
  99657. /**
  99658. * Defines the type of event (PointerEventTypes)
  99659. */
  99660. type: number,
  99661. /**
  99662. * Defines the related dom event
  99663. */
  99664. event: PointerEvent | MouseWheelEvent);
  99665. }
  99666. /**
  99667. * This class is used to store pointer related info for the onPrePointerObservable event.
  99668. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99669. */
  99670. export class PointerInfoPre extends PointerInfoBase {
  99671. /**
  99672. * Ray from a pointer if availible (eg. 6dof controller)
  99673. */
  99674. ray: Nullable<Ray>;
  99675. /**
  99676. * Defines the local position of the pointer on the canvas.
  99677. */
  99678. localPosition: Vector2;
  99679. /**
  99680. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99681. */
  99682. skipOnPointerObservable: boolean;
  99683. /**
  99684. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99685. * @param type Defines the type of event (PointerEventTypes)
  99686. * @param event Defines the related dom event
  99687. * @param localX Defines the local x coordinates of the pointer when the event occured
  99688. * @param localY Defines the local y coordinates of the pointer when the event occured
  99689. */
  99690. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99691. }
  99692. /**
  99693. * This type contains all the data related to a pointer event in Babylon.js.
  99694. * 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.
  99695. */
  99696. export class PointerInfo extends PointerInfoBase {
  99697. /**
  99698. * Defines the picking info associated to the info (if any)\
  99699. */
  99700. pickInfo: Nullable<PickingInfo>;
  99701. /**
  99702. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99703. * @param type Defines the type of event (PointerEventTypes)
  99704. * @param event Defines the related dom event
  99705. * @param pickInfo Defines the picking info associated to the info (if any)\
  99706. */
  99707. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99708. /**
  99709. * Defines the picking info associated to the info (if any)\
  99710. */
  99711. pickInfo: Nullable<PickingInfo>);
  99712. }
  99713. /**
  99714. * Data relating to a touch event on the screen.
  99715. */
  99716. export interface PointerTouch {
  99717. /**
  99718. * X coordinate of touch.
  99719. */
  99720. x: number;
  99721. /**
  99722. * Y coordinate of touch.
  99723. */
  99724. y: number;
  99725. /**
  99726. * Id of touch. Unique for each finger.
  99727. */
  99728. pointerId: number;
  99729. /**
  99730. * Event type passed from DOM.
  99731. */
  99732. type: any;
  99733. }
  99734. }
  99735. declare module BABYLON {
  99736. /**
  99737. * Manage the mouse inputs to control the movement of a free camera.
  99738. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99739. */
  99740. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99741. /**
  99742. * Define if touch is enabled in the mouse input
  99743. */
  99744. touchEnabled: boolean;
  99745. /**
  99746. * Defines the camera the input is attached to.
  99747. */
  99748. camera: FreeCamera;
  99749. /**
  99750. * Defines the buttons associated with the input to handle camera move.
  99751. */
  99752. buttons: number[];
  99753. /**
  99754. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99755. */
  99756. angularSensibility: number;
  99757. private _pointerInput;
  99758. private _onMouseMove;
  99759. private _observer;
  99760. private previousPosition;
  99761. /**
  99762. * Observable for when a pointer move event occurs containing the move offset
  99763. */
  99764. onPointerMovedObservable: Observable<{
  99765. offsetX: number;
  99766. offsetY: number;
  99767. }>;
  99768. /**
  99769. * @hidden
  99770. * If the camera should be rotated automatically based on pointer movement
  99771. */
  99772. _allowCameraRotation: boolean;
  99773. /**
  99774. * Manage the mouse inputs to control the movement of a free camera.
  99775. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99776. * @param touchEnabled Defines if touch is enabled or not
  99777. */
  99778. constructor(
  99779. /**
  99780. * Define if touch is enabled in the mouse input
  99781. */
  99782. touchEnabled?: boolean);
  99783. /**
  99784. * Attach the input controls to a specific dom element to get the input from.
  99785. * @param element Defines the element the controls should be listened from
  99786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99787. */
  99788. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99789. /**
  99790. * Called on JS contextmenu event.
  99791. * Override this method to provide functionality.
  99792. */
  99793. protected onContextMenu(evt: PointerEvent): void;
  99794. /**
  99795. * Detach the current controls from the specified dom element.
  99796. * @param element Defines the element to stop listening the inputs from
  99797. */
  99798. detachControl(element: Nullable<HTMLElement>): void;
  99799. /**
  99800. * Gets the class name of the current intput.
  99801. * @returns the class name
  99802. */
  99803. getClassName(): string;
  99804. /**
  99805. * Get the friendly name associated with the input class.
  99806. * @returns the input friendly name
  99807. */
  99808. getSimpleName(): string;
  99809. }
  99810. }
  99811. declare module BABYLON {
  99812. /**
  99813. * Manage the touch inputs to control the movement of a free camera.
  99814. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99815. */
  99816. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99817. /**
  99818. * Define if mouse events can be treated as touch events
  99819. */
  99820. allowMouse: boolean;
  99821. /**
  99822. * Defines the camera the input is attached to.
  99823. */
  99824. camera: FreeCamera;
  99825. /**
  99826. * Defines the touch sensibility for rotation.
  99827. * The higher the faster.
  99828. */
  99829. touchAngularSensibility: number;
  99830. /**
  99831. * Defines the touch sensibility for move.
  99832. * The higher the faster.
  99833. */
  99834. touchMoveSensibility: number;
  99835. private _offsetX;
  99836. private _offsetY;
  99837. private _pointerPressed;
  99838. private _pointerInput;
  99839. private _observer;
  99840. private _onLostFocus;
  99841. /**
  99842. * Manage the touch inputs to control the movement of a free camera.
  99843. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99844. * @param allowMouse Defines if mouse events can be treated as touch events
  99845. */
  99846. constructor(
  99847. /**
  99848. * Define if mouse events can be treated as touch events
  99849. */
  99850. allowMouse?: boolean);
  99851. /**
  99852. * Attach the input controls to a specific dom element to get the input from.
  99853. * @param element Defines the element the controls should be listened from
  99854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99855. */
  99856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99857. /**
  99858. * Detach the current controls from the specified dom element.
  99859. * @param element Defines the element to stop listening the inputs from
  99860. */
  99861. detachControl(element: Nullable<HTMLElement>): void;
  99862. /**
  99863. * Update the current camera state depending on the inputs that have been used this frame.
  99864. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99865. */
  99866. checkInputs(): void;
  99867. /**
  99868. * Gets the class name of the current intput.
  99869. * @returns the class name
  99870. */
  99871. getClassName(): string;
  99872. /**
  99873. * Get the friendly name associated with the input class.
  99874. * @returns the input friendly name
  99875. */
  99876. getSimpleName(): string;
  99877. }
  99878. }
  99879. declare module BABYLON {
  99880. /**
  99881. * Default Inputs manager for the FreeCamera.
  99882. * It groups all the default supported inputs for ease of use.
  99883. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99884. */
  99885. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99886. /**
  99887. * @hidden
  99888. */
  99889. _mouseInput: Nullable<FreeCameraMouseInput>;
  99890. /**
  99891. * Instantiates a new FreeCameraInputsManager.
  99892. * @param camera Defines the camera the inputs belong to
  99893. */
  99894. constructor(camera: FreeCamera);
  99895. /**
  99896. * Add keyboard input support to the input manager.
  99897. * @returns the current input manager
  99898. */
  99899. addKeyboard(): FreeCameraInputsManager;
  99900. /**
  99901. * Add mouse input support to the input manager.
  99902. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99903. * @returns the current input manager
  99904. */
  99905. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99906. /**
  99907. * Removes the mouse input support from the manager
  99908. * @returns the current input manager
  99909. */
  99910. removeMouse(): FreeCameraInputsManager;
  99911. /**
  99912. * Add touch input support to the input manager.
  99913. * @returns the current input manager
  99914. */
  99915. addTouch(): FreeCameraInputsManager;
  99916. /**
  99917. * Remove all attached input methods from a camera
  99918. */
  99919. clear(): void;
  99920. }
  99921. }
  99922. declare module BABYLON {
  99923. /**
  99924. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99925. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99926. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99927. */
  99928. export class FreeCamera extends TargetCamera {
  99929. /**
  99930. * Define the collision ellipsoid of the camera.
  99931. * This is helpful to simulate a camera body like the player body around the camera
  99932. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99933. */
  99934. ellipsoid: Vector3;
  99935. /**
  99936. * Define an offset for the position of the ellipsoid around the camera.
  99937. * This can be helpful to determine the center of the body near the gravity center of the body
  99938. * instead of its head.
  99939. */
  99940. ellipsoidOffset: Vector3;
  99941. /**
  99942. * Enable or disable collisions of the camera with the rest of the scene objects.
  99943. */
  99944. checkCollisions: boolean;
  99945. /**
  99946. * Enable or disable gravity on the camera.
  99947. */
  99948. applyGravity: boolean;
  99949. /**
  99950. * Define the input manager associated to the camera.
  99951. */
  99952. inputs: FreeCameraInputsManager;
  99953. /**
  99954. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99955. * Higher values reduce sensitivity.
  99956. */
  99957. get angularSensibility(): number;
  99958. /**
  99959. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99960. * Higher values reduce sensitivity.
  99961. */
  99962. set angularSensibility(value: number);
  99963. /**
  99964. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99965. */
  99966. get keysUp(): number[];
  99967. set keysUp(value: number[]);
  99968. /**
  99969. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99970. */
  99971. get keysUpward(): number[];
  99972. set keysUpward(value: number[]);
  99973. /**
  99974. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99975. */
  99976. get keysDown(): number[];
  99977. set keysDown(value: number[]);
  99978. /**
  99979. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99980. */
  99981. get keysDownward(): number[];
  99982. set keysDownward(value: number[]);
  99983. /**
  99984. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99985. */
  99986. get keysLeft(): number[];
  99987. set keysLeft(value: number[]);
  99988. /**
  99989. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99990. */
  99991. get keysRight(): number[];
  99992. set keysRight(value: number[]);
  99993. /**
  99994. * Event raised when the camera collide with a mesh in the scene.
  99995. */
  99996. onCollide: (collidedMesh: AbstractMesh) => void;
  99997. private _collider;
  99998. private _needMoveForGravity;
  99999. private _oldPosition;
  100000. private _diffPosition;
  100001. private _newPosition;
  100002. /** @hidden */
  100003. _localDirection: Vector3;
  100004. /** @hidden */
  100005. _transformedDirection: Vector3;
  100006. /**
  100007. * Instantiates a Free Camera.
  100008. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100009. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  100010. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  100011. * @param name Define the name of the camera in the scene
  100012. * @param position Define the start position of the camera in the scene
  100013. * @param scene Define the scene the camera belongs to
  100014. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100015. */
  100016. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100017. /**
  100018. * Attached controls to the current camera.
  100019. * @param element Defines the element the controls should be listened from
  100020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100021. */
  100022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100023. /**
  100024. * Detach the current controls from the camera.
  100025. * The camera will stop reacting to inputs.
  100026. * @param element Defines the element to stop listening the inputs from
  100027. */
  100028. detachControl(element: HTMLElement): void;
  100029. private _collisionMask;
  100030. /**
  100031. * Define a collision mask to limit the list of object the camera can collide with
  100032. */
  100033. get collisionMask(): number;
  100034. set collisionMask(mask: number);
  100035. /** @hidden */
  100036. _collideWithWorld(displacement: Vector3): void;
  100037. private _onCollisionPositionChange;
  100038. /** @hidden */
  100039. _checkInputs(): void;
  100040. /** @hidden */
  100041. _decideIfNeedsToMove(): boolean;
  100042. /** @hidden */
  100043. _updatePosition(): void;
  100044. /**
  100045. * Destroy the camera and release the current resources hold by it.
  100046. */
  100047. dispose(): void;
  100048. /**
  100049. * Gets the current object class name.
  100050. * @return the class name
  100051. */
  100052. getClassName(): string;
  100053. }
  100054. }
  100055. declare module BABYLON {
  100056. /**
  100057. * Represents a gamepad control stick position
  100058. */
  100059. export class StickValues {
  100060. /**
  100061. * The x component of the control stick
  100062. */
  100063. x: number;
  100064. /**
  100065. * The y component of the control stick
  100066. */
  100067. y: number;
  100068. /**
  100069. * Initializes the gamepad x and y control stick values
  100070. * @param x The x component of the gamepad control stick value
  100071. * @param y The y component of the gamepad control stick value
  100072. */
  100073. constructor(
  100074. /**
  100075. * The x component of the control stick
  100076. */
  100077. x: number,
  100078. /**
  100079. * The y component of the control stick
  100080. */
  100081. y: number);
  100082. }
  100083. /**
  100084. * An interface which manages callbacks for gamepad button changes
  100085. */
  100086. export interface GamepadButtonChanges {
  100087. /**
  100088. * Called when a gamepad has been changed
  100089. */
  100090. changed: boolean;
  100091. /**
  100092. * Called when a gamepad press event has been triggered
  100093. */
  100094. pressChanged: boolean;
  100095. /**
  100096. * Called when a touch event has been triggered
  100097. */
  100098. touchChanged: boolean;
  100099. /**
  100100. * Called when a value has changed
  100101. */
  100102. valueChanged: boolean;
  100103. }
  100104. /**
  100105. * Represents a gamepad
  100106. */
  100107. export class Gamepad {
  100108. /**
  100109. * The id of the gamepad
  100110. */
  100111. id: string;
  100112. /**
  100113. * The index of the gamepad
  100114. */
  100115. index: number;
  100116. /**
  100117. * The browser gamepad
  100118. */
  100119. browserGamepad: any;
  100120. /**
  100121. * Specifies what type of gamepad this represents
  100122. */
  100123. type: number;
  100124. private _leftStick;
  100125. private _rightStick;
  100126. /** @hidden */
  100127. _isConnected: boolean;
  100128. private _leftStickAxisX;
  100129. private _leftStickAxisY;
  100130. private _rightStickAxisX;
  100131. private _rightStickAxisY;
  100132. /**
  100133. * Triggered when the left control stick has been changed
  100134. */
  100135. private _onleftstickchanged;
  100136. /**
  100137. * Triggered when the right control stick has been changed
  100138. */
  100139. private _onrightstickchanged;
  100140. /**
  100141. * Represents a gamepad controller
  100142. */
  100143. static GAMEPAD: number;
  100144. /**
  100145. * Represents a generic controller
  100146. */
  100147. static GENERIC: number;
  100148. /**
  100149. * Represents an XBox controller
  100150. */
  100151. static XBOX: number;
  100152. /**
  100153. * Represents a pose-enabled controller
  100154. */
  100155. static POSE_ENABLED: number;
  100156. /**
  100157. * Represents an Dual Shock controller
  100158. */
  100159. static DUALSHOCK: number;
  100160. /**
  100161. * Specifies whether the left control stick should be Y-inverted
  100162. */
  100163. protected _invertLeftStickY: boolean;
  100164. /**
  100165. * Specifies if the gamepad has been connected
  100166. */
  100167. get isConnected(): boolean;
  100168. /**
  100169. * Initializes the gamepad
  100170. * @param id The id of the gamepad
  100171. * @param index The index of the gamepad
  100172. * @param browserGamepad The browser gamepad
  100173. * @param leftStickX The x component of the left joystick
  100174. * @param leftStickY The y component of the left joystick
  100175. * @param rightStickX The x component of the right joystick
  100176. * @param rightStickY The y component of the right joystick
  100177. */
  100178. constructor(
  100179. /**
  100180. * The id of the gamepad
  100181. */
  100182. id: string,
  100183. /**
  100184. * The index of the gamepad
  100185. */
  100186. index: number,
  100187. /**
  100188. * The browser gamepad
  100189. */
  100190. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100191. /**
  100192. * Callback triggered when the left joystick has changed
  100193. * @param callback
  100194. */
  100195. onleftstickchanged(callback: (values: StickValues) => void): void;
  100196. /**
  100197. * Callback triggered when the right joystick has changed
  100198. * @param callback
  100199. */
  100200. onrightstickchanged(callback: (values: StickValues) => void): void;
  100201. /**
  100202. * Gets the left joystick
  100203. */
  100204. get leftStick(): StickValues;
  100205. /**
  100206. * Sets the left joystick values
  100207. */
  100208. set leftStick(newValues: StickValues);
  100209. /**
  100210. * Gets the right joystick
  100211. */
  100212. get rightStick(): StickValues;
  100213. /**
  100214. * Sets the right joystick value
  100215. */
  100216. set rightStick(newValues: StickValues);
  100217. /**
  100218. * Updates the gamepad joystick positions
  100219. */
  100220. update(): void;
  100221. /**
  100222. * Disposes the gamepad
  100223. */
  100224. dispose(): void;
  100225. }
  100226. /**
  100227. * Represents a generic gamepad
  100228. */
  100229. export class GenericPad extends Gamepad {
  100230. private _buttons;
  100231. private _onbuttondown;
  100232. private _onbuttonup;
  100233. /**
  100234. * Observable triggered when a button has been pressed
  100235. */
  100236. onButtonDownObservable: Observable<number>;
  100237. /**
  100238. * Observable triggered when a button has been released
  100239. */
  100240. onButtonUpObservable: Observable<number>;
  100241. /**
  100242. * Callback triggered when a button has been pressed
  100243. * @param callback Called when a button has been pressed
  100244. */
  100245. onbuttondown(callback: (buttonPressed: number) => void): void;
  100246. /**
  100247. * Callback triggered when a button has been released
  100248. * @param callback Called when a button has been released
  100249. */
  100250. onbuttonup(callback: (buttonReleased: number) => void): void;
  100251. /**
  100252. * Initializes the generic gamepad
  100253. * @param id The id of the generic gamepad
  100254. * @param index The index of the generic gamepad
  100255. * @param browserGamepad The browser gamepad
  100256. */
  100257. constructor(id: string, index: number, browserGamepad: any);
  100258. private _setButtonValue;
  100259. /**
  100260. * Updates the generic gamepad
  100261. */
  100262. update(): void;
  100263. /**
  100264. * Disposes the generic gamepad
  100265. */
  100266. dispose(): void;
  100267. }
  100268. }
  100269. declare module BABYLON {
  100270. /**
  100271. * Defines the types of pose enabled controllers that are supported
  100272. */
  100273. export enum PoseEnabledControllerType {
  100274. /**
  100275. * HTC Vive
  100276. */
  100277. VIVE = 0,
  100278. /**
  100279. * Oculus Rift
  100280. */
  100281. OCULUS = 1,
  100282. /**
  100283. * Windows mixed reality
  100284. */
  100285. WINDOWS = 2,
  100286. /**
  100287. * Samsung gear VR
  100288. */
  100289. GEAR_VR = 3,
  100290. /**
  100291. * Google Daydream
  100292. */
  100293. DAYDREAM = 4,
  100294. /**
  100295. * Generic
  100296. */
  100297. GENERIC = 5
  100298. }
  100299. /**
  100300. * Defines the MutableGamepadButton interface for the state of a gamepad button
  100301. */
  100302. export interface MutableGamepadButton {
  100303. /**
  100304. * Value of the button/trigger
  100305. */
  100306. value: number;
  100307. /**
  100308. * If the button/trigger is currently touched
  100309. */
  100310. touched: boolean;
  100311. /**
  100312. * If the button/trigger is currently pressed
  100313. */
  100314. pressed: boolean;
  100315. }
  100316. /**
  100317. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  100318. * @hidden
  100319. */
  100320. export interface ExtendedGamepadButton extends GamepadButton {
  100321. /**
  100322. * If the button/trigger is currently pressed
  100323. */
  100324. readonly pressed: boolean;
  100325. /**
  100326. * If the button/trigger is currently touched
  100327. */
  100328. readonly touched: boolean;
  100329. /**
  100330. * Value of the button/trigger
  100331. */
  100332. readonly value: number;
  100333. }
  100334. /** @hidden */
  100335. export interface _GamePadFactory {
  100336. /**
  100337. * Returns whether or not the current gamepad can be created for this type of controller.
  100338. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100339. * @returns true if it can be created, otherwise false
  100340. */
  100341. canCreate(gamepadInfo: any): boolean;
  100342. /**
  100343. * Creates a new instance of the Gamepad.
  100344. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100345. * @returns the new gamepad instance
  100346. */
  100347. create(gamepadInfo: any): Gamepad;
  100348. }
  100349. /**
  100350. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100351. */
  100352. export class PoseEnabledControllerHelper {
  100353. /** @hidden */
  100354. static _ControllerFactories: _GamePadFactory[];
  100355. /** @hidden */
  100356. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100357. /**
  100358. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100359. * @param vrGamepad the gamepad to initialized
  100360. * @returns a vr controller of the type the gamepad identified as
  100361. */
  100362. static InitiateController(vrGamepad: any): Gamepad;
  100363. }
  100364. /**
  100365. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100366. */
  100367. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100368. /**
  100369. * If the controller is used in a webXR session
  100370. */
  100371. isXR: boolean;
  100372. private _deviceRoomPosition;
  100373. private _deviceRoomRotationQuaternion;
  100374. /**
  100375. * The device position in babylon space
  100376. */
  100377. devicePosition: Vector3;
  100378. /**
  100379. * The device rotation in babylon space
  100380. */
  100381. deviceRotationQuaternion: Quaternion;
  100382. /**
  100383. * The scale factor of the device in babylon space
  100384. */
  100385. deviceScaleFactor: number;
  100386. /**
  100387. * (Likely devicePosition should be used instead) The device position in its room space
  100388. */
  100389. position: Vector3;
  100390. /**
  100391. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  100392. */
  100393. rotationQuaternion: Quaternion;
  100394. /**
  100395. * The type of controller (Eg. Windows mixed reality)
  100396. */
  100397. controllerType: PoseEnabledControllerType;
  100398. protected _calculatedPosition: Vector3;
  100399. private _calculatedRotation;
  100400. /**
  100401. * The raw pose from the device
  100402. */
  100403. rawPose: DevicePose;
  100404. private _trackPosition;
  100405. private _maxRotationDistFromHeadset;
  100406. private _draggedRoomRotation;
  100407. /**
  100408. * @hidden
  100409. */
  100410. _disableTrackPosition(fixedPosition: Vector3): void;
  100411. /**
  100412. * Internal, the mesh attached to the controller
  100413. * @hidden
  100414. */
  100415. _mesh: Nullable<AbstractMesh>;
  100416. private _poseControlledCamera;
  100417. private _leftHandSystemQuaternion;
  100418. /**
  100419. * Internal, matrix used to convert room space to babylon space
  100420. * @hidden
  100421. */
  100422. _deviceToWorld: Matrix;
  100423. /**
  100424. * Node to be used when casting a ray from the controller
  100425. * @hidden
  100426. */
  100427. _pointingPoseNode: Nullable<TransformNode>;
  100428. /**
  100429. * Name of the child mesh that can be used to cast a ray from the controller
  100430. */
  100431. static readonly POINTING_POSE: string;
  100432. /**
  100433. * Creates a new PoseEnabledController from a gamepad
  100434. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  100435. */
  100436. constructor(browserGamepad: any);
  100437. private _workingMatrix;
  100438. /**
  100439. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  100440. */
  100441. update(): void;
  100442. /**
  100443. * Updates only the pose device and mesh without doing any button event checking
  100444. */
  100445. protected _updatePoseAndMesh(): void;
  100446. /**
  100447. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  100448. * @param poseData raw pose fromthe device
  100449. */
  100450. updateFromDevice(poseData: DevicePose): void;
  100451. /**
  100452. * @hidden
  100453. */
  100454. _meshAttachedObservable: Observable<AbstractMesh>;
  100455. /**
  100456. * Attaches a mesh to the controller
  100457. * @param mesh the mesh to be attached
  100458. */
  100459. attachToMesh(mesh: AbstractMesh): void;
  100460. /**
  100461. * Attaches the controllers mesh to a camera
  100462. * @param camera the camera the mesh should be attached to
  100463. */
  100464. attachToPoseControlledCamera(camera: TargetCamera): void;
  100465. /**
  100466. * Disposes of the controller
  100467. */
  100468. dispose(): void;
  100469. /**
  100470. * The mesh that is attached to the controller
  100471. */
  100472. get mesh(): Nullable<AbstractMesh>;
  100473. /**
  100474. * Gets the ray of the controller in the direction the controller is pointing
  100475. * @param length the length the resulting ray should be
  100476. * @returns a ray in the direction the controller is pointing
  100477. */
  100478. getForwardRay(length?: number): Ray;
  100479. }
  100480. }
  100481. declare module BABYLON {
  100482. /**
  100483. * Defines the WebVRController object that represents controllers tracked in 3D space
  100484. */
  100485. export abstract class WebVRController extends PoseEnabledController {
  100486. /**
  100487. * Internal, the default controller model for the controller
  100488. */
  100489. protected _defaultModel: Nullable<AbstractMesh>;
  100490. /**
  100491. * Fired when the trigger state has changed
  100492. */
  100493. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100494. /**
  100495. * Fired when the main button state has changed
  100496. */
  100497. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100498. /**
  100499. * Fired when the secondary button state has changed
  100500. */
  100501. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100502. /**
  100503. * Fired when the pad state has changed
  100504. */
  100505. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  100506. /**
  100507. * Fired when controllers stick values have changed
  100508. */
  100509. onPadValuesChangedObservable: Observable<StickValues>;
  100510. /**
  100511. * Array of button availible on the controller
  100512. */
  100513. protected _buttons: Array<MutableGamepadButton>;
  100514. private _onButtonStateChange;
  100515. /**
  100516. * Fired when a controller button's state has changed
  100517. * @param callback the callback containing the button that was modified
  100518. */
  100519. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  100520. /**
  100521. * X and Y axis corresponding to the controllers joystick
  100522. */
  100523. pad: StickValues;
  100524. /**
  100525. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  100526. */
  100527. hand: string;
  100528. /**
  100529. * The default controller model for the controller
  100530. */
  100531. get defaultModel(): Nullable<AbstractMesh>;
  100532. /**
  100533. * Creates a new WebVRController from a gamepad
  100534. * @param vrGamepad the gamepad that the WebVRController should be created from
  100535. */
  100536. constructor(vrGamepad: any);
  100537. /**
  100538. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  100539. */
  100540. update(): void;
  100541. /**
  100542. * Function to be called when a button is modified
  100543. */
  100544. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100545. /**
  100546. * Loads a mesh and attaches it to the controller
  100547. * @param scene the scene the mesh should be added to
  100548. * @param meshLoaded callback for when the mesh has been loaded
  100549. */
  100550. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100551. private _setButtonValue;
  100552. private _changes;
  100553. private _checkChanges;
  100554. /**
  100555. * Disposes of th webVRCOntroller
  100556. */
  100557. dispose(): void;
  100558. }
  100559. }
  100560. declare module BABYLON {
  100561. /**
  100562. * The HemisphericLight simulates the ambient environment light,
  100563. * so the passed direction is the light reflection direction, not the incoming direction.
  100564. */
  100565. export class HemisphericLight extends Light {
  100566. /**
  100567. * The groundColor is the light in the opposite direction to the one specified during creation.
  100568. * 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.
  100569. */
  100570. groundColor: Color3;
  100571. /**
  100572. * The light reflection direction, not the incoming direction.
  100573. */
  100574. direction: Vector3;
  100575. /**
  100576. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100577. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100578. * The HemisphericLight can't cast shadows.
  100579. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100580. * @param name The friendly name of the light
  100581. * @param direction The direction of the light reflection
  100582. * @param scene The scene the light belongs to
  100583. */
  100584. constructor(name: string, direction: Vector3, scene: Scene);
  100585. protected _buildUniformLayout(): void;
  100586. /**
  100587. * Returns the string "HemisphericLight".
  100588. * @return The class name
  100589. */
  100590. getClassName(): string;
  100591. /**
  100592. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100593. * Returns the updated direction.
  100594. * @param target The target the direction should point to
  100595. * @return The computed direction
  100596. */
  100597. setDirectionToTarget(target: Vector3): Vector3;
  100598. /**
  100599. * Returns the shadow generator associated to the light.
  100600. * @returns Always null for hemispheric lights because it does not support shadows.
  100601. */
  100602. getShadowGenerator(): Nullable<IShadowGenerator>;
  100603. /**
  100604. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100605. * @param effect The effect to update
  100606. * @param lightIndex The index of the light in the effect to update
  100607. * @returns The hemispheric light
  100608. */
  100609. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100610. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100611. /**
  100612. * Computes the world matrix of the node
  100613. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100614. * @param useWasUpdatedFlag defines a reserved property
  100615. * @returns the world matrix
  100616. */
  100617. computeWorldMatrix(): Matrix;
  100618. /**
  100619. * Returns the integer 3.
  100620. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100621. */
  100622. getTypeID(): number;
  100623. /**
  100624. * Prepares the list of defines specific to the light type.
  100625. * @param defines the list of defines
  100626. * @param lightIndex defines the index of the light for the effect
  100627. */
  100628. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100629. }
  100630. }
  100631. declare module BABYLON {
  100632. /** @hidden */
  100633. export var vrMultiviewToSingleviewPixelShader: {
  100634. name: string;
  100635. shader: string;
  100636. };
  100637. }
  100638. declare module BABYLON {
  100639. /**
  100640. * Renders to multiple views with a single draw call
  100641. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100642. */
  100643. export class MultiviewRenderTarget extends RenderTargetTexture {
  100644. /**
  100645. * Creates a multiview render target
  100646. * @param scene scene used with the render target
  100647. * @param size the size of the render target (used for each view)
  100648. */
  100649. constructor(scene: Scene, size?: number | {
  100650. width: number;
  100651. height: number;
  100652. } | {
  100653. ratio: number;
  100654. });
  100655. /**
  100656. * @hidden
  100657. * @param faceIndex the face index, if its a cube texture
  100658. */
  100659. _bindFrameBuffer(faceIndex?: number): void;
  100660. /**
  100661. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100662. * @returns the view count
  100663. */
  100664. getViewCount(): number;
  100665. }
  100666. }
  100667. declare module BABYLON {
  100668. interface Engine {
  100669. /**
  100670. * Creates a new multiview render target
  100671. * @param width defines the width of the texture
  100672. * @param height defines the height of the texture
  100673. * @returns the created multiview texture
  100674. */
  100675. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100676. /**
  100677. * Binds a multiview framebuffer to be drawn to
  100678. * @param multiviewTexture texture to bind
  100679. */
  100680. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100681. }
  100682. interface Camera {
  100683. /**
  100684. * @hidden
  100685. * 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)
  100686. */
  100687. _useMultiviewToSingleView: boolean;
  100688. /**
  100689. * @hidden
  100690. * 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)
  100691. */
  100692. _multiviewTexture: Nullable<RenderTargetTexture>;
  100693. /**
  100694. * @hidden
  100695. * ensures the multiview texture of the camera exists and has the specified width/height
  100696. * @param width height to set on the multiview texture
  100697. * @param height width to set on the multiview texture
  100698. */
  100699. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100700. }
  100701. interface Scene {
  100702. /** @hidden */
  100703. _transformMatrixR: Matrix;
  100704. /** @hidden */
  100705. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100706. /** @hidden */
  100707. _createMultiviewUbo(): void;
  100708. /** @hidden */
  100709. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100710. /** @hidden */
  100711. _renderMultiviewToSingleView(camera: Camera): void;
  100712. }
  100713. }
  100714. declare module BABYLON {
  100715. /**
  100716. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100717. * This will not be used for webXR as it supports displaying texture arrays directly
  100718. */
  100719. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100720. /**
  100721. * Gets a string identifying the name of the class
  100722. * @returns "VRMultiviewToSingleviewPostProcess" string
  100723. */
  100724. getClassName(): string;
  100725. /**
  100726. * Initializes a VRMultiviewToSingleview
  100727. * @param name name of the post process
  100728. * @param camera camera to be applied to
  100729. * @param scaleFactor scaling factor to the size of the output texture
  100730. */
  100731. constructor(name: string, camera: Camera, scaleFactor: number);
  100732. }
  100733. }
  100734. declare module BABYLON {
  100735. /**
  100736. * Interface used to define additional presentation attributes
  100737. */
  100738. export interface IVRPresentationAttributes {
  100739. /**
  100740. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100741. */
  100742. highRefreshRate: boolean;
  100743. /**
  100744. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100745. */
  100746. foveationLevel: number;
  100747. }
  100748. interface Engine {
  100749. /** @hidden */
  100750. _vrDisplay: any;
  100751. /** @hidden */
  100752. _vrSupported: boolean;
  100753. /** @hidden */
  100754. _oldSize: Size;
  100755. /** @hidden */
  100756. _oldHardwareScaleFactor: number;
  100757. /** @hidden */
  100758. _vrExclusivePointerMode: boolean;
  100759. /** @hidden */
  100760. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100761. /** @hidden */
  100762. _onVRDisplayPointerRestricted: () => void;
  100763. /** @hidden */
  100764. _onVRDisplayPointerUnrestricted: () => void;
  100765. /** @hidden */
  100766. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100767. /** @hidden */
  100768. _onVrDisplayDisconnect: Nullable<() => void>;
  100769. /** @hidden */
  100770. _onVrDisplayPresentChange: Nullable<() => void>;
  100771. /**
  100772. * Observable signaled when VR display mode changes
  100773. */
  100774. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100775. /**
  100776. * Observable signaled when VR request present is complete
  100777. */
  100778. onVRRequestPresentComplete: Observable<boolean>;
  100779. /**
  100780. * Observable signaled when VR request present starts
  100781. */
  100782. onVRRequestPresentStart: Observable<Engine>;
  100783. /**
  100784. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100785. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100786. */
  100787. isInVRExclusivePointerMode: boolean;
  100788. /**
  100789. * Gets a boolean indicating if a webVR device was detected
  100790. * @returns true if a webVR device was detected
  100791. */
  100792. isVRDevicePresent(): boolean;
  100793. /**
  100794. * Gets the current webVR device
  100795. * @returns the current webVR device (or null)
  100796. */
  100797. getVRDevice(): any;
  100798. /**
  100799. * Initializes a webVR display and starts listening to display change events
  100800. * The onVRDisplayChangedObservable will be notified upon these changes
  100801. * @returns A promise containing a VRDisplay and if vr is supported
  100802. */
  100803. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100804. /** @hidden */
  100805. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100806. /**
  100807. * Gets or sets the presentation attributes used to configure VR rendering
  100808. */
  100809. vrPresentationAttributes?: IVRPresentationAttributes;
  100810. /**
  100811. * Call this function to switch to webVR mode
  100812. * Will do nothing if webVR is not supported or if there is no webVR device
  100813. * @param options the webvr options provided to the camera. mainly used for multiview
  100814. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100815. */
  100816. enableVR(options: WebVROptions): void;
  100817. /** @hidden */
  100818. _onVRFullScreenTriggered(): void;
  100819. }
  100820. }
  100821. declare module BABYLON {
  100822. /**
  100823. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100824. * IMPORTANT!! The data is right-hand data.
  100825. * @export
  100826. * @interface DevicePose
  100827. */
  100828. export interface DevicePose {
  100829. /**
  100830. * The position of the device, values in array are [x,y,z].
  100831. */
  100832. readonly position: Nullable<Float32Array>;
  100833. /**
  100834. * The linearVelocity of the device, values in array are [x,y,z].
  100835. */
  100836. readonly linearVelocity: Nullable<Float32Array>;
  100837. /**
  100838. * The linearAcceleration of the device, values in array are [x,y,z].
  100839. */
  100840. readonly linearAcceleration: Nullable<Float32Array>;
  100841. /**
  100842. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100843. */
  100844. readonly orientation: Nullable<Float32Array>;
  100845. /**
  100846. * The angularVelocity of the device, values in array are [x,y,z].
  100847. */
  100848. readonly angularVelocity: Nullable<Float32Array>;
  100849. /**
  100850. * The angularAcceleration of the device, values in array are [x,y,z].
  100851. */
  100852. readonly angularAcceleration: Nullable<Float32Array>;
  100853. }
  100854. /**
  100855. * Interface representing a pose controlled object in Babylon.
  100856. * A pose controlled object has both regular pose values as well as pose values
  100857. * from an external device such as a VR head mounted display
  100858. */
  100859. export interface PoseControlled {
  100860. /**
  100861. * The position of the object in babylon space.
  100862. */
  100863. position: Vector3;
  100864. /**
  100865. * The rotation quaternion of the object in babylon space.
  100866. */
  100867. rotationQuaternion: Quaternion;
  100868. /**
  100869. * The position of the device in babylon space.
  100870. */
  100871. devicePosition?: Vector3;
  100872. /**
  100873. * The rotation quaternion of the device in babylon space.
  100874. */
  100875. deviceRotationQuaternion: Quaternion;
  100876. /**
  100877. * The raw pose coming from the device.
  100878. */
  100879. rawPose: Nullable<DevicePose>;
  100880. /**
  100881. * The scale of the device to be used when translating from device space to babylon space.
  100882. */
  100883. deviceScaleFactor: number;
  100884. /**
  100885. * Updates the poseControlled values based on the input device pose.
  100886. * @param poseData the pose data to update the object with
  100887. */
  100888. updateFromDevice(poseData: DevicePose): void;
  100889. }
  100890. /**
  100891. * Set of options to customize the webVRCamera
  100892. */
  100893. export interface WebVROptions {
  100894. /**
  100895. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100896. */
  100897. trackPosition?: boolean;
  100898. /**
  100899. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100900. */
  100901. positionScale?: number;
  100902. /**
  100903. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100904. */
  100905. displayName?: string;
  100906. /**
  100907. * Should the native controller meshes be initialized. (default: true)
  100908. */
  100909. controllerMeshes?: boolean;
  100910. /**
  100911. * Creating a default HemiLight only on controllers. (default: true)
  100912. */
  100913. defaultLightingOnControllers?: boolean;
  100914. /**
  100915. * If you don't want to use the default VR button of the helper. (default: false)
  100916. */
  100917. useCustomVRButton?: boolean;
  100918. /**
  100919. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100920. */
  100921. customVRButton?: HTMLButtonElement;
  100922. /**
  100923. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100924. */
  100925. rayLength?: number;
  100926. /**
  100927. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100928. */
  100929. defaultHeight?: number;
  100930. /**
  100931. * If multiview should be used if availible (default: false)
  100932. */
  100933. useMultiview?: boolean;
  100934. }
  100935. /**
  100936. * This represents a WebVR camera.
  100937. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100938. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100939. */
  100940. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100941. private webVROptions;
  100942. /**
  100943. * @hidden
  100944. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100945. */
  100946. _vrDevice: any;
  100947. /**
  100948. * The rawPose of the vrDevice.
  100949. */
  100950. rawPose: Nullable<DevicePose>;
  100951. private _onVREnabled;
  100952. private _specsVersion;
  100953. private _attached;
  100954. private _frameData;
  100955. protected _descendants: Array<Node>;
  100956. private _deviceRoomPosition;
  100957. /** @hidden */
  100958. _deviceRoomRotationQuaternion: Quaternion;
  100959. private _standingMatrix;
  100960. /**
  100961. * Represents device position in babylon space.
  100962. */
  100963. devicePosition: Vector3;
  100964. /**
  100965. * Represents device rotation in babylon space.
  100966. */
  100967. deviceRotationQuaternion: Quaternion;
  100968. /**
  100969. * The scale of the device to be used when translating from device space to babylon space.
  100970. */
  100971. deviceScaleFactor: number;
  100972. private _deviceToWorld;
  100973. private _worldToDevice;
  100974. /**
  100975. * References to the webVR controllers for the vrDevice.
  100976. */
  100977. controllers: Array<WebVRController>;
  100978. /**
  100979. * Emits an event when a controller is attached.
  100980. */
  100981. onControllersAttachedObservable: Observable<WebVRController[]>;
  100982. /**
  100983. * Emits an event when a controller's mesh has been loaded;
  100984. */
  100985. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100986. /**
  100987. * Emits an event when the HMD's pose has been updated.
  100988. */
  100989. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100990. private _poseSet;
  100991. /**
  100992. * If the rig cameras be used as parent instead of this camera.
  100993. */
  100994. rigParenting: boolean;
  100995. private _lightOnControllers;
  100996. private _defaultHeight?;
  100997. /**
  100998. * Instantiates a WebVRFreeCamera.
  100999. * @param name The name of the WebVRFreeCamera
  101000. * @param position The starting anchor position for the camera
  101001. * @param scene The scene the camera belongs to
  101002. * @param webVROptions a set of customizable options for the webVRCamera
  101003. */
  101004. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  101005. /**
  101006. * Gets the device distance from the ground in meters.
  101007. * @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.
  101008. */
  101009. deviceDistanceToRoomGround(): number;
  101010. /**
  101011. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101012. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  101013. */
  101014. useStandingMatrix(callback?: (bool: boolean) => void): void;
  101015. /**
  101016. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101017. * @returns A promise with a boolean set to if the standing matrix is supported.
  101018. */
  101019. useStandingMatrixAsync(): Promise<boolean>;
  101020. /**
  101021. * Disposes the camera
  101022. */
  101023. dispose(): void;
  101024. /**
  101025. * Gets a vrController by name.
  101026. * @param name The name of the controller to retreive
  101027. * @returns the controller matching the name specified or null if not found
  101028. */
  101029. getControllerByName(name: string): Nullable<WebVRController>;
  101030. private _leftController;
  101031. /**
  101032. * The controller corresponding to the users left hand.
  101033. */
  101034. get leftController(): Nullable<WebVRController>;
  101035. private _rightController;
  101036. /**
  101037. * The controller corresponding to the users right hand.
  101038. */
  101039. get rightController(): Nullable<WebVRController>;
  101040. /**
  101041. * Casts a ray forward from the vrCamera's gaze.
  101042. * @param length Length of the ray (default: 100)
  101043. * @returns the ray corresponding to the gaze
  101044. */
  101045. getForwardRay(length?: number): Ray;
  101046. /**
  101047. * @hidden
  101048. * Updates the camera based on device's frame data
  101049. */
  101050. _checkInputs(): void;
  101051. /**
  101052. * Updates the poseControlled values based on the input device pose.
  101053. * @param poseData Pose coming from the device
  101054. */
  101055. updateFromDevice(poseData: DevicePose): void;
  101056. private _htmlElementAttached;
  101057. private _detachIfAttached;
  101058. /**
  101059. * WebVR's attach control will start broadcasting frames to the device.
  101060. * Note that in certain browsers (chrome for example) this function must be called
  101061. * within a user-interaction callback. Example:
  101062. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  101063. *
  101064. * @param element html element to attach the vrDevice to
  101065. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  101066. */
  101067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101068. /**
  101069. * Detaches the camera from the html element and disables VR
  101070. *
  101071. * @param element html element to detach from
  101072. */
  101073. detachControl(element: HTMLElement): void;
  101074. /**
  101075. * @returns the name of this class
  101076. */
  101077. getClassName(): string;
  101078. /**
  101079. * Calls resetPose on the vrDisplay
  101080. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  101081. */
  101082. resetToCurrentRotation(): void;
  101083. /**
  101084. * @hidden
  101085. * Updates the rig cameras (left and right eye)
  101086. */
  101087. _updateRigCameras(): void;
  101088. private _workingVector;
  101089. private _oneVector;
  101090. private _workingMatrix;
  101091. private updateCacheCalled;
  101092. private _correctPositionIfNotTrackPosition;
  101093. /**
  101094. * @hidden
  101095. * Updates the cached values of the camera
  101096. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  101097. */
  101098. _updateCache(ignoreParentClass?: boolean): void;
  101099. /**
  101100. * @hidden
  101101. * Get current device position in babylon world
  101102. */
  101103. _computeDevicePosition(): void;
  101104. /**
  101105. * Updates the current device position and rotation in the babylon world
  101106. */
  101107. update(): void;
  101108. /**
  101109. * @hidden
  101110. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  101111. * @returns an identity matrix
  101112. */
  101113. _getViewMatrix(): Matrix;
  101114. private _tmpMatrix;
  101115. /**
  101116. * This function is called by the two RIG cameras.
  101117. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  101118. * @hidden
  101119. */
  101120. _getWebVRViewMatrix(): Matrix;
  101121. /** @hidden */
  101122. _getWebVRProjectionMatrix(): Matrix;
  101123. private _onGamepadConnectedObserver;
  101124. private _onGamepadDisconnectedObserver;
  101125. private _updateCacheWhenTrackingDisabledObserver;
  101126. /**
  101127. * Initializes the controllers and their meshes
  101128. */
  101129. initControllers(): void;
  101130. }
  101131. }
  101132. declare module BABYLON {
  101133. /**
  101134. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  101135. *
  101136. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  101137. *
  101138. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  101139. */
  101140. export class MaterialHelper {
  101141. /**
  101142. * Bind the current view position to an effect.
  101143. * @param effect The effect to be bound
  101144. * @param scene The scene the eyes position is used from
  101145. * @param variableName name of the shader variable that will hold the eye position
  101146. */
  101147. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  101148. /**
  101149. * Helps preparing the defines values about the UVs in used in the effect.
  101150. * UVs are shared as much as we can accross channels in the shaders.
  101151. * @param texture The texture we are preparing the UVs for
  101152. * @param defines The defines to update
  101153. * @param key The channel key "diffuse", "specular"... used in the shader
  101154. */
  101155. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  101156. /**
  101157. * Binds a texture matrix value to its corrsponding uniform
  101158. * @param texture The texture to bind the matrix for
  101159. * @param uniformBuffer The uniform buffer receivin the data
  101160. * @param key The channel key "diffuse", "specular"... used in the shader
  101161. */
  101162. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  101163. /**
  101164. * Gets the current status of the fog (should it be enabled?)
  101165. * @param mesh defines the mesh to evaluate for fog support
  101166. * @param scene defines the hosting scene
  101167. * @returns true if fog must be enabled
  101168. */
  101169. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  101170. /**
  101171. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  101172. * @param mesh defines the current mesh
  101173. * @param scene defines the current scene
  101174. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  101175. * @param pointsCloud defines if point cloud rendering has to be turned on
  101176. * @param fogEnabled defines if fog has to be turned on
  101177. * @param alphaTest defines if alpha testing has to be turned on
  101178. * @param defines defines the current list of defines
  101179. */
  101180. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  101181. /**
  101182. * Helper used to prepare the list of defines associated with frame values for shader compilation
  101183. * @param scene defines the current scene
  101184. * @param engine defines the current engine
  101185. * @param defines specifies the list of active defines
  101186. * @param useInstances defines if instances have to be turned on
  101187. * @param useClipPlane defines if clip plane have to be turned on
  101188. * @param useInstances defines if instances have to be turned on
  101189. * @param useThinInstances defines if thin instances have to be turned on
  101190. */
  101191. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101192. /**
  101193. * Prepares the defines for bones
  101194. * @param mesh The mesh containing the geometry data we will draw
  101195. * @param defines The defines to update
  101196. */
  101197. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101198. /**
  101199. * Prepares the defines for morph targets
  101200. * @param mesh The mesh containing the geometry data we will draw
  101201. * @param defines The defines to update
  101202. */
  101203. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101204. /**
  101205. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101206. * @param mesh The mesh containing the geometry data we will draw
  101207. * @param defines The defines to update
  101208. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101209. * @param useBones Precise whether bones should be used or not (override mesh info)
  101210. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101211. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101212. * @returns false if defines are considered not dirty and have not been checked
  101213. */
  101214. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101215. /**
  101216. * Prepares the defines related to multiview
  101217. * @param scene The scene we are intending to draw
  101218. * @param defines The defines to update
  101219. */
  101220. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101221. /**
  101222. * Prepares the defines related to the prepass
  101223. * @param scene The scene we are intending to draw
  101224. * @param defines The defines to update
  101225. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101226. */
  101227. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101228. /**
  101229. * Prepares the defines related to the light information passed in parameter
  101230. * @param scene The scene we are intending to draw
  101231. * @param mesh The mesh the effect is compiling for
  101232. * @param light The light the effect is compiling for
  101233. * @param lightIndex The index of the light
  101234. * @param defines The defines to update
  101235. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101236. * @param state Defines the current state regarding what is needed (normals, etc...)
  101237. */
  101238. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101239. needNormals: boolean;
  101240. needRebuild: boolean;
  101241. shadowEnabled: boolean;
  101242. specularEnabled: boolean;
  101243. lightmapMode: boolean;
  101244. }): void;
  101245. /**
  101246. * Prepares the defines related to the light information passed in parameter
  101247. * @param scene The scene we are intending to draw
  101248. * @param mesh The mesh the effect is compiling for
  101249. * @param defines The defines to update
  101250. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101251. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101252. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101253. * @returns true if normals will be required for the rest of the effect
  101254. */
  101255. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101256. /**
  101257. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101258. * @param lightIndex defines the light index
  101259. * @param uniformsList The uniform list
  101260. * @param samplersList The sampler list
  101261. * @param projectedLightTexture defines if projected texture must be used
  101262. * @param uniformBuffersList defines an optional list of uniform buffers
  101263. */
  101264. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101265. /**
  101266. * Prepares the uniforms and samplers list to be used in the effect
  101267. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101268. * @param samplersList The sampler list
  101269. * @param defines The defines helping in the list generation
  101270. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101271. */
  101272. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101273. /**
  101274. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101275. * @param defines The defines to update while falling back
  101276. * @param fallbacks The authorized effect fallbacks
  101277. * @param maxSimultaneousLights The maximum number of lights allowed
  101278. * @param rank the current rank of the Effect
  101279. * @returns The newly affected rank
  101280. */
  101281. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101282. private static _TmpMorphInfluencers;
  101283. /**
  101284. * Prepares the list of attributes required for morph targets according to the effect defines.
  101285. * @param attribs The current list of supported attribs
  101286. * @param mesh The mesh to prepare the morph targets attributes for
  101287. * @param influencers The number of influencers
  101288. */
  101289. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101290. /**
  101291. * Prepares the list of attributes required for morph targets according to the effect defines.
  101292. * @param attribs The current list of supported attribs
  101293. * @param mesh The mesh to prepare the morph targets attributes for
  101294. * @param defines The current Defines of the effect
  101295. */
  101296. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  101297. /**
  101298. * Prepares the list of attributes required for bones according to the effect defines.
  101299. * @param attribs The current list of supported attribs
  101300. * @param mesh The mesh to prepare the bones attributes for
  101301. * @param defines The current Defines of the effect
  101302. * @param fallbacks The current efffect fallback strategy
  101303. */
  101304. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  101305. /**
  101306. * Check and prepare the list of attributes required for instances according to the effect defines.
  101307. * @param attribs The current list of supported attribs
  101308. * @param defines The current MaterialDefines of the effect
  101309. */
  101310. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  101311. /**
  101312. * Add the list of attributes required for instances to the attribs array.
  101313. * @param attribs The current list of supported attribs
  101314. */
  101315. static PushAttributesForInstances(attribs: string[]): void;
  101316. /**
  101317. * Binds the light information to the effect.
  101318. * @param light The light containing the generator
  101319. * @param effect The effect we are binding the data to
  101320. * @param lightIndex The light index in the effect used to render
  101321. */
  101322. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  101323. /**
  101324. * Binds the lights information from the scene to the effect for the given mesh.
  101325. * @param light Light to bind
  101326. * @param lightIndex Light index
  101327. * @param scene The scene where the light belongs to
  101328. * @param effect The effect we are binding the data to
  101329. * @param useSpecular Defines if specular is supported
  101330. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101331. */
  101332. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  101333. /**
  101334. * Binds the lights information from the scene to the effect for the given mesh.
  101335. * @param scene The scene the lights belongs to
  101336. * @param mesh The mesh we are binding the information to render
  101337. * @param effect The effect we are binding the data to
  101338. * @param defines The generated defines for the effect
  101339. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  101340. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101341. */
  101342. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101343. private static _tempFogColor;
  101344. /**
  101345. * Binds the fog information from the scene to the effect for the given mesh.
  101346. * @param scene The scene the lights belongs to
  101347. * @param mesh The mesh we are binding the information to render
  101348. * @param effect The effect we are binding the data to
  101349. * @param linearSpace Defines if the fog effect is applied in linear space
  101350. */
  101351. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101352. /**
  101353. * Binds the bones information from the mesh to the effect.
  101354. * @param mesh The mesh we are binding the information to render
  101355. * @param effect The effect we are binding the data to
  101356. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101357. */
  101358. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101359. private static _CopyBonesTransformationMatrices;
  101360. /**
  101361. * Binds the morph targets information from the mesh to the effect.
  101362. * @param abstractMesh The mesh we are binding the information to render
  101363. * @param effect The effect we are binding the data to
  101364. */
  101365. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101366. /**
  101367. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101368. * @param defines The generated defines used in the effect
  101369. * @param effect The effect we are binding the data to
  101370. * @param scene The scene we are willing to render with logarithmic scale for
  101371. */
  101372. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101373. /**
  101374. * Binds the clip plane information from the scene to the effect.
  101375. * @param scene The scene the clip plane information are extracted from
  101376. * @param effect The effect we are binding the data to
  101377. */
  101378. static BindClipPlane(effect: Effect, scene: Scene): void;
  101379. }
  101380. }
  101381. declare module BABYLON {
  101382. /**
  101383. * Block used to expose an input value
  101384. */
  101385. export class InputBlock extends NodeMaterialBlock {
  101386. private _mode;
  101387. private _associatedVariableName;
  101388. private _storedValue;
  101389. private _valueCallback;
  101390. private _type;
  101391. private _animationType;
  101392. /** Gets or set a value used to limit the range of float values */
  101393. min: number;
  101394. /** Gets or set a value used to limit the range of float values */
  101395. max: number;
  101396. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  101397. isBoolean: boolean;
  101398. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  101399. matrixMode: number;
  101400. /** @hidden */
  101401. _systemValue: Nullable<NodeMaterialSystemValues>;
  101402. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  101403. isConstant: boolean;
  101404. /** Gets or sets the group to use to display this block in the Inspector */
  101405. groupInInspector: string;
  101406. /** Gets an observable raised when the value is changed */
  101407. onValueChangedObservable: Observable<InputBlock>;
  101408. /**
  101409. * Gets or sets the connection point type (default is float)
  101410. */
  101411. get type(): NodeMaterialBlockConnectionPointTypes;
  101412. /**
  101413. * Creates a new InputBlock
  101414. * @param name defines the block name
  101415. * @param target defines the target of that block (Vertex by default)
  101416. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  101417. */
  101418. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  101419. /**
  101420. * Validates if a name is a reserve word.
  101421. * @param newName the new name to be given to the node.
  101422. * @returns false if the name is a reserve word, else true.
  101423. */
  101424. validateBlockName(newName: string): boolean;
  101425. /**
  101426. * Gets the output component
  101427. */
  101428. get output(): NodeMaterialConnectionPoint;
  101429. /**
  101430. * Set the source of this connection point to a vertex attribute
  101431. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  101432. * @returns the current connection point
  101433. */
  101434. setAsAttribute(attributeName?: string): InputBlock;
  101435. /**
  101436. * Set the source of this connection point to a system value
  101437. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  101438. * @returns the current connection point
  101439. */
  101440. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  101441. /**
  101442. * Gets or sets the value of that point.
  101443. * Please note that this value will be ignored if valueCallback is defined
  101444. */
  101445. get value(): any;
  101446. set value(value: any);
  101447. /**
  101448. * Gets or sets a callback used to get the value of that point.
  101449. * Please note that setting this value will force the connection point to ignore the value property
  101450. */
  101451. get valueCallback(): () => any;
  101452. set valueCallback(value: () => any);
  101453. /**
  101454. * Gets or sets the associated variable name in the shader
  101455. */
  101456. get associatedVariableName(): string;
  101457. set associatedVariableName(value: string);
  101458. /** Gets or sets the type of animation applied to the input */
  101459. get animationType(): AnimatedInputBlockTypes;
  101460. set animationType(value: AnimatedInputBlockTypes);
  101461. /**
  101462. * Gets a boolean indicating that this connection point not defined yet
  101463. */
  101464. get isUndefined(): boolean;
  101465. /**
  101466. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  101467. * In this case the connection point name must be the name of the uniform to use.
  101468. * Can only be set on inputs
  101469. */
  101470. get isUniform(): boolean;
  101471. set isUniform(value: boolean);
  101472. /**
  101473. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  101474. * In this case the connection point name must be the name of the attribute to use
  101475. * Can only be set on inputs
  101476. */
  101477. get isAttribute(): boolean;
  101478. set isAttribute(value: boolean);
  101479. /**
  101480. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  101481. * Can only be set on exit points
  101482. */
  101483. get isVarying(): boolean;
  101484. set isVarying(value: boolean);
  101485. /**
  101486. * Gets a boolean indicating that the current connection point is a system value
  101487. */
  101488. get isSystemValue(): boolean;
  101489. /**
  101490. * Gets or sets the current well known value or null if not defined as a system value
  101491. */
  101492. get systemValue(): Nullable<NodeMaterialSystemValues>;
  101493. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  101494. /**
  101495. * Gets the current class name
  101496. * @returns the class name
  101497. */
  101498. getClassName(): string;
  101499. /**
  101500. * Animate the input if animationType !== None
  101501. * @param scene defines the rendering scene
  101502. */
  101503. animate(scene: Scene): void;
  101504. private _emitDefine;
  101505. initialize(state: NodeMaterialBuildState): void;
  101506. /**
  101507. * Set the input block to its default value (based on its type)
  101508. */
  101509. setDefaultValue(): void;
  101510. private _emitConstant;
  101511. /** @hidden */
  101512. get _noContextSwitch(): boolean;
  101513. private _emit;
  101514. /** @hidden */
  101515. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  101516. /** @hidden */
  101517. _transmit(effect: Effect, scene: Scene): void;
  101518. protected _buildBlock(state: NodeMaterialBuildState): void;
  101519. protected _dumpPropertiesCode(): string;
  101520. dispose(): void;
  101521. serialize(): any;
  101522. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101523. }
  101524. }
  101525. declare module BABYLON {
  101526. /**
  101527. * Enum used to define the compatibility state between two connection points
  101528. */
  101529. export enum NodeMaterialConnectionPointCompatibilityStates {
  101530. /** Points are compatibles */
  101531. Compatible = 0,
  101532. /** Points are incompatible because of their types */
  101533. TypeIncompatible = 1,
  101534. /** Points are incompatible because of their targets (vertex vs fragment) */
  101535. TargetIncompatible = 2
  101536. }
  101537. /**
  101538. * Defines the direction of a connection point
  101539. */
  101540. export enum NodeMaterialConnectionPointDirection {
  101541. /** Input */
  101542. Input = 0,
  101543. /** Output */
  101544. Output = 1
  101545. }
  101546. /**
  101547. * Defines a connection point for a block
  101548. */
  101549. export class NodeMaterialConnectionPoint {
  101550. /** @hidden */
  101551. _ownerBlock: NodeMaterialBlock;
  101552. /** @hidden */
  101553. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  101554. private _endpoints;
  101555. private _associatedVariableName;
  101556. private _direction;
  101557. /** @hidden */
  101558. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101559. /** @hidden */
  101560. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101561. private _type;
  101562. /** @hidden */
  101563. _enforceAssociatedVariableName: boolean;
  101564. /** Gets the direction of the point */
  101565. get direction(): NodeMaterialConnectionPointDirection;
  101566. /** Indicates that this connection point needs dual validation before being connected to another point */
  101567. needDualDirectionValidation: boolean;
  101568. /**
  101569. * Gets or sets the additional types supported by this connection point
  101570. */
  101571. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101572. /**
  101573. * Gets or sets the additional types excluded by this connection point
  101574. */
  101575. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101576. /**
  101577. * Observable triggered when this point is connected
  101578. */
  101579. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101580. /**
  101581. * Gets or sets the associated variable name in the shader
  101582. */
  101583. get associatedVariableName(): string;
  101584. set associatedVariableName(value: string);
  101585. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101586. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101587. /**
  101588. * Gets or sets the connection point type (default is float)
  101589. */
  101590. get type(): NodeMaterialBlockConnectionPointTypes;
  101591. set type(value: NodeMaterialBlockConnectionPointTypes);
  101592. /**
  101593. * Gets or sets the connection point name
  101594. */
  101595. name: string;
  101596. /**
  101597. * Gets or sets the connection point name
  101598. */
  101599. displayName: string;
  101600. /**
  101601. * Gets or sets a boolean indicating that this connection point can be omitted
  101602. */
  101603. isOptional: boolean;
  101604. /**
  101605. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101606. */
  101607. isExposedOnFrame: boolean;
  101608. /**
  101609. * Gets or sets number indicating the position that the port is exposed to on a frame
  101610. */
  101611. exposedPortPosition: number;
  101612. /**
  101613. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101614. */
  101615. define: string;
  101616. /** @hidden */
  101617. _prioritizeVertex: boolean;
  101618. private _target;
  101619. /** Gets or sets the target of that connection point */
  101620. get target(): NodeMaterialBlockTargets;
  101621. set target(value: NodeMaterialBlockTargets);
  101622. /**
  101623. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101624. */
  101625. get isConnected(): boolean;
  101626. /**
  101627. * Gets a boolean indicating that the current point is connected to an input block
  101628. */
  101629. get isConnectedToInputBlock(): boolean;
  101630. /**
  101631. * Gets a the connected input block (if any)
  101632. */
  101633. get connectInputBlock(): Nullable<InputBlock>;
  101634. /** Get the other side of the connection (if any) */
  101635. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101636. /** Get the block that owns this connection point */
  101637. get ownerBlock(): NodeMaterialBlock;
  101638. /** Get the block connected on the other side of this connection (if any) */
  101639. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101640. /** Get the block connected on the endpoints of this connection (if any) */
  101641. get connectedBlocks(): Array<NodeMaterialBlock>;
  101642. /** Gets the list of connected endpoints */
  101643. get endpoints(): NodeMaterialConnectionPoint[];
  101644. /** Gets a boolean indicating if that output point is connected to at least one input */
  101645. get hasEndpoints(): boolean;
  101646. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101647. get isConnectedInVertexShader(): boolean;
  101648. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101649. get isConnectedInFragmentShader(): boolean;
  101650. /**
  101651. * Creates a block suitable to be used as an input for this input point.
  101652. * If null is returned, a block based on the point type will be created.
  101653. * @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
  101654. */
  101655. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101656. /**
  101657. * Creates a new connection point
  101658. * @param name defines the connection point name
  101659. * @param ownerBlock defines the block hosting this connection point
  101660. * @param direction defines the direction of the connection point
  101661. */
  101662. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101663. /**
  101664. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101665. * @returns the class name
  101666. */
  101667. getClassName(): string;
  101668. /**
  101669. * Gets a boolean indicating if the current point can be connected to another point
  101670. * @param connectionPoint defines the other connection point
  101671. * @returns a boolean
  101672. */
  101673. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101674. /**
  101675. * Gets a number indicating if the current point can be connected to another point
  101676. * @param connectionPoint defines the other connection point
  101677. * @returns a number defining the compatibility state
  101678. */
  101679. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101680. /**
  101681. * Connect this point to another connection point
  101682. * @param connectionPoint defines the other connection point
  101683. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101684. * @returns the current connection point
  101685. */
  101686. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101687. /**
  101688. * Disconnect this point from one of his endpoint
  101689. * @param endpoint defines the other connection point
  101690. * @returns the current connection point
  101691. */
  101692. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101693. /**
  101694. * Serializes this point in a JSON representation
  101695. * @param isInput defines if the connection point is an input (default is true)
  101696. * @returns the serialized point object
  101697. */
  101698. serialize(isInput?: boolean): any;
  101699. /**
  101700. * Release resources
  101701. */
  101702. dispose(): void;
  101703. }
  101704. }
  101705. declare module BABYLON {
  101706. /**
  101707. * Enum used to define the material modes
  101708. */
  101709. export enum NodeMaterialModes {
  101710. /** Regular material */
  101711. Material = 0,
  101712. /** For post process */
  101713. PostProcess = 1,
  101714. /** For particle system */
  101715. Particle = 2,
  101716. /** For procedural texture */
  101717. ProceduralTexture = 3
  101718. }
  101719. }
  101720. declare module BABYLON {
  101721. /**
  101722. * Block used to read a texture from a sampler
  101723. */
  101724. export class TextureBlock extends NodeMaterialBlock {
  101725. private _defineName;
  101726. private _linearDefineName;
  101727. private _gammaDefineName;
  101728. private _tempTextureRead;
  101729. private _samplerName;
  101730. private _transformedUVName;
  101731. private _textureTransformName;
  101732. private _textureInfoName;
  101733. private _mainUVName;
  101734. private _mainUVDefineName;
  101735. private _fragmentOnly;
  101736. /**
  101737. * Gets or sets the texture associated with the node
  101738. */
  101739. texture: Nullable<Texture>;
  101740. /**
  101741. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101742. */
  101743. convertToGammaSpace: boolean;
  101744. /**
  101745. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101746. */
  101747. convertToLinearSpace: boolean;
  101748. /**
  101749. * Create a new TextureBlock
  101750. * @param name defines the block name
  101751. */
  101752. constructor(name: string, fragmentOnly?: boolean);
  101753. /**
  101754. * Gets the current class name
  101755. * @returns the class name
  101756. */
  101757. getClassName(): string;
  101758. /**
  101759. * Gets the uv input component
  101760. */
  101761. get uv(): NodeMaterialConnectionPoint;
  101762. /**
  101763. * Gets the rgba output component
  101764. */
  101765. get rgba(): NodeMaterialConnectionPoint;
  101766. /**
  101767. * Gets the rgb output component
  101768. */
  101769. get rgb(): NodeMaterialConnectionPoint;
  101770. /**
  101771. * Gets the r output component
  101772. */
  101773. get r(): NodeMaterialConnectionPoint;
  101774. /**
  101775. * Gets the g output component
  101776. */
  101777. get g(): NodeMaterialConnectionPoint;
  101778. /**
  101779. * Gets the b output component
  101780. */
  101781. get b(): NodeMaterialConnectionPoint;
  101782. /**
  101783. * Gets the a output component
  101784. */
  101785. get a(): NodeMaterialConnectionPoint;
  101786. get target(): NodeMaterialBlockTargets;
  101787. autoConfigure(material: NodeMaterial): void;
  101788. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101789. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101790. isReady(): boolean;
  101791. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101792. private get _isMixed();
  101793. private _injectVertexCode;
  101794. private _writeTextureRead;
  101795. private _writeOutput;
  101796. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101797. protected _dumpPropertiesCode(): string;
  101798. serialize(): any;
  101799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101800. }
  101801. }
  101802. declare module BABYLON {
  101803. /** @hidden */
  101804. export var reflectionFunction: {
  101805. name: string;
  101806. shader: string;
  101807. };
  101808. }
  101809. declare module BABYLON {
  101810. /**
  101811. * Base block used to read a reflection texture from a sampler
  101812. */
  101813. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101814. /** @hidden */
  101815. _define3DName: string;
  101816. /** @hidden */
  101817. _defineCubicName: string;
  101818. /** @hidden */
  101819. _defineExplicitName: string;
  101820. /** @hidden */
  101821. _defineProjectionName: string;
  101822. /** @hidden */
  101823. _defineLocalCubicName: string;
  101824. /** @hidden */
  101825. _defineSphericalName: string;
  101826. /** @hidden */
  101827. _definePlanarName: string;
  101828. /** @hidden */
  101829. _defineEquirectangularName: string;
  101830. /** @hidden */
  101831. _defineMirroredEquirectangularFixedName: string;
  101832. /** @hidden */
  101833. _defineEquirectangularFixedName: string;
  101834. /** @hidden */
  101835. _defineSkyboxName: string;
  101836. /** @hidden */
  101837. _defineOppositeZ: string;
  101838. /** @hidden */
  101839. _cubeSamplerName: string;
  101840. /** @hidden */
  101841. _2DSamplerName: string;
  101842. protected _positionUVWName: string;
  101843. protected _directionWName: string;
  101844. protected _reflectionVectorName: string;
  101845. /** @hidden */
  101846. _reflectionCoordsName: string;
  101847. /** @hidden */
  101848. _reflectionMatrixName: string;
  101849. protected _reflectionColorName: string;
  101850. /**
  101851. * Gets or sets the texture associated with the node
  101852. */
  101853. texture: Nullable<BaseTexture>;
  101854. /**
  101855. * Create a new ReflectionTextureBaseBlock
  101856. * @param name defines the block name
  101857. */
  101858. constructor(name: string);
  101859. /**
  101860. * Gets the current class name
  101861. * @returns the class name
  101862. */
  101863. getClassName(): string;
  101864. /**
  101865. * Gets the world position input component
  101866. */
  101867. abstract get position(): NodeMaterialConnectionPoint;
  101868. /**
  101869. * Gets the world position input component
  101870. */
  101871. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101872. /**
  101873. * Gets the world normal input component
  101874. */
  101875. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101876. /**
  101877. * Gets the world input component
  101878. */
  101879. abstract get world(): NodeMaterialConnectionPoint;
  101880. /**
  101881. * Gets the camera (or eye) position component
  101882. */
  101883. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101884. /**
  101885. * Gets the view input component
  101886. */
  101887. abstract get view(): NodeMaterialConnectionPoint;
  101888. protected _getTexture(): Nullable<BaseTexture>;
  101889. autoConfigure(material: NodeMaterial): void;
  101890. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101891. isReady(): boolean;
  101892. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101893. /**
  101894. * Gets the code to inject in the vertex shader
  101895. * @param state current state of the node material building
  101896. * @returns the shader code
  101897. */
  101898. handleVertexSide(state: NodeMaterialBuildState): string;
  101899. /**
  101900. * Handles the inits for the fragment code path
  101901. * @param state node material build state
  101902. */
  101903. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101904. /**
  101905. * Generates the reflection coords code for the fragment code path
  101906. * @param worldNormalVarName name of the world normal variable
  101907. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101908. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101909. * @returns the shader code
  101910. */
  101911. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101912. /**
  101913. * Generates the reflection color code for the fragment code path
  101914. * @param lodVarName name of the lod variable
  101915. * @param swizzleLookupTexture swizzle to use for the final color variable
  101916. * @returns the shader code
  101917. */
  101918. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101919. /**
  101920. * Generates the code corresponding to the connected output points
  101921. * @param state node material build state
  101922. * @param varName name of the variable to output
  101923. * @returns the shader code
  101924. */
  101925. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101926. protected _buildBlock(state: NodeMaterialBuildState): this;
  101927. protected _dumpPropertiesCode(): string;
  101928. serialize(): any;
  101929. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101930. }
  101931. }
  101932. declare module BABYLON {
  101933. /**
  101934. * Defines a connection point to be used for points with a custom object type
  101935. */
  101936. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101937. private _blockType;
  101938. private _blockName;
  101939. private _nameForCheking?;
  101940. /**
  101941. * Creates a new connection point
  101942. * @param name defines the connection point name
  101943. * @param ownerBlock defines the block hosting this connection point
  101944. * @param direction defines the direction of the connection point
  101945. */
  101946. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101947. /**
  101948. * Gets a number indicating if the current point can be connected to another point
  101949. * @param connectionPoint defines the other connection point
  101950. * @returns a number defining the compatibility state
  101951. */
  101952. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101953. /**
  101954. * Creates a block suitable to be used as an input for this input point.
  101955. * If null is returned, a block based on the point type will be created.
  101956. * @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
  101957. */
  101958. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101959. }
  101960. }
  101961. declare module BABYLON {
  101962. /**
  101963. * Enum defining the type of properties that can be edited in the property pages in the NME
  101964. */
  101965. export enum PropertyTypeForEdition {
  101966. /** property is a boolean */
  101967. Boolean = 0,
  101968. /** property is a float */
  101969. Float = 1,
  101970. /** property is a Vector2 */
  101971. Vector2 = 2,
  101972. /** property is a list of values */
  101973. List = 3
  101974. }
  101975. /**
  101976. * Interface that defines an option in a variable of type list
  101977. */
  101978. export interface IEditablePropertyListOption {
  101979. /** label of the option */
  101980. "label": string;
  101981. /** value of the option */
  101982. "value": number;
  101983. }
  101984. /**
  101985. * Interface that defines the options available for an editable property
  101986. */
  101987. export interface IEditablePropertyOption {
  101988. /** min value */
  101989. "min"?: number;
  101990. /** max value */
  101991. "max"?: number;
  101992. /** notifiers: indicates which actions to take when the property is changed */
  101993. "notifiers"?: {
  101994. /** the material should be rebuilt */
  101995. "rebuild"?: boolean;
  101996. /** the preview should be updated */
  101997. "update"?: boolean;
  101998. };
  101999. /** list of the options for a variable of type list */
  102000. "options"?: IEditablePropertyListOption[];
  102001. }
  102002. /**
  102003. * Interface that describes an editable property
  102004. */
  102005. export interface IPropertyDescriptionForEdition {
  102006. /** name of the property */
  102007. "propertyName": string;
  102008. /** display name of the property */
  102009. "displayName": string;
  102010. /** type of the property */
  102011. "type": PropertyTypeForEdition;
  102012. /** group of the property - all properties with the same group value will be displayed in a specific section */
  102013. "groupName": string;
  102014. /** options for the property */
  102015. "options": IEditablePropertyOption;
  102016. }
  102017. /**
  102018. * Decorator that flags a property in a node material block as being editable
  102019. */
  102020. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  102021. }
  102022. declare module BABYLON {
  102023. /**
  102024. * Block used to implement the refraction part of the sub surface module of the PBR material
  102025. */
  102026. export class RefractionBlock extends NodeMaterialBlock {
  102027. /** @hidden */
  102028. _define3DName: string;
  102029. /** @hidden */
  102030. _refractionMatrixName: string;
  102031. /** @hidden */
  102032. _defineLODRefractionAlpha: string;
  102033. /** @hidden */
  102034. _defineLinearSpecularRefraction: string;
  102035. /** @hidden */
  102036. _defineOppositeZ: string;
  102037. /** @hidden */
  102038. _cubeSamplerName: string;
  102039. /** @hidden */
  102040. _2DSamplerName: string;
  102041. /** @hidden */
  102042. _vRefractionMicrosurfaceInfosName: string;
  102043. /** @hidden */
  102044. _vRefractionInfosName: string;
  102045. private _scene;
  102046. /**
  102047. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102048. * Materials half opaque for instance using refraction could benefit from this control.
  102049. */
  102050. linkRefractionWithTransparency: boolean;
  102051. /**
  102052. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102053. */
  102054. invertRefractionY: boolean;
  102055. /**
  102056. * Gets or sets the texture associated with the node
  102057. */
  102058. texture: Nullable<BaseTexture>;
  102059. /**
  102060. * Create a new RefractionBlock
  102061. * @param name defines the block name
  102062. */
  102063. constructor(name: string);
  102064. /**
  102065. * Gets the current class name
  102066. * @returns the class name
  102067. */
  102068. getClassName(): string;
  102069. /**
  102070. * Gets the intensity input component
  102071. */
  102072. get intensity(): NodeMaterialConnectionPoint;
  102073. /**
  102074. * Gets the index of refraction input component
  102075. */
  102076. get indexOfRefraction(): NodeMaterialConnectionPoint;
  102077. /**
  102078. * Gets the tint at distance input component
  102079. */
  102080. get tintAtDistance(): NodeMaterialConnectionPoint;
  102081. /**
  102082. * Gets the view input component
  102083. */
  102084. get view(): NodeMaterialConnectionPoint;
  102085. /**
  102086. * Gets the refraction object output component
  102087. */
  102088. get refraction(): NodeMaterialConnectionPoint;
  102089. /**
  102090. * Returns true if the block has a texture
  102091. */
  102092. get hasTexture(): boolean;
  102093. protected _getTexture(): Nullable<BaseTexture>;
  102094. autoConfigure(material: NodeMaterial): void;
  102095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102096. isReady(): boolean;
  102097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102098. /**
  102099. * Gets the main code of the block (fragment side)
  102100. * @param state current state of the node material building
  102101. * @returns the shader code
  102102. */
  102103. getCode(state: NodeMaterialBuildState): string;
  102104. protected _buildBlock(state: NodeMaterialBuildState): this;
  102105. protected _dumpPropertiesCode(): string;
  102106. serialize(): any;
  102107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102108. }
  102109. }
  102110. declare module BABYLON {
  102111. /**
  102112. * Base block used as input for post process
  102113. */
  102114. export class CurrentScreenBlock extends NodeMaterialBlock {
  102115. private _samplerName;
  102116. private _linearDefineName;
  102117. private _gammaDefineName;
  102118. private _mainUVName;
  102119. private _tempTextureRead;
  102120. /**
  102121. * Gets or sets the texture associated with the node
  102122. */
  102123. texture: Nullable<BaseTexture>;
  102124. /**
  102125. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102126. */
  102127. convertToGammaSpace: boolean;
  102128. /**
  102129. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102130. */
  102131. convertToLinearSpace: boolean;
  102132. /**
  102133. * Create a new CurrentScreenBlock
  102134. * @param name defines the block name
  102135. */
  102136. constructor(name: string);
  102137. /**
  102138. * Gets the current class name
  102139. * @returns the class name
  102140. */
  102141. getClassName(): string;
  102142. /**
  102143. * Gets the uv input component
  102144. */
  102145. get uv(): NodeMaterialConnectionPoint;
  102146. /**
  102147. * Gets the rgba output component
  102148. */
  102149. get rgba(): NodeMaterialConnectionPoint;
  102150. /**
  102151. * Gets the rgb output component
  102152. */
  102153. get rgb(): NodeMaterialConnectionPoint;
  102154. /**
  102155. * Gets the r output component
  102156. */
  102157. get r(): NodeMaterialConnectionPoint;
  102158. /**
  102159. * Gets the g output component
  102160. */
  102161. get g(): NodeMaterialConnectionPoint;
  102162. /**
  102163. * Gets the b output component
  102164. */
  102165. get b(): NodeMaterialConnectionPoint;
  102166. /**
  102167. * Gets the a output component
  102168. */
  102169. get a(): NodeMaterialConnectionPoint;
  102170. /**
  102171. * Initialize the block and prepare the context for build
  102172. * @param state defines the state that will be used for the build
  102173. */
  102174. initialize(state: NodeMaterialBuildState): void;
  102175. get target(): NodeMaterialBlockTargets;
  102176. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102177. isReady(): boolean;
  102178. private _injectVertexCode;
  102179. private _writeTextureRead;
  102180. private _writeOutput;
  102181. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102182. serialize(): any;
  102183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102184. }
  102185. }
  102186. declare module BABYLON {
  102187. /**
  102188. * Base block used for the particle texture
  102189. */
  102190. export class ParticleTextureBlock extends NodeMaterialBlock {
  102191. private _samplerName;
  102192. private _linearDefineName;
  102193. private _gammaDefineName;
  102194. private _tempTextureRead;
  102195. /**
  102196. * Gets or sets the texture associated with the node
  102197. */
  102198. texture: Nullable<BaseTexture>;
  102199. /**
  102200. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102201. */
  102202. convertToGammaSpace: boolean;
  102203. /**
  102204. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102205. */
  102206. convertToLinearSpace: boolean;
  102207. /**
  102208. * Create a new ParticleTextureBlock
  102209. * @param name defines the block name
  102210. */
  102211. constructor(name: string);
  102212. /**
  102213. * Gets the current class name
  102214. * @returns the class name
  102215. */
  102216. getClassName(): string;
  102217. /**
  102218. * Gets the uv input component
  102219. */
  102220. get uv(): NodeMaterialConnectionPoint;
  102221. /**
  102222. * Gets the rgba output component
  102223. */
  102224. get rgba(): NodeMaterialConnectionPoint;
  102225. /**
  102226. * Gets the rgb output component
  102227. */
  102228. get rgb(): NodeMaterialConnectionPoint;
  102229. /**
  102230. * Gets the r output component
  102231. */
  102232. get r(): NodeMaterialConnectionPoint;
  102233. /**
  102234. * Gets the g output component
  102235. */
  102236. get g(): NodeMaterialConnectionPoint;
  102237. /**
  102238. * Gets the b output component
  102239. */
  102240. get b(): NodeMaterialConnectionPoint;
  102241. /**
  102242. * Gets the a output component
  102243. */
  102244. get a(): NodeMaterialConnectionPoint;
  102245. /**
  102246. * Initialize the block and prepare the context for build
  102247. * @param state defines the state that will be used for the build
  102248. */
  102249. initialize(state: NodeMaterialBuildState): void;
  102250. autoConfigure(material: NodeMaterial): void;
  102251. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102252. isReady(): boolean;
  102253. private _writeOutput;
  102254. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102255. serialize(): any;
  102256. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102257. }
  102258. }
  102259. declare module BABYLON {
  102260. /**
  102261. * Class used to store shared data between 2 NodeMaterialBuildState
  102262. */
  102263. export class NodeMaterialBuildStateSharedData {
  102264. /**
  102265. * Gets the list of emitted varyings
  102266. */
  102267. temps: string[];
  102268. /**
  102269. * Gets the list of emitted varyings
  102270. */
  102271. varyings: string[];
  102272. /**
  102273. * Gets the varying declaration string
  102274. */
  102275. varyingDeclaration: string;
  102276. /**
  102277. * Input blocks
  102278. */
  102279. inputBlocks: InputBlock[];
  102280. /**
  102281. * Input blocks
  102282. */
  102283. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102284. /**
  102285. * Bindable blocks (Blocks that need to set data to the effect)
  102286. */
  102287. bindableBlocks: NodeMaterialBlock[];
  102288. /**
  102289. * List of blocks that can provide a compilation fallback
  102290. */
  102291. blocksWithFallbacks: NodeMaterialBlock[];
  102292. /**
  102293. * List of blocks that can provide a define update
  102294. */
  102295. blocksWithDefines: NodeMaterialBlock[];
  102296. /**
  102297. * List of blocks that can provide a repeatable content
  102298. */
  102299. repeatableContentBlocks: NodeMaterialBlock[];
  102300. /**
  102301. * List of blocks that can provide a dynamic list of uniforms
  102302. */
  102303. dynamicUniformBlocks: NodeMaterialBlock[];
  102304. /**
  102305. * List of blocks that can block the isReady function for the material
  102306. */
  102307. blockingBlocks: NodeMaterialBlock[];
  102308. /**
  102309. * Gets the list of animated inputs
  102310. */
  102311. animatedInputs: InputBlock[];
  102312. /**
  102313. * Build Id used to avoid multiple recompilations
  102314. */
  102315. buildId: number;
  102316. /** List of emitted variables */
  102317. variableNames: {
  102318. [key: string]: number;
  102319. };
  102320. /** List of emitted defines */
  102321. defineNames: {
  102322. [key: string]: number;
  102323. };
  102324. /** Should emit comments? */
  102325. emitComments: boolean;
  102326. /** Emit build activity */
  102327. verbose: boolean;
  102328. /** Gets or sets the hosting scene */
  102329. scene: Scene;
  102330. /**
  102331. * Gets the compilation hints emitted at compilation time
  102332. */
  102333. hints: {
  102334. needWorldViewMatrix: boolean;
  102335. needWorldViewProjectionMatrix: boolean;
  102336. needAlphaBlending: boolean;
  102337. needAlphaTesting: boolean;
  102338. };
  102339. /**
  102340. * List of compilation checks
  102341. */
  102342. checks: {
  102343. emitVertex: boolean;
  102344. emitFragment: boolean;
  102345. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102346. };
  102347. /**
  102348. * Is vertex program allowed to be empty?
  102349. */
  102350. allowEmptyVertexProgram: boolean;
  102351. /** Creates a new shared data */
  102352. constructor();
  102353. /**
  102354. * Emits console errors and exceptions if there is a failing check
  102355. */
  102356. emitErrors(): void;
  102357. }
  102358. }
  102359. declare module BABYLON {
  102360. /**
  102361. * Class used to store node based material build state
  102362. */
  102363. export class NodeMaterialBuildState {
  102364. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102365. supportUniformBuffers: boolean;
  102366. /**
  102367. * Gets the list of emitted attributes
  102368. */
  102369. attributes: string[];
  102370. /**
  102371. * Gets the list of emitted uniforms
  102372. */
  102373. uniforms: string[];
  102374. /**
  102375. * Gets the list of emitted constants
  102376. */
  102377. constants: string[];
  102378. /**
  102379. * Gets the list of emitted samplers
  102380. */
  102381. samplers: string[];
  102382. /**
  102383. * Gets the list of emitted functions
  102384. */
  102385. functions: {
  102386. [key: string]: string;
  102387. };
  102388. /**
  102389. * Gets the list of emitted extensions
  102390. */
  102391. extensions: {
  102392. [key: string]: string;
  102393. };
  102394. /**
  102395. * Gets the target of the compilation state
  102396. */
  102397. target: NodeMaterialBlockTargets;
  102398. /**
  102399. * Gets the list of emitted counters
  102400. */
  102401. counters: {
  102402. [key: string]: number;
  102403. };
  102404. /**
  102405. * Shared data between multiple NodeMaterialBuildState instances
  102406. */
  102407. sharedData: NodeMaterialBuildStateSharedData;
  102408. /** @hidden */
  102409. _vertexState: NodeMaterialBuildState;
  102410. /** @hidden */
  102411. _attributeDeclaration: string;
  102412. /** @hidden */
  102413. _uniformDeclaration: string;
  102414. /** @hidden */
  102415. _constantDeclaration: string;
  102416. /** @hidden */
  102417. _samplerDeclaration: string;
  102418. /** @hidden */
  102419. _varyingTransfer: string;
  102420. /** @hidden */
  102421. _injectAtEnd: string;
  102422. private _repeatableContentAnchorIndex;
  102423. /** @hidden */
  102424. _builtCompilationString: string;
  102425. /**
  102426. * Gets the emitted compilation strings
  102427. */
  102428. compilationString: string;
  102429. /**
  102430. * Finalize the compilation strings
  102431. * @param state defines the current compilation state
  102432. */
  102433. finalize(state: NodeMaterialBuildState): void;
  102434. /** @hidden */
  102435. get _repeatableContentAnchor(): string;
  102436. /** @hidden */
  102437. _getFreeVariableName(prefix: string): string;
  102438. /** @hidden */
  102439. _getFreeDefineName(prefix: string): string;
  102440. /** @hidden */
  102441. _excludeVariableName(name: string): void;
  102442. /** @hidden */
  102443. _emit2DSampler(name: string): void;
  102444. /** @hidden */
  102445. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  102446. /** @hidden */
  102447. _emitExtension(name: string, extension: string, define?: string): void;
  102448. /** @hidden */
  102449. _emitFunction(name: string, code: string, comments: string): void;
  102450. /** @hidden */
  102451. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  102452. replaceStrings?: {
  102453. search: RegExp;
  102454. replace: string;
  102455. }[];
  102456. repeatKey?: string;
  102457. }): string;
  102458. /** @hidden */
  102459. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  102460. repeatKey?: string;
  102461. removeAttributes?: boolean;
  102462. removeUniforms?: boolean;
  102463. removeVaryings?: boolean;
  102464. removeIfDef?: boolean;
  102465. replaceStrings?: {
  102466. search: RegExp;
  102467. replace: string;
  102468. }[];
  102469. }, storeKey?: string): void;
  102470. /** @hidden */
  102471. _registerTempVariable(name: string): boolean;
  102472. /** @hidden */
  102473. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  102474. /** @hidden */
  102475. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  102476. /** @hidden */
  102477. _emitFloat(value: number): string;
  102478. }
  102479. }
  102480. declare module BABYLON {
  102481. /**
  102482. * Helper class used to generate session unique ID
  102483. */
  102484. export class UniqueIdGenerator {
  102485. private static _UniqueIdCounter;
  102486. /**
  102487. * Gets an unique (relatively to the current scene) Id
  102488. */
  102489. static get UniqueId(): number;
  102490. }
  102491. }
  102492. declare module BABYLON {
  102493. /**
  102494. * Defines a block that can be used inside a node based material
  102495. */
  102496. export class NodeMaterialBlock {
  102497. private _buildId;
  102498. private _buildTarget;
  102499. private _target;
  102500. private _isFinalMerger;
  102501. private _isInput;
  102502. private _name;
  102503. protected _isUnique: boolean;
  102504. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  102505. inputsAreExclusive: boolean;
  102506. /** @hidden */
  102507. _codeVariableName: string;
  102508. /** @hidden */
  102509. _inputs: NodeMaterialConnectionPoint[];
  102510. /** @hidden */
  102511. _outputs: NodeMaterialConnectionPoint[];
  102512. /** @hidden */
  102513. _preparationId: number;
  102514. /**
  102515. * Gets the name of the block
  102516. */
  102517. get name(): string;
  102518. /**
  102519. * Sets the name of the block. Will check if the name is valid.
  102520. */
  102521. set name(newName: string);
  102522. /**
  102523. * Gets or sets the unique id of the node
  102524. */
  102525. uniqueId: number;
  102526. /**
  102527. * Gets or sets the comments associated with this block
  102528. */
  102529. comments: string;
  102530. /**
  102531. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  102532. */
  102533. get isUnique(): boolean;
  102534. /**
  102535. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  102536. */
  102537. get isFinalMerger(): boolean;
  102538. /**
  102539. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  102540. */
  102541. get isInput(): boolean;
  102542. /**
  102543. * Gets or sets the build Id
  102544. */
  102545. get buildId(): number;
  102546. set buildId(value: number);
  102547. /**
  102548. * Gets or sets the target of the block
  102549. */
  102550. get target(): NodeMaterialBlockTargets;
  102551. set target(value: NodeMaterialBlockTargets);
  102552. /**
  102553. * Gets the list of input points
  102554. */
  102555. get inputs(): NodeMaterialConnectionPoint[];
  102556. /** Gets the list of output points */
  102557. get outputs(): NodeMaterialConnectionPoint[];
  102558. /**
  102559. * Find an input by its name
  102560. * @param name defines the name of the input to look for
  102561. * @returns the input or null if not found
  102562. */
  102563. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102564. /**
  102565. * Find an output by its name
  102566. * @param name defines the name of the outputto look for
  102567. * @returns the output or null if not found
  102568. */
  102569. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102570. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102571. visibleInInspector: boolean;
  102572. /**
  102573. * Creates a new NodeMaterialBlock
  102574. * @param name defines the block name
  102575. * @param target defines the target of that block (Vertex by default)
  102576. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102577. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102578. */
  102579. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102580. /**
  102581. * Initialize the block and prepare the context for build
  102582. * @param state defines the state that will be used for the build
  102583. */
  102584. initialize(state: NodeMaterialBuildState): void;
  102585. /**
  102586. * Bind data to effect. Will only be called for blocks with isBindable === true
  102587. * @param effect defines the effect to bind data to
  102588. * @param nodeMaterial defines the hosting NodeMaterial
  102589. * @param mesh defines the mesh that will be rendered
  102590. * @param subMesh defines the submesh that will be rendered
  102591. */
  102592. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102593. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102594. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102595. protected _writeFloat(value: number): string;
  102596. /**
  102597. * Gets the current class name e.g. "NodeMaterialBlock"
  102598. * @returns the class name
  102599. */
  102600. getClassName(): string;
  102601. /**
  102602. * Register a new input. Must be called inside a block constructor
  102603. * @param name defines the connection point name
  102604. * @param type defines the connection point type
  102605. * @param isOptional defines a boolean indicating that this input can be omitted
  102606. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102607. * @param point an already created connection point. If not provided, create a new one
  102608. * @returns the current block
  102609. */
  102610. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102611. /**
  102612. * Register a new output. Must be called inside a block constructor
  102613. * @param name defines the connection point name
  102614. * @param type defines the connection point type
  102615. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102616. * @param point an already created connection point. If not provided, create a new one
  102617. * @returns the current block
  102618. */
  102619. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102620. /**
  102621. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102622. * @param forOutput defines an optional connection point to check compatibility with
  102623. * @returns the first available input or null
  102624. */
  102625. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102626. /**
  102627. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102628. * @param forBlock defines an optional block to check compatibility with
  102629. * @returns the first available input or null
  102630. */
  102631. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102632. /**
  102633. * Gets the sibling of the given output
  102634. * @param current defines the current output
  102635. * @returns the next output in the list or null
  102636. */
  102637. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102638. /**
  102639. * Connect current block with another block
  102640. * @param other defines the block to connect with
  102641. * @param options define the various options to help pick the right connections
  102642. * @returns the current block
  102643. */
  102644. connectTo(other: NodeMaterialBlock, options?: {
  102645. input?: string;
  102646. output?: string;
  102647. outputSwizzle?: string;
  102648. }): this | undefined;
  102649. protected _buildBlock(state: NodeMaterialBuildState): void;
  102650. /**
  102651. * Add uniforms, samplers and uniform buffers at compilation time
  102652. * @param state defines the state to update
  102653. * @param nodeMaterial defines the node material requesting the update
  102654. * @param defines defines the material defines to update
  102655. * @param uniformBuffers defines the list of uniform buffer names
  102656. */
  102657. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102658. /**
  102659. * Add potential fallbacks if shader compilation fails
  102660. * @param mesh defines the mesh to be rendered
  102661. * @param fallbacks defines the current prioritized list of fallbacks
  102662. */
  102663. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102664. /**
  102665. * Initialize defines for shader compilation
  102666. * @param mesh defines the mesh to be rendered
  102667. * @param nodeMaterial defines the node material requesting the update
  102668. * @param defines defines the material defines to update
  102669. * @param useInstances specifies that instances should be used
  102670. */
  102671. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102672. /**
  102673. * Update defines for shader compilation
  102674. * @param mesh defines the mesh to be rendered
  102675. * @param nodeMaterial defines the node material requesting the update
  102676. * @param defines defines the material defines to update
  102677. * @param useInstances specifies that instances should be used
  102678. * @param subMesh defines which submesh to render
  102679. */
  102680. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102681. /**
  102682. * Lets the block try to connect some inputs automatically
  102683. * @param material defines the hosting NodeMaterial
  102684. */
  102685. autoConfigure(material: NodeMaterial): void;
  102686. /**
  102687. * Function called when a block is declared as repeatable content generator
  102688. * @param vertexShaderState defines the current compilation state for the vertex shader
  102689. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102690. * @param mesh defines the mesh to be rendered
  102691. * @param defines defines the material defines to update
  102692. */
  102693. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102694. /**
  102695. * Checks if the block is ready
  102696. * @param mesh defines the mesh to be rendered
  102697. * @param nodeMaterial defines the node material requesting the update
  102698. * @param defines defines the material defines to update
  102699. * @param useInstances specifies that instances should be used
  102700. * @returns true if the block is ready
  102701. */
  102702. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102703. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102704. private _processBuild;
  102705. /**
  102706. * Validates the new name for the block node.
  102707. * @param newName the new name to be given to the node.
  102708. * @returns false if the name is a reserve word, else true.
  102709. */
  102710. validateBlockName(newName: string): boolean;
  102711. /**
  102712. * Compile the current node and generate the shader code
  102713. * @param state defines the current compilation state (uniforms, samplers, current string)
  102714. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102715. * @returns true if already built
  102716. */
  102717. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102718. protected _inputRename(name: string): string;
  102719. protected _outputRename(name: string): string;
  102720. protected _dumpPropertiesCode(): string;
  102721. /** @hidden */
  102722. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102723. /** @hidden */
  102724. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102725. /**
  102726. * Clone the current block to a new identical block
  102727. * @param scene defines the hosting scene
  102728. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102729. * @returns a copy of the current block
  102730. */
  102731. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102732. /**
  102733. * Serializes this block in a JSON representation
  102734. * @returns the serialized block object
  102735. */
  102736. serialize(): any;
  102737. /** @hidden */
  102738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102739. private _deserializePortDisplayNamesAndExposedOnFrame;
  102740. /**
  102741. * Release resources
  102742. */
  102743. dispose(): void;
  102744. }
  102745. }
  102746. declare module BABYLON {
  102747. /**
  102748. * Base class of materials working in push mode in babylon JS
  102749. * @hidden
  102750. */
  102751. export class PushMaterial extends Material {
  102752. protected _activeEffect: Effect;
  102753. protected _normalMatrix: Matrix;
  102754. constructor(name: string, scene: Scene);
  102755. getEffect(): Effect;
  102756. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102757. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102758. /**
  102759. * Binds the given world matrix to the active effect
  102760. *
  102761. * @param world the matrix to bind
  102762. */
  102763. bindOnlyWorldMatrix(world: Matrix): void;
  102764. /**
  102765. * Binds the given normal matrix to the active effect
  102766. *
  102767. * @param normalMatrix the matrix to bind
  102768. */
  102769. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102770. bind(world: Matrix, mesh?: Mesh): void;
  102771. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102772. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102773. }
  102774. }
  102775. declare module BABYLON {
  102776. /**
  102777. * Root class for all node material optimizers
  102778. */
  102779. export class NodeMaterialOptimizer {
  102780. /**
  102781. * Function used to optimize a NodeMaterial graph
  102782. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102783. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102784. */
  102785. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102786. }
  102787. }
  102788. declare module BABYLON {
  102789. /**
  102790. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102791. */
  102792. export class TransformBlock extends NodeMaterialBlock {
  102793. /**
  102794. * Defines the value to use to complement W value to transform it to a Vector4
  102795. */
  102796. complementW: number;
  102797. /**
  102798. * Defines the value to use to complement z value to transform it to a Vector4
  102799. */
  102800. complementZ: number;
  102801. /**
  102802. * Creates a new TransformBlock
  102803. * @param name defines the block name
  102804. */
  102805. constructor(name: string);
  102806. /**
  102807. * Gets the current class name
  102808. * @returns the class name
  102809. */
  102810. getClassName(): string;
  102811. /**
  102812. * Gets the vector input
  102813. */
  102814. get vector(): NodeMaterialConnectionPoint;
  102815. /**
  102816. * Gets the output component
  102817. */
  102818. get output(): NodeMaterialConnectionPoint;
  102819. /**
  102820. * Gets the xyz output component
  102821. */
  102822. get xyz(): NodeMaterialConnectionPoint;
  102823. /**
  102824. * Gets the matrix transform input
  102825. */
  102826. get transform(): NodeMaterialConnectionPoint;
  102827. protected _buildBlock(state: NodeMaterialBuildState): this;
  102828. /**
  102829. * Update defines for shader compilation
  102830. * @param mesh defines the mesh to be rendered
  102831. * @param nodeMaterial defines the node material requesting the update
  102832. * @param defines defines the material defines to update
  102833. * @param useInstances specifies that instances should be used
  102834. * @param subMesh defines which submesh to render
  102835. */
  102836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102837. serialize(): any;
  102838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102839. protected _dumpPropertiesCode(): string;
  102840. }
  102841. }
  102842. declare module BABYLON {
  102843. /**
  102844. * Block used to output the vertex position
  102845. */
  102846. export class VertexOutputBlock extends NodeMaterialBlock {
  102847. /**
  102848. * Creates a new VertexOutputBlock
  102849. * @param name defines the block name
  102850. */
  102851. constructor(name: string);
  102852. /**
  102853. * Gets the current class name
  102854. * @returns the class name
  102855. */
  102856. getClassName(): string;
  102857. /**
  102858. * Gets the vector input component
  102859. */
  102860. get vector(): NodeMaterialConnectionPoint;
  102861. protected _buildBlock(state: NodeMaterialBuildState): this;
  102862. }
  102863. }
  102864. declare module BABYLON {
  102865. /**
  102866. * Block used to output the final color
  102867. */
  102868. export class FragmentOutputBlock extends NodeMaterialBlock {
  102869. /**
  102870. * Create a new FragmentOutputBlock
  102871. * @param name defines the block name
  102872. */
  102873. constructor(name: string);
  102874. /**
  102875. * Gets the current class name
  102876. * @returns the class name
  102877. */
  102878. getClassName(): string;
  102879. /**
  102880. * Gets the rgba input component
  102881. */
  102882. get rgba(): NodeMaterialConnectionPoint;
  102883. /**
  102884. * Gets the rgb input component
  102885. */
  102886. get rgb(): NodeMaterialConnectionPoint;
  102887. /**
  102888. * Gets the a input component
  102889. */
  102890. get a(): NodeMaterialConnectionPoint;
  102891. protected _buildBlock(state: NodeMaterialBuildState): this;
  102892. }
  102893. }
  102894. declare module BABYLON {
  102895. /**
  102896. * Block used for the particle ramp gradient section
  102897. */
  102898. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102899. /**
  102900. * Create a new ParticleRampGradientBlock
  102901. * @param name defines the block name
  102902. */
  102903. constructor(name: string);
  102904. /**
  102905. * Gets the current class name
  102906. * @returns the class name
  102907. */
  102908. getClassName(): string;
  102909. /**
  102910. * Gets the color input component
  102911. */
  102912. get color(): NodeMaterialConnectionPoint;
  102913. /**
  102914. * Gets the rampColor output component
  102915. */
  102916. get rampColor(): NodeMaterialConnectionPoint;
  102917. /**
  102918. * Initialize the block and prepare the context for build
  102919. * @param state defines the state that will be used for the build
  102920. */
  102921. initialize(state: NodeMaterialBuildState): void;
  102922. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102923. }
  102924. }
  102925. declare module BABYLON {
  102926. /**
  102927. * Block used for the particle blend multiply section
  102928. */
  102929. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102930. /**
  102931. * Create a new ParticleBlendMultiplyBlock
  102932. * @param name defines the block name
  102933. */
  102934. constructor(name: string);
  102935. /**
  102936. * Gets the current class name
  102937. * @returns the class name
  102938. */
  102939. getClassName(): string;
  102940. /**
  102941. * Gets the color input component
  102942. */
  102943. get color(): NodeMaterialConnectionPoint;
  102944. /**
  102945. * Gets the alphaTexture input component
  102946. */
  102947. get alphaTexture(): NodeMaterialConnectionPoint;
  102948. /**
  102949. * Gets the alphaColor input component
  102950. */
  102951. get alphaColor(): NodeMaterialConnectionPoint;
  102952. /**
  102953. * Gets the blendColor output component
  102954. */
  102955. get blendColor(): NodeMaterialConnectionPoint;
  102956. /**
  102957. * Initialize the block and prepare the context for build
  102958. * @param state defines the state that will be used for the build
  102959. */
  102960. initialize(state: NodeMaterialBuildState): void;
  102961. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102962. }
  102963. }
  102964. declare module BABYLON {
  102965. /**
  102966. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102967. */
  102968. export class VectorMergerBlock extends NodeMaterialBlock {
  102969. /**
  102970. * Create a new VectorMergerBlock
  102971. * @param name defines the block name
  102972. */
  102973. constructor(name: string);
  102974. /**
  102975. * Gets the current class name
  102976. * @returns the class name
  102977. */
  102978. getClassName(): string;
  102979. /**
  102980. * Gets the xyz component (input)
  102981. */
  102982. get xyzIn(): NodeMaterialConnectionPoint;
  102983. /**
  102984. * Gets the xy component (input)
  102985. */
  102986. get xyIn(): NodeMaterialConnectionPoint;
  102987. /**
  102988. * Gets the x component (input)
  102989. */
  102990. get x(): NodeMaterialConnectionPoint;
  102991. /**
  102992. * Gets the y component (input)
  102993. */
  102994. get y(): NodeMaterialConnectionPoint;
  102995. /**
  102996. * Gets the z component (input)
  102997. */
  102998. get z(): NodeMaterialConnectionPoint;
  102999. /**
  103000. * Gets the w component (input)
  103001. */
  103002. get w(): NodeMaterialConnectionPoint;
  103003. /**
  103004. * Gets the xyzw component (output)
  103005. */
  103006. get xyzw(): NodeMaterialConnectionPoint;
  103007. /**
  103008. * Gets the xyz component (output)
  103009. */
  103010. get xyzOut(): NodeMaterialConnectionPoint;
  103011. /**
  103012. * Gets the xy component (output)
  103013. */
  103014. get xyOut(): NodeMaterialConnectionPoint;
  103015. /**
  103016. * Gets the xy component (output)
  103017. * @deprecated Please use xyOut instead.
  103018. */
  103019. get xy(): NodeMaterialConnectionPoint;
  103020. /**
  103021. * Gets the xyz component (output)
  103022. * @deprecated Please use xyzOut instead.
  103023. */
  103024. get xyz(): NodeMaterialConnectionPoint;
  103025. protected _buildBlock(state: NodeMaterialBuildState): this;
  103026. }
  103027. }
  103028. declare module BABYLON {
  103029. /**
  103030. * Block used to remap a float from a range to a new one
  103031. */
  103032. export class RemapBlock extends NodeMaterialBlock {
  103033. /**
  103034. * Gets or sets the source range
  103035. */
  103036. sourceRange: Vector2;
  103037. /**
  103038. * Gets or sets the target range
  103039. */
  103040. targetRange: Vector2;
  103041. /**
  103042. * Creates a new RemapBlock
  103043. * @param name defines the block name
  103044. */
  103045. constructor(name: string);
  103046. /**
  103047. * Gets the current class name
  103048. * @returns the class name
  103049. */
  103050. getClassName(): string;
  103051. /**
  103052. * Gets the input component
  103053. */
  103054. get input(): NodeMaterialConnectionPoint;
  103055. /**
  103056. * Gets the source min input component
  103057. */
  103058. get sourceMin(): NodeMaterialConnectionPoint;
  103059. /**
  103060. * Gets the source max input component
  103061. */
  103062. get sourceMax(): NodeMaterialConnectionPoint;
  103063. /**
  103064. * Gets the target min input component
  103065. */
  103066. get targetMin(): NodeMaterialConnectionPoint;
  103067. /**
  103068. * Gets the target max input component
  103069. */
  103070. get targetMax(): NodeMaterialConnectionPoint;
  103071. /**
  103072. * Gets the output component
  103073. */
  103074. get output(): NodeMaterialConnectionPoint;
  103075. protected _buildBlock(state: NodeMaterialBuildState): this;
  103076. protected _dumpPropertiesCode(): string;
  103077. serialize(): any;
  103078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103079. }
  103080. }
  103081. declare module BABYLON {
  103082. /**
  103083. * Block used to multiply 2 values
  103084. */
  103085. export class MultiplyBlock extends NodeMaterialBlock {
  103086. /**
  103087. * Creates a new MultiplyBlock
  103088. * @param name defines the block name
  103089. */
  103090. constructor(name: string);
  103091. /**
  103092. * Gets the current class name
  103093. * @returns the class name
  103094. */
  103095. getClassName(): string;
  103096. /**
  103097. * Gets the left operand input component
  103098. */
  103099. get left(): NodeMaterialConnectionPoint;
  103100. /**
  103101. * Gets the right operand input component
  103102. */
  103103. get right(): NodeMaterialConnectionPoint;
  103104. /**
  103105. * Gets the output component
  103106. */
  103107. get output(): NodeMaterialConnectionPoint;
  103108. protected _buildBlock(state: NodeMaterialBuildState): this;
  103109. }
  103110. }
  103111. declare module BABYLON {
  103112. /**
  103113. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  103114. */
  103115. export class ColorSplitterBlock extends NodeMaterialBlock {
  103116. /**
  103117. * Create a new ColorSplitterBlock
  103118. * @param name defines the block name
  103119. */
  103120. constructor(name: string);
  103121. /**
  103122. * Gets the current class name
  103123. * @returns the class name
  103124. */
  103125. getClassName(): string;
  103126. /**
  103127. * Gets the rgba component (input)
  103128. */
  103129. get rgba(): NodeMaterialConnectionPoint;
  103130. /**
  103131. * Gets the rgb component (input)
  103132. */
  103133. get rgbIn(): NodeMaterialConnectionPoint;
  103134. /**
  103135. * Gets the rgb component (output)
  103136. */
  103137. get rgbOut(): NodeMaterialConnectionPoint;
  103138. /**
  103139. * Gets the r component (output)
  103140. */
  103141. get r(): NodeMaterialConnectionPoint;
  103142. /**
  103143. * Gets the g component (output)
  103144. */
  103145. get g(): NodeMaterialConnectionPoint;
  103146. /**
  103147. * Gets the b component (output)
  103148. */
  103149. get b(): NodeMaterialConnectionPoint;
  103150. /**
  103151. * Gets the a component (output)
  103152. */
  103153. get a(): NodeMaterialConnectionPoint;
  103154. protected _inputRename(name: string): string;
  103155. protected _outputRename(name: string): string;
  103156. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103157. }
  103158. }
  103159. declare module BABYLON {
  103160. /**
  103161. * Operations supported by the Trigonometry block
  103162. */
  103163. export enum TrigonometryBlockOperations {
  103164. /** Cos */
  103165. Cos = 0,
  103166. /** Sin */
  103167. Sin = 1,
  103168. /** Abs */
  103169. Abs = 2,
  103170. /** Exp */
  103171. Exp = 3,
  103172. /** Exp2 */
  103173. Exp2 = 4,
  103174. /** Round */
  103175. Round = 5,
  103176. /** Floor */
  103177. Floor = 6,
  103178. /** Ceiling */
  103179. Ceiling = 7,
  103180. /** Square root */
  103181. Sqrt = 8,
  103182. /** Log */
  103183. Log = 9,
  103184. /** Tangent */
  103185. Tan = 10,
  103186. /** Arc tangent */
  103187. ArcTan = 11,
  103188. /** Arc cosinus */
  103189. ArcCos = 12,
  103190. /** Arc sinus */
  103191. ArcSin = 13,
  103192. /** Fraction */
  103193. Fract = 14,
  103194. /** Sign */
  103195. Sign = 15,
  103196. /** To radians (from degrees) */
  103197. Radians = 16,
  103198. /** To degrees (from radians) */
  103199. Degrees = 17
  103200. }
  103201. /**
  103202. * Block used to apply trigonometry operation to floats
  103203. */
  103204. export class TrigonometryBlock extends NodeMaterialBlock {
  103205. /**
  103206. * Gets or sets the operation applied by the block
  103207. */
  103208. operation: TrigonometryBlockOperations;
  103209. /**
  103210. * Creates a new TrigonometryBlock
  103211. * @param name defines the block name
  103212. */
  103213. constructor(name: string);
  103214. /**
  103215. * Gets the current class name
  103216. * @returns the class name
  103217. */
  103218. getClassName(): string;
  103219. /**
  103220. * Gets the input component
  103221. */
  103222. get input(): NodeMaterialConnectionPoint;
  103223. /**
  103224. * Gets the output component
  103225. */
  103226. get output(): NodeMaterialConnectionPoint;
  103227. protected _buildBlock(state: NodeMaterialBuildState): this;
  103228. serialize(): any;
  103229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103230. protected _dumpPropertiesCode(): string;
  103231. }
  103232. }
  103233. declare module BABYLON {
  103234. /**
  103235. * Interface used to configure the node material editor
  103236. */
  103237. export interface INodeMaterialEditorOptions {
  103238. /** Define the URl to load node editor script */
  103239. editorURL?: string;
  103240. }
  103241. /** @hidden */
  103242. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103243. NORMAL: boolean;
  103244. TANGENT: boolean;
  103245. UV1: boolean;
  103246. /** BONES */
  103247. NUM_BONE_INFLUENCERS: number;
  103248. BonesPerMesh: number;
  103249. BONETEXTURE: boolean;
  103250. /** MORPH TARGETS */
  103251. MORPHTARGETS: boolean;
  103252. MORPHTARGETS_NORMAL: boolean;
  103253. MORPHTARGETS_TANGENT: boolean;
  103254. MORPHTARGETS_UV: boolean;
  103255. NUM_MORPH_INFLUENCERS: number;
  103256. /** IMAGE PROCESSING */
  103257. IMAGEPROCESSING: boolean;
  103258. VIGNETTE: boolean;
  103259. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103260. VIGNETTEBLENDMODEOPAQUE: boolean;
  103261. TONEMAPPING: boolean;
  103262. TONEMAPPING_ACES: boolean;
  103263. CONTRAST: boolean;
  103264. EXPOSURE: boolean;
  103265. COLORCURVES: boolean;
  103266. COLORGRADING: boolean;
  103267. COLORGRADING3D: boolean;
  103268. SAMPLER3DGREENDEPTH: boolean;
  103269. SAMPLER3DBGRMAP: boolean;
  103270. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103271. /** MISC. */
  103272. BUMPDIRECTUV: number;
  103273. constructor();
  103274. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103275. }
  103276. /**
  103277. * Class used to configure NodeMaterial
  103278. */
  103279. export interface INodeMaterialOptions {
  103280. /**
  103281. * Defines if blocks should emit comments
  103282. */
  103283. emitComments: boolean;
  103284. }
  103285. /**
  103286. * Class used to create a node based material built by assembling shader blocks
  103287. */
  103288. export class NodeMaterial extends PushMaterial {
  103289. private static _BuildIdGenerator;
  103290. private _options;
  103291. private _vertexCompilationState;
  103292. private _fragmentCompilationState;
  103293. private _sharedData;
  103294. private _buildId;
  103295. private _buildWasSuccessful;
  103296. private _cachedWorldViewMatrix;
  103297. private _cachedWorldViewProjectionMatrix;
  103298. private _optimizers;
  103299. private _animationFrame;
  103300. /** Define the Url to load node editor script */
  103301. static EditorURL: string;
  103302. /** Define the Url to load snippets */
  103303. static SnippetUrl: string;
  103304. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  103305. static IgnoreTexturesAtLoadTime: boolean;
  103306. private BJSNODEMATERIALEDITOR;
  103307. /** Get the inspector from bundle or global */
  103308. private _getGlobalNodeMaterialEditor;
  103309. /**
  103310. * Snippet ID if the material was created from the snippet server
  103311. */
  103312. snippetId: string;
  103313. /**
  103314. * Gets or sets data used by visual editor
  103315. * @see https://nme.babylonjs.com
  103316. */
  103317. editorData: any;
  103318. /**
  103319. * 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)
  103320. */
  103321. ignoreAlpha: boolean;
  103322. /**
  103323. * Defines the maximum number of lights that can be used in the material
  103324. */
  103325. maxSimultaneousLights: number;
  103326. /**
  103327. * Observable raised when the material is built
  103328. */
  103329. onBuildObservable: Observable<NodeMaterial>;
  103330. /**
  103331. * Gets or sets the root nodes of the material vertex shader
  103332. */
  103333. _vertexOutputNodes: NodeMaterialBlock[];
  103334. /**
  103335. * Gets or sets the root nodes of the material fragment (pixel) shader
  103336. */
  103337. _fragmentOutputNodes: NodeMaterialBlock[];
  103338. /** Gets or sets options to control the node material overall behavior */
  103339. get options(): INodeMaterialOptions;
  103340. set options(options: INodeMaterialOptions);
  103341. /**
  103342. * Default configuration related to image processing available in the standard Material.
  103343. */
  103344. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103345. /**
  103346. * Gets the image processing configuration used either in this material.
  103347. */
  103348. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103349. /**
  103350. * Sets the Default image processing configuration used either in the this material.
  103351. *
  103352. * If sets to null, the scene one is in use.
  103353. */
  103354. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103355. /**
  103356. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103357. */
  103358. attachedBlocks: NodeMaterialBlock[];
  103359. /**
  103360. * Specifies the mode of the node material
  103361. * @hidden
  103362. */
  103363. _mode: NodeMaterialModes;
  103364. /**
  103365. * Gets the mode property
  103366. */
  103367. get mode(): NodeMaterialModes;
  103368. /**
  103369. * Create a new node based material
  103370. * @param name defines the material name
  103371. * @param scene defines the hosting scene
  103372. * @param options defines creation option
  103373. */
  103374. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103375. /**
  103376. * Gets the current class name of the material e.g. "NodeMaterial"
  103377. * @returns the class name
  103378. */
  103379. getClassName(): string;
  103380. /**
  103381. * Keep track of the image processing observer to allow dispose and replace.
  103382. */
  103383. private _imageProcessingObserver;
  103384. /**
  103385. * Attaches a new image processing configuration to the Standard Material.
  103386. * @param configuration
  103387. */
  103388. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103389. /**
  103390. * Get a block by its name
  103391. * @param name defines the name of the block to retrieve
  103392. * @returns the required block or null if not found
  103393. */
  103394. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103395. /**
  103396. * Get a block by its name
  103397. * @param predicate defines the predicate used to find the good candidate
  103398. * @returns the required block or null if not found
  103399. */
  103400. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103401. /**
  103402. * Get an input block by its name
  103403. * @param predicate defines the predicate used to find the good candidate
  103404. * @returns the required input block or null if not found
  103405. */
  103406. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103407. /**
  103408. * Gets the list of input blocks attached to this material
  103409. * @returns an array of InputBlocks
  103410. */
  103411. getInputBlocks(): InputBlock[];
  103412. /**
  103413. * Adds a new optimizer to the list of optimizers
  103414. * @param optimizer defines the optimizers to add
  103415. * @returns the current material
  103416. */
  103417. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103418. /**
  103419. * Remove an optimizer from the list of optimizers
  103420. * @param optimizer defines the optimizers to remove
  103421. * @returns the current material
  103422. */
  103423. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103424. /**
  103425. * Add a new block to the list of output nodes
  103426. * @param node defines the node to add
  103427. * @returns the current material
  103428. */
  103429. addOutputNode(node: NodeMaterialBlock): this;
  103430. /**
  103431. * Remove a block from the list of root nodes
  103432. * @param node defines the node to remove
  103433. * @returns the current material
  103434. */
  103435. removeOutputNode(node: NodeMaterialBlock): this;
  103436. private _addVertexOutputNode;
  103437. private _removeVertexOutputNode;
  103438. private _addFragmentOutputNode;
  103439. private _removeFragmentOutputNode;
  103440. /**
  103441. * Specifies if the material will require alpha blending
  103442. * @returns a boolean specifying if alpha blending is needed
  103443. */
  103444. needAlphaBlending(): boolean;
  103445. /**
  103446. * Specifies if this material should be rendered in alpha test mode
  103447. * @returns a boolean specifying if an alpha test is needed.
  103448. */
  103449. needAlphaTesting(): boolean;
  103450. private _initializeBlock;
  103451. private _resetDualBlocks;
  103452. /**
  103453. * Remove a block from the current node material
  103454. * @param block defines the block to remove
  103455. */
  103456. removeBlock(block: NodeMaterialBlock): void;
  103457. /**
  103458. * Build the material and generates the inner effect
  103459. * @param verbose defines if the build should log activity
  103460. */
  103461. build(verbose?: boolean): void;
  103462. /**
  103463. * Runs an otpimization phase to try to improve the shader code
  103464. */
  103465. optimize(): void;
  103466. private _prepareDefinesForAttributes;
  103467. /**
  103468. * Create a post process from the material
  103469. * @param camera The camera to apply the render pass to.
  103470. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103472. * @param engine The engine which the post process will be applied. (default: current engine)
  103473. * @param reusable If the post process can be reused on the same frame. (default: false)
  103474. * @param textureType Type of textures used when performing the post process. (default: 0)
  103475. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103476. * @returns the post process created
  103477. */
  103478. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103479. /**
  103480. * Create the post process effect from the material
  103481. * @param postProcess The post process to create the effect for
  103482. */
  103483. createEffectForPostProcess(postProcess: PostProcess): void;
  103484. private _createEffectForPostProcess;
  103485. /**
  103486. * Create a new procedural texture based on this node material
  103487. * @param size defines the size of the texture
  103488. * @param scene defines the hosting scene
  103489. * @returns the new procedural texture attached to this node material
  103490. */
  103491. createProceduralTexture(size: number | {
  103492. width: number;
  103493. height: number;
  103494. layers?: number;
  103495. }, scene: Scene): Nullable<ProceduralTexture>;
  103496. private _createEffectForParticles;
  103497. private _checkInternals;
  103498. /**
  103499. * Create the effect to be used as the custom effect for a particle system
  103500. * @param particleSystem Particle system to create the effect for
  103501. * @param onCompiled defines a function to call when the effect creation is successful
  103502. * @param onError defines a function to call when the effect creation has failed
  103503. */
  103504. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103505. private _processDefines;
  103506. /**
  103507. * Get if the submesh is ready to be used and all its information available.
  103508. * Child classes can use it to update shaders
  103509. * @param mesh defines the mesh to check
  103510. * @param subMesh defines which submesh to check
  103511. * @param useInstances specifies that instances should be used
  103512. * @returns a boolean indicating that the submesh is ready or not
  103513. */
  103514. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103515. /**
  103516. * Get a string representing the shaders built by the current node graph
  103517. */
  103518. get compiledShaders(): string;
  103519. /**
  103520. * Binds the world matrix to the material
  103521. * @param world defines the world transformation matrix
  103522. */
  103523. bindOnlyWorldMatrix(world: Matrix): void;
  103524. /**
  103525. * Binds the submesh to this material by preparing the effect and shader to draw
  103526. * @param world defines the world transformation matrix
  103527. * @param mesh defines the mesh containing the submesh
  103528. * @param subMesh defines the submesh to bind the material to
  103529. */
  103530. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103531. /**
  103532. * Gets the active textures from the material
  103533. * @returns an array of textures
  103534. */
  103535. getActiveTextures(): BaseTexture[];
  103536. /**
  103537. * Gets the list of texture blocks
  103538. * @returns an array of texture blocks
  103539. */
  103540. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103541. /**
  103542. * Specifies if the material uses a texture
  103543. * @param texture defines the texture to check against the material
  103544. * @returns a boolean specifying if the material uses the texture
  103545. */
  103546. hasTexture(texture: BaseTexture): boolean;
  103547. /**
  103548. * Disposes the material
  103549. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103550. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103551. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103552. */
  103553. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103554. /** Creates the node editor window. */
  103555. private _createNodeEditor;
  103556. /**
  103557. * Launch the node material editor
  103558. * @param config Define the configuration of the editor
  103559. * @return a promise fulfilled when the node editor is visible
  103560. */
  103561. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103562. /**
  103563. * Clear the current material
  103564. */
  103565. clear(): void;
  103566. /**
  103567. * Clear the current material and set it to a default state
  103568. */
  103569. setToDefault(): void;
  103570. /**
  103571. * Clear the current material and set it to a default state for post process
  103572. */
  103573. setToDefaultPostProcess(): void;
  103574. /**
  103575. * Clear the current material and set it to a default state for procedural texture
  103576. */
  103577. setToDefaultProceduralTexture(): void;
  103578. /**
  103579. * Clear the current material and set it to a default state for particle
  103580. */
  103581. setToDefaultParticle(): void;
  103582. /**
  103583. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103584. * @param url defines the url to load from
  103585. * @returns a promise that will fullfil when the material is fully loaded
  103586. */
  103587. loadAsync(url: string): Promise<void>;
  103588. private _gatherBlocks;
  103589. /**
  103590. * Generate a string containing the code declaration required to create an equivalent of this material
  103591. * @returns a string
  103592. */
  103593. generateCode(): string;
  103594. /**
  103595. * Serializes this material in a JSON representation
  103596. * @returns the serialized material object
  103597. */
  103598. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103599. private _restoreConnections;
  103600. /**
  103601. * Clear the current graph and load a new one from a serialization object
  103602. * @param source defines the JSON representation of the material
  103603. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103604. * @param merge defines whether or not the source must be merged or replace the current content
  103605. */
  103606. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103607. /**
  103608. * Makes a duplicate of the current material.
  103609. * @param name - name to use for the new material.
  103610. */
  103611. clone(name: string): NodeMaterial;
  103612. /**
  103613. * Creates a node material from parsed material data
  103614. * @param source defines the JSON representation of the material
  103615. * @param scene defines the hosting scene
  103616. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103617. * @returns a new node material
  103618. */
  103619. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103620. /**
  103621. * Creates a node material from a snippet saved in a remote file
  103622. * @param name defines the name of the material to create
  103623. * @param url defines the url to load from
  103624. * @param scene defines the hosting scene
  103625. * @returns a promise that will resolve to the new node material
  103626. */
  103627. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103628. /**
  103629. * Creates a node material from a snippet saved by the node material editor
  103630. * @param snippetId defines the snippet to load
  103631. * @param scene defines the hosting scene
  103632. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103633. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103634. * @returns a promise that will resolve to the new node material
  103635. */
  103636. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103637. /**
  103638. * Creates a new node material set to default basic configuration
  103639. * @param name defines the name of the material
  103640. * @param scene defines the hosting scene
  103641. * @returns a new NodeMaterial
  103642. */
  103643. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103644. }
  103645. }
  103646. declare module BABYLON {
  103647. interface ThinEngine {
  103648. /**
  103649. * Unbind a list of render target textures from the webGL context
  103650. * This is used only when drawBuffer extension or webGL2 are active
  103651. * @param textures defines the render target textures to unbind
  103652. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103653. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103654. */
  103655. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103656. /**
  103657. * Create a multi render target texture
  103658. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103659. * @param size defines the size of the texture
  103660. * @param options defines the creation options
  103661. * @returns the cube texture as an InternalTexture
  103662. */
  103663. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103664. /**
  103665. * Update the sample count for a given multiple render target texture
  103666. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103667. * @param textures defines the textures to update
  103668. * @param samples defines the sample count to set
  103669. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103670. */
  103671. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103672. /**
  103673. * Select a subsets of attachments to draw to.
  103674. * @param attachments gl attachments
  103675. */
  103676. bindAttachments(attachments: number[]): void;
  103677. /**
  103678. * Creates a layout object to draw/clear on specific textures in a MRT
  103679. * @param textureStatus textureStatus[i] indicates if the i-th is active
  103680. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  103681. */
  103682. buildTextureLayout(textureStatus: boolean[]): number[];
  103683. /**
  103684. * Restores the webgl state to only draw on the main color attachment
  103685. */
  103686. restoreSingleAttachment(): void;
  103687. }
  103688. }
  103689. declare module BABYLON {
  103690. /**
  103691. * Creation options of the multi render target texture.
  103692. */
  103693. export interface IMultiRenderTargetOptions {
  103694. /**
  103695. * Define if the texture needs to create mip maps after render.
  103696. */
  103697. generateMipMaps?: boolean;
  103698. /**
  103699. * Define the types of all the draw buffers we want to create
  103700. */
  103701. types?: number[];
  103702. /**
  103703. * Define the sampling modes of all the draw buffers we want to create
  103704. */
  103705. samplingModes?: number[];
  103706. /**
  103707. * Define if a depth buffer is required
  103708. */
  103709. generateDepthBuffer?: boolean;
  103710. /**
  103711. * Define if a stencil buffer is required
  103712. */
  103713. generateStencilBuffer?: boolean;
  103714. /**
  103715. * Define if a depth texture is required instead of a depth buffer
  103716. */
  103717. generateDepthTexture?: boolean;
  103718. /**
  103719. * Define the number of desired draw buffers
  103720. */
  103721. textureCount?: number;
  103722. /**
  103723. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103724. */
  103725. doNotChangeAspectRatio?: boolean;
  103726. /**
  103727. * Define the default type of the buffers we are creating
  103728. */
  103729. defaultType?: number;
  103730. }
  103731. /**
  103732. * A multi render target, like a render target provides the ability to render to a texture.
  103733. * Unlike the render target, it can render to several draw buffers in one draw.
  103734. * This is specially interesting in deferred rendering or for any effects requiring more than
  103735. * just one color from a single pass.
  103736. */
  103737. export class MultiRenderTarget extends RenderTargetTexture {
  103738. private _internalTextures;
  103739. private _textures;
  103740. private _multiRenderTargetOptions;
  103741. private _count;
  103742. /**
  103743. * Get if draw buffers are currently supported by the used hardware and browser.
  103744. */
  103745. get isSupported(): boolean;
  103746. /**
  103747. * Get the list of textures generated by the multi render target.
  103748. */
  103749. get textures(): Texture[];
  103750. /**
  103751. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103752. */
  103753. get count(): number;
  103754. /**
  103755. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103756. */
  103757. get depthTexture(): Texture;
  103758. /**
  103759. * Set the wrapping mode on U of all the textures we are rendering to.
  103760. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103761. */
  103762. set wrapU(wrap: number);
  103763. /**
  103764. * Set the wrapping mode on V of all the textures we are rendering to.
  103765. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103766. */
  103767. set wrapV(wrap: number);
  103768. /**
  103769. * Instantiate a new multi render target texture.
  103770. * A multi render target, like a render target provides the ability to render to a texture.
  103771. * Unlike the render target, it can render to several draw buffers in one draw.
  103772. * This is specially interesting in deferred rendering or for any effects requiring more than
  103773. * just one color from a single pass.
  103774. * @param name Define the name of the texture
  103775. * @param size Define the size of the buffers to render to
  103776. * @param count Define the number of target we are rendering into
  103777. * @param scene Define the scene the texture belongs to
  103778. * @param options Define the options used to create the multi render target
  103779. */
  103780. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103781. private _initTypes;
  103782. /** @hidden */
  103783. _rebuild(forceFullRebuild?: boolean): void;
  103784. private _createInternalTextures;
  103785. private _createTextures;
  103786. /**
  103787. * Replaces a texture within the MRT.
  103788. * @param texture The new texture to insert in the MRT
  103789. * @param index The index of the texture to replace
  103790. */
  103791. replaceTexture(texture: Texture, index: number): void;
  103792. /**
  103793. * Define the number of samples used if MSAA is enabled.
  103794. */
  103795. get samples(): number;
  103796. set samples(value: number);
  103797. /**
  103798. * Resize all the textures in the multi render target.
  103799. * Be careful as it will recreate all the data in the new texture.
  103800. * @param size Define the new size
  103801. */
  103802. resize(size: any): void;
  103803. /**
  103804. * Changes the number of render targets in this MRT
  103805. * Be careful as it will recreate all the data in the new texture.
  103806. * @param count new texture count
  103807. * @param options Specifies texture types and sampling modes for new textures
  103808. */
  103809. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103810. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103811. /**
  103812. * Dispose the render targets and their associated resources
  103813. */
  103814. dispose(): void;
  103815. /**
  103816. * Release all the underlying texture used as draw buffers.
  103817. */
  103818. releaseInternalTextures(): void;
  103819. }
  103820. }
  103821. declare module BABYLON {
  103822. /** @hidden */
  103823. export var imageProcessingPixelShader: {
  103824. name: string;
  103825. shader: string;
  103826. };
  103827. }
  103828. declare module BABYLON {
  103829. /**
  103830. * ImageProcessingPostProcess
  103831. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103832. */
  103833. export class ImageProcessingPostProcess extends PostProcess {
  103834. /**
  103835. * Default configuration related to image processing available in the PBR Material.
  103836. */
  103837. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103838. /**
  103839. * Gets the image processing configuration used either in this material.
  103840. */
  103841. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103842. /**
  103843. * Sets the Default image processing configuration used either in the this material.
  103844. *
  103845. * If sets to null, the scene one is in use.
  103846. */
  103847. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103848. /**
  103849. * Keep track of the image processing observer to allow dispose and replace.
  103850. */
  103851. private _imageProcessingObserver;
  103852. /**
  103853. * Attaches a new image processing configuration to the PBR Material.
  103854. * @param configuration
  103855. */
  103856. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103857. /**
  103858. * If the post process is supported.
  103859. */
  103860. get isSupported(): boolean;
  103861. /**
  103862. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103863. */
  103864. get colorCurves(): Nullable<ColorCurves>;
  103865. /**
  103866. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103867. */
  103868. set colorCurves(value: Nullable<ColorCurves>);
  103869. /**
  103870. * Gets wether the color curves effect is enabled.
  103871. */
  103872. get colorCurvesEnabled(): boolean;
  103873. /**
  103874. * Sets wether the color curves effect is enabled.
  103875. */
  103876. set colorCurvesEnabled(value: boolean);
  103877. /**
  103878. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103879. */
  103880. get colorGradingTexture(): Nullable<BaseTexture>;
  103881. /**
  103882. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103883. */
  103884. set colorGradingTexture(value: Nullable<BaseTexture>);
  103885. /**
  103886. * Gets wether the color grading effect is enabled.
  103887. */
  103888. get colorGradingEnabled(): boolean;
  103889. /**
  103890. * Gets wether the color grading effect is enabled.
  103891. */
  103892. set colorGradingEnabled(value: boolean);
  103893. /**
  103894. * Gets exposure used in the effect.
  103895. */
  103896. get exposure(): number;
  103897. /**
  103898. * Sets exposure used in the effect.
  103899. */
  103900. set exposure(value: number);
  103901. /**
  103902. * Gets wether tonemapping is enabled or not.
  103903. */
  103904. get toneMappingEnabled(): boolean;
  103905. /**
  103906. * Sets wether tonemapping is enabled or not
  103907. */
  103908. set toneMappingEnabled(value: boolean);
  103909. /**
  103910. * Gets the type of tone mapping effect.
  103911. */
  103912. get toneMappingType(): number;
  103913. /**
  103914. * Sets the type of tone mapping effect.
  103915. */
  103916. set toneMappingType(value: number);
  103917. /**
  103918. * Gets contrast used in the effect.
  103919. */
  103920. get contrast(): number;
  103921. /**
  103922. * Sets contrast used in the effect.
  103923. */
  103924. set contrast(value: number);
  103925. /**
  103926. * Gets Vignette stretch size.
  103927. */
  103928. get vignetteStretch(): number;
  103929. /**
  103930. * Sets Vignette stretch size.
  103931. */
  103932. set vignetteStretch(value: number);
  103933. /**
  103934. * Gets Vignette centre X Offset.
  103935. */
  103936. get vignetteCentreX(): number;
  103937. /**
  103938. * Sets Vignette centre X Offset.
  103939. */
  103940. set vignetteCentreX(value: number);
  103941. /**
  103942. * Gets Vignette centre Y Offset.
  103943. */
  103944. get vignetteCentreY(): number;
  103945. /**
  103946. * Sets Vignette centre Y Offset.
  103947. */
  103948. set vignetteCentreY(value: number);
  103949. /**
  103950. * Gets Vignette weight or intensity of the vignette effect.
  103951. */
  103952. get vignetteWeight(): number;
  103953. /**
  103954. * Sets Vignette weight or intensity of the vignette effect.
  103955. */
  103956. set vignetteWeight(value: number);
  103957. /**
  103958. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103959. * if vignetteEnabled is set to true.
  103960. */
  103961. get vignetteColor(): Color4;
  103962. /**
  103963. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103964. * if vignetteEnabled is set to true.
  103965. */
  103966. set vignetteColor(value: Color4);
  103967. /**
  103968. * Gets Camera field of view used by the Vignette effect.
  103969. */
  103970. get vignetteCameraFov(): number;
  103971. /**
  103972. * Sets Camera field of view used by the Vignette effect.
  103973. */
  103974. set vignetteCameraFov(value: number);
  103975. /**
  103976. * Gets the vignette blend mode allowing different kind of effect.
  103977. */
  103978. get vignetteBlendMode(): number;
  103979. /**
  103980. * Sets the vignette blend mode allowing different kind of effect.
  103981. */
  103982. set vignetteBlendMode(value: number);
  103983. /**
  103984. * Gets wether the vignette effect is enabled.
  103985. */
  103986. get vignetteEnabled(): boolean;
  103987. /**
  103988. * Sets wether the vignette effect is enabled.
  103989. */
  103990. set vignetteEnabled(value: boolean);
  103991. private _fromLinearSpace;
  103992. /**
  103993. * Gets wether the input of the processing is in Gamma or Linear Space.
  103994. */
  103995. get fromLinearSpace(): boolean;
  103996. /**
  103997. * Sets wether the input of the processing is in Gamma or Linear Space.
  103998. */
  103999. set fromLinearSpace(value: boolean);
  104000. /**
  104001. * Defines cache preventing GC.
  104002. */
  104003. private _defines;
  104004. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104005. /**
  104006. * "ImageProcessingPostProcess"
  104007. * @returns "ImageProcessingPostProcess"
  104008. */
  104009. getClassName(): string;
  104010. /**
  104011. * @hidden
  104012. */
  104013. _updateParameters(): void;
  104014. dispose(camera?: Camera): void;
  104015. }
  104016. }
  104017. declare module BABYLON {
  104018. /**
  104019. * Interface for defining prepass effects in the prepass post-process pipeline
  104020. */
  104021. export interface PrePassEffectConfiguration {
  104022. /**
  104023. * Name of the effect
  104024. */
  104025. name: string;
  104026. /**
  104027. * Post process to attach for this effect
  104028. */
  104029. postProcess?: PostProcess;
  104030. /**
  104031. * Textures required in the MRT
  104032. */
  104033. texturesRequired: number[];
  104034. /**
  104035. * Is the effect enabled
  104036. */
  104037. enabled: boolean;
  104038. /**
  104039. * Disposes the effect configuration
  104040. */
  104041. dispose?: () => void;
  104042. /**
  104043. * Creates the associated post process
  104044. */
  104045. createPostProcess?: () => PostProcess;
  104046. }
  104047. }
  104048. declare module BABYLON {
  104049. /**
  104050. * Options to be used when creating a FresnelParameters.
  104051. */
  104052. export type IFresnelParametersCreationOptions = {
  104053. /**
  104054. * Define the color used on edges (grazing angle)
  104055. */
  104056. leftColor?: Color3;
  104057. /**
  104058. * Define the color used on center
  104059. */
  104060. rightColor?: Color3;
  104061. /**
  104062. * Define bias applied to computed fresnel term
  104063. */
  104064. bias?: number;
  104065. /**
  104066. * Defined the power exponent applied to fresnel term
  104067. */
  104068. power?: number;
  104069. /**
  104070. * Define if the fresnel effect is enable or not.
  104071. */
  104072. isEnabled?: boolean;
  104073. };
  104074. /**
  104075. * Serialized format for FresnelParameters.
  104076. */
  104077. export type IFresnelParametersSerialized = {
  104078. /**
  104079. * Define the color used on edges (grazing angle) [as an array]
  104080. */
  104081. leftColor: number[];
  104082. /**
  104083. * Define the color used on center [as an array]
  104084. */
  104085. rightColor: number[];
  104086. /**
  104087. * Define bias applied to computed fresnel term
  104088. */
  104089. bias: number;
  104090. /**
  104091. * Defined the power exponent applied to fresnel term
  104092. */
  104093. power?: number;
  104094. /**
  104095. * Define if the fresnel effect is enable or not.
  104096. */
  104097. isEnabled: boolean;
  104098. };
  104099. /**
  104100. * This represents all the required information to add a fresnel effect on a material:
  104101. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104102. */
  104103. export class FresnelParameters {
  104104. private _isEnabled;
  104105. /**
  104106. * Define if the fresnel effect is enable or not.
  104107. */
  104108. get isEnabled(): boolean;
  104109. set isEnabled(value: boolean);
  104110. /**
  104111. * Define the color used on edges (grazing angle)
  104112. */
  104113. leftColor: Color3;
  104114. /**
  104115. * Define the color used on center
  104116. */
  104117. rightColor: Color3;
  104118. /**
  104119. * Define bias applied to computed fresnel term
  104120. */
  104121. bias: number;
  104122. /**
  104123. * Defined the power exponent applied to fresnel term
  104124. */
  104125. power: number;
  104126. /**
  104127. * Creates a new FresnelParameters object.
  104128. *
  104129. * @param options provide your own settings to optionally to override defaults
  104130. */
  104131. constructor(options?: IFresnelParametersCreationOptions);
  104132. /**
  104133. * Clones the current fresnel and its valuues
  104134. * @returns a clone fresnel configuration
  104135. */
  104136. clone(): FresnelParameters;
  104137. /**
  104138. * Determines equality between FresnelParameters objects
  104139. * @param otherFresnelParameters defines the second operand
  104140. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  104141. */
  104142. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  104143. /**
  104144. * Serializes the current fresnel parameters to a JSON representation.
  104145. * @return the JSON serialization
  104146. */
  104147. serialize(): IFresnelParametersSerialized;
  104148. /**
  104149. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  104150. * @param parsedFresnelParameters Define the JSON representation
  104151. * @returns the parsed parameters
  104152. */
  104153. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  104154. }
  104155. }
  104156. declare module BABYLON {
  104157. /**
  104158. * This groups all the flags used to control the materials channel.
  104159. */
  104160. export class MaterialFlags {
  104161. private static _DiffuseTextureEnabled;
  104162. /**
  104163. * Are diffuse textures enabled in the application.
  104164. */
  104165. static get DiffuseTextureEnabled(): boolean;
  104166. static set DiffuseTextureEnabled(value: boolean);
  104167. private static _DetailTextureEnabled;
  104168. /**
  104169. * Are detail textures enabled in the application.
  104170. */
  104171. static get DetailTextureEnabled(): boolean;
  104172. static set DetailTextureEnabled(value: boolean);
  104173. private static _AmbientTextureEnabled;
  104174. /**
  104175. * Are ambient textures enabled in the application.
  104176. */
  104177. static get AmbientTextureEnabled(): boolean;
  104178. static set AmbientTextureEnabled(value: boolean);
  104179. private static _OpacityTextureEnabled;
  104180. /**
  104181. * Are opacity textures enabled in the application.
  104182. */
  104183. static get OpacityTextureEnabled(): boolean;
  104184. static set OpacityTextureEnabled(value: boolean);
  104185. private static _ReflectionTextureEnabled;
  104186. /**
  104187. * Are reflection textures enabled in the application.
  104188. */
  104189. static get ReflectionTextureEnabled(): boolean;
  104190. static set ReflectionTextureEnabled(value: boolean);
  104191. private static _EmissiveTextureEnabled;
  104192. /**
  104193. * Are emissive textures enabled in the application.
  104194. */
  104195. static get EmissiveTextureEnabled(): boolean;
  104196. static set EmissiveTextureEnabled(value: boolean);
  104197. private static _SpecularTextureEnabled;
  104198. /**
  104199. * Are specular textures enabled in the application.
  104200. */
  104201. static get SpecularTextureEnabled(): boolean;
  104202. static set SpecularTextureEnabled(value: boolean);
  104203. private static _BumpTextureEnabled;
  104204. /**
  104205. * Are bump textures enabled in the application.
  104206. */
  104207. static get BumpTextureEnabled(): boolean;
  104208. static set BumpTextureEnabled(value: boolean);
  104209. private static _LightmapTextureEnabled;
  104210. /**
  104211. * Are lightmap textures enabled in the application.
  104212. */
  104213. static get LightmapTextureEnabled(): boolean;
  104214. static set LightmapTextureEnabled(value: boolean);
  104215. private static _RefractionTextureEnabled;
  104216. /**
  104217. * Are refraction textures enabled in the application.
  104218. */
  104219. static get RefractionTextureEnabled(): boolean;
  104220. static set RefractionTextureEnabled(value: boolean);
  104221. private static _ColorGradingTextureEnabled;
  104222. /**
  104223. * Are color grading textures enabled in the application.
  104224. */
  104225. static get ColorGradingTextureEnabled(): boolean;
  104226. static set ColorGradingTextureEnabled(value: boolean);
  104227. private static _FresnelEnabled;
  104228. /**
  104229. * Are fresnels enabled in the application.
  104230. */
  104231. static get FresnelEnabled(): boolean;
  104232. static set FresnelEnabled(value: boolean);
  104233. private static _ClearCoatTextureEnabled;
  104234. /**
  104235. * Are clear coat textures enabled in the application.
  104236. */
  104237. static get ClearCoatTextureEnabled(): boolean;
  104238. static set ClearCoatTextureEnabled(value: boolean);
  104239. private static _ClearCoatBumpTextureEnabled;
  104240. /**
  104241. * Are clear coat bump textures enabled in the application.
  104242. */
  104243. static get ClearCoatBumpTextureEnabled(): boolean;
  104244. static set ClearCoatBumpTextureEnabled(value: boolean);
  104245. private static _ClearCoatTintTextureEnabled;
  104246. /**
  104247. * Are clear coat tint textures enabled in the application.
  104248. */
  104249. static get ClearCoatTintTextureEnabled(): boolean;
  104250. static set ClearCoatTintTextureEnabled(value: boolean);
  104251. private static _SheenTextureEnabled;
  104252. /**
  104253. * Are sheen textures enabled in the application.
  104254. */
  104255. static get SheenTextureEnabled(): boolean;
  104256. static set SheenTextureEnabled(value: boolean);
  104257. private static _AnisotropicTextureEnabled;
  104258. /**
  104259. * Are anisotropic textures enabled in the application.
  104260. */
  104261. static get AnisotropicTextureEnabled(): boolean;
  104262. static set AnisotropicTextureEnabled(value: boolean);
  104263. private static _ThicknessTextureEnabled;
  104264. /**
  104265. * Are thickness textures enabled in the application.
  104266. */
  104267. static get ThicknessTextureEnabled(): boolean;
  104268. static set ThicknessTextureEnabled(value: boolean);
  104269. }
  104270. }
  104271. declare module BABYLON {
  104272. /** @hidden */
  104273. export var defaultFragmentDeclaration: {
  104274. name: string;
  104275. shader: string;
  104276. };
  104277. }
  104278. declare module BABYLON {
  104279. /** @hidden */
  104280. export var defaultUboDeclaration: {
  104281. name: string;
  104282. shader: string;
  104283. };
  104284. }
  104285. declare module BABYLON {
  104286. /** @hidden */
  104287. export var prePassDeclaration: {
  104288. name: string;
  104289. shader: string;
  104290. };
  104291. }
  104292. declare module BABYLON {
  104293. /** @hidden */
  104294. export var lightFragmentDeclaration: {
  104295. name: string;
  104296. shader: string;
  104297. };
  104298. }
  104299. declare module BABYLON {
  104300. /** @hidden */
  104301. export var lightUboDeclaration: {
  104302. name: string;
  104303. shader: string;
  104304. };
  104305. }
  104306. declare module BABYLON {
  104307. /** @hidden */
  104308. export var lightsFragmentFunctions: {
  104309. name: string;
  104310. shader: string;
  104311. };
  104312. }
  104313. declare module BABYLON {
  104314. /** @hidden */
  104315. export var shadowsFragmentFunctions: {
  104316. name: string;
  104317. shader: string;
  104318. };
  104319. }
  104320. declare module BABYLON {
  104321. /** @hidden */
  104322. export var fresnelFunction: {
  104323. name: string;
  104324. shader: string;
  104325. };
  104326. }
  104327. declare module BABYLON {
  104328. /** @hidden */
  104329. export var bumpFragmentMainFunctions: {
  104330. name: string;
  104331. shader: string;
  104332. };
  104333. }
  104334. declare module BABYLON {
  104335. /** @hidden */
  104336. export var bumpFragmentFunctions: {
  104337. name: string;
  104338. shader: string;
  104339. };
  104340. }
  104341. declare module BABYLON {
  104342. /** @hidden */
  104343. export var logDepthDeclaration: {
  104344. name: string;
  104345. shader: string;
  104346. };
  104347. }
  104348. declare module BABYLON {
  104349. /** @hidden */
  104350. export var bumpFragment: {
  104351. name: string;
  104352. shader: string;
  104353. };
  104354. }
  104355. declare module BABYLON {
  104356. /** @hidden */
  104357. export var depthPrePass: {
  104358. name: string;
  104359. shader: string;
  104360. };
  104361. }
  104362. declare module BABYLON {
  104363. /** @hidden */
  104364. export var lightFragment: {
  104365. name: string;
  104366. shader: string;
  104367. };
  104368. }
  104369. declare module BABYLON {
  104370. /** @hidden */
  104371. export var logDepthFragment: {
  104372. name: string;
  104373. shader: string;
  104374. };
  104375. }
  104376. declare module BABYLON {
  104377. /** @hidden */
  104378. export var defaultPixelShader: {
  104379. name: string;
  104380. shader: string;
  104381. };
  104382. }
  104383. declare module BABYLON {
  104384. /** @hidden */
  104385. export var defaultVertexDeclaration: {
  104386. name: string;
  104387. shader: string;
  104388. };
  104389. }
  104390. declare module BABYLON {
  104391. /** @hidden */
  104392. export var prePassVertexDeclaration: {
  104393. name: string;
  104394. shader: string;
  104395. };
  104396. }
  104397. declare module BABYLON {
  104398. /** @hidden */
  104399. export var bumpVertexDeclaration: {
  104400. name: string;
  104401. shader: string;
  104402. };
  104403. }
  104404. declare module BABYLON {
  104405. /** @hidden */
  104406. export var prePassVertex: {
  104407. name: string;
  104408. shader: string;
  104409. };
  104410. }
  104411. declare module BABYLON {
  104412. /** @hidden */
  104413. export var bumpVertex: {
  104414. name: string;
  104415. shader: string;
  104416. };
  104417. }
  104418. declare module BABYLON {
  104419. /** @hidden */
  104420. export var fogVertex: {
  104421. name: string;
  104422. shader: string;
  104423. };
  104424. }
  104425. declare module BABYLON {
  104426. /** @hidden */
  104427. export var shadowsVertex: {
  104428. name: string;
  104429. shader: string;
  104430. };
  104431. }
  104432. declare module BABYLON {
  104433. /** @hidden */
  104434. export var pointCloudVertex: {
  104435. name: string;
  104436. shader: string;
  104437. };
  104438. }
  104439. declare module BABYLON {
  104440. /** @hidden */
  104441. export var logDepthVertex: {
  104442. name: string;
  104443. shader: string;
  104444. };
  104445. }
  104446. declare module BABYLON {
  104447. /** @hidden */
  104448. export var defaultVertexShader: {
  104449. name: string;
  104450. shader: string;
  104451. };
  104452. }
  104453. declare module BABYLON {
  104454. /**
  104455. * @hidden
  104456. */
  104457. export interface IMaterialDetailMapDefines {
  104458. DETAIL: boolean;
  104459. DETAILDIRECTUV: number;
  104460. DETAIL_NORMALBLENDMETHOD: number;
  104461. /** @hidden */
  104462. _areTexturesDirty: boolean;
  104463. }
  104464. /**
  104465. * Define the code related to the detail map parameters of a material
  104466. *
  104467. * Inspired from:
  104468. * 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
  104469. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  104470. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  104471. */
  104472. export class DetailMapConfiguration {
  104473. private _texture;
  104474. /**
  104475. * The detail texture of the material.
  104476. */
  104477. texture: Nullable<BaseTexture>;
  104478. /**
  104479. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  104480. * Bigger values mean stronger blending
  104481. */
  104482. diffuseBlendLevel: number;
  104483. /**
  104484. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  104485. * Bigger values mean stronger blending. Only used with PBR materials
  104486. */
  104487. roughnessBlendLevel: number;
  104488. /**
  104489. * Defines how strong the bump effect from the detail map is
  104490. * Bigger values mean stronger effect
  104491. */
  104492. bumpLevel: number;
  104493. private _normalBlendMethod;
  104494. /**
  104495. * The method used to blend the bump and detail normals together
  104496. */
  104497. normalBlendMethod: number;
  104498. private _isEnabled;
  104499. /**
  104500. * Enable or disable the detail map on this material
  104501. */
  104502. isEnabled: boolean;
  104503. /** @hidden */
  104504. private _internalMarkAllSubMeshesAsTexturesDirty;
  104505. /** @hidden */
  104506. _markAllSubMeshesAsTexturesDirty(): void;
  104507. /**
  104508. * Instantiate a new detail map
  104509. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104510. */
  104511. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104512. /**
  104513. * Gets whether the submesh is ready to be used or not.
  104514. * @param defines the list of "defines" to update.
  104515. * @param scene defines the scene the material belongs to.
  104516. * @returns - boolean indicating that the submesh is ready or not.
  104517. */
  104518. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  104519. /**
  104520. * Update the defines for detail map usage
  104521. * @param defines the list of "defines" to update.
  104522. * @param scene defines the scene the material belongs to.
  104523. */
  104524. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  104525. /**
  104526. * Binds the material data.
  104527. * @param uniformBuffer defines the Uniform buffer to fill in.
  104528. * @param scene defines the scene the material belongs to.
  104529. * @param isFrozen defines whether the material is frozen or not.
  104530. */
  104531. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104532. /**
  104533. * Checks to see if a texture is used in the material.
  104534. * @param texture - Base texture to use.
  104535. * @returns - Boolean specifying if a texture is used in the material.
  104536. */
  104537. hasTexture(texture: BaseTexture): boolean;
  104538. /**
  104539. * Returns an array of the actively used textures.
  104540. * @param activeTextures Array of BaseTextures
  104541. */
  104542. getActiveTextures(activeTextures: BaseTexture[]): void;
  104543. /**
  104544. * Returns the animatable textures.
  104545. * @param animatables Array of animatable textures.
  104546. */
  104547. getAnimatables(animatables: IAnimatable[]): void;
  104548. /**
  104549. * Disposes the resources of the material.
  104550. * @param forceDisposeTextures - Forces the disposal of all textures.
  104551. */
  104552. dispose(forceDisposeTextures?: boolean): void;
  104553. /**
  104554. * Get the current class name useful for serialization or dynamic coding.
  104555. * @returns "DetailMap"
  104556. */
  104557. getClassName(): string;
  104558. /**
  104559. * Add the required uniforms to the current list.
  104560. * @param uniforms defines the current uniform list.
  104561. */
  104562. static AddUniforms(uniforms: string[]): void;
  104563. /**
  104564. * Add the required samplers to the current list.
  104565. * @param samplers defines the current sampler list.
  104566. */
  104567. static AddSamplers(samplers: string[]): void;
  104568. /**
  104569. * Add the required uniforms to the current buffer.
  104570. * @param uniformBuffer defines the current uniform buffer.
  104571. */
  104572. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104573. /**
  104574. * Makes a duplicate of the current instance into another one.
  104575. * @param detailMap define the instance where to copy the info
  104576. */
  104577. copyTo(detailMap: DetailMapConfiguration): void;
  104578. /**
  104579. * Serializes this detail map instance
  104580. * @returns - An object with the serialized instance.
  104581. */
  104582. serialize(): any;
  104583. /**
  104584. * Parses a detail map setting from a serialized object.
  104585. * @param source - Serialized object.
  104586. * @param scene Defines the scene we are parsing for
  104587. * @param rootUrl Defines the rootUrl to load from
  104588. */
  104589. parse(source: any, scene: Scene, rootUrl: string): void;
  104590. }
  104591. }
  104592. declare module BABYLON {
  104593. /** @hidden */
  104594. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  104595. MAINUV1: boolean;
  104596. MAINUV2: boolean;
  104597. DIFFUSE: boolean;
  104598. DIFFUSEDIRECTUV: number;
  104599. DETAIL: boolean;
  104600. DETAILDIRECTUV: number;
  104601. DETAIL_NORMALBLENDMETHOD: number;
  104602. AMBIENT: boolean;
  104603. AMBIENTDIRECTUV: number;
  104604. OPACITY: boolean;
  104605. OPACITYDIRECTUV: number;
  104606. OPACITYRGB: boolean;
  104607. REFLECTION: boolean;
  104608. EMISSIVE: boolean;
  104609. EMISSIVEDIRECTUV: number;
  104610. SPECULAR: boolean;
  104611. SPECULARDIRECTUV: number;
  104612. BUMP: boolean;
  104613. BUMPDIRECTUV: number;
  104614. PARALLAX: boolean;
  104615. PARALLAXOCCLUSION: boolean;
  104616. SPECULAROVERALPHA: boolean;
  104617. CLIPPLANE: boolean;
  104618. CLIPPLANE2: boolean;
  104619. CLIPPLANE3: boolean;
  104620. CLIPPLANE4: boolean;
  104621. CLIPPLANE5: boolean;
  104622. CLIPPLANE6: boolean;
  104623. ALPHATEST: boolean;
  104624. DEPTHPREPASS: boolean;
  104625. ALPHAFROMDIFFUSE: boolean;
  104626. POINTSIZE: boolean;
  104627. FOG: boolean;
  104628. SPECULARTERM: boolean;
  104629. DIFFUSEFRESNEL: boolean;
  104630. OPACITYFRESNEL: boolean;
  104631. REFLECTIONFRESNEL: boolean;
  104632. REFRACTIONFRESNEL: boolean;
  104633. EMISSIVEFRESNEL: boolean;
  104634. FRESNEL: boolean;
  104635. NORMAL: boolean;
  104636. UV1: boolean;
  104637. UV2: boolean;
  104638. VERTEXCOLOR: boolean;
  104639. VERTEXALPHA: boolean;
  104640. NUM_BONE_INFLUENCERS: number;
  104641. BonesPerMesh: number;
  104642. BONETEXTURE: boolean;
  104643. BONES_VELOCITY_ENABLED: boolean;
  104644. INSTANCES: boolean;
  104645. THIN_INSTANCES: boolean;
  104646. GLOSSINESS: boolean;
  104647. ROUGHNESS: boolean;
  104648. EMISSIVEASILLUMINATION: boolean;
  104649. LINKEMISSIVEWITHDIFFUSE: boolean;
  104650. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104651. LIGHTMAP: boolean;
  104652. LIGHTMAPDIRECTUV: number;
  104653. OBJECTSPACE_NORMALMAP: boolean;
  104654. USELIGHTMAPASSHADOWMAP: boolean;
  104655. REFLECTIONMAP_3D: boolean;
  104656. REFLECTIONMAP_SPHERICAL: boolean;
  104657. REFLECTIONMAP_PLANAR: boolean;
  104658. REFLECTIONMAP_CUBIC: boolean;
  104659. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104660. REFLECTIONMAP_PROJECTION: boolean;
  104661. REFLECTIONMAP_SKYBOX: boolean;
  104662. REFLECTIONMAP_EXPLICIT: boolean;
  104663. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104664. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104665. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104666. INVERTCUBICMAP: boolean;
  104667. LOGARITHMICDEPTH: boolean;
  104668. REFRACTION: boolean;
  104669. REFRACTIONMAP_3D: boolean;
  104670. REFLECTIONOVERALPHA: boolean;
  104671. TWOSIDEDLIGHTING: boolean;
  104672. SHADOWFLOAT: boolean;
  104673. MORPHTARGETS: boolean;
  104674. MORPHTARGETS_NORMAL: boolean;
  104675. MORPHTARGETS_TANGENT: boolean;
  104676. MORPHTARGETS_UV: boolean;
  104677. NUM_MORPH_INFLUENCERS: number;
  104678. NONUNIFORMSCALING: boolean;
  104679. PREMULTIPLYALPHA: boolean;
  104680. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  104681. ALPHABLEND: boolean;
  104682. PREPASS: boolean;
  104683. PREPASS_IRRADIANCE: boolean;
  104684. PREPASS_IRRADIANCE_INDEX: number;
  104685. PREPASS_ALBEDO: boolean;
  104686. PREPASS_ALBEDO_INDEX: number;
  104687. PREPASS_DEPTHNORMAL: boolean;
  104688. PREPASS_DEPTHNORMAL_INDEX: number;
  104689. PREPASS_POSITION: boolean;
  104690. PREPASS_POSITION_INDEX: number;
  104691. PREPASS_VELOCITY: boolean;
  104692. PREPASS_VELOCITY_INDEX: number;
  104693. PREPASS_REFLECTIVITY: boolean;
  104694. PREPASS_REFLECTIVITY_INDEX: number;
  104695. SCENE_MRT_COUNT: number;
  104696. RGBDLIGHTMAP: boolean;
  104697. RGBDREFLECTION: boolean;
  104698. RGBDREFRACTION: boolean;
  104699. IMAGEPROCESSING: boolean;
  104700. VIGNETTE: boolean;
  104701. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104702. VIGNETTEBLENDMODEOPAQUE: boolean;
  104703. TONEMAPPING: boolean;
  104704. TONEMAPPING_ACES: boolean;
  104705. CONTRAST: boolean;
  104706. COLORCURVES: boolean;
  104707. COLORGRADING: boolean;
  104708. COLORGRADING3D: boolean;
  104709. SAMPLER3DGREENDEPTH: boolean;
  104710. SAMPLER3DBGRMAP: boolean;
  104711. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104712. MULTIVIEW: boolean;
  104713. /**
  104714. * If the reflection texture on this material is in linear color space
  104715. * @hidden
  104716. */
  104717. IS_REFLECTION_LINEAR: boolean;
  104718. /**
  104719. * If the refraction texture on this material is in linear color space
  104720. * @hidden
  104721. */
  104722. IS_REFRACTION_LINEAR: boolean;
  104723. EXPOSURE: boolean;
  104724. constructor();
  104725. setReflectionMode(modeToEnable: string): void;
  104726. }
  104727. /**
  104728. * This is the default material used in Babylon. It is the best trade off between quality
  104729. * and performances.
  104730. * @see https://doc.babylonjs.com/babylon101/materials
  104731. */
  104732. export class StandardMaterial extends PushMaterial {
  104733. private _diffuseTexture;
  104734. /**
  104735. * The basic texture of the material as viewed under a light.
  104736. */
  104737. diffuseTexture: Nullable<BaseTexture>;
  104738. private _ambientTexture;
  104739. /**
  104740. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104741. */
  104742. ambientTexture: Nullable<BaseTexture>;
  104743. private _opacityTexture;
  104744. /**
  104745. * Define the transparency of the material from a texture.
  104746. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104747. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104748. */
  104749. opacityTexture: Nullable<BaseTexture>;
  104750. private _reflectionTexture;
  104751. /**
  104752. * Define the texture used to display the reflection.
  104753. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104754. */
  104755. reflectionTexture: Nullable<BaseTexture>;
  104756. private _emissiveTexture;
  104757. /**
  104758. * Define texture of the material as if self lit.
  104759. * This will be mixed in the final result even in the absence of light.
  104760. */
  104761. emissiveTexture: Nullable<BaseTexture>;
  104762. private _specularTexture;
  104763. /**
  104764. * Define how the color and intensity of the highlight given by the light in the material.
  104765. */
  104766. specularTexture: Nullable<BaseTexture>;
  104767. private _bumpTexture;
  104768. /**
  104769. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104770. * 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.
  104771. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  104772. */
  104773. bumpTexture: Nullable<BaseTexture>;
  104774. private _lightmapTexture;
  104775. /**
  104776. * Complex lighting can be computationally expensive to compute at runtime.
  104777. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104778. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  104779. */
  104780. lightmapTexture: Nullable<BaseTexture>;
  104781. private _refractionTexture;
  104782. /**
  104783. * Define the texture used to display the refraction.
  104784. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104785. */
  104786. refractionTexture: Nullable<BaseTexture>;
  104787. /**
  104788. * The color of the material lit by the environmental background lighting.
  104789. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104790. */
  104791. ambientColor: Color3;
  104792. /**
  104793. * The basic color of the material as viewed under a light.
  104794. */
  104795. diffuseColor: Color3;
  104796. /**
  104797. * Define how the color and intensity of the highlight given by the light in the material.
  104798. */
  104799. specularColor: Color3;
  104800. /**
  104801. * Define the color of the material as if self lit.
  104802. * This will be mixed in the final result even in the absence of light.
  104803. */
  104804. emissiveColor: Color3;
  104805. /**
  104806. * Defines how sharp are the highlights in the material.
  104807. * The bigger the value the sharper giving a more glossy feeling to the result.
  104808. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104809. */
  104810. specularPower: number;
  104811. private _useAlphaFromDiffuseTexture;
  104812. /**
  104813. * Does the transparency come from the diffuse texture alpha channel.
  104814. */
  104815. useAlphaFromDiffuseTexture: boolean;
  104816. private _useEmissiveAsIllumination;
  104817. /**
  104818. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104819. */
  104820. useEmissiveAsIllumination: boolean;
  104821. private _linkEmissiveWithDiffuse;
  104822. /**
  104823. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104824. * the emissive level when the final color is close to one.
  104825. */
  104826. linkEmissiveWithDiffuse: boolean;
  104827. private _useSpecularOverAlpha;
  104828. /**
  104829. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104830. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104831. */
  104832. useSpecularOverAlpha: boolean;
  104833. private _useReflectionOverAlpha;
  104834. /**
  104835. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104836. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104837. */
  104838. useReflectionOverAlpha: boolean;
  104839. private _disableLighting;
  104840. /**
  104841. * Does lights from the scene impacts this material.
  104842. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104843. */
  104844. disableLighting: boolean;
  104845. private _useObjectSpaceNormalMap;
  104846. /**
  104847. * Allows using an object space normal map (instead of tangent space).
  104848. */
  104849. useObjectSpaceNormalMap: boolean;
  104850. private _useParallax;
  104851. /**
  104852. * Is parallax enabled or not.
  104853. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104854. */
  104855. useParallax: boolean;
  104856. private _useParallaxOcclusion;
  104857. /**
  104858. * Is parallax occlusion enabled or not.
  104859. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104860. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104861. */
  104862. useParallaxOcclusion: boolean;
  104863. /**
  104864. * 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.
  104865. */
  104866. parallaxScaleBias: number;
  104867. private _roughness;
  104868. /**
  104869. * Helps to define how blurry the reflections should appears in the material.
  104870. */
  104871. roughness: number;
  104872. /**
  104873. * In case of refraction, define the value of the index of refraction.
  104874. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104875. */
  104876. indexOfRefraction: number;
  104877. /**
  104878. * Invert the refraction texture alongside the y axis.
  104879. * It can be useful with procedural textures or probe for instance.
  104880. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104881. */
  104882. invertRefractionY: boolean;
  104883. /**
  104884. * Defines the alpha limits in alpha test mode.
  104885. */
  104886. alphaCutOff: number;
  104887. private _useLightmapAsShadowmap;
  104888. /**
  104889. * In case of light mapping, define whether the map contains light or shadow informations.
  104890. */
  104891. useLightmapAsShadowmap: boolean;
  104892. private _diffuseFresnelParameters;
  104893. /**
  104894. * Define the diffuse fresnel parameters of the material.
  104895. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104896. */
  104897. diffuseFresnelParameters: FresnelParameters;
  104898. private _opacityFresnelParameters;
  104899. /**
  104900. * Define the opacity fresnel parameters of the material.
  104901. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104902. */
  104903. opacityFresnelParameters: FresnelParameters;
  104904. private _reflectionFresnelParameters;
  104905. /**
  104906. * Define the reflection fresnel parameters of the material.
  104907. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104908. */
  104909. reflectionFresnelParameters: FresnelParameters;
  104910. private _refractionFresnelParameters;
  104911. /**
  104912. * Define the refraction fresnel parameters of the material.
  104913. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104914. */
  104915. refractionFresnelParameters: FresnelParameters;
  104916. private _emissiveFresnelParameters;
  104917. /**
  104918. * Define the emissive fresnel parameters of the material.
  104919. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104920. */
  104921. emissiveFresnelParameters: FresnelParameters;
  104922. private _useReflectionFresnelFromSpecular;
  104923. /**
  104924. * If true automatically deducts the fresnels values from the material specularity.
  104925. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104926. */
  104927. useReflectionFresnelFromSpecular: boolean;
  104928. private _useGlossinessFromSpecularMapAlpha;
  104929. /**
  104930. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104931. */
  104932. useGlossinessFromSpecularMapAlpha: boolean;
  104933. private _maxSimultaneousLights;
  104934. /**
  104935. * Defines the maximum number of lights that can be used in the material
  104936. */
  104937. maxSimultaneousLights: number;
  104938. private _invertNormalMapX;
  104939. /**
  104940. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104941. */
  104942. invertNormalMapX: boolean;
  104943. private _invertNormalMapY;
  104944. /**
  104945. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104946. */
  104947. invertNormalMapY: boolean;
  104948. private _twoSidedLighting;
  104949. /**
  104950. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104951. */
  104952. twoSidedLighting: boolean;
  104953. /**
  104954. * Default configuration related to image processing available in the standard Material.
  104955. */
  104956. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104957. /**
  104958. * Gets the image processing configuration used either in this material.
  104959. */
  104960. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104961. /**
  104962. * Sets the Default image processing configuration used either in the this material.
  104963. *
  104964. * If sets to null, the scene one is in use.
  104965. */
  104966. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104967. /**
  104968. * Keep track of the image processing observer to allow dispose and replace.
  104969. */
  104970. private _imageProcessingObserver;
  104971. /**
  104972. * Attaches a new image processing configuration to the Standard Material.
  104973. * @param configuration
  104974. */
  104975. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104976. /**
  104977. * Defines additionnal PrePass parameters for the material.
  104978. */
  104979. readonly prePassConfiguration: PrePassConfiguration;
  104980. /**
  104981. * Gets wether the color curves effect is enabled.
  104982. */
  104983. get cameraColorCurvesEnabled(): boolean;
  104984. /**
  104985. * Sets wether the color curves effect is enabled.
  104986. */
  104987. set cameraColorCurvesEnabled(value: boolean);
  104988. /**
  104989. * Gets wether the color grading effect is enabled.
  104990. */
  104991. get cameraColorGradingEnabled(): boolean;
  104992. /**
  104993. * Gets wether the color grading effect is enabled.
  104994. */
  104995. set cameraColorGradingEnabled(value: boolean);
  104996. /**
  104997. * Gets wether tonemapping is enabled or not.
  104998. */
  104999. get cameraToneMappingEnabled(): boolean;
  105000. /**
  105001. * Sets wether tonemapping is enabled or not
  105002. */
  105003. set cameraToneMappingEnabled(value: boolean);
  105004. /**
  105005. * The camera exposure used on this material.
  105006. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105007. * This corresponds to a photographic exposure.
  105008. */
  105009. get cameraExposure(): number;
  105010. /**
  105011. * The camera exposure used on this material.
  105012. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105013. * This corresponds to a photographic exposure.
  105014. */
  105015. set cameraExposure(value: number);
  105016. /**
  105017. * Gets The camera contrast used on this material.
  105018. */
  105019. get cameraContrast(): number;
  105020. /**
  105021. * Sets The camera contrast used on this material.
  105022. */
  105023. set cameraContrast(value: number);
  105024. /**
  105025. * Gets the Color Grading 2D Lookup Texture.
  105026. */
  105027. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  105028. /**
  105029. * Sets the Color Grading 2D Lookup Texture.
  105030. */
  105031. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  105032. /**
  105033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105035. * 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;
  105036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105037. */
  105038. get cameraColorCurves(): Nullable<ColorCurves>;
  105039. /**
  105040. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105041. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105042. * 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;
  105043. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105044. */
  105045. set cameraColorCurves(value: Nullable<ColorCurves>);
  105046. /**
  105047. * Can this material render to several textures at once
  105048. */
  105049. get canRenderToMRT(): boolean;
  105050. /**
  105051. * Defines the detail map parameters for the material.
  105052. */
  105053. readonly detailMap: DetailMapConfiguration;
  105054. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105055. protected _worldViewProjectionMatrix: Matrix;
  105056. protected _globalAmbientColor: Color3;
  105057. protected _useLogarithmicDepth: boolean;
  105058. protected _rebuildInParallel: boolean;
  105059. /**
  105060. * Instantiates a new standard material.
  105061. * This is the default material used in Babylon. It is the best trade off between quality
  105062. * and performances.
  105063. * @see https://doc.babylonjs.com/babylon101/materials
  105064. * @param name Define the name of the material in the scene
  105065. * @param scene Define the scene the material belong to
  105066. */
  105067. constructor(name: string, scene: Scene);
  105068. /**
  105069. * Gets a boolean indicating that current material needs to register RTT
  105070. */
  105071. get hasRenderTargetTextures(): boolean;
  105072. /**
  105073. * Gets the current class name of the material e.g. "StandardMaterial"
  105074. * Mainly use in serialization.
  105075. * @returns the class name
  105076. */
  105077. getClassName(): string;
  105078. /**
  105079. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105080. * You can try switching to logarithmic depth.
  105081. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105082. */
  105083. get useLogarithmicDepth(): boolean;
  105084. set useLogarithmicDepth(value: boolean);
  105085. /**
  105086. * Specifies if the material will require alpha blending
  105087. * @returns a boolean specifying if alpha blending is needed
  105088. */
  105089. needAlphaBlending(): boolean;
  105090. /**
  105091. * Specifies if this material should be rendered in alpha test mode
  105092. * @returns a boolean specifying if an alpha test is needed.
  105093. */
  105094. needAlphaTesting(): boolean;
  105095. /**
  105096. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  105097. */
  105098. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105099. /**
  105100. * Specifies whether or not there is a usable alpha channel for transparency.
  105101. */
  105102. protected _hasAlphaChannel(): boolean;
  105103. /**
  105104. * Get the texture used for alpha test purpose.
  105105. * @returns the diffuse texture in case of the standard material.
  105106. */
  105107. getAlphaTestTexture(): Nullable<BaseTexture>;
  105108. /**
  105109. * Get if the submesh is ready to be used and all its information available.
  105110. * Child classes can use it to update shaders
  105111. * @param mesh defines the mesh to check
  105112. * @param subMesh defines which submesh to check
  105113. * @param useInstances specifies that instances should be used
  105114. * @returns a boolean indicating that the submesh is ready or not
  105115. */
  105116. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105117. /**
  105118. * Builds the material UBO layouts.
  105119. * Used internally during the effect preparation.
  105120. */
  105121. buildUniformLayout(): void;
  105122. /**
  105123. * Unbinds the material from the mesh
  105124. */
  105125. unbind(): void;
  105126. /**
  105127. * Binds the submesh to this material by preparing the effect and shader to draw
  105128. * @param world defines the world transformation matrix
  105129. * @param mesh defines the mesh containing the submesh
  105130. * @param subMesh defines the submesh to bind the material to
  105131. */
  105132. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105133. /**
  105134. * Get the list of animatables in the material.
  105135. * @returns the list of animatables object used in the material
  105136. */
  105137. getAnimatables(): IAnimatable[];
  105138. /**
  105139. * Gets the active textures from the material
  105140. * @returns an array of textures
  105141. */
  105142. getActiveTextures(): BaseTexture[];
  105143. /**
  105144. * Specifies if the material uses a texture
  105145. * @param texture defines the texture to check against the material
  105146. * @returns a boolean specifying if the material uses the texture
  105147. */
  105148. hasTexture(texture: BaseTexture): boolean;
  105149. /**
  105150. * Disposes the material
  105151. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105152. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105153. */
  105154. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105155. /**
  105156. * Makes a duplicate of the material, and gives it a new name
  105157. * @param name defines the new name for the duplicated material
  105158. * @returns the cloned material
  105159. */
  105160. clone(name: string): StandardMaterial;
  105161. /**
  105162. * Serializes this material in a JSON representation
  105163. * @returns the serialized material object
  105164. */
  105165. serialize(): any;
  105166. /**
  105167. * Creates a standard material from parsed material data
  105168. * @param source defines the JSON representation of the material
  105169. * @param scene defines the hosting scene
  105170. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105171. * @returns a new standard material
  105172. */
  105173. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105174. /**
  105175. * Are diffuse textures enabled in the application.
  105176. */
  105177. static get DiffuseTextureEnabled(): boolean;
  105178. static set DiffuseTextureEnabled(value: boolean);
  105179. /**
  105180. * Are detail textures enabled in the application.
  105181. */
  105182. static get DetailTextureEnabled(): boolean;
  105183. static set DetailTextureEnabled(value: boolean);
  105184. /**
  105185. * Are ambient textures enabled in the application.
  105186. */
  105187. static get AmbientTextureEnabled(): boolean;
  105188. static set AmbientTextureEnabled(value: boolean);
  105189. /**
  105190. * Are opacity textures enabled in the application.
  105191. */
  105192. static get OpacityTextureEnabled(): boolean;
  105193. static set OpacityTextureEnabled(value: boolean);
  105194. /**
  105195. * Are reflection textures enabled in the application.
  105196. */
  105197. static get ReflectionTextureEnabled(): boolean;
  105198. static set ReflectionTextureEnabled(value: boolean);
  105199. /**
  105200. * Are emissive textures enabled in the application.
  105201. */
  105202. static get EmissiveTextureEnabled(): boolean;
  105203. static set EmissiveTextureEnabled(value: boolean);
  105204. /**
  105205. * Are specular textures enabled in the application.
  105206. */
  105207. static get SpecularTextureEnabled(): boolean;
  105208. static set SpecularTextureEnabled(value: boolean);
  105209. /**
  105210. * Are bump textures enabled in the application.
  105211. */
  105212. static get BumpTextureEnabled(): boolean;
  105213. static set BumpTextureEnabled(value: boolean);
  105214. /**
  105215. * Are lightmap textures enabled in the application.
  105216. */
  105217. static get LightmapTextureEnabled(): boolean;
  105218. static set LightmapTextureEnabled(value: boolean);
  105219. /**
  105220. * Are refraction textures enabled in the application.
  105221. */
  105222. static get RefractionTextureEnabled(): boolean;
  105223. static set RefractionTextureEnabled(value: boolean);
  105224. /**
  105225. * Are color grading textures enabled in the application.
  105226. */
  105227. static get ColorGradingTextureEnabled(): boolean;
  105228. static set ColorGradingTextureEnabled(value: boolean);
  105229. /**
  105230. * Are fresnels enabled in the application.
  105231. */
  105232. static get FresnelEnabled(): boolean;
  105233. static set FresnelEnabled(value: boolean);
  105234. }
  105235. }
  105236. declare module BABYLON {
  105237. /** @hidden */
  105238. export var rgbdDecodePixelShader: {
  105239. name: string;
  105240. shader: string;
  105241. };
  105242. }
  105243. declare module BABYLON {
  105244. /**
  105245. * Class used to host RGBD texture specific utilities
  105246. */
  105247. export class RGBDTextureTools {
  105248. /**
  105249. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105250. * @param texture the texture to expand.
  105251. */
  105252. static ExpandRGBDTexture(texture: Texture): void;
  105253. }
  105254. }
  105255. declare module BABYLON {
  105256. /**
  105257. * Class used to host texture specific utilities
  105258. */
  105259. export class BRDFTextureTools {
  105260. /**
  105261. * Prevents texture cache collision
  105262. */
  105263. private static _instanceNumber;
  105264. /**
  105265. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105266. * @param scene defines the hosting scene
  105267. * @returns the environment BRDF texture
  105268. */
  105269. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105270. private static _environmentBRDFBase64Texture;
  105271. }
  105272. }
  105273. declare module BABYLON {
  105274. /**
  105275. * @hidden
  105276. */
  105277. export interface IMaterialClearCoatDefines {
  105278. CLEARCOAT: boolean;
  105279. CLEARCOAT_DEFAULTIOR: boolean;
  105280. CLEARCOAT_TEXTURE: boolean;
  105281. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  105282. CLEARCOAT_TEXTUREDIRECTUV: number;
  105283. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  105284. CLEARCOAT_BUMP: boolean;
  105285. CLEARCOAT_BUMPDIRECTUV: number;
  105286. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105287. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105288. CLEARCOAT_REMAP_F0: boolean;
  105289. CLEARCOAT_TINT: boolean;
  105290. CLEARCOAT_TINT_TEXTURE: boolean;
  105291. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105292. /** @hidden */
  105293. _areTexturesDirty: boolean;
  105294. }
  105295. /**
  105296. * Define the code related to the clear coat parameters of the pbr material.
  105297. */
  105298. export class PBRClearCoatConfiguration {
  105299. /**
  105300. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105301. * The default fits with a polyurethane material.
  105302. */
  105303. private static readonly _DefaultIndexOfRefraction;
  105304. private _isEnabled;
  105305. /**
  105306. * Defines if the clear coat is enabled in the material.
  105307. */
  105308. isEnabled: boolean;
  105309. /**
  105310. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105311. */
  105312. intensity: number;
  105313. /**
  105314. * Defines the clear coat layer roughness.
  105315. */
  105316. roughness: number;
  105317. private _indexOfRefraction;
  105318. /**
  105319. * Defines the index of refraction of the clear coat.
  105320. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105321. * The default fits with a polyurethane material.
  105322. * Changing the default value is more performance intensive.
  105323. */
  105324. indexOfRefraction: number;
  105325. private _texture;
  105326. /**
  105327. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  105328. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  105329. * if textureRoughness is not empty, else no texture roughness is used
  105330. */
  105331. texture: Nullable<BaseTexture>;
  105332. private _useRoughnessFromMainTexture;
  105333. /**
  105334. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  105335. * If false, the green channel from textureRoughness is used for roughness
  105336. */
  105337. useRoughnessFromMainTexture: boolean;
  105338. private _textureRoughness;
  105339. /**
  105340. * Stores the clear coat roughness in a texture (green channel)
  105341. * Not used if useRoughnessFromMainTexture is true
  105342. */
  105343. textureRoughness: Nullable<BaseTexture>;
  105344. private _remapF0OnInterfaceChange;
  105345. /**
  105346. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105347. */
  105348. remapF0OnInterfaceChange: boolean;
  105349. private _bumpTexture;
  105350. /**
  105351. * Define the clear coat specific bump texture.
  105352. */
  105353. bumpTexture: Nullable<BaseTexture>;
  105354. private _isTintEnabled;
  105355. /**
  105356. * Defines if the clear coat tint is enabled in the material.
  105357. */
  105358. isTintEnabled: boolean;
  105359. /**
  105360. * Defines the clear coat tint of the material.
  105361. * This is only use if tint is enabled
  105362. */
  105363. tintColor: Color3;
  105364. /**
  105365. * Defines the distance at which the tint color should be found in the
  105366. * clear coat media.
  105367. * This is only use if tint is enabled
  105368. */
  105369. tintColorAtDistance: number;
  105370. /**
  105371. * Defines the clear coat layer thickness.
  105372. * This is only use if tint is enabled
  105373. */
  105374. tintThickness: number;
  105375. private _tintTexture;
  105376. /**
  105377. * Stores the clear tint values in a texture.
  105378. * rgb is tint
  105379. * a is a thickness factor
  105380. */
  105381. tintTexture: Nullable<BaseTexture>;
  105382. /** @hidden */
  105383. private _internalMarkAllSubMeshesAsTexturesDirty;
  105384. /** @hidden */
  105385. _markAllSubMeshesAsTexturesDirty(): void;
  105386. /**
  105387. * Instantiate a new istance of clear coat configuration.
  105388. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105389. */
  105390. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105391. /**
  105392. * Gets wehter the submesh is ready to be used or not.
  105393. * @param defines the list of "defines" to update.
  105394. * @param scene defines the scene the material belongs to.
  105395. * @param engine defines the engine the material belongs to.
  105396. * @param disableBumpMap defines wether the material disables bump or not.
  105397. * @returns - boolean indicating that the submesh is ready or not.
  105398. */
  105399. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  105400. /**
  105401. * Checks to see if a texture is used in the material.
  105402. * @param defines the list of "defines" to update.
  105403. * @param scene defines the scene to the material belongs to.
  105404. */
  105405. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  105406. /**
  105407. * Binds the material data.
  105408. * @param uniformBuffer defines the Uniform buffer to fill in.
  105409. * @param scene defines the scene the material belongs to.
  105410. * @param engine defines the engine the material belongs to.
  105411. * @param disableBumpMap defines wether the material disables bump or not.
  105412. * @param isFrozen defines wether the material is frozen or not.
  105413. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105414. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105415. * @param subMesh the submesh to bind data for
  105416. */
  105417. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  105418. /**
  105419. * Checks to see if a texture is used in the material.
  105420. * @param texture - Base texture to use.
  105421. * @returns - Boolean specifying if a texture is used in the material.
  105422. */
  105423. hasTexture(texture: BaseTexture): boolean;
  105424. /**
  105425. * Returns an array of the actively used textures.
  105426. * @param activeTextures Array of BaseTextures
  105427. */
  105428. getActiveTextures(activeTextures: BaseTexture[]): void;
  105429. /**
  105430. * Returns the animatable textures.
  105431. * @param animatables Array of animatable textures.
  105432. */
  105433. getAnimatables(animatables: IAnimatable[]): void;
  105434. /**
  105435. * Disposes the resources of the material.
  105436. * @param forceDisposeTextures - Forces the disposal of all textures.
  105437. */
  105438. dispose(forceDisposeTextures?: boolean): void;
  105439. /**
  105440. * Get the current class name of the texture useful for serialization or dynamic coding.
  105441. * @returns "PBRClearCoatConfiguration"
  105442. */
  105443. getClassName(): string;
  105444. /**
  105445. * Add fallbacks to the effect fallbacks list.
  105446. * @param defines defines the Base texture to use.
  105447. * @param fallbacks defines the current fallback list.
  105448. * @param currentRank defines the current fallback rank.
  105449. * @returns the new fallback rank.
  105450. */
  105451. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105452. /**
  105453. * Add the required uniforms to the current list.
  105454. * @param uniforms defines the current uniform list.
  105455. */
  105456. static AddUniforms(uniforms: string[]): void;
  105457. /**
  105458. * Add the required samplers to the current list.
  105459. * @param samplers defines the current sampler list.
  105460. */
  105461. static AddSamplers(samplers: string[]): void;
  105462. /**
  105463. * Add the required uniforms to the current buffer.
  105464. * @param uniformBuffer defines the current uniform buffer.
  105465. */
  105466. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105467. /**
  105468. * Makes a duplicate of the current configuration into another one.
  105469. * @param clearCoatConfiguration define the config where to copy the info
  105470. */
  105471. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  105472. /**
  105473. * Serializes this clear coat configuration.
  105474. * @returns - An object with the serialized config.
  105475. */
  105476. serialize(): any;
  105477. /**
  105478. * Parses a anisotropy Configuration from a serialized object.
  105479. * @param source - Serialized object.
  105480. * @param scene Defines the scene we are parsing for
  105481. * @param rootUrl Defines the rootUrl to load from
  105482. */
  105483. parse(source: any, scene: Scene, rootUrl: string): void;
  105484. }
  105485. }
  105486. declare module BABYLON {
  105487. /**
  105488. * @hidden
  105489. */
  105490. export interface IMaterialAnisotropicDefines {
  105491. ANISOTROPIC: boolean;
  105492. ANISOTROPIC_TEXTURE: boolean;
  105493. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105494. MAINUV1: boolean;
  105495. _areTexturesDirty: boolean;
  105496. _needUVs: boolean;
  105497. }
  105498. /**
  105499. * Define the code related to the anisotropic parameters of the pbr material.
  105500. */
  105501. export class PBRAnisotropicConfiguration {
  105502. private _isEnabled;
  105503. /**
  105504. * Defines if the anisotropy is enabled in the material.
  105505. */
  105506. isEnabled: boolean;
  105507. /**
  105508. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  105509. */
  105510. intensity: number;
  105511. /**
  105512. * Defines if the effect is along the tangents, bitangents or in between.
  105513. * By default, the effect is "strectching" the highlights along the tangents.
  105514. */
  105515. direction: Vector2;
  105516. private _texture;
  105517. /**
  105518. * Stores the anisotropy values in a texture.
  105519. * rg is direction (like normal from -1 to 1)
  105520. * b is a intensity
  105521. */
  105522. texture: Nullable<BaseTexture>;
  105523. /** @hidden */
  105524. private _internalMarkAllSubMeshesAsTexturesDirty;
  105525. /** @hidden */
  105526. _markAllSubMeshesAsTexturesDirty(): void;
  105527. /**
  105528. * Instantiate a new istance of anisotropy configuration.
  105529. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105530. */
  105531. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105532. /**
  105533. * Specifies that the submesh is ready to be used.
  105534. * @param defines the list of "defines" to update.
  105535. * @param scene defines the scene the material belongs to.
  105536. * @returns - boolean indicating that the submesh is ready or not.
  105537. */
  105538. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  105539. /**
  105540. * Checks to see if a texture is used in the material.
  105541. * @param defines the list of "defines" to update.
  105542. * @param mesh the mesh we are preparing the defines for.
  105543. * @param scene defines the scene the material belongs to.
  105544. */
  105545. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  105546. /**
  105547. * Binds the material data.
  105548. * @param uniformBuffer defines the Uniform buffer to fill in.
  105549. * @param scene defines the scene the material belongs to.
  105550. * @param isFrozen defines wether the material is frozen or not.
  105551. */
  105552. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105553. /**
  105554. * Checks to see if a texture is used in the material.
  105555. * @param texture - Base texture to use.
  105556. * @returns - Boolean specifying if a texture is used in the material.
  105557. */
  105558. hasTexture(texture: BaseTexture): boolean;
  105559. /**
  105560. * Returns an array of the actively used textures.
  105561. * @param activeTextures Array of BaseTextures
  105562. */
  105563. getActiveTextures(activeTextures: BaseTexture[]): void;
  105564. /**
  105565. * Returns the animatable textures.
  105566. * @param animatables Array of animatable textures.
  105567. */
  105568. getAnimatables(animatables: IAnimatable[]): void;
  105569. /**
  105570. * Disposes the resources of the material.
  105571. * @param forceDisposeTextures - Forces the disposal of all textures.
  105572. */
  105573. dispose(forceDisposeTextures?: boolean): void;
  105574. /**
  105575. * Get the current class name of the texture useful for serialization or dynamic coding.
  105576. * @returns "PBRAnisotropicConfiguration"
  105577. */
  105578. getClassName(): string;
  105579. /**
  105580. * Add fallbacks to the effect fallbacks list.
  105581. * @param defines defines the Base texture to use.
  105582. * @param fallbacks defines the current fallback list.
  105583. * @param currentRank defines the current fallback rank.
  105584. * @returns the new fallback rank.
  105585. */
  105586. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105587. /**
  105588. * Add the required uniforms to the current list.
  105589. * @param uniforms defines the current uniform list.
  105590. */
  105591. static AddUniforms(uniforms: string[]): void;
  105592. /**
  105593. * Add the required uniforms to the current buffer.
  105594. * @param uniformBuffer defines the current uniform buffer.
  105595. */
  105596. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105597. /**
  105598. * Add the required samplers to the current list.
  105599. * @param samplers defines the current sampler list.
  105600. */
  105601. static AddSamplers(samplers: string[]): void;
  105602. /**
  105603. * Makes a duplicate of the current configuration into another one.
  105604. * @param anisotropicConfiguration define the config where to copy the info
  105605. */
  105606. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  105607. /**
  105608. * Serializes this anisotropy configuration.
  105609. * @returns - An object with the serialized config.
  105610. */
  105611. serialize(): any;
  105612. /**
  105613. * Parses a anisotropy Configuration from a serialized object.
  105614. * @param source - Serialized object.
  105615. * @param scene Defines the scene we are parsing for
  105616. * @param rootUrl Defines the rootUrl to load from
  105617. */
  105618. parse(source: any, scene: Scene, rootUrl: string): void;
  105619. }
  105620. }
  105621. declare module BABYLON {
  105622. /**
  105623. * @hidden
  105624. */
  105625. export interface IMaterialBRDFDefines {
  105626. BRDF_V_HEIGHT_CORRELATED: boolean;
  105627. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105628. SPHERICAL_HARMONICS: boolean;
  105629. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  105630. /** @hidden */
  105631. _areMiscDirty: boolean;
  105632. }
  105633. /**
  105634. * Define the code related to the BRDF parameters of the pbr material.
  105635. */
  105636. export class PBRBRDFConfiguration {
  105637. /**
  105638. * Default value used for the energy conservation.
  105639. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105640. */
  105641. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  105642. /**
  105643. * Default value used for the Smith Visibility Height Correlated mode.
  105644. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105645. */
  105646. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  105647. /**
  105648. * Default value used for the IBL diffuse part.
  105649. * This can help switching back to the polynomials mode globally which is a tiny bit
  105650. * less GPU intensive at the drawback of a lower quality.
  105651. */
  105652. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  105653. /**
  105654. * Default value used for activating energy conservation for the specular workflow.
  105655. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105656. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105657. */
  105658. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  105659. private _useEnergyConservation;
  105660. /**
  105661. * Defines if the material uses energy conservation.
  105662. */
  105663. useEnergyConservation: boolean;
  105664. private _useSmithVisibilityHeightCorrelated;
  105665. /**
  105666. * LEGACY Mode set to false
  105667. * Defines if the material uses height smith correlated visibility term.
  105668. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  105669. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105670. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  105671. * Not relying on height correlated will also disable energy conservation.
  105672. */
  105673. useSmithVisibilityHeightCorrelated: boolean;
  105674. private _useSphericalHarmonics;
  105675. /**
  105676. * LEGACY Mode set to false
  105677. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  105678. * diffuse part of the IBL.
  105679. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  105680. * to the ground truth.
  105681. */
  105682. useSphericalHarmonics: boolean;
  105683. private _useSpecularGlossinessInputEnergyConservation;
  105684. /**
  105685. * Defines if the material uses energy conservation, when the specular workflow is active.
  105686. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105687. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105688. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  105689. */
  105690. useSpecularGlossinessInputEnergyConservation: boolean;
  105691. /** @hidden */
  105692. private _internalMarkAllSubMeshesAsMiscDirty;
  105693. /** @hidden */
  105694. _markAllSubMeshesAsMiscDirty(): void;
  105695. /**
  105696. * Instantiate a new istance of clear coat configuration.
  105697. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  105698. */
  105699. constructor(markAllSubMeshesAsMiscDirty: () => void);
  105700. /**
  105701. * Checks to see if a texture is used in the material.
  105702. * @param defines the list of "defines" to update.
  105703. */
  105704. prepareDefines(defines: IMaterialBRDFDefines): void;
  105705. /**
  105706. * Get the current class name of the texture useful for serialization or dynamic coding.
  105707. * @returns "PBRClearCoatConfiguration"
  105708. */
  105709. getClassName(): string;
  105710. /**
  105711. * Makes a duplicate of the current configuration into another one.
  105712. * @param brdfConfiguration define the config where to copy the info
  105713. */
  105714. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  105715. /**
  105716. * Serializes this BRDF configuration.
  105717. * @returns - An object with the serialized config.
  105718. */
  105719. serialize(): any;
  105720. /**
  105721. * Parses a anisotropy Configuration from a serialized object.
  105722. * @param source - Serialized object.
  105723. * @param scene Defines the scene we are parsing for
  105724. * @param rootUrl Defines the rootUrl to load from
  105725. */
  105726. parse(source: any, scene: Scene, rootUrl: string): void;
  105727. }
  105728. }
  105729. declare module BABYLON {
  105730. /**
  105731. * @hidden
  105732. */
  105733. export interface IMaterialSheenDefines {
  105734. SHEEN: boolean;
  105735. SHEEN_TEXTURE: boolean;
  105736. SHEEN_TEXTURE_ROUGHNESS: boolean;
  105737. SHEEN_TEXTUREDIRECTUV: number;
  105738. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  105739. SHEEN_LINKWITHALBEDO: boolean;
  105740. SHEEN_ROUGHNESS: boolean;
  105741. SHEEN_ALBEDOSCALING: boolean;
  105742. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105743. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105744. /** @hidden */
  105745. _areTexturesDirty: boolean;
  105746. }
  105747. /**
  105748. * Define the code related to the Sheen parameters of the pbr material.
  105749. */
  105750. export class PBRSheenConfiguration {
  105751. private _isEnabled;
  105752. /**
  105753. * Defines if the material uses sheen.
  105754. */
  105755. isEnabled: boolean;
  105756. private _linkSheenWithAlbedo;
  105757. /**
  105758. * Defines if the sheen is linked to the sheen color.
  105759. */
  105760. linkSheenWithAlbedo: boolean;
  105761. /**
  105762. * Defines the sheen intensity.
  105763. */
  105764. intensity: number;
  105765. /**
  105766. * Defines the sheen color.
  105767. */
  105768. color: Color3;
  105769. private _texture;
  105770. /**
  105771. * Stores the sheen tint values in a texture.
  105772. * rgb is tint
  105773. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  105774. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  105775. */
  105776. texture: Nullable<BaseTexture>;
  105777. private _useRoughnessFromMainTexture;
  105778. /**
  105779. * Indicates that the alpha channel of the texture property will be used for roughness.
  105780. * Has no effect if the roughness (and texture!) property is not defined
  105781. */
  105782. useRoughnessFromMainTexture: boolean;
  105783. private _roughness;
  105784. /**
  105785. * Defines the sheen roughness.
  105786. * It is not taken into account if linkSheenWithAlbedo is true.
  105787. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105788. */
  105789. roughness: Nullable<number>;
  105790. private _textureRoughness;
  105791. /**
  105792. * Stores the sheen roughness in a texture.
  105793. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  105794. */
  105795. textureRoughness: Nullable<BaseTexture>;
  105796. private _albedoScaling;
  105797. /**
  105798. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105799. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105800. * making it easier to setup and tweak the effect
  105801. */
  105802. albedoScaling: boolean;
  105803. /** @hidden */
  105804. private _internalMarkAllSubMeshesAsTexturesDirty;
  105805. /** @hidden */
  105806. _markAllSubMeshesAsTexturesDirty(): void;
  105807. /**
  105808. * Instantiate a new istance of clear coat configuration.
  105809. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105810. */
  105811. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105812. /**
  105813. * Specifies that the submesh is ready to be used.
  105814. * @param defines the list of "defines" to update.
  105815. * @param scene defines the scene the material belongs to.
  105816. * @returns - boolean indicating that the submesh is ready or not.
  105817. */
  105818. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105819. /**
  105820. * Checks to see if a texture is used in the material.
  105821. * @param defines the list of "defines" to update.
  105822. * @param scene defines the scene the material belongs to.
  105823. */
  105824. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105825. /**
  105826. * Binds the material data.
  105827. * @param uniformBuffer defines the Uniform buffer to fill in.
  105828. * @param scene defines the scene the material belongs to.
  105829. * @param isFrozen defines wether the material is frozen or not.
  105830. * @param subMesh the submesh to bind data for
  105831. */
  105832. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  105833. /**
  105834. * Checks to see if a texture is used in the material.
  105835. * @param texture - Base texture to use.
  105836. * @returns - Boolean specifying if a texture is used in the material.
  105837. */
  105838. hasTexture(texture: BaseTexture): boolean;
  105839. /**
  105840. * Returns an array of the actively used textures.
  105841. * @param activeTextures Array of BaseTextures
  105842. */
  105843. getActiveTextures(activeTextures: BaseTexture[]): void;
  105844. /**
  105845. * Returns the animatable textures.
  105846. * @param animatables Array of animatable textures.
  105847. */
  105848. getAnimatables(animatables: IAnimatable[]): void;
  105849. /**
  105850. * Disposes the resources of the material.
  105851. * @param forceDisposeTextures - Forces the disposal of all textures.
  105852. */
  105853. dispose(forceDisposeTextures?: boolean): void;
  105854. /**
  105855. * Get the current class name of the texture useful for serialization or dynamic coding.
  105856. * @returns "PBRSheenConfiguration"
  105857. */
  105858. getClassName(): string;
  105859. /**
  105860. * Add fallbacks to the effect fallbacks list.
  105861. * @param defines defines the Base texture to use.
  105862. * @param fallbacks defines the current fallback list.
  105863. * @param currentRank defines the current fallback rank.
  105864. * @returns the new fallback rank.
  105865. */
  105866. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105867. /**
  105868. * Add the required uniforms to the current list.
  105869. * @param uniforms defines the current uniform list.
  105870. */
  105871. static AddUniforms(uniforms: string[]): void;
  105872. /**
  105873. * Add the required uniforms to the current buffer.
  105874. * @param uniformBuffer defines the current uniform buffer.
  105875. */
  105876. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105877. /**
  105878. * Add the required samplers to the current list.
  105879. * @param samplers defines the current sampler list.
  105880. */
  105881. static AddSamplers(samplers: string[]): void;
  105882. /**
  105883. * Makes a duplicate of the current configuration into another one.
  105884. * @param sheenConfiguration define the config where to copy the info
  105885. */
  105886. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105887. /**
  105888. * Serializes this BRDF configuration.
  105889. * @returns - An object with the serialized config.
  105890. */
  105891. serialize(): any;
  105892. /**
  105893. * Parses a anisotropy Configuration from a serialized object.
  105894. * @param source - Serialized object.
  105895. * @param scene Defines the scene we are parsing for
  105896. * @param rootUrl Defines the rootUrl to load from
  105897. */
  105898. parse(source: any, scene: Scene, rootUrl: string): void;
  105899. }
  105900. }
  105901. declare module BABYLON {
  105902. /**
  105903. * @hidden
  105904. */
  105905. export interface IMaterialSubSurfaceDefines {
  105906. SUBSURFACE: boolean;
  105907. SS_REFRACTION: boolean;
  105908. SS_TRANSLUCENCY: boolean;
  105909. SS_SCATTERING: boolean;
  105910. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105911. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105912. SS_REFRACTIONMAP_3D: boolean;
  105913. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105914. SS_LODINREFRACTIONALPHA: boolean;
  105915. SS_GAMMAREFRACTION: boolean;
  105916. SS_RGBDREFRACTION: boolean;
  105917. SS_LINEARSPECULARREFRACTION: boolean;
  105918. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105919. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105920. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105921. /** @hidden */
  105922. _areTexturesDirty: boolean;
  105923. }
  105924. /**
  105925. * Define the code related to the sub surface parameters of the pbr material.
  105926. */
  105927. export class PBRSubSurfaceConfiguration {
  105928. private _isRefractionEnabled;
  105929. /**
  105930. * Defines if the refraction is enabled in the material.
  105931. */
  105932. isRefractionEnabled: boolean;
  105933. private _isTranslucencyEnabled;
  105934. /**
  105935. * Defines if the translucency is enabled in the material.
  105936. */
  105937. isTranslucencyEnabled: boolean;
  105938. private _isScatteringEnabled;
  105939. /**
  105940. * Defines if the sub surface scattering is enabled in the material.
  105941. */
  105942. isScatteringEnabled: boolean;
  105943. private _scatteringDiffusionProfileIndex;
  105944. /**
  105945. * Diffusion profile for subsurface scattering.
  105946. * Useful for better scattering in the skins or foliages.
  105947. */
  105948. get scatteringDiffusionProfile(): Nullable<Color3>;
  105949. set scatteringDiffusionProfile(c: Nullable<Color3>);
  105950. /**
  105951. * Defines the refraction intensity of the material.
  105952. * The refraction when enabled replaces the Diffuse part of the material.
  105953. * The intensity helps transitionning between diffuse and refraction.
  105954. */
  105955. refractionIntensity: number;
  105956. /**
  105957. * Defines the translucency intensity of the material.
  105958. * When translucency has been enabled, this defines how much of the "translucency"
  105959. * is addded to the diffuse part of the material.
  105960. */
  105961. translucencyIntensity: number;
  105962. /**
  105963. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  105964. */
  105965. useAlbedoToTintRefraction: boolean;
  105966. private _thicknessTexture;
  105967. /**
  105968. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  105969. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  105970. * 0 would mean minimumThickness
  105971. * 1 would mean maximumThickness
  105972. * The other channels might be use as a mask to vary the different effects intensity.
  105973. */
  105974. thicknessTexture: Nullable<BaseTexture>;
  105975. private _refractionTexture;
  105976. /**
  105977. * Defines the texture to use for refraction.
  105978. */
  105979. refractionTexture: Nullable<BaseTexture>;
  105980. private _indexOfRefraction;
  105981. /**
  105982. * Index of refraction of the material base layer.
  105983. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105984. *
  105985. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  105986. *
  105987. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  105988. */
  105989. indexOfRefraction: number;
  105990. private _volumeIndexOfRefraction;
  105991. /**
  105992. * Index of refraction of the material's volume.
  105993. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105994. *
  105995. * This ONLY impacts refraction. If not provided or given a non-valid value,
  105996. * the volume will use the same IOR as the surface.
  105997. */
  105998. get volumeIndexOfRefraction(): number;
  105999. set volumeIndexOfRefraction(value: number);
  106000. private _invertRefractionY;
  106001. /**
  106002. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  106003. */
  106004. invertRefractionY: boolean;
  106005. private _linkRefractionWithTransparency;
  106006. /**
  106007. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  106008. * Materials half opaque for instance using refraction could benefit from this control.
  106009. */
  106010. linkRefractionWithTransparency: boolean;
  106011. /**
  106012. * Defines the minimum thickness stored in the thickness map.
  106013. * If no thickness map is defined, this value will be used to simulate thickness.
  106014. */
  106015. minimumThickness: number;
  106016. /**
  106017. * Defines the maximum thickness stored in the thickness map.
  106018. */
  106019. maximumThickness: number;
  106020. /**
  106021. * Defines the volume tint of the material.
  106022. * This is used for both translucency and scattering.
  106023. */
  106024. tintColor: Color3;
  106025. /**
  106026. * Defines the distance at which the tint color should be found in the media.
  106027. * This is used for refraction only.
  106028. */
  106029. tintColorAtDistance: number;
  106030. /**
  106031. * Defines how far each channel transmit through the media.
  106032. * It is defined as a color to simplify it selection.
  106033. */
  106034. diffusionDistance: Color3;
  106035. private _useMaskFromThicknessTexture;
  106036. /**
  106037. * Stores the intensity of the different subsurface effects in the thickness texture.
  106038. * * the green channel is the translucency intensity.
  106039. * * the blue channel is the scattering intensity.
  106040. * * the alpha channel is the refraction intensity.
  106041. */
  106042. useMaskFromThicknessTexture: boolean;
  106043. private _scene;
  106044. /** @hidden */
  106045. private _internalMarkAllSubMeshesAsTexturesDirty;
  106046. private _internalMarkScenePrePassDirty;
  106047. /** @hidden */
  106048. _markAllSubMeshesAsTexturesDirty(): void;
  106049. /** @hidden */
  106050. _markScenePrePassDirty(): void;
  106051. /**
  106052. * Instantiate a new istance of sub surface configuration.
  106053. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106054. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  106055. * @param scene The scene
  106056. */
  106057. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  106058. /**
  106059. * Gets wehter the submesh is ready to be used or not.
  106060. * @param defines the list of "defines" to update.
  106061. * @param scene defines the scene the material belongs to.
  106062. * @returns - boolean indicating that the submesh is ready or not.
  106063. */
  106064. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  106065. /**
  106066. * Checks to see if a texture is used in the material.
  106067. * @param defines the list of "defines" to update.
  106068. * @param scene defines the scene to the material belongs to.
  106069. */
  106070. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  106071. /**
  106072. * Binds the material data.
  106073. * @param uniformBuffer defines the Uniform buffer to fill in.
  106074. * @param scene defines the scene the material belongs to.
  106075. * @param engine defines the engine the material belongs to.
  106076. * @param isFrozen defines whether the material is frozen or not.
  106077. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  106078. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  106079. */
  106080. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  106081. /**
  106082. * Unbinds the material from the mesh.
  106083. * @param activeEffect defines the effect that should be unbound from.
  106084. * @returns true if unbound, otherwise false
  106085. */
  106086. unbind(activeEffect: Effect): boolean;
  106087. /**
  106088. * Returns the texture used for refraction or null if none is used.
  106089. * @param scene defines the scene the material belongs to.
  106090. * @returns - Refraction texture if present. If no refraction texture and refraction
  106091. * is linked with transparency, returns environment texture. Otherwise, returns null.
  106092. */
  106093. private _getRefractionTexture;
  106094. /**
  106095. * Returns true if alpha blending should be disabled.
  106096. */
  106097. get disableAlphaBlending(): boolean;
  106098. /**
  106099. * Fills the list of render target textures.
  106100. * @param renderTargets the list of render targets to update
  106101. */
  106102. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  106103. /**
  106104. * Checks to see if a texture is used in the material.
  106105. * @param texture - Base texture to use.
  106106. * @returns - Boolean specifying if a texture is used in the material.
  106107. */
  106108. hasTexture(texture: BaseTexture): boolean;
  106109. /**
  106110. * Gets a boolean indicating that current material needs to register RTT
  106111. * @returns true if this uses a render target otherwise false.
  106112. */
  106113. hasRenderTargetTextures(): boolean;
  106114. /**
  106115. * Returns an array of the actively used textures.
  106116. * @param activeTextures Array of BaseTextures
  106117. */
  106118. getActiveTextures(activeTextures: BaseTexture[]): void;
  106119. /**
  106120. * Returns the animatable textures.
  106121. * @param animatables Array of animatable textures.
  106122. */
  106123. getAnimatables(animatables: IAnimatable[]): void;
  106124. /**
  106125. * Disposes the resources of the material.
  106126. * @param forceDisposeTextures - Forces the disposal of all textures.
  106127. */
  106128. dispose(forceDisposeTextures?: boolean): void;
  106129. /**
  106130. * Get the current class name of the texture useful for serialization or dynamic coding.
  106131. * @returns "PBRSubSurfaceConfiguration"
  106132. */
  106133. getClassName(): string;
  106134. /**
  106135. * Add fallbacks to the effect fallbacks list.
  106136. * @param defines defines the Base texture to use.
  106137. * @param fallbacks defines the current fallback list.
  106138. * @param currentRank defines the current fallback rank.
  106139. * @returns the new fallback rank.
  106140. */
  106141. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106142. /**
  106143. * Add the required uniforms to the current list.
  106144. * @param uniforms defines the current uniform list.
  106145. */
  106146. static AddUniforms(uniforms: string[]): void;
  106147. /**
  106148. * Add the required samplers to the current list.
  106149. * @param samplers defines the current sampler list.
  106150. */
  106151. static AddSamplers(samplers: string[]): void;
  106152. /**
  106153. * Add the required uniforms to the current buffer.
  106154. * @param uniformBuffer defines the current uniform buffer.
  106155. */
  106156. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106157. /**
  106158. * Makes a duplicate of the current configuration into another one.
  106159. * @param configuration define the config where to copy the info
  106160. */
  106161. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106162. /**
  106163. * Serializes this Sub Surface configuration.
  106164. * @returns - An object with the serialized config.
  106165. */
  106166. serialize(): any;
  106167. /**
  106168. * Parses a anisotropy Configuration from a serialized object.
  106169. * @param source - Serialized object.
  106170. * @param scene Defines the scene we are parsing for
  106171. * @param rootUrl Defines the rootUrl to load from
  106172. */
  106173. parse(source: any, scene: Scene, rootUrl: string): void;
  106174. }
  106175. }
  106176. declare module BABYLON {
  106177. /**
  106178. * Class representing spherical harmonics coefficients to the 3rd degree
  106179. */
  106180. export class SphericalHarmonics {
  106181. /**
  106182. * Defines whether or not the harmonics have been prescaled for rendering.
  106183. */
  106184. preScaled: boolean;
  106185. /**
  106186. * The l0,0 coefficients of the spherical harmonics
  106187. */
  106188. l00: Vector3;
  106189. /**
  106190. * The l1,-1 coefficients of the spherical harmonics
  106191. */
  106192. l1_1: Vector3;
  106193. /**
  106194. * The l1,0 coefficients of the spherical harmonics
  106195. */
  106196. l10: Vector3;
  106197. /**
  106198. * The l1,1 coefficients of the spherical harmonics
  106199. */
  106200. l11: Vector3;
  106201. /**
  106202. * The l2,-2 coefficients of the spherical harmonics
  106203. */
  106204. l2_2: Vector3;
  106205. /**
  106206. * The l2,-1 coefficients of the spherical harmonics
  106207. */
  106208. l2_1: Vector3;
  106209. /**
  106210. * The l2,0 coefficients of the spherical harmonics
  106211. */
  106212. l20: Vector3;
  106213. /**
  106214. * The l2,1 coefficients of the spherical harmonics
  106215. */
  106216. l21: Vector3;
  106217. /**
  106218. * The l2,2 coefficients of the spherical harmonics
  106219. */
  106220. l22: Vector3;
  106221. /**
  106222. * Adds a light to the spherical harmonics
  106223. * @param direction the direction of the light
  106224. * @param color the color of the light
  106225. * @param deltaSolidAngle the delta solid angle of the light
  106226. */
  106227. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106228. /**
  106229. * Scales the spherical harmonics by the given amount
  106230. * @param scale the amount to scale
  106231. */
  106232. scaleInPlace(scale: number): void;
  106233. /**
  106234. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106235. *
  106236. * ```
  106237. * E_lm = A_l * L_lm
  106238. * ```
  106239. *
  106240. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106241. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106242. * the scaling factors are given in equation 9.
  106243. */
  106244. convertIncidentRadianceToIrradiance(): void;
  106245. /**
  106246. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106247. *
  106248. * ```
  106249. * L = (1/pi) * E * rho
  106250. * ```
  106251. *
  106252. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106253. */
  106254. convertIrradianceToLambertianRadiance(): void;
  106255. /**
  106256. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106257. * required operations at run time.
  106258. *
  106259. * This is simply done by scaling back the SH with Ylm constants parameter.
  106260. * The trigonometric part being applied by the shader at run time.
  106261. */
  106262. preScaleForRendering(): void;
  106263. /**
  106264. * Constructs a spherical harmonics from an array.
  106265. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106266. * @returns the spherical harmonics
  106267. */
  106268. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106269. /**
  106270. * Gets the spherical harmonics from polynomial
  106271. * @param polynomial the spherical polynomial
  106272. * @returns the spherical harmonics
  106273. */
  106274. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106275. }
  106276. /**
  106277. * Class representing spherical polynomial coefficients to the 3rd degree
  106278. */
  106279. export class SphericalPolynomial {
  106280. private _harmonics;
  106281. /**
  106282. * The spherical harmonics used to create the polynomials.
  106283. */
  106284. get preScaledHarmonics(): SphericalHarmonics;
  106285. /**
  106286. * The x coefficients of the spherical polynomial
  106287. */
  106288. x: Vector3;
  106289. /**
  106290. * The y coefficients of the spherical polynomial
  106291. */
  106292. y: Vector3;
  106293. /**
  106294. * The z coefficients of the spherical polynomial
  106295. */
  106296. z: Vector3;
  106297. /**
  106298. * The xx coefficients of the spherical polynomial
  106299. */
  106300. xx: Vector3;
  106301. /**
  106302. * The yy coefficients of the spherical polynomial
  106303. */
  106304. yy: Vector3;
  106305. /**
  106306. * The zz coefficients of the spherical polynomial
  106307. */
  106308. zz: Vector3;
  106309. /**
  106310. * The xy coefficients of the spherical polynomial
  106311. */
  106312. xy: Vector3;
  106313. /**
  106314. * The yz coefficients of the spherical polynomial
  106315. */
  106316. yz: Vector3;
  106317. /**
  106318. * The zx coefficients of the spherical polynomial
  106319. */
  106320. zx: Vector3;
  106321. /**
  106322. * Adds an ambient color to the spherical polynomial
  106323. * @param color the color to add
  106324. */
  106325. addAmbient(color: Color3): void;
  106326. /**
  106327. * Scales the spherical polynomial by the given amount
  106328. * @param scale the amount to scale
  106329. */
  106330. scaleInPlace(scale: number): void;
  106331. /**
  106332. * Gets the spherical polynomial from harmonics
  106333. * @param harmonics the spherical harmonics
  106334. * @returns the spherical polynomial
  106335. */
  106336. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106337. /**
  106338. * Constructs a spherical polynomial from an array.
  106339. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106340. * @returns the spherical polynomial
  106341. */
  106342. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106343. }
  106344. }
  106345. declare module BABYLON {
  106346. /**
  106347. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106348. */
  106349. export interface CubeMapInfo {
  106350. /**
  106351. * The pixel array for the front face.
  106352. * This is stored in format, left to right, up to down format.
  106353. */
  106354. front: Nullable<ArrayBufferView>;
  106355. /**
  106356. * The pixel array for the back face.
  106357. * This is stored in format, left to right, up to down format.
  106358. */
  106359. back: Nullable<ArrayBufferView>;
  106360. /**
  106361. * The pixel array for the left face.
  106362. * This is stored in format, left to right, up to down format.
  106363. */
  106364. left: Nullable<ArrayBufferView>;
  106365. /**
  106366. * The pixel array for the right face.
  106367. * This is stored in format, left to right, up to down format.
  106368. */
  106369. right: Nullable<ArrayBufferView>;
  106370. /**
  106371. * The pixel array for the up face.
  106372. * This is stored in format, left to right, up to down format.
  106373. */
  106374. up: Nullable<ArrayBufferView>;
  106375. /**
  106376. * The pixel array for the down face.
  106377. * This is stored in format, left to right, up to down format.
  106378. */
  106379. down: Nullable<ArrayBufferView>;
  106380. /**
  106381. * The size of the cubemap stored.
  106382. *
  106383. * Each faces will be size * size pixels.
  106384. */
  106385. size: number;
  106386. /**
  106387. * The format of the texture.
  106388. *
  106389. * RGBA, RGB.
  106390. */
  106391. format: number;
  106392. /**
  106393. * The type of the texture data.
  106394. *
  106395. * UNSIGNED_INT, FLOAT.
  106396. */
  106397. type: number;
  106398. /**
  106399. * Specifies whether the texture is in gamma space.
  106400. */
  106401. gammaSpace: boolean;
  106402. }
  106403. /**
  106404. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106405. */
  106406. export class PanoramaToCubeMapTools {
  106407. private static FACE_LEFT;
  106408. private static FACE_RIGHT;
  106409. private static FACE_FRONT;
  106410. private static FACE_BACK;
  106411. private static FACE_DOWN;
  106412. private static FACE_UP;
  106413. /**
  106414. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  106415. *
  106416. * @param float32Array The source data.
  106417. * @param inputWidth The width of the input panorama.
  106418. * @param inputHeight The height of the input panorama.
  106419. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  106420. * @return The cubemap data
  106421. */
  106422. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  106423. private static CreateCubemapTexture;
  106424. private static CalcProjectionSpherical;
  106425. }
  106426. }
  106427. declare module BABYLON {
  106428. /**
  106429. * Helper class dealing with the extraction of spherical polynomial dataArray
  106430. * from a cube map.
  106431. */
  106432. export class CubeMapToSphericalPolynomialTools {
  106433. private static FileFaces;
  106434. /**
  106435. * Converts a texture to the according Spherical Polynomial data.
  106436. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106437. *
  106438. * @param texture The texture to extract the information from.
  106439. * @return The Spherical Polynomial data.
  106440. */
  106441. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  106442. /**
  106443. * Converts a cubemap to the according Spherical Polynomial data.
  106444. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106445. *
  106446. * @param cubeInfo The Cube map to extract the information from.
  106447. * @return The Spherical Polynomial data.
  106448. */
  106449. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  106450. }
  106451. }
  106452. declare module BABYLON {
  106453. interface BaseTexture {
  106454. /**
  106455. * Get the polynomial representation of the texture data.
  106456. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  106457. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  106458. */
  106459. sphericalPolynomial: Nullable<SphericalPolynomial>;
  106460. }
  106461. }
  106462. declare module BABYLON {
  106463. /** @hidden */
  106464. export var pbrFragmentDeclaration: {
  106465. name: string;
  106466. shader: string;
  106467. };
  106468. }
  106469. declare module BABYLON {
  106470. /** @hidden */
  106471. export var pbrUboDeclaration: {
  106472. name: string;
  106473. shader: string;
  106474. };
  106475. }
  106476. declare module BABYLON {
  106477. /** @hidden */
  106478. export var pbrFragmentExtraDeclaration: {
  106479. name: string;
  106480. shader: string;
  106481. };
  106482. }
  106483. declare module BABYLON {
  106484. /** @hidden */
  106485. export var pbrFragmentSamplersDeclaration: {
  106486. name: string;
  106487. shader: string;
  106488. };
  106489. }
  106490. declare module BABYLON {
  106491. /** @hidden */
  106492. export var subSurfaceScatteringFunctions: {
  106493. name: string;
  106494. shader: string;
  106495. };
  106496. }
  106497. declare module BABYLON {
  106498. /** @hidden */
  106499. export var importanceSampling: {
  106500. name: string;
  106501. shader: string;
  106502. };
  106503. }
  106504. declare module BABYLON {
  106505. /** @hidden */
  106506. export var pbrHelperFunctions: {
  106507. name: string;
  106508. shader: string;
  106509. };
  106510. }
  106511. declare module BABYLON {
  106512. /** @hidden */
  106513. export var harmonicsFunctions: {
  106514. name: string;
  106515. shader: string;
  106516. };
  106517. }
  106518. declare module BABYLON {
  106519. /** @hidden */
  106520. export var pbrDirectLightingSetupFunctions: {
  106521. name: string;
  106522. shader: string;
  106523. };
  106524. }
  106525. declare module BABYLON {
  106526. /** @hidden */
  106527. export var pbrDirectLightingFalloffFunctions: {
  106528. name: string;
  106529. shader: string;
  106530. };
  106531. }
  106532. declare module BABYLON {
  106533. /** @hidden */
  106534. export var pbrBRDFFunctions: {
  106535. name: string;
  106536. shader: string;
  106537. };
  106538. }
  106539. declare module BABYLON {
  106540. /** @hidden */
  106541. export var hdrFilteringFunctions: {
  106542. name: string;
  106543. shader: string;
  106544. };
  106545. }
  106546. declare module BABYLON {
  106547. /** @hidden */
  106548. export var pbrDirectLightingFunctions: {
  106549. name: string;
  106550. shader: string;
  106551. };
  106552. }
  106553. declare module BABYLON {
  106554. /** @hidden */
  106555. export var pbrIBLFunctions: {
  106556. name: string;
  106557. shader: string;
  106558. };
  106559. }
  106560. declare module BABYLON {
  106561. /** @hidden */
  106562. export var pbrBlockAlbedoOpacity: {
  106563. name: string;
  106564. shader: string;
  106565. };
  106566. }
  106567. declare module BABYLON {
  106568. /** @hidden */
  106569. export var pbrBlockReflectivity: {
  106570. name: string;
  106571. shader: string;
  106572. };
  106573. }
  106574. declare module BABYLON {
  106575. /** @hidden */
  106576. export var pbrBlockAmbientOcclusion: {
  106577. name: string;
  106578. shader: string;
  106579. };
  106580. }
  106581. declare module BABYLON {
  106582. /** @hidden */
  106583. export var pbrBlockAlphaFresnel: {
  106584. name: string;
  106585. shader: string;
  106586. };
  106587. }
  106588. declare module BABYLON {
  106589. /** @hidden */
  106590. export var pbrBlockAnisotropic: {
  106591. name: string;
  106592. shader: string;
  106593. };
  106594. }
  106595. declare module BABYLON {
  106596. /** @hidden */
  106597. export var pbrBlockReflection: {
  106598. name: string;
  106599. shader: string;
  106600. };
  106601. }
  106602. declare module BABYLON {
  106603. /** @hidden */
  106604. export var pbrBlockSheen: {
  106605. name: string;
  106606. shader: string;
  106607. };
  106608. }
  106609. declare module BABYLON {
  106610. /** @hidden */
  106611. export var pbrBlockClearcoat: {
  106612. name: string;
  106613. shader: string;
  106614. };
  106615. }
  106616. declare module BABYLON {
  106617. /** @hidden */
  106618. export var pbrBlockSubSurface: {
  106619. name: string;
  106620. shader: string;
  106621. };
  106622. }
  106623. declare module BABYLON {
  106624. /** @hidden */
  106625. export var pbrBlockNormalGeometric: {
  106626. name: string;
  106627. shader: string;
  106628. };
  106629. }
  106630. declare module BABYLON {
  106631. /** @hidden */
  106632. export var pbrBlockNormalFinal: {
  106633. name: string;
  106634. shader: string;
  106635. };
  106636. }
  106637. declare module BABYLON {
  106638. /** @hidden */
  106639. export var pbrBlockLightmapInit: {
  106640. name: string;
  106641. shader: string;
  106642. };
  106643. }
  106644. declare module BABYLON {
  106645. /** @hidden */
  106646. export var pbrBlockGeometryInfo: {
  106647. name: string;
  106648. shader: string;
  106649. };
  106650. }
  106651. declare module BABYLON {
  106652. /** @hidden */
  106653. export var pbrBlockReflectance0: {
  106654. name: string;
  106655. shader: string;
  106656. };
  106657. }
  106658. declare module BABYLON {
  106659. /** @hidden */
  106660. export var pbrBlockReflectance: {
  106661. name: string;
  106662. shader: string;
  106663. };
  106664. }
  106665. declare module BABYLON {
  106666. /** @hidden */
  106667. export var pbrBlockDirectLighting: {
  106668. name: string;
  106669. shader: string;
  106670. };
  106671. }
  106672. declare module BABYLON {
  106673. /** @hidden */
  106674. export var pbrBlockFinalLitComponents: {
  106675. name: string;
  106676. shader: string;
  106677. };
  106678. }
  106679. declare module BABYLON {
  106680. /** @hidden */
  106681. export var pbrBlockFinalUnlitComponents: {
  106682. name: string;
  106683. shader: string;
  106684. };
  106685. }
  106686. declare module BABYLON {
  106687. /** @hidden */
  106688. export var pbrBlockFinalColorComposition: {
  106689. name: string;
  106690. shader: string;
  106691. };
  106692. }
  106693. declare module BABYLON {
  106694. /** @hidden */
  106695. export var pbrBlockImageProcessing: {
  106696. name: string;
  106697. shader: string;
  106698. };
  106699. }
  106700. declare module BABYLON {
  106701. /** @hidden */
  106702. export var pbrDebug: {
  106703. name: string;
  106704. shader: string;
  106705. };
  106706. }
  106707. declare module BABYLON {
  106708. /** @hidden */
  106709. export var pbrPixelShader: {
  106710. name: string;
  106711. shader: string;
  106712. };
  106713. }
  106714. declare module BABYLON {
  106715. /** @hidden */
  106716. export var pbrVertexDeclaration: {
  106717. name: string;
  106718. shader: string;
  106719. };
  106720. }
  106721. declare module BABYLON {
  106722. /** @hidden */
  106723. export var pbrVertexShader: {
  106724. name: string;
  106725. shader: string;
  106726. };
  106727. }
  106728. declare module BABYLON {
  106729. /**
  106730. * Manages the defines for the PBR Material.
  106731. * @hidden
  106732. */
  106733. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  106734. PBR: boolean;
  106735. NUM_SAMPLES: string;
  106736. REALTIME_FILTERING: boolean;
  106737. MAINUV1: boolean;
  106738. MAINUV2: boolean;
  106739. UV1: boolean;
  106740. UV2: boolean;
  106741. ALBEDO: boolean;
  106742. GAMMAALBEDO: boolean;
  106743. ALBEDODIRECTUV: number;
  106744. VERTEXCOLOR: boolean;
  106745. DETAIL: boolean;
  106746. DETAILDIRECTUV: number;
  106747. DETAIL_NORMALBLENDMETHOD: number;
  106748. AMBIENT: boolean;
  106749. AMBIENTDIRECTUV: number;
  106750. AMBIENTINGRAYSCALE: boolean;
  106751. OPACITY: boolean;
  106752. VERTEXALPHA: boolean;
  106753. OPACITYDIRECTUV: number;
  106754. OPACITYRGB: boolean;
  106755. ALPHATEST: boolean;
  106756. DEPTHPREPASS: boolean;
  106757. ALPHABLEND: boolean;
  106758. ALPHAFROMALBEDO: boolean;
  106759. ALPHATESTVALUE: string;
  106760. SPECULAROVERALPHA: boolean;
  106761. RADIANCEOVERALPHA: boolean;
  106762. ALPHAFRESNEL: boolean;
  106763. LINEARALPHAFRESNEL: boolean;
  106764. PREMULTIPLYALPHA: boolean;
  106765. EMISSIVE: boolean;
  106766. EMISSIVEDIRECTUV: number;
  106767. REFLECTIVITY: boolean;
  106768. REFLECTIVITYDIRECTUV: number;
  106769. SPECULARTERM: boolean;
  106770. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  106771. MICROSURFACEAUTOMATIC: boolean;
  106772. LODBASEDMICROSFURACE: boolean;
  106773. MICROSURFACEMAP: boolean;
  106774. MICROSURFACEMAPDIRECTUV: number;
  106775. METALLICWORKFLOW: boolean;
  106776. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106777. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106778. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106779. AOSTOREINMETALMAPRED: boolean;
  106780. METALLIC_REFLECTANCE: boolean;
  106781. METALLIC_REFLECTANCEDIRECTUV: number;
  106782. ENVIRONMENTBRDF: boolean;
  106783. ENVIRONMENTBRDF_RGBD: boolean;
  106784. NORMAL: boolean;
  106785. TANGENT: boolean;
  106786. BUMP: boolean;
  106787. BUMPDIRECTUV: number;
  106788. OBJECTSPACE_NORMALMAP: boolean;
  106789. PARALLAX: boolean;
  106790. PARALLAXOCCLUSION: boolean;
  106791. NORMALXYSCALE: boolean;
  106792. LIGHTMAP: boolean;
  106793. LIGHTMAPDIRECTUV: number;
  106794. USELIGHTMAPASSHADOWMAP: boolean;
  106795. GAMMALIGHTMAP: boolean;
  106796. RGBDLIGHTMAP: boolean;
  106797. REFLECTION: boolean;
  106798. REFLECTIONMAP_3D: boolean;
  106799. REFLECTIONMAP_SPHERICAL: boolean;
  106800. REFLECTIONMAP_PLANAR: boolean;
  106801. REFLECTIONMAP_CUBIC: boolean;
  106802. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106803. REFLECTIONMAP_PROJECTION: boolean;
  106804. REFLECTIONMAP_SKYBOX: boolean;
  106805. REFLECTIONMAP_EXPLICIT: boolean;
  106806. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106807. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106808. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106809. INVERTCUBICMAP: boolean;
  106810. USESPHERICALFROMREFLECTIONMAP: boolean;
  106811. USEIRRADIANCEMAP: boolean;
  106812. SPHERICAL_HARMONICS: boolean;
  106813. USESPHERICALINVERTEX: boolean;
  106814. REFLECTIONMAP_OPPOSITEZ: boolean;
  106815. LODINREFLECTIONALPHA: boolean;
  106816. GAMMAREFLECTION: boolean;
  106817. RGBDREFLECTION: boolean;
  106818. LINEARSPECULARREFLECTION: boolean;
  106819. RADIANCEOCCLUSION: boolean;
  106820. HORIZONOCCLUSION: boolean;
  106821. INSTANCES: boolean;
  106822. THIN_INSTANCES: boolean;
  106823. PREPASS: boolean;
  106824. PREPASS_IRRADIANCE: boolean;
  106825. PREPASS_IRRADIANCE_INDEX: number;
  106826. PREPASS_ALBEDO: boolean;
  106827. PREPASS_ALBEDO_INDEX: number;
  106828. PREPASS_DEPTHNORMAL: boolean;
  106829. PREPASS_DEPTHNORMAL_INDEX: number;
  106830. PREPASS_POSITION: boolean;
  106831. PREPASS_POSITION_INDEX: number;
  106832. PREPASS_VELOCITY: boolean;
  106833. PREPASS_VELOCITY_INDEX: number;
  106834. PREPASS_REFLECTIVITY: boolean;
  106835. PREPASS_REFLECTIVITY_INDEX: number;
  106836. SCENE_MRT_COUNT: number;
  106837. NUM_BONE_INFLUENCERS: number;
  106838. BonesPerMesh: number;
  106839. BONETEXTURE: boolean;
  106840. BONES_VELOCITY_ENABLED: boolean;
  106841. NONUNIFORMSCALING: boolean;
  106842. MORPHTARGETS: boolean;
  106843. MORPHTARGETS_NORMAL: boolean;
  106844. MORPHTARGETS_TANGENT: boolean;
  106845. MORPHTARGETS_UV: boolean;
  106846. NUM_MORPH_INFLUENCERS: number;
  106847. IMAGEPROCESSING: boolean;
  106848. VIGNETTE: boolean;
  106849. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106850. VIGNETTEBLENDMODEOPAQUE: boolean;
  106851. TONEMAPPING: boolean;
  106852. TONEMAPPING_ACES: boolean;
  106853. CONTRAST: boolean;
  106854. COLORCURVES: boolean;
  106855. COLORGRADING: boolean;
  106856. COLORGRADING3D: boolean;
  106857. SAMPLER3DGREENDEPTH: boolean;
  106858. SAMPLER3DBGRMAP: boolean;
  106859. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106860. EXPOSURE: boolean;
  106861. MULTIVIEW: boolean;
  106862. USEPHYSICALLIGHTFALLOFF: boolean;
  106863. USEGLTFLIGHTFALLOFF: boolean;
  106864. TWOSIDEDLIGHTING: boolean;
  106865. SHADOWFLOAT: boolean;
  106866. CLIPPLANE: boolean;
  106867. CLIPPLANE2: boolean;
  106868. CLIPPLANE3: boolean;
  106869. CLIPPLANE4: boolean;
  106870. CLIPPLANE5: boolean;
  106871. CLIPPLANE6: boolean;
  106872. POINTSIZE: boolean;
  106873. FOG: boolean;
  106874. LOGARITHMICDEPTH: boolean;
  106875. FORCENORMALFORWARD: boolean;
  106876. SPECULARAA: boolean;
  106877. CLEARCOAT: boolean;
  106878. CLEARCOAT_DEFAULTIOR: boolean;
  106879. CLEARCOAT_TEXTURE: boolean;
  106880. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  106881. CLEARCOAT_TEXTUREDIRECTUV: number;
  106882. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  106883. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106884. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106885. CLEARCOAT_BUMP: boolean;
  106886. CLEARCOAT_BUMPDIRECTUV: number;
  106887. CLEARCOAT_REMAP_F0: boolean;
  106888. CLEARCOAT_TINT: boolean;
  106889. CLEARCOAT_TINT_TEXTURE: boolean;
  106890. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106891. ANISOTROPIC: boolean;
  106892. ANISOTROPIC_TEXTURE: boolean;
  106893. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106894. BRDF_V_HEIGHT_CORRELATED: boolean;
  106895. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106896. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106897. SHEEN: boolean;
  106898. SHEEN_TEXTURE: boolean;
  106899. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106900. SHEEN_TEXTUREDIRECTUV: number;
  106901. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106902. SHEEN_LINKWITHALBEDO: boolean;
  106903. SHEEN_ROUGHNESS: boolean;
  106904. SHEEN_ALBEDOSCALING: boolean;
  106905. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106906. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106907. SUBSURFACE: boolean;
  106908. SS_REFRACTION: boolean;
  106909. SS_TRANSLUCENCY: boolean;
  106910. SS_SCATTERING: boolean;
  106911. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106912. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106913. SS_REFRACTIONMAP_3D: boolean;
  106914. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106915. SS_LODINREFRACTIONALPHA: boolean;
  106916. SS_GAMMAREFRACTION: boolean;
  106917. SS_RGBDREFRACTION: boolean;
  106918. SS_LINEARSPECULARREFRACTION: boolean;
  106919. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106920. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106921. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106922. UNLIT: boolean;
  106923. DEBUGMODE: number;
  106924. /**
  106925. * Initializes the PBR Material defines.
  106926. */
  106927. constructor();
  106928. /**
  106929. * Resets the PBR Material defines.
  106930. */
  106931. reset(): void;
  106932. }
  106933. /**
  106934. * The Physically based material base class of BJS.
  106935. *
  106936. * This offers the main features of a standard PBR material.
  106937. * For more information, please refer to the documentation :
  106938. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106939. */
  106940. export abstract class PBRBaseMaterial extends PushMaterial {
  106941. /**
  106942. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106943. */
  106944. static readonly PBRMATERIAL_OPAQUE: number;
  106945. /**
  106946. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106947. */
  106948. static readonly PBRMATERIAL_ALPHATEST: number;
  106949. /**
  106950. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106951. */
  106952. static readonly PBRMATERIAL_ALPHABLEND: number;
  106953. /**
  106954. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106955. * They are also discarded below the alpha cutoff threshold to improve performances.
  106956. */
  106957. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106958. /**
  106959. * Defines the default value of how much AO map is occluding the analytical lights
  106960. * (point spot...).
  106961. */
  106962. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106963. /**
  106964. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  106965. */
  106966. static readonly LIGHTFALLOFF_PHYSICAL: number;
  106967. /**
  106968. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  106969. * to enhance interoperability with other engines.
  106970. */
  106971. static readonly LIGHTFALLOFF_GLTF: number;
  106972. /**
  106973. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  106974. * to enhance interoperability with other materials.
  106975. */
  106976. static readonly LIGHTFALLOFF_STANDARD: number;
  106977. /**
  106978. * Intensity of the direct lights e.g. the four lights available in your scene.
  106979. * This impacts both the direct diffuse and specular highlights.
  106980. */
  106981. protected _directIntensity: number;
  106982. /**
  106983. * Intensity of the emissive part of the material.
  106984. * This helps controlling the emissive effect without modifying the emissive color.
  106985. */
  106986. protected _emissiveIntensity: number;
  106987. /**
  106988. * Intensity of the environment e.g. how much the environment will light the object
  106989. * either through harmonics for rough material or through the refelction for shiny ones.
  106990. */
  106991. protected _environmentIntensity: number;
  106992. /**
  106993. * This is a special control allowing the reduction of the specular highlights coming from the
  106994. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106995. */
  106996. protected _specularIntensity: number;
  106997. /**
  106998. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  106999. */
  107000. private _lightingInfos;
  107001. /**
  107002. * Debug Control allowing disabling the bump map on this material.
  107003. */
  107004. protected _disableBumpMap: boolean;
  107005. /**
  107006. * AKA Diffuse Texture in standard nomenclature.
  107007. */
  107008. protected _albedoTexture: Nullable<BaseTexture>;
  107009. /**
  107010. * AKA Occlusion Texture in other nomenclature.
  107011. */
  107012. protected _ambientTexture: Nullable<BaseTexture>;
  107013. /**
  107014. * AKA Occlusion Texture Intensity in other nomenclature.
  107015. */
  107016. protected _ambientTextureStrength: number;
  107017. /**
  107018. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107019. * 1 means it completely occludes it
  107020. * 0 mean it has no impact
  107021. */
  107022. protected _ambientTextureImpactOnAnalyticalLights: number;
  107023. /**
  107024. * Stores the alpha values in a texture.
  107025. */
  107026. protected _opacityTexture: Nullable<BaseTexture>;
  107027. /**
  107028. * Stores the reflection values in a texture.
  107029. */
  107030. protected _reflectionTexture: Nullable<BaseTexture>;
  107031. /**
  107032. * Stores the emissive values in a texture.
  107033. */
  107034. protected _emissiveTexture: Nullable<BaseTexture>;
  107035. /**
  107036. * AKA Specular texture in other nomenclature.
  107037. */
  107038. protected _reflectivityTexture: Nullable<BaseTexture>;
  107039. /**
  107040. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107041. */
  107042. protected _metallicTexture: Nullable<BaseTexture>;
  107043. /**
  107044. * Specifies the metallic scalar of the metallic/roughness workflow.
  107045. * Can also be used to scale the metalness values of the metallic texture.
  107046. */
  107047. protected _metallic: Nullable<number>;
  107048. /**
  107049. * Specifies the roughness scalar of the metallic/roughness workflow.
  107050. * Can also be used to scale the roughness values of the metallic texture.
  107051. */
  107052. protected _roughness: Nullable<number>;
  107053. /**
  107054. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107055. * By default the indexOfrefraction is used to compute F0;
  107056. *
  107057. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107058. *
  107059. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107060. * F90 = metallicReflectanceColor;
  107061. */
  107062. protected _metallicF0Factor: number;
  107063. /**
  107064. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107065. * By default the F90 is always 1;
  107066. *
  107067. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107068. *
  107069. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107070. * F90 = metallicReflectanceColor;
  107071. */
  107072. protected _metallicReflectanceColor: Color3;
  107073. /**
  107074. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107075. * This is multiply against the scalar values defined in the material.
  107076. */
  107077. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  107078. /**
  107079. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107080. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107081. */
  107082. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107083. /**
  107084. * Stores surface normal data used to displace a mesh in a texture.
  107085. */
  107086. protected _bumpTexture: Nullable<BaseTexture>;
  107087. /**
  107088. * Stores the pre-calculated light information of a mesh in a texture.
  107089. */
  107090. protected _lightmapTexture: Nullable<BaseTexture>;
  107091. /**
  107092. * The color of a material in ambient lighting.
  107093. */
  107094. protected _ambientColor: Color3;
  107095. /**
  107096. * AKA Diffuse Color in other nomenclature.
  107097. */
  107098. protected _albedoColor: Color3;
  107099. /**
  107100. * AKA Specular Color in other nomenclature.
  107101. */
  107102. protected _reflectivityColor: Color3;
  107103. /**
  107104. * The color applied when light is reflected from a material.
  107105. */
  107106. protected _reflectionColor: Color3;
  107107. /**
  107108. * The color applied when light is emitted from a material.
  107109. */
  107110. protected _emissiveColor: Color3;
  107111. /**
  107112. * AKA Glossiness in other nomenclature.
  107113. */
  107114. protected _microSurface: number;
  107115. /**
  107116. * Specifies that the material will use the light map as a show map.
  107117. */
  107118. protected _useLightmapAsShadowmap: boolean;
  107119. /**
  107120. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107121. * makes the reflect vector face the model (under horizon).
  107122. */
  107123. protected _useHorizonOcclusion: boolean;
  107124. /**
  107125. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107126. * too much the area relying on ambient texture to define their ambient occlusion.
  107127. */
  107128. protected _useRadianceOcclusion: boolean;
  107129. /**
  107130. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107131. */
  107132. protected _useAlphaFromAlbedoTexture: boolean;
  107133. /**
  107134. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107135. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107136. */
  107137. protected _useSpecularOverAlpha: boolean;
  107138. /**
  107139. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107140. */
  107141. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107142. /**
  107143. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107144. */
  107145. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107146. /**
  107147. * Specifies if the metallic texture contains the roughness information in its green channel.
  107148. */
  107149. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107150. /**
  107151. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107152. */
  107153. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107154. /**
  107155. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107156. */
  107157. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107158. /**
  107159. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107160. */
  107161. protected _useAmbientInGrayScale: boolean;
  107162. /**
  107163. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107164. * The material will try to infer what glossiness each pixel should be.
  107165. */
  107166. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107167. /**
  107168. * Defines the falloff type used in this material.
  107169. * It by default is Physical.
  107170. */
  107171. protected _lightFalloff: number;
  107172. /**
  107173. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107174. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107175. */
  107176. protected _useRadianceOverAlpha: boolean;
  107177. /**
  107178. * Allows using an object space normal map (instead of tangent space).
  107179. */
  107180. protected _useObjectSpaceNormalMap: boolean;
  107181. /**
  107182. * Allows using the bump map in parallax mode.
  107183. */
  107184. protected _useParallax: boolean;
  107185. /**
  107186. * Allows using the bump map in parallax occlusion mode.
  107187. */
  107188. protected _useParallaxOcclusion: boolean;
  107189. /**
  107190. * Controls the scale bias of the parallax mode.
  107191. */
  107192. protected _parallaxScaleBias: number;
  107193. /**
  107194. * If sets to true, disables all the lights affecting the material.
  107195. */
  107196. protected _disableLighting: boolean;
  107197. /**
  107198. * Number of Simultaneous lights allowed on the material.
  107199. */
  107200. protected _maxSimultaneousLights: number;
  107201. /**
  107202. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107203. */
  107204. protected _invertNormalMapX: boolean;
  107205. /**
  107206. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107207. */
  107208. protected _invertNormalMapY: boolean;
  107209. /**
  107210. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107211. */
  107212. protected _twoSidedLighting: boolean;
  107213. /**
  107214. * Defines the alpha limits in alpha test mode.
  107215. */
  107216. protected _alphaCutOff: number;
  107217. /**
  107218. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107219. */
  107220. protected _forceAlphaTest: boolean;
  107221. /**
  107222. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107223. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107224. */
  107225. protected _useAlphaFresnel: boolean;
  107226. /**
  107227. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107228. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107229. */
  107230. protected _useLinearAlphaFresnel: boolean;
  107231. /**
  107232. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107233. * from cos thetav and roughness:
  107234. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107235. */
  107236. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107237. /**
  107238. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107239. */
  107240. protected _forceIrradianceInFragment: boolean;
  107241. private _realTimeFiltering;
  107242. /**
  107243. * Enables realtime filtering on the texture.
  107244. */
  107245. get realTimeFiltering(): boolean;
  107246. set realTimeFiltering(b: boolean);
  107247. private _realTimeFilteringQuality;
  107248. /**
  107249. * Quality switch for realtime filtering
  107250. */
  107251. get realTimeFilteringQuality(): number;
  107252. set realTimeFilteringQuality(n: number);
  107253. /**
  107254. * Can this material render to several textures at once
  107255. */
  107256. get canRenderToMRT(): boolean;
  107257. /**
  107258. * Force normal to face away from face.
  107259. */
  107260. protected _forceNormalForward: boolean;
  107261. /**
  107262. * Enables specular anti aliasing in the PBR shader.
  107263. * It will both interacts on the Geometry for analytical and IBL lighting.
  107264. * It also prefilter the roughness map based on the bump values.
  107265. */
  107266. protected _enableSpecularAntiAliasing: boolean;
  107267. /**
  107268. * Default configuration related to image processing available in the PBR Material.
  107269. */
  107270. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107271. /**
  107272. * Keep track of the image processing observer to allow dispose and replace.
  107273. */
  107274. private _imageProcessingObserver;
  107275. /**
  107276. * Attaches a new image processing configuration to the PBR Material.
  107277. * @param configuration
  107278. */
  107279. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107280. /**
  107281. * Stores the available render targets.
  107282. */
  107283. private _renderTargets;
  107284. /**
  107285. * Sets the global ambient color for the material used in lighting calculations.
  107286. */
  107287. private _globalAmbientColor;
  107288. /**
  107289. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107290. */
  107291. private _useLogarithmicDepth;
  107292. /**
  107293. * If set to true, no lighting calculations will be applied.
  107294. */
  107295. private _unlit;
  107296. private _debugMode;
  107297. /**
  107298. * @hidden
  107299. * This is reserved for the inspector.
  107300. * Defines the material debug mode.
  107301. * It helps seeing only some components of the material while troubleshooting.
  107302. */
  107303. debugMode: number;
  107304. /**
  107305. * @hidden
  107306. * This is reserved for the inspector.
  107307. * Specify from where on screen the debug mode should start.
  107308. * The value goes from -1 (full screen) to 1 (not visible)
  107309. * It helps with side by side comparison against the final render
  107310. * This defaults to -1
  107311. */
  107312. private debugLimit;
  107313. /**
  107314. * @hidden
  107315. * This is reserved for the inspector.
  107316. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107317. * You can use the factor to better multiply the final value.
  107318. */
  107319. private debugFactor;
  107320. /**
  107321. * Defines the clear coat layer parameters for the material.
  107322. */
  107323. readonly clearCoat: PBRClearCoatConfiguration;
  107324. /**
  107325. * Defines the anisotropic parameters for the material.
  107326. */
  107327. readonly anisotropy: PBRAnisotropicConfiguration;
  107328. /**
  107329. * Defines the BRDF parameters for the material.
  107330. */
  107331. readonly brdf: PBRBRDFConfiguration;
  107332. /**
  107333. * Defines the Sheen parameters for the material.
  107334. */
  107335. readonly sheen: PBRSheenConfiguration;
  107336. /**
  107337. * Defines the SubSurface parameters for the material.
  107338. */
  107339. readonly subSurface: PBRSubSurfaceConfiguration;
  107340. /**
  107341. * Defines additionnal PrePass parameters for the material.
  107342. */
  107343. readonly prePassConfiguration: PrePassConfiguration;
  107344. /**
  107345. * Defines the detail map parameters for the material.
  107346. */
  107347. readonly detailMap: DetailMapConfiguration;
  107348. protected _rebuildInParallel: boolean;
  107349. /**
  107350. * Instantiates a new PBRMaterial instance.
  107351. *
  107352. * @param name The material name
  107353. * @param scene The scene the material will be use in.
  107354. */
  107355. constructor(name: string, scene: Scene);
  107356. /**
  107357. * Gets a boolean indicating that current material needs to register RTT
  107358. */
  107359. get hasRenderTargetTextures(): boolean;
  107360. /**
  107361. * Gets the name of the material class.
  107362. */
  107363. getClassName(): string;
  107364. /**
  107365. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107366. */
  107367. get useLogarithmicDepth(): boolean;
  107368. /**
  107369. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107370. */
  107371. set useLogarithmicDepth(value: boolean);
  107372. /**
  107373. * Returns true if alpha blending should be disabled.
  107374. */
  107375. protected get _disableAlphaBlending(): boolean;
  107376. /**
  107377. * Specifies whether or not this material should be rendered in alpha blend mode.
  107378. */
  107379. needAlphaBlending(): boolean;
  107380. /**
  107381. * Specifies whether or not this material should be rendered in alpha test mode.
  107382. */
  107383. needAlphaTesting(): boolean;
  107384. /**
  107385. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107386. */
  107387. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107388. /**
  107389. * Specifies whether or not there is a usable alpha channel for transparency.
  107390. */
  107391. protected _hasAlphaChannel(): boolean;
  107392. /**
  107393. * Gets the texture used for the alpha test.
  107394. */
  107395. getAlphaTestTexture(): Nullable<BaseTexture>;
  107396. /**
  107397. * Specifies that the submesh is ready to be used.
  107398. * @param mesh - BJS mesh.
  107399. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107400. * @param useInstances - Specifies that instances should be used.
  107401. * @returns - boolean indicating that the submesh is ready or not.
  107402. */
  107403. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107404. /**
  107405. * Specifies if the material uses metallic roughness workflow.
  107406. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107407. */
  107408. isMetallicWorkflow(): boolean;
  107409. private _prepareEffect;
  107410. private _prepareDefines;
  107411. /**
  107412. * Force shader compilation
  107413. */
  107414. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  107415. /**
  107416. * Initializes the uniform buffer layout for the shader.
  107417. */
  107418. buildUniformLayout(): void;
  107419. /**
  107420. * Unbinds the material from the mesh
  107421. */
  107422. unbind(): void;
  107423. /**
  107424. * Binds the submesh data.
  107425. * @param world - The world matrix.
  107426. * @param mesh - The BJS mesh.
  107427. * @param subMesh - A submesh of the BJS mesh.
  107428. */
  107429. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107430. /**
  107431. * Returns the animatable textures.
  107432. * @returns - Array of animatable textures.
  107433. */
  107434. getAnimatables(): IAnimatable[];
  107435. /**
  107436. * Returns the texture used for reflections.
  107437. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107438. */
  107439. private _getReflectionTexture;
  107440. /**
  107441. * Returns an array of the actively used textures.
  107442. * @returns - Array of BaseTextures
  107443. */
  107444. getActiveTextures(): BaseTexture[];
  107445. /**
  107446. * Checks to see if a texture is used in the material.
  107447. * @param texture - Base texture to use.
  107448. * @returns - Boolean specifying if a texture is used in the material.
  107449. */
  107450. hasTexture(texture: BaseTexture): boolean;
  107451. /**
  107452. * Sets the required values to the prepass renderer.
  107453. * @param prePassRenderer defines the prepass renderer to setup
  107454. */
  107455. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107456. /**
  107457. * Disposes the resources of the material.
  107458. * @param forceDisposeEffect - Forces the disposal of effects.
  107459. * @param forceDisposeTextures - Forces the disposal of all textures.
  107460. */
  107461. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107462. }
  107463. }
  107464. declare module BABYLON {
  107465. /**
  107466. * The Physically based material of BJS.
  107467. *
  107468. * This offers the main features of a standard PBR material.
  107469. * For more information, please refer to the documentation :
  107470. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107471. */
  107472. export class PBRMaterial extends PBRBaseMaterial {
  107473. /**
  107474. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107475. */
  107476. static readonly PBRMATERIAL_OPAQUE: number;
  107477. /**
  107478. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107479. */
  107480. static readonly PBRMATERIAL_ALPHATEST: number;
  107481. /**
  107482. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107483. */
  107484. static readonly PBRMATERIAL_ALPHABLEND: number;
  107485. /**
  107486. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107487. * They are also discarded below the alpha cutoff threshold to improve performances.
  107488. */
  107489. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107490. /**
  107491. * Defines the default value of how much AO map is occluding the analytical lights
  107492. * (point spot...).
  107493. */
  107494. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107495. /**
  107496. * Intensity of the direct lights e.g. the four lights available in your scene.
  107497. * This impacts both the direct diffuse and specular highlights.
  107498. */
  107499. directIntensity: number;
  107500. /**
  107501. * Intensity of the emissive part of the material.
  107502. * This helps controlling the emissive effect without modifying the emissive color.
  107503. */
  107504. emissiveIntensity: number;
  107505. /**
  107506. * Intensity of the environment e.g. how much the environment will light the object
  107507. * either through harmonics for rough material or through the refelction for shiny ones.
  107508. */
  107509. environmentIntensity: number;
  107510. /**
  107511. * This is a special control allowing the reduction of the specular highlights coming from the
  107512. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107513. */
  107514. specularIntensity: number;
  107515. /**
  107516. * Debug Control allowing disabling the bump map on this material.
  107517. */
  107518. disableBumpMap: boolean;
  107519. /**
  107520. * AKA Diffuse Texture in standard nomenclature.
  107521. */
  107522. albedoTexture: BaseTexture;
  107523. /**
  107524. * AKA Occlusion Texture in other nomenclature.
  107525. */
  107526. ambientTexture: BaseTexture;
  107527. /**
  107528. * AKA Occlusion Texture Intensity in other nomenclature.
  107529. */
  107530. ambientTextureStrength: number;
  107531. /**
  107532. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107533. * 1 means it completely occludes it
  107534. * 0 mean it has no impact
  107535. */
  107536. ambientTextureImpactOnAnalyticalLights: number;
  107537. /**
  107538. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  107539. */
  107540. opacityTexture: BaseTexture;
  107541. /**
  107542. * Stores the reflection values in a texture.
  107543. */
  107544. reflectionTexture: Nullable<BaseTexture>;
  107545. /**
  107546. * Stores the emissive values in a texture.
  107547. */
  107548. emissiveTexture: BaseTexture;
  107549. /**
  107550. * AKA Specular texture in other nomenclature.
  107551. */
  107552. reflectivityTexture: BaseTexture;
  107553. /**
  107554. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107555. */
  107556. metallicTexture: BaseTexture;
  107557. /**
  107558. * Specifies the metallic scalar of the metallic/roughness workflow.
  107559. * Can also be used to scale the metalness values of the metallic texture.
  107560. */
  107561. metallic: Nullable<number>;
  107562. /**
  107563. * Specifies the roughness scalar of the metallic/roughness workflow.
  107564. * Can also be used to scale the roughness values of the metallic texture.
  107565. */
  107566. roughness: Nullable<number>;
  107567. /**
  107568. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107569. * By default the indexOfrefraction is used to compute F0;
  107570. *
  107571. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107572. *
  107573. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107574. * F90 = metallicReflectanceColor;
  107575. */
  107576. metallicF0Factor: number;
  107577. /**
  107578. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107579. * By default the F90 is always 1;
  107580. *
  107581. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107582. *
  107583. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107584. * F90 = metallicReflectanceColor;
  107585. */
  107586. metallicReflectanceColor: Color3;
  107587. /**
  107588. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107589. * This is multiply against the scalar values defined in the material.
  107590. */
  107591. metallicReflectanceTexture: Nullable<BaseTexture>;
  107592. /**
  107593. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107594. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107595. */
  107596. microSurfaceTexture: BaseTexture;
  107597. /**
  107598. * Stores surface normal data used to displace a mesh in a texture.
  107599. */
  107600. bumpTexture: BaseTexture;
  107601. /**
  107602. * Stores the pre-calculated light information of a mesh in a texture.
  107603. */
  107604. lightmapTexture: BaseTexture;
  107605. /**
  107606. * Stores the refracted light information in a texture.
  107607. */
  107608. get refractionTexture(): Nullable<BaseTexture>;
  107609. set refractionTexture(value: Nullable<BaseTexture>);
  107610. /**
  107611. * The color of a material in ambient lighting.
  107612. */
  107613. ambientColor: Color3;
  107614. /**
  107615. * AKA Diffuse Color in other nomenclature.
  107616. */
  107617. albedoColor: Color3;
  107618. /**
  107619. * AKA Specular Color in other nomenclature.
  107620. */
  107621. reflectivityColor: Color3;
  107622. /**
  107623. * The color reflected from the material.
  107624. */
  107625. reflectionColor: Color3;
  107626. /**
  107627. * The color emitted from the material.
  107628. */
  107629. emissiveColor: Color3;
  107630. /**
  107631. * AKA Glossiness in other nomenclature.
  107632. */
  107633. microSurface: number;
  107634. /**
  107635. * Index of refraction of the material base layer.
  107636. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107637. *
  107638. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  107639. *
  107640. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  107641. */
  107642. get indexOfRefraction(): number;
  107643. set indexOfRefraction(value: number);
  107644. /**
  107645. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107646. */
  107647. get invertRefractionY(): boolean;
  107648. set invertRefractionY(value: boolean);
  107649. /**
  107650. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107651. * Materials half opaque for instance using refraction could benefit from this control.
  107652. */
  107653. get linkRefractionWithTransparency(): boolean;
  107654. set linkRefractionWithTransparency(value: boolean);
  107655. /**
  107656. * If true, the light map contains occlusion information instead of lighting info.
  107657. */
  107658. useLightmapAsShadowmap: boolean;
  107659. /**
  107660. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107661. */
  107662. useAlphaFromAlbedoTexture: boolean;
  107663. /**
  107664. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107665. */
  107666. forceAlphaTest: boolean;
  107667. /**
  107668. * Defines the alpha limits in alpha test mode.
  107669. */
  107670. alphaCutOff: number;
  107671. /**
  107672. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107673. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107674. */
  107675. useSpecularOverAlpha: boolean;
  107676. /**
  107677. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107678. */
  107679. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107680. /**
  107681. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107682. */
  107683. useRoughnessFromMetallicTextureAlpha: boolean;
  107684. /**
  107685. * Specifies if the metallic texture contains the roughness information in its green channel.
  107686. */
  107687. useRoughnessFromMetallicTextureGreen: boolean;
  107688. /**
  107689. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107690. */
  107691. useMetallnessFromMetallicTextureBlue: boolean;
  107692. /**
  107693. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107694. */
  107695. useAmbientOcclusionFromMetallicTextureRed: boolean;
  107696. /**
  107697. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107698. */
  107699. useAmbientInGrayScale: boolean;
  107700. /**
  107701. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107702. * The material will try to infer what glossiness each pixel should be.
  107703. */
  107704. useAutoMicroSurfaceFromReflectivityMap: boolean;
  107705. /**
  107706. * BJS is using an harcoded light falloff based on a manually sets up range.
  107707. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107708. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107709. */
  107710. get usePhysicalLightFalloff(): boolean;
  107711. /**
  107712. * BJS is using an harcoded light falloff based on a manually sets up range.
  107713. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107714. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107715. */
  107716. set usePhysicalLightFalloff(value: boolean);
  107717. /**
  107718. * In order to support the falloff compatibility with gltf, a special mode has been added
  107719. * to reproduce the gltf light falloff.
  107720. */
  107721. get useGLTFLightFalloff(): boolean;
  107722. /**
  107723. * In order to support the falloff compatibility with gltf, a special mode has been added
  107724. * to reproduce the gltf light falloff.
  107725. */
  107726. set useGLTFLightFalloff(value: boolean);
  107727. /**
  107728. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107729. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107730. */
  107731. useRadianceOverAlpha: boolean;
  107732. /**
  107733. * Allows using an object space normal map (instead of tangent space).
  107734. */
  107735. useObjectSpaceNormalMap: boolean;
  107736. /**
  107737. * Allows using the bump map in parallax mode.
  107738. */
  107739. useParallax: boolean;
  107740. /**
  107741. * Allows using the bump map in parallax occlusion mode.
  107742. */
  107743. useParallaxOcclusion: boolean;
  107744. /**
  107745. * Controls the scale bias of the parallax mode.
  107746. */
  107747. parallaxScaleBias: number;
  107748. /**
  107749. * If sets to true, disables all the lights affecting the material.
  107750. */
  107751. disableLighting: boolean;
  107752. /**
  107753. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107754. */
  107755. forceIrradianceInFragment: boolean;
  107756. /**
  107757. * Number of Simultaneous lights allowed on the material.
  107758. */
  107759. maxSimultaneousLights: number;
  107760. /**
  107761. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107762. */
  107763. invertNormalMapX: boolean;
  107764. /**
  107765. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107766. */
  107767. invertNormalMapY: boolean;
  107768. /**
  107769. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107770. */
  107771. twoSidedLighting: boolean;
  107772. /**
  107773. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107774. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107775. */
  107776. useAlphaFresnel: boolean;
  107777. /**
  107778. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107779. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107780. */
  107781. useLinearAlphaFresnel: boolean;
  107782. /**
  107783. * Let user defines the brdf lookup texture used for IBL.
  107784. * A default 8bit version is embedded but you could point at :
  107785. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107786. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107787. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107788. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107789. */
  107790. environmentBRDFTexture: Nullable<BaseTexture>;
  107791. /**
  107792. * Force normal to face away from face.
  107793. */
  107794. forceNormalForward: boolean;
  107795. /**
  107796. * Enables specular anti aliasing in the PBR shader.
  107797. * It will both interacts on the Geometry for analytical and IBL lighting.
  107798. * It also prefilter the roughness map based on the bump values.
  107799. */
  107800. enableSpecularAntiAliasing: boolean;
  107801. /**
  107802. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107803. * makes the reflect vector face the model (under horizon).
  107804. */
  107805. useHorizonOcclusion: boolean;
  107806. /**
  107807. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107808. * too much the area relying on ambient texture to define their ambient occlusion.
  107809. */
  107810. useRadianceOcclusion: boolean;
  107811. /**
  107812. * If set to true, no lighting calculations will be applied.
  107813. */
  107814. unlit: boolean;
  107815. /**
  107816. * Gets the image processing configuration used either in this material.
  107817. */
  107818. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107819. /**
  107820. * Sets the Default image processing configuration used either in the this material.
  107821. *
  107822. * If sets to null, the scene one is in use.
  107823. */
  107824. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107825. /**
  107826. * Gets wether the color curves effect is enabled.
  107827. */
  107828. get cameraColorCurvesEnabled(): boolean;
  107829. /**
  107830. * Sets wether the color curves effect is enabled.
  107831. */
  107832. set cameraColorCurvesEnabled(value: boolean);
  107833. /**
  107834. * Gets wether the color grading effect is enabled.
  107835. */
  107836. get cameraColorGradingEnabled(): boolean;
  107837. /**
  107838. * Gets wether the color grading effect is enabled.
  107839. */
  107840. set cameraColorGradingEnabled(value: boolean);
  107841. /**
  107842. * Gets wether tonemapping is enabled or not.
  107843. */
  107844. get cameraToneMappingEnabled(): boolean;
  107845. /**
  107846. * Sets wether tonemapping is enabled or not
  107847. */
  107848. set cameraToneMappingEnabled(value: boolean);
  107849. /**
  107850. * The camera exposure used on this material.
  107851. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107852. * This corresponds to a photographic exposure.
  107853. */
  107854. get cameraExposure(): number;
  107855. /**
  107856. * The camera exposure used on this material.
  107857. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107858. * This corresponds to a photographic exposure.
  107859. */
  107860. set cameraExposure(value: number);
  107861. /**
  107862. * Gets The camera contrast used on this material.
  107863. */
  107864. get cameraContrast(): number;
  107865. /**
  107866. * Sets The camera contrast used on this material.
  107867. */
  107868. set cameraContrast(value: number);
  107869. /**
  107870. * Gets the Color Grading 2D Lookup Texture.
  107871. */
  107872. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107873. /**
  107874. * Sets the Color Grading 2D Lookup Texture.
  107875. */
  107876. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107877. /**
  107878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107880. * 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;
  107881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107882. */
  107883. get cameraColorCurves(): Nullable<ColorCurves>;
  107884. /**
  107885. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107886. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107887. * 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;
  107888. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107889. */
  107890. set cameraColorCurves(value: Nullable<ColorCurves>);
  107891. /**
  107892. * Instantiates a new PBRMaterial instance.
  107893. *
  107894. * @param name The material name
  107895. * @param scene The scene the material will be use in.
  107896. */
  107897. constructor(name: string, scene: Scene);
  107898. /**
  107899. * Returns the name of this material class.
  107900. */
  107901. getClassName(): string;
  107902. /**
  107903. * Makes a duplicate of the current material.
  107904. * @param name - name to use for the new material.
  107905. */
  107906. clone(name: string): PBRMaterial;
  107907. /**
  107908. * Serializes this PBR Material.
  107909. * @returns - An object with the serialized material.
  107910. */
  107911. serialize(): any;
  107912. /**
  107913. * Parses a PBR Material from a serialized object.
  107914. * @param source - Serialized object.
  107915. * @param scene - BJS scene instance.
  107916. * @param rootUrl - url for the scene object
  107917. * @returns - PBRMaterial
  107918. */
  107919. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107920. }
  107921. }
  107922. declare module BABYLON {
  107923. /** @hidden */
  107924. export var mrtFragmentDeclaration: {
  107925. name: string;
  107926. shader: string;
  107927. };
  107928. }
  107929. declare module BABYLON {
  107930. /** @hidden */
  107931. export var geometryPixelShader: {
  107932. name: string;
  107933. shader: string;
  107934. };
  107935. }
  107936. declare module BABYLON {
  107937. /** @hidden */
  107938. export var geometryVertexShader: {
  107939. name: string;
  107940. shader: string;
  107941. };
  107942. }
  107943. declare module BABYLON {
  107944. /** @hidden */
  107945. interface ISavedTransformationMatrix {
  107946. world: Matrix;
  107947. viewProjection: Matrix;
  107948. }
  107949. /**
  107950. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107951. */
  107952. export class GeometryBufferRenderer {
  107953. /**
  107954. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  107955. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  107956. */
  107957. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  107958. /**
  107959. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107960. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107961. */
  107962. static readonly POSITION_TEXTURE_TYPE: number;
  107963. /**
  107964. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107965. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107966. */
  107967. static readonly VELOCITY_TEXTURE_TYPE: number;
  107968. /**
  107969. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  107970. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  107971. */
  107972. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  107973. /**
  107974. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107975. * in order to compute objects velocities when enableVelocity is set to "true"
  107976. * @hidden
  107977. */
  107978. _previousTransformationMatrices: {
  107979. [index: number]: ISavedTransformationMatrix;
  107980. };
  107981. /**
  107982. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  107983. * in order to compute objects velocities when enableVelocity is set to "true"
  107984. * @hidden
  107985. */
  107986. _previousBonesTransformationMatrices: {
  107987. [index: number]: Float32Array;
  107988. };
  107989. /**
  107990. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  107991. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  107992. */
  107993. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  107994. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  107995. renderTransparentMeshes: boolean;
  107996. private _scene;
  107997. private _resizeObserver;
  107998. private _multiRenderTarget;
  107999. private _ratio;
  108000. private _enablePosition;
  108001. private _enableVelocity;
  108002. private _enableReflectivity;
  108003. private _positionIndex;
  108004. private _velocityIndex;
  108005. private _reflectivityIndex;
  108006. private _depthNormalIndex;
  108007. private _linkedWithPrePass;
  108008. private _prePassRenderer;
  108009. private _attachments;
  108010. protected _effect: Effect;
  108011. protected _cachedDefines: string;
  108012. /**
  108013. * @hidden
  108014. * Sets up internal structures to share outputs with PrePassRenderer
  108015. * This method should only be called by the PrePassRenderer itself
  108016. */
  108017. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  108018. /**
  108019. * @hidden
  108020. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  108021. * This method should only be called by the PrePassRenderer itself
  108022. */
  108023. _unlinkPrePassRenderer(): void;
  108024. /**
  108025. * @hidden
  108026. * Resets the geometry buffer layout
  108027. */
  108028. _resetLayout(): void;
  108029. /**
  108030. * @hidden
  108031. * Replaces a texture in the geometry buffer renderer
  108032. * Useful when linking textures of the prepass renderer
  108033. */
  108034. _forceTextureType(geometryBufferType: number, index: number): void;
  108035. /**
  108036. * @hidden
  108037. * Sets texture attachments
  108038. * Useful when linking textures of the prepass renderer
  108039. */
  108040. _setAttachments(attachments: number[]): void;
  108041. /**
  108042. * @hidden
  108043. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  108044. * Useful when linking textures of the prepass renderer
  108045. */
  108046. _linkInternalTexture(internalTexture: InternalTexture): void;
  108047. /**
  108048. * Gets the render list (meshes to be rendered) used in the G buffer.
  108049. */
  108050. get renderList(): Nullable<AbstractMesh[]>;
  108051. /**
  108052. * Set the render list (meshes to be rendered) used in the G buffer.
  108053. */
  108054. set renderList(meshes: Nullable<AbstractMesh[]>);
  108055. /**
  108056. * Gets wether or not G buffer are supported by the running hardware.
  108057. * This requires draw buffer supports
  108058. */
  108059. get isSupported(): boolean;
  108060. /**
  108061. * Returns the index of the given texture type in the G-Buffer textures array
  108062. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108063. * @returns the index of the given texture type in the G-Buffer textures array
  108064. */
  108065. getTextureIndex(textureType: number): number;
  108066. /**
  108067. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108068. */
  108069. get enablePosition(): boolean;
  108070. /**
  108071. * Sets whether or not objects positions are enabled for the G buffer.
  108072. */
  108073. set enablePosition(enable: boolean);
  108074. /**
  108075. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108076. */
  108077. get enableVelocity(): boolean;
  108078. /**
  108079. * Sets wether or not objects velocities are enabled for the G buffer.
  108080. */
  108081. set enableVelocity(enable: boolean);
  108082. /**
  108083. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  108084. */
  108085. get enableReflectivity(): boolean;
  108086. /**
  108087. * Sets wether or not objects roughness are enabled for the G buffer.
  108088. */
  108089. set enableReflectivity(enable: boolean);
  108090. /**
  108091. * Gets the scene associated with the buffer.
  108092. */
  108093. get scene(): Scene;
  108094. /**
  108095. * Gets the ratio used by the buffer during its creation.
  108096. * How big is the buffer related to the main canvas.
  108097. */
  108098. get ratio(): number;
  108099. /** @hidden */
  108100. static _SceneComponentInitialization: (scene: Scene) => void;
  108101. /**
  108102. * Creates a new G Buffer for the scene
  108103. * @param scene The scene the buffer belongs to
  108104. * @param ratio How big is the buffer related to the main canvas.
  108105. */
  108106. constructor(scene: Scene, ratio?: number);
  108107. /**
  108108. * Checks wether everything is ready to render a submesh to the G buffer.
  108109. * @param subMesh the submesh to check readiness for
  108110. * @param useInstances is the mesh drawn using instance or not
  108111. * @returns true if ready otherwise false
  108112. */
  108113. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108114. /**
  108115. * Gets the current underlying G Buffer.
  108116. * @returns the buffer
  108117. */
  108118. getGBuffer(): MultiRenderTarget;
  108119. /**
  108120. * Gets the number of samples used to render the buffer (anti aliasing).
  108121. */
  108122. get samples(): number;
  108123. /**
  108124. * Sets the number of samples used to render the buffer (anti aliasing).
  108125. */
  108126. set samples(value: number);
  108127. /**
  108128. * Disposes the renderer and frees up associated resources.
  108129. */
  108130. dispose(): void;
  108131. private _assignRenderTargetIndices;
  108132. protected _createRenderTargets(): void;
  108133. private _copyBonesTransformationMatrices;
  108134. }
  108135. }
  108136. declare module BABYLON {
  108137. /**
  108138. * Renders a pre pass of the scene
  108139. * This means every mesh in the scene will be rendered to a render target texture
  108140. * And then this texture will be composited to the rendering canvas with post processes
  108141. * It is necessary for effects like subsurface scattering or deferred shading
  108142. */
  108143. export class PrePassRenderer {
  108144. /** @hidden */
  108145. static _SceneComponentInitialization: (scene: Scene) => void;
  108146. private _textureFormats;
  108147. /**
  108148. * To save performance, we can excluded skinned meshes from the prepass
  108149. */
  108150. excludedSkinnedMesh: AbstractMesh[];
  108151. /**
  108152. * Force material to be excluded from the prepass
  108153. * Can be useful when `useGeometryBufferFallback` is set to `true`
  108154. * and you don't want a material to show in the effect.
  108155. */
  108156. excludedMaterials: Material[];
  108157. private _textureIndices;
  108158. private _scene;
  108159. private _engine;
  108160. private _isDirty;
  108161. /**
  108162. * Number of textures in the multi render target texture where the scene is directly rendered
  108163. */
  108164. mrtCount: number;
  108165. /**
  108166. * The render target where the scene is directly rendered
  108167. */
  108168. prePassRT: MultiRenderTarget;
  108169. private _multiRenderAttachments;
  108170. private _defaultAttachments;
  108171. private _clearAttachments;
  108172. private _postProcesses;
  108173. private readonly _clearColor;
  108174. /**
  108175. * Image processing post process for composition
  108176. */
  108177. imageProcessingPostProcess: ImageProcessingPostProcess;
  108178. /**
  108179. * Configuration for prepass effects
  108180. */
  108181. private _effectConfigurations;
  108182. private _mrtFormats;
  108183. private _mrtLayout;
  108184. private _enabled;
  108185. /**
  108186. * Indicates if the prepass is enabled
  108187. */
  108188. get enabled(): boolean;
  108189. /**
  108190. * How many samples are used for MSAA of the scene render target
  108191. */
  108192. get samples(): number;
  108193. set samples(n: number);
  108194. private _geometryBuffer;
  108195. private _useGeometryBufferFallback;
  108196. /**
  108197. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  108198. */
  108199. get useGeometryBufferFallback(): boolean;
  108200. set useGeometryBufferFallback(value: boolean);
  108201. /**
  108202. * Instanciates a prepass renderer
  108203. * @param scene The scene
  108204. */
  108205. constructor(scene: Scene);
  108206. private _initializeAttachments;
  108207. private _createCompositionEffect;
  108208. /**
  108209. * Indicates if rendering a prepass is supported
  108210. */
  108211. get isSupported(): boolean;
  108212. /**
  108213. * Sets the proper output textures to draw in the engine.
  108214. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108215. * @param subMesh Submesh on which the effect is applied
  108216. */
  108217. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108218. /**
  108219. * @hidden
  108220. */
  108221. _beforeCameraDraw(): void;
  108222. /**
  108223. * @hidden
  108224. */
  108225. _afterCameraDraw(): void;
  108226. private _checkRTSize;
  108227. private _bindFrameBuffer;
  108228. /**
  108229. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  108230. */
  108231. clear(): void;
  108232. private _setState;
  108233. private _updateGeometryBufferLayout;
  108234. /**
  108235. * Adds an effect configuration to the prepass.
  108236. * If an effect has already been added, it won't add it twice and will return the configuration
  108237. * already present.
  108238. * @param cfg the effect configuration
  108239. * @return the effect configuration now used by the prepass
  108240. */
  108241. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108242. /**
  108243. * Returns the index of a texture in the multi render target texture array.
  108244. * @param type Texture type
  108245. * @return The index
  108246. */
  108247. getIndex(type: number): number;
  108248. private _enable;
  108249. private _disable;
  108250. private _resetLayout;
  108251. private _resetPostProcessChain;
  108252. private _bindPostProcessChain;
  108253. /**
  108254. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108255. */
  108256. markAsDirty(): void;
  108257. /**
  108258. * Enables a texture on the MultiRenderTarget for prepass
  108259. */
  108260. private _enableTextures;
  108261. private _update;
  108262. private _markAllMaterialsAsPrePassDirty;
  108263. /**
  108264. * Disposes the prepass renderer.
  108265. */
  108266. dispose(): void;
  108267. }
  108268. }
  108269. declare module BABYLON {
  108270. /**
  108271. * Size options for a post process
  108272. */
  108273. export type PostProcessOptions = {
  108274. width: number;
  108275. height: number;
  108276. };
  108277. /**
  108278. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108279. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108280. */
  108281. export class PostProcess {
  108282. /**
  108283. * Gets or sets the unique id of the post process
  108284. */
  108285. uniqueId: number;
  108286. /** Name of the PostProcess. */
  108287. name: string;
  108288. /**
  108289. * Width of the texture to apply the post process on
  108290. */
  108291. width: number;
  108292. /**
  108293. * Height of the texture to apply the post process on
  108294. */
  108295. height: number;
  108296. /**
  108297. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108298. */
  108299. nodeMaterialSource: Nullable<NodeMaterial>;
  108300. /**
  108301. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108302. * @hidden
  108303. */
  108304. _outputTexture: Nullable<InternalTexture>;
  108305. /**
  108306. * Sampling mode used by the shader
  108307. * See https://doc.babylonjs.com/classes/3.1/texture
  108308. */
  108309. renderTargetSamplingMode: number;
  108310. /**
  108311. * Clear color to use when screen clearing
  108312. */
  108313. clearColor: Color4;
  108314. /**
  108315. * If the buffer needs to be cleared before applying the post process. (default: true)
  108316. * Should be set to false if shader will overwrite all previous pixels.
  108317. */
  108318. autoClear: boolean;
  108319. /**
  108320. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108321. */
  108322. alphaMode: number;
  108323. /**
  108324. * Sets the setAlphaBlendConstants of the babylon engine
  108325. */
  108326. alphaConstants: Color4;
  108327. /**
  108328. * Animations to be used for the post processing
  108329. */
  108330. animations: Animation[];
  108331. /**
  108332. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108333. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108334. */
  108335. enablePixelPerfectMode: boolean;
  108336. /**
  108337. * Force the postprocess to be applied without taking in account viewport
  108338. */
  108339. forceFullscreenViewport: boolean;
  108340. /**
  108341. * List of inspectable custom properties (used by the Inspector)
  108342. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108343. */
  108344. inspectableCustomProperties: IInspectable[];
  108345. /**
  108346. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108347. *
  108348. * | Value | Type | Description |
  108349. * | ----- | ----------------------------------- | ----------- |
  108350. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108351. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108352. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108353. *
  108354. */
  108355. scaleMode: number;
  108356. /**
  108357. * Force textures to be a power of two (default: false)
  108358. */
  108359. alwaysForcePOT: boolean;
  108360. private _samples;
  108361. /**
  108362. * Number of sample textures (default: 1)
  108363. */
  108364. get samples(): number;
  108365. set samples(n: number);
  108366. /**
  108367. * Modify the scale of the post process to be the same as the viewport (default: false)
  108368. */
  108369. adaptScaleToCurrentViewport: boolean;
  108370. private _camera;
  108371. protected _scene: Scene;
  108372. private _engine;
  108373. private _options;
  108374. private _reusable;
  108375. private _textureType;
  108376. private _textureFormat;
  108377. /**
  108378. * Smart array of input and output textures for the post process.
  108379. * @hidden
  108380. */
  108381. _textures: SmartArray<InternalTexture>;
  108382. /**
  108383. * The index in _textures that corresponds to the output texture.
  108384. * @hidden
  108385. */
  108386. _currentRenderTextureInd: number;
  108387. private _effect;
  108388. private _samplers;
  108389. private _fragmentUrl;
  108390. private _vertexUrl;
  108391. private _parameters;
  108392. private _scaleRatio;
  108393. protected _indexParameters: any;
  108394. private _shareOutputWithPostProcess;
  108395. private _texelSize;
  108396. private _forcedOutputTexture;
  108397. /**
  108398. * Prepass configuration in case this post process needs a texture from prepass
  108399. * @hidden
  108400. */
  108401. _prePassEffectConfiguration: PrePassEffectConfiguration;
  108402. /**
  108403. * Returns the fragment url or shader name used in the post process.
  108404. * @returns the fragment url or name in the shader store.
  108405. */
  108406. getEffectName(): string;
  108407. /**
  108408. * An event triggered when the postprocess is activated.
  108409. */
  108410. onActivateObservable: Observable<Camera>;
  108411. private _onActivateObserver;
  108412. /**
  108413. * A function that is added to the onActivateObservable
  108414. */
  108415. set onActivate(callback: Nullable<(camera: Camera) => void>);
  108416. /**
  108417. * An event triggered when the postprocess changes its size.
  108418. */
  108419. onSizeChangedObservable: Observable<PostProcess>;
  108420. private _onSizeChangedObserver;
  108421. /**
  108422. * A function that is added to the onSizeChangedObservable
  108423. */
  108424. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  108425. /**
  108426. * An event triggered when the postprocess applies its effect.
  108427. */
  108428. onApplyObservable: Observable<Effect>;
  108429. private _onApplyObserver;
  108430. /**
  108431. * A function that is added to the onApplyObservable
  108432. */
  108433. set onApply(callback: (effect: Effect) => void);
  108434. /**
  108435. * An event triggered before rendering the postprocess
  108436. */
  108437. onBeforeRenderObservable: Observable<Effect>;
  108438. private _onBeforeRenderObserver;
  108439. /**
  108440. * A function that is added to the onBeforeRenderObservable
  108441. */
  108442. set onBeforeRender(callback: (effect: Effect) => void);
  108443. /**
  108444. * An event triggered after rendering the postprocess
  108445. */
  108446. onAfterRenderObservable: Observable<Effect>;
  108447. private _onAfterRenderObserver;
  108448. /**
  108449. * A function that is added to the onAfterRenderObservable
  108450. */
  108451. set onAfterRender(callback: (efect: Effect) => void);
  108452. /**
  108453. * 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
  108454. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  108455. */
  108456. get inputTexture(): InternalTexture;
  108457. set inputTexture(value: InternalTexture);
  108458. /**
  108459. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  108460. * the only way to unset it is to use this function to restore its internal state
  108461. */
  108462. restoreDefaultInputTexture(): void;
  108463. /**
  108464. * Gets the camera which post process is applied to.
  108465. * @returns The camera the post process is applied to.
  108466. */
  108467. getCamera(): Camera;
  108468. /**
  108469. * Gets the texel size of the postprocess.
  108470. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  108471. */
  108472. get texelSize(): Vector2;
  108473. /**
  108474. * Creates a new instance PostProcess
  108475. * @param name The name of the PostProcess.
  108476. * @param fragmentUrl The url of the fragment shader to be used.
  108477. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  108478. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  108479. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108480. * @param camera The camera to apply the render pass to.
  108481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108482. * @param engine The engine which the post process will be applied. (default: current engine)
  108483. * @param reusable If the post process can be reused on the same frame. (default: false)
  108484. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  108485. * @param textureType Type of textures used when performing the post process. (default: 0)
  108486. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  108487. * @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
  108488. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  108489. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  108490. */
  108491. 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);
  108492. /**
  108493. * Gets a string identifying the name of the class
  108494. * @returns "PostProcess" string
  108495. */
  108496. getClassName(): string;
  108497. /**
  108498. * Gets the engine which this post process belongs to.
  108499. * @returns The engine the post process was enabled with.
  108500. */
  108501. getEngine(): Engine;
  108502. /**
  108503. * The effect that is created when initializing the post process.
  108504. * @returns The created effect corresponding the the postprocess.
  108505. */
  108506. getEffect(): Effect;
  108507. /**
  108508. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  108509. * @param postProcess The post process to share the output with.
  108510. * @returns This post process.
  108511. */
  108512. shareOutputWith(postProcess: PostProcess): PostProcess;
  108513. /**
  108514. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  108515. * This should be called if the post process that shares output with this post process is disabled/disposed.
  108516. */
  108517. useOwnOutput(): void;
  108518. /**
  108519. * Updates the effect with the current post process compile time values and recompiles the shader.
  108520. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108521. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108522. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108523. * @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
  108524. * @param onCompiled Called when the shader has been compiled.
  108525. * @param onError Called if there is an error when compiling a shader.
  108526. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  108527. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  108528. */
  108529. 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;
  108530. /**
  108531. * The post process is reusable if it can be used multiple times within one frame.
  108532. * @returns If the post process is reusable
  108533. */
  108534. isReusable(): boolean;
  108535. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  108536. markTextureDirty(): void;
  108537. /**
  108538. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  108539. * 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.
  108540. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  108541. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  108542. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  108543. * @returns The target texture that was bound to be written to.
  108544. */
  108545. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  108546. /**
  108547. * If the post process is supported.
  108548. */
  108549. get isSupported(): boolean;
  108550. /**
  108551. * The aspect ratio of the output texture.
  108552. */
  108553. get aspectRatio(): number;
  108554. /**
  108555. * Get a value indicating if the post-process is ready to be used
  108556. * @returns true if the post-process is ready (shader is compiled)
  108557. */
  108558. isReady(): boolean;
  108559. /**
  108560. * Binds all textures and uniforms to the shader, this will be run on every pass.
  108561. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  108562. */
  108563. apply(): Nullable<Effect>;
  108564. private _disposeTextures;
  108565. /**
  108566. * Sets the required values to the prepass renderer.
  108567. * @param prePassRenderer defines the prepass renderer to setup.
  108568. * @returns true if the pre pass is needed.
  108569. */
  108570. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108571. /**
  108572. * Disposes the post process.
  108573. * @param camera The camera to dispose the post process on.
  108574. */
  108575. dispose(camera?: Camera): void;
  108576. /**
  108577. * Serializes the particle system to a JSON object
  108578. * @returns the JSON object
  108579. */
  108580. serialize(): any;
  108581. /**
  108582. * Creates a material from parsed material data
  108583. * @param parsedPostProcess defines parsed post process data
  108584. * @param scene defines the hosting scene
  108585. * @param rootUrl defines the root URL to use to load textures
  108586. * @returns a new post process
  108587. */
  108588. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  108589. }
  108590. }
  108591. declare module BABYLON {
  108592. /** @hidden */
  108593. export var kernelBlurVaryingDeclaration: {
  108594. name: string;
  108595. shader: string;
  108596. };
  108597. }
  108598. declare module BABYLON {
  108599. /** @hidden */
  108600. export var kernelBlurFragment: {
  108601. name: string;
  108602. shader: string;
  108603. };
  108604. }
  108605. declare module BABYLON {
  108606. /** @hidden */
  108607. export var kernelBlurFragment2: {
  108608. name: string;
  108609. shader: string;
  108610. };
  108611. }
  108612. declare module BABYLON {
  108613. /** @hidden */
  108614. export var kernelBlurPixelShader: {
  108615. name: string;
  108616. shader: string;
  108617. };
  108618. }
  108619. declare module BABYLON {
  108620. /** @hidden */
  108621. export var kernelBlurVertex: {
  108622. name: string;
  108623. shader: string;
  108624. };
  108625. }
  108626. declare module BABYLON {
  108627. /** @hidden */
  108628. export var kernelBlurVertexShader: {
  108629. name: string;
  108630. shader: string;
  108631. };
  108632. }
  108633. declare module BABYLON {
  108634. /**
  108635. * The Blur Post Process which blurs an image based on a kernel and direction.
  108636. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  108637. */
  108638. export class BlurPostProcess extends PostProcess {
  108639. private blockCompilation;
  108640. protected _kernel: number;
  108641. protected _idealKernel: number;
  108642. protected _packedFloat: boolean;
  108643. private _staticDefines;
  108644. /** The direction in which to blur the image. */
  108645. direction: Vector2;
  108646. /**
  108647. * Sets the length in pixels of the blur sample region
  108648. */
  108649. set kernel(v: number);
  108650. /**
  108651. * Gets the length in pixels of the blur sample region
  108652. */
  108653. get kernel(): number;
  108654. /**
  108655. * Sets wether or not the blur needs to unpack/repack floats
  108656. */
  108657. set packedFloat(v: boolean);
  108658. /**
  108659. * Gets wether or not the blur is unpacking/repacking floats
  108660. */
  108661. get packedFloat(): boolean;
  108662. /**
  108663. * Gets a string identifying the name of the class
  108664. * @returns "BlurPostProcess" string
  108665. */
  108666. getClassName(): string;
  108667. /**
  108668. * Creates a new instance BlurPostProcess
  108669. * @param name The name of the effect.
  108670. * @param direction The direction in which to blur the image.
  108671. * @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.
  108672. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108673. * @param camera The camera to apply the render pass to.
  108674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108675. * @param engine The engine which the post process will be applied. (default: current engine)
  108676. * @param reusable If the post process can be reused on the same frame. (default: false)
  108677. * @param textureType Type of textures used when performing the post process. (default: 0)
  108678. * @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)
  108679. */
  108680. 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);
  108681. /**
  108682. * Updates the effect with the current post process compile time values and recompiles the shader.
  108683. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108684. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108685. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108686. * @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
  108687. * @param onCompiled Called when the shader has been compiled.
  108688. * @param onError Called if there is an error when compiling a shader.
  108689. */
  108690. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108691. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108692. /**
  108693. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  108694. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  108695. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  108696. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  108697. * The gaps between physical kernels are compensated for in the weighting of the samples
  108698. * @param idealKernel Ideal blur kernel.
  108699. * @return Nearest best kernel.
  108700. */
  108701. protected _nearestBestKernel(idealKernel: number): number;
  108702. /**
  108703. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  108704. * @param x The point on the Gaussian distribution to sample.
  108705. * @return the value of the Gaussian function at x.
  108706. */
  108707. protected _gaussianWeight(x: number): number;
  108708. /**
  108709. * Generates a string that can be used as a floating point number in GLSL.
  108710. * @param x Value to print.
  108711. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  108712. * @return GLSL float string.
  108713. */
  108714. protected _glslFloat(x: number, decimalFigures?: number): string;
  108715. /** @hidden */
  108716. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  108717. }
  108718. }
  108719. declare module BABYLON {
  108720. /**
  108721. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108722. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108723. * You can then easily use it as a reflectionTexture on a flat surface.
  108724. * In case the surface is not a plane, please consider relying on reflection probes.
  108725. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108726. */
  108727. export class MirrorTexture extends RenderTargetTexture {
  108728. private scene;
  108729. /**
  108730. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  108731. * 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.
  108732. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108733. */
  108734. mirrorPlane: Plane;
  108735. /**
  108736. * Define the blur ratio used to blur the reflection if needed.
  108737. */
  108738. set blurRatio(value: number);
  108739. get blurRatio(): number;
  108740. /**
  108741. * Define the adaptive blur kernel used to blur the reflection if needed.
  108742. * This will autocompute the closest best match for the `blurKernel`
  108743. */
  108744. set adaptiveBlurKernel(value: number);
  108745. /**
  108746. * Define the blur kernel used to blur the reflection if needed.
  108747. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108748. */
  108749. set blurKernel(value: number);
  108750. /**
  108751. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108752. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108753. */
  108754. set blurKernelX(value: number);
  108755. get blurKernelX(): number;
  108756. /**
  108757. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108758. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108759. */
  108760. set blurKernelY(value: number);
  108761. get blurKernelY(): number;
  108762. private _autoComputeBlurKernel;
  108763. protected _onRatioRescale(): void;
  108764. private _updateGammaSpace;
  108765. private _imageProcessingConfigChangeObserver;
  108766. private _transformMatrix;
  108767. private _mirrorMatrix;
  108768. private _savedViewMatrix;
  108769. private _blurX;
  108770. private _blurY;
  108771. private _adaptiveBlurKernel;
  108772. private _blurKernelX;
  108773. private _blurKernelY;
  108774. private _blurRatio;
  108775. /**
  108776. * Instantiates a Mirror Texture.
  108777. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108778. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108779. * You can then easily use it as a reflectionTexture on a flat surface.
  108780. * In case the surface is not a plane, please consider relying on reflection probes.
  108781. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108782. * @param name
  108783. * @param size
  108784. * @param scene
  108785. * @param generateMipMaps
  108786. * @param type
  108787. * @param samplingMode
  108788. * @param generateDepthBuffer
  108789. */
  108790. constructor(name: string, size: number | {
  108791. width: number;
  108792. height: number;
  108793. } | {
  108794. ratio: number;
  108795. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108796. private _preparePostProcesses;
  108797. /**
  108798. * Clone the mirror texture.
  108799. * @returns the cloned texture
  108800. */
  108801. clone(): MirrorTexture;
  108802. /**
  108803. * Serialize the texture to a JSON representation you could use in Parse later on
  108804. * @returns the serialized JSON representation
  108805. */
  108806. serialize(): any;
  108807. /**
  108808. * Dispose the texture and release its associated resources.
  108809. */
  108810. dispose(): void;
  108811. }
  108812. }
  108813. declare module BABYLON {
  108814. /**
  108815. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108816. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108817. */
  108818. export class Texture extends BaseTexture {
  108819. /**
  108820. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108821. */
  108822. static SerializeBuffers: boolean;
  108823. /** @hidden */
  108824. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108825. /** @hidden */
  108826. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108827. /** @hidden */
  108828. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108829. /** nearest is mag = nearest and min = nearest and mip = linear */
  108830. static readonly NEAREST_SAMPLINGMODE: number;
  108831. /** nearest is mag = nearest and min = nearest and mip = linear */
  108832. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108833. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108834. static readonly BILINEAR_SAMPLINGMODE: number;
  108835. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108836. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108837. /** Trilinear is mag = linear and min = linear and mip = linear */
  108838. static readonly TRILINEAR_SAMPLINGMODE: number;
  108839. /** Trilinear is mag = linear and min = linear and mip = linear */
  108840. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108841. /** mag = nearest and min = nearest and mip = nearest */
  108842. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108843. /** mag = nearest and min = linear and mip = nearest */
  108844. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108845. /** mag = nearest and min = linear and mip = linear */
  108846. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108847. /** mag = nearest and min = linear and mip = none */
  108848. static readonly NEAREST_LINEAR: number;
  108849. /** mag = nearest and min = nearest and mip = none */
  108850. static readonly NEAREST_NEAREST: number;
  108851. /** mag = linear and min = nearest and mip = nearest */
  108852. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108853. /** mag = linear and min = nearest and mip = linear */
  108854. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108855. /** mag = linear and min = linear and mip = none */
  108856. static readonly LINEAR_LINEAR: number;
  108857. /** mag = linear and min = nearest and mip = none */
  108858. static readonly LINEAR_NEAREST: number;
  108859. /** Explicit coordinates mode */
  108860. static readonly EXPLICIT_MODE: number;
  108861. /** Spherical coordinates mode */
  108862. static readonly SPHERICAL_MODE: number;
  108863. /** Planar coordinates mode */
  108864. static readonly PLANAR_MODE: number;
  108865. /** Cubic coordinates mode */
  108866. static readonly CUBIC_MODE: number;
  108867. /** Projection coordinates mode */
  108868. static readonly PROJECTION_MODE: number;
  108869. /** Inverse Cubic coordinates mode */
  108870. static readonly SKYBOX_MODE: number;
  108871. /** Inverse Cubic coordinates mode */
  108872. static readonly INVCUBIC_MODE: number;
  108873. /** Equirectangular coordinates mode */
  108874. static readonly EQUIRECTANGULAR_MODE: number;
  108875. /** Equirectangular Fixed coordinates mode */
  108876. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108877. /** Equirectangular Fixed Mirrored coordinates mode */
  108878. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108879. /** Texture is not repeating outside of 0..1 UVs */
  108880. static readonly CLAMP_ADDRESSMODE: number;
  108881. /** Texture is repeating outside of 0..1 UVs */
  108882. static readonly WRAP_ADDRESSMODE: number;
  108883. /** Texture is repeating and mirrored */
  108884. static readonly MIRROR_ADDRESSMODE: number;
  108885. /**
  108886. * 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
  108887. */
  108888. static UseSerializedUrlIfAny: boolean;
  108889. /**
  108890. * Define the url of the texture.
  108891. */
  108892. url: Nullable<string>;
  108893. /**
  108894. * Define an offset on the texture to offset the u coordinates of the UVs
  108895. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108896. */
  108897. uOffset: number;
  108898. /**
  108899. * Define an offset on the texture to offset the v coordinates of the UVs
  108900. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108901. */
  108902. vOffset: number;
  108903. /**
  108904. * Define an offset on the texture to scale the u coordinates of the UVs
  108905. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108906. */
  108907. uScale: number;
  108908. /**
  108909. * Define an offset on the texture to scale the v coordinates of the UVs
  108910. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108911. */
  108912. vScale: number;
  108913. /**
  108914. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108915. * @see https://doc.babylonjs.com/how_to/more_materials
  108916. */
  108917. uAng: number;
  108918. /**
  108919. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108920. * @see https://doc.babylonjs.com/how_to/more_materials
  108921. */
  108922. vAng: number;
  108923. /**
  108924. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108925. * @see https://doc.babylonjs.com/how_to/more_materials
  108926. */
  108927. wAng: number;
  108928. /**
  108929. * Defines the center of rotation (U)
  108930. */
  108931. uRotationCenter: number;
  108932. /**
  108933. * Defines the center of rotation (V)
  108934. */
  108935. vRotationCenter: number;
  108936. /**
  108937. * Defines the center of rotation (W)
  108938. */
  108939. wRotationCenter: number;
  108940. /**
  108941. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108942. */
  108943. homogeneousRotationInUVTransform: boolean;
  108944. /**
  108945. * Are mip maps generated for this texture or not.
  108946. */
  108947. get noMipmap(): boolean;
  108948. /**
  108949. * List of inspectable custom properties (used by the Inspector)
  108950. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108951. */
  108952. inspectableCustomProperties: Nullable<IInspectable[]>;
  108953. private _noMipmap;
  108954. /** @hidden */
  108955. _invertY: boolean;
  108956. private _rowGenerationMatrix;
  108957. private _cachedTextureMatrix;
  108958. private _projectionModeMatrix;
  108959. private _t0;
  108960. private _t1;
  108961. private _t2;
  108962. private _cachedUOffset;
  108963. private _cachedVOffset;
  108964. private _cachedUScale;
  108965. private _cachedVScale;
  108966. private _cachedUAng;
  108967. private _cachedVAng;
  108968. private _cachedWAng;
  108969. private _cachedProjectionMatrixId;
  108970. private _cachedURotationCenter;
  108971. private _cachedVRotationCenter;
  108972. private _cachedWRotationCenter;
  108973. private _cachedHomogeneousRotationInUVTransform;
  108974. private _cachedCoordinatesMode;
  108975. /** @hidden */
  108976. protected _initialSamplingMode: number;
  108977. /** @hidden */
  108978. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108979. private _deleteBuffer;
  108980. protected _format: Nullable<number>;
  108981. private _delayedOnLoad;
  108982. private _delayedOnError;
  108983. private _mimeType?;
  108984. private _loaderOptions?;
  108985. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  108986. get mimeType(): string | undefined;
  108987. /**
  108988. * Observable triggered once the texture has been loaded.
  108989. */
  108990. onLoadObservable: Observable<Texture>;
  108991. protected _isBlocking: boolean;
  108992. /**
  108993. * Is the texture preventing material to render while loading.
  108994. * If false, a default texture will be used instead of the loading one during the preparation step.
  108995. */
  108996. set isBlocking(value: boolean);
  108997. get isBlocking(): boolean;
  108998. /**
  108999. * Get the current sampling mode associated with the texture.
  109000. */
  109001. get samplingMode(): number;
  109002. /**
  109003. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  109004. */
  109005. get invertY(): boolean;
  109006. /**
  109007. * Instantiates a new texture.
  109008. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109009. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109010. * @param url defines the url of the picture to load as a texture
  109011. * @param sceneOrEngine defines the scene or engine the texture will belong to
  109012. * @param noMipmap defines if the texture will require mip maps or not
  109013. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  109014. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109015. * @param onLoad defines a callback triggered when the texture has been loaded
  109016. * @param onError defines a callback triggered when an error occurred during the loading session
  109017. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  109018. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  109019. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109020. * @param mimeType defines an optional mime type information
  109021. * @param loaderOptions options to be passed to the loader
  109022. */
  109023. 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, loaderOptions?: any);
  109024. /**
  109025. * Update the url (and optional buffer) of this texture if url was null during construction.
  109026. * @param url the url of the texture
  109027. * @param buffer the buffer of the texture (defaults to null)
  109028. * @param onLoad callback called when the texture is loaded (defaults to null)
  109029. */
  109030. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  109031. /**
  109032. * Finish the loading sequence of a texture flagged as delayed load.
  109033. * @hidden
  109034. */
  109035. delayLoad(): void;
  109036. private _prepareRowForTextureGeneration;
  109037. /**
  109038. * Checks if the texture has the same transform matrix than another texture
  109039. * @param texture texture to check against
  109040. * @returns true if the transforms are the same, else false
  109041. */
  109042. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  109043. /**
  109044. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  109045. * @returns the transform matrix of the texture.
  109046. */
  109047. getTextureMatrix(uBase?: number): Matrix;
  109048. /**
  109049. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  109050. * @returns The reflection texture transform
  109051. */
  109052. getReflectionTextureMatrix(): Matrix;
  109053. /**
  109054. * Clones the texture.
  109055. * @returns the cloned texture
  109056. */
  109057. clone(): Texture;
  109058. /**
  109059. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109060. * @returns The JSON representation of the texture
  109061. */
  109062. serialize(): any;
  109063. /**
  109064. * Get the current class name of the texture useful for serialization or dynamic coding.
  109065. * @returns "Texture"
  109066. */
  109067. getClassName(): string;
  109068. /**
  109069. * Dispose the texture and release its associated resources.
  109070. */
  109071. dispose(): void;
  109072. /**
  109073. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  109074. * @param parsedTexture Define the JSON representation of the texture
  109075. * @param scene Define the scene the parsed texture should be instantiated in
  109076. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  109077. * @returns The parsed texture if successful
  109078. */
  109079. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  109080. /**
  109081. * Creates a texture from its base 64 representation.
  109082. * @param data Define the base64 payload without the data: prefix
  109083. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109084. * @param scene Define the scene the texture should belong to
  109085. * @param noMipmap Forces the texture to not create mip map information if true
  109086. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109087. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109088. * @param onLoad define a callback triggered when the texture has been loaded
  109089. * @param onError define a callback triggered when an error occurred during the loading session
  109090. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109091. * @returns the created texture
  109092. */
  109093. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  109094. /**
  109095. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  109096. * @param data Define the base64 payload without the data: prefix
  109097. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109098. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  109099. * @param scene Define the scene the texture should belong to
  109100. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  109101. * @param noMipmap Forces the texture to not create mip map information if true
  109102. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109103. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109104. * @param onLoad define a callback triggered when the texture has been loaded
  109105. * @param onError define a callback triggered when an error occurred during the loading session
  109106. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109107. * @returns the created texture
  109108. */
  109109. 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;
  109110. }
  109111. }
  109112. declare module BABYLON {
  109113. /**
  109114. * PostProcessManager is used to manage one or more post processes or post process pipelines
  109115. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109116. */
  109117. export class PostProcessManager {
  109118. private _scene;
  109119. private _indexBuffer;
  109120. private _vertexBuffers;
  109121. /**
  109122. * Creates a new instance PostProcess
  109123. * @param scene The scene that the post process is associated with.
  109124. */
  109125. constructor(scene: Scene);
  109126. private _prepareBuffers;
  109127. private _buildIndexBuffer;
  109128. /**
  109129. * Rebuilds the vertex buffers of the manager.
  109130. * @hidden
  109131. */
  109132. _rebuild(): void;
  109133. /**
  109134. * Prepares a frame to be run through a post process.
  109135. * @param sourceTexture The input texture to the post procesess. (default: null)
  109136. * @param postProcesses An array of post processes to be run. (default: null)
  109137. * @returns True if the post processes were able to be run.
  109138. * @hidden
  109139. */
  109140. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  109141. /**
  109142. * Manually render a set of post processes to a texture.
  109143. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  109144. * @param postProcesses An array of post processes to be run.
  109145. * @param targetTexture The target texture to render to.
  109146. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  109147. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  109148. * @param lodLevel defines which lod of the texture to render to
  109149. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  109150. */
  109151. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  109152. /**
  109153. * Finalize the result of the output of the postprocesses.
  109154. * @param doNotPresent If true the result will not be displayed to the screen.
  109155. * @param targetTexture The target texture to render to.
  109156. * @param faceIndex The index of the face to bind the target texture to.
  109157. * @param postProcesses The array of post processes to render.
  109158. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  109159. * @hidden
  109160. */
  109161. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  109162. /**
  109163. * Disposes of the post process manager.
  109164. */
  109165. dispose(): void;
  109166. }
  109167. }
  109168. declare module BABYLON {
  109169. /**
  109170. * This Helps creating a texture that will be created from a camera in your scene.
  109171. * It is basically a dynamic texture that could be used to create special effects for instance.
  109172. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  109173. */
  109174. export class RenderTargetTexture extends Texture {
  109175. /**
  109176. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  109177. */
  109178. static readonly REFRESHRATE_RENDER_ONCE: number;
  109179. /**
  109180. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  109181. */
  109182. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  109183. /**
  109184. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  109185. * the central point of your effect and can save a lot of performances.
  109186. */
  109187. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  109188. /**
  109189. * Use this predicate to dynamically define the list of mesh you want to render.
  109190. * If set, the renderList property will be overwritten.
  109191. */
  109192. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  109193. private _renderList;
  109194. /**
  109195. * Use this list to define the list of mesh you want to render.
  109196. */
  109197. get renderList(): Nullable<Array<AbstractMesh>>;
  109198. set renderList(value: Nullable<Array<AbstractMesh>>);
  109199. /**
  109200. * Use this function to overload the renderList array at rendering time.
  109201. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  109202. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  109203. * the cube (if the RTT is a cube, else layerOrFace=0).
  109204. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  109205. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  109206. * hold dummy elements!
  109207. */
  109208. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  109209. private _hookArray;
  109210. /**
  109211. * Define if particles should be rendered in your texture.
  109212. */
  109213. renderParticles: boolean;
  109214. /**
  109215. * Define if sprites should be rendered in your texture.
  109216. */
  109217. renderSprites: boolean;
  109218. /**
  109219. * Define the camera used to render the texture.
  109220. */
  109221. activeCamera: Nullable<Camera>;
  109222. /**
  109223. * Override the mesh isReady function with your own one.
  109224. */
  109225. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  109226. /**
  109227. * Override the render function of the texture with your own one.
  109228. */
  109229. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  109230. /**
  109231. * Define if camera post processes should be use while rendering the texture.
  109232. */
  109233. useCameraPostProcesses: boolean;
  109234. /**
  109235. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  109236. */
  109237. ignoreCameraViewport: boolean;
  109238. private _postProcessManager;
  109239. private _postProcesses;
  109240. private _resizeObserver;
  109241. /**
  109242. * An event triggered when the texture is unbind.
  109243. */
  109244. onBeforeBindObservable: Observable<RenderTargetTexture>;
  109245. /**
  109246. * An event triggered when the texture is unbind.
  109247. */
  109248. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  109249. private _onAfterUnbindObserver;
  109250. /**
  109251. * Set a after unbind callback in the texture.
  109252. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109253. */
  109254. set onAfterUnbind(callback: () => void);
  109255. /**
  109256. * An event triggered before rendering the texture
  109257. */
  109258. onBeforeRenderObservable: Observable<number>;
  109259. private _onBeforeRenderObserver;
  109260. /**
  109261. * Set a before render callback in the texture.
  109262. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109263. */
  109264. set onBeforeRender(callback: (faceIndex: number) => void);
  109265. /**
  109266. * An event triggered after rendering the texture
  109267. */
  109268. onAfterRenderObservable: Observable<number>;
  109269. private _onAfterRenderObserver;
  109270. /**
  109271. * Set a after render callback in the texture.
  109272. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109273. */
  109274. set onAfterRender(callback: (faceIndex: number) => void);
  109275. /**
  109276. * An event triggered after the texture clear
  109277. */
  109278. onClearObservable: Observable<Engine>;
  109279. private _onClearObserver;
  109280. /**
  109281. * Set a clear callback in the texture.
  109282. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  109283. */
  109284. set onClear(callback: (Engine: Engine) => void);
  109285. /**
  109286. * An event triggered when the texture is resized.
  109287. */
  109288. onResizeObservable: Observable<RenderTargetTexture>;
  109289. /**
  109290. * Define the clear color of the Render Target if it should be different from the scene.
  109291. */
  109292. clearColor: Color4;
  109293. protected _size: number | {
  109294. width: number;
  109295. height: number;
  109296. layers?: number;
  109297. };
  109298. protected _initialSizeParameter: number | {
  109299. width: number;
  109300. height: number;
  109301. } | {
  109302. ratio: number;
  109303. };
  109304. protected _sizeRatio: Nullable<number>;
  109305. /** @hidden */
  109306. _generateMipMaps: boolean;
  109307. protected _renderingManager: RenderingManager;
  109308. /** @hidden */
  109309. _waitingRenderList?: string[];
  109310. protected _doNotChangeAspectRatio: boolean;
  109311. protected _currentRefreshId: number;
  109312. protected _refreshRate: number;
  109313. protected _textureMatrix: Matrix;
  109314. protected _samples: number;
  109315. protected _renderTargetOptions: RenderTargetCreationOptions;
  109316. /**
  109317. * Gets render target creation options that were used.
  109318. */
  109319. get renderTargetOptions(): RenderTargetCreationOptions;
  109320. protected _onRatioRescale(): void;
  109321. /**
  109322. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  109323. * It must define where the camera used to render the texture is set
  109324. */
  109325. boundingBoxPosition: Vector3;
  109326. private _boundingBoxSize;
  109327. /**
  109328. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  109329. * When defined, the cubemap will switch to local mode
  109330. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  109331. * @example https://www.babylonjs-playground.com/#RNASML
  109332. */
  109333. set boundingBoxSize(value: Vector3);
  109334. get boundingBoxSize(): Vector3;
  109335. /**
  109336. * In case the RTT has been created with a depth texture, get the associated
  109337. * depth texture.
  109338. * Otherwise, return null.
  109339. */
  109340. get depthStencilTexture(): Nullable<InternalTexture>;
  109341. /**
  109342. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  109343. * or used a shadow, depth texture...
  109344. * @param name The friendly name of the texture
  109345. * @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)
  109346. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  109347. * @param generateMipMaps True if mip maps need to be generated after render.
  109348. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  109349. * @param type The type of the buffer in the RTT (int, half float, float...)
  109350. * @param isCube True if a cube texture needs to be created
  109351. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  109352. * @param generateDepthBuffer True to generate a depth buffer
  109353. * @param generateStencilBuffer True to generate a stencil buffer
  109354. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  109355. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  109356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109357. */
  109358. constructor(name: string, size: number | {
  109359. width: number;
  109360. height: number;
  109361. layers?: number;
  109362. } | {
  109363. ratio: number;
  109364. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  109365. /**
  109366. * Creates a depth stencil texture.
  109367. * This is only available in WebGL 2 or with the depth texture extension available.
  109368. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  109369. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  109370. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  109371. */
  109372. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  109373. private _processSizeParameter;
  109374. /**
  109375. * Define the number of samples to use in case of MSAA.
  109376. * It defaults to one meaning no MSAA has been enabled.
  109377. */
  109378. get samples(): number;
  109379. set samples(value: number);
  109380. /**
  109381. * Resets the refresh counter of the texture and start bak from scratch.
  109382. * Could be useful to regenerate the texture if it is setup to render only once.
  109383. */
  109384. resetRefreshCounter(): void;
  109385. /**
  109386. * Define the refresh rate of the texture or the rendering frequency.
  109387. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  109388. */
  109389. get refreshRate(): number;
  109390. set refreshRate(value: number);
  109391. /**
  109392. * Adds a post process to the render target rendering passes.
  109393. * @param postProcess define the post process to add
  109394. */
  109395. addPostProcess(postProcess: PostProcess): void;
  109396. /**
  109397. * Clear all the post processes attached to the render target
  109398. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  109399. */
  109400. clearPostProcesses(dispose?: boolean): void;
  109401. /**
  109402. * Remove one of the post process from the list of attached post processes to the texture
  109403. * @param postProcess define the post process to remove from the list
  109404. */
  109405. removePostProcess(postProcess: PostProcess): void;
  109406. /** @hidden */
  109407. _shouldRender(): boolean;
  109408. /**
  109409. * Gets the actual render size of the texture.
  109410. * @returns the width of the render size
  109411. */
  109412. getRenderSize(): number;
  109413. /**
  109414. * Gets the actual render width of the texture.
  109415. * @returns the width of the render size
  109416. */
  109417. getRenderWidth(): number;
  109418. /**
  109419. * Gets the actual render height of the texture.
  109420. * @returns the height of the render size
  109421. */
  109422. getRenderHeight(): number;
  109423. /**
  109424. * Gets the actual number of layers of the texture.
  109425. * @returns the number of layers
  109426. */
  109427. getRenderLayers(): number;
  109428. /**
  109429. * Get if the texture can be rescaled or not.
  109430. */
  109431. get canRescale(): boolean;
  109432. /**
  109433. * Resize the texture using a ratio.
  109434. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  109435. */
  109436. scale(ratio: number): void;
  109437. /**
  109438. * Get the texture reflection matrix used to rotate/transform the reflection.
  109439. * @returns the reflection matrix
  109440. */
  109441. getReflectionTextureMatrix(): Matrix;
  109442. /**
  109443. * Resize the texture to a new desired size.
  109444. * Be carrefull as it will recreate all the data in the new texture.
  109445. * @param size Define the new size. It can be:
  109446. * - a number for squared texture,
  109447. * - an object containing { width: number, height: number }
  109448. * - or an object containing a ratio { ratio: number }
  109449. */
  109450. resize(size: number | {
  109451. width: number;
  109452. height: number;
  109453. } | {
  109454. ratio: number;
  109455. }): void;
  109456. private _defaultRenderListPrepared;
  109457. /**
  109458. * Renders all the objects from the render list into the texture.
  109459. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  109460. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  109461. */
  109462. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  109463. private _bestReflectionRenderTargetDimension;
  109464. private _prepareRenderingManager;
  109465. /**
  109466. * @hidden
  109467. * @param faceIndex face index to bind to if this is a cubetexture
  109468. * @param layer defines the index of the texture to bind in the array
  109469. */
  109470. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  109471. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109472. private renderToTarget;
  109473. /**
  109474. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109475. * This allowed control for front to back rendering or reversly depending of the special needs.
  109476. *
  109477. * @param renderingGroupId The rendering group id corresponding to its index
  109478. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109479. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109480. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109481. */
  109482. 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;
  109483. /**
  109484. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109485. *
  109486. * @param renderingGroupId The rendering group id corresponding to its index
  109487. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109488. */
  109489. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  109490. /**
  109491. * Clones the texture.
  109492. * @returns the cloned texture
  109493. */
  109494. clone(): RenderTargetTexture;
  109495. /**
  109496. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109497. * @returns The JSON representation of the texture
  109498. */
  109499. serialize(): any;
  109500. /**
  109501. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  109502. */
  109503. disposeFramebufferObjects(): void;
  109504. /**
  109505. * Dispose the texture and release its associated resources.
  109506. */
  109507. dispose(): void;
  109508. /** @hidden */
  109509. _rebuild(): void;
  109510. /**
  109511. * Clear the info related to rendering groups preventing retention point in material dispose.
  109512. */
  109513. freeRenderingGroups(): void;
  109514. /**
  109515. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  109516. * @returns the view count
  109517. */
  109518. getViewCount(): number;
  109519. }
  109520. }
  109521. declare module BABYLON {
  109522. /**
  109523. * Class used to manipulate GUIDs
  109524. */
  109525. export class GUID {
  109526. /**
  109527. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  109528. * Be aware Math.random() could cause collisions, but:
  109529. * "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"
  109530. * @returns a pseudo random id
  109531. */
  109532. static RandomId(): string;
  109533. }
  109534. }
  109535. declare module BABYLON {
  109536. /**
  109537. * Options to be used when creating a shadow depth material
  109538. */
  109539. export interface IIOptionShadowDepthMaterial {
  109540. /** Variables in the vertex shader code that need to have their names remapped.
  109541. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  109542. * "var_name" should be either: worldPos or vNormalW
  109543. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  109544. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  109545. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  109546. */
  109547. remappedVariables?: string[];
  109548. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  109549. standalone?: boolean;
  109550. }
  109551. /**
  109552. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  109553. */
  109554. export class ShadowDepthWrapper {
  109555. private _scene;
  109556. private _options?;
  109557. private _baseMaterial;
  109558. private _onEffectCreatedObserver;
  109559. private _subMeshToEffect;
  109560. private _subMeshToDepthEffect;
  109561. private _meshes;
  109562. /** @hidden */
  109563. _matriceNames: any;
  109564. /** Gets the standalone status of the wrapper */
  109565. get standalone(): boolean;
  109566. /** Gets the base material the wrapper is built upon */
  109567. get baseMaterial(): Material;
  109568. /**
  109569. * Instantiate a new shadow depth wrapper.
  109570. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  109571. * generate the shadow depth map. For more information, please refer to the documentation:
  109572. * https://doc.babylonjs.com/babylon101/shadows
  109573. * @param baseMaterial Material to wrap
  109574. * @param scene Define the scene the material belongs to
  109575. * @param options Options used to create the wrapper
  109576. */
  109577. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  109578. /**
  109579. * Gets the effect to use to generate the depth map
  109580. * @param subMesh subMesh to get the effect for
  109581. * @param shadowGenerator shadow generator to get the effect for
  109582. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  109583. */
  109584. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  109585. /**
  109586. * Specifies that the submesh is ready to be used for depth rendering
  109587. * @param subMesh submesh to check
  109588. * @param defines the list of defines to take into account when checking the effect
  109589. * @param shadowGenerator combined with subMesh, it defines the effect to check
  109590. * @param useInstances specifies that instances should be used
  109591. * @returns a boolean indicating that the submesh is ready or not
  109592. */
  109593. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  109594. /**
  109595. * Disposes the resources
  109596. */
  109597. dispose(): void;
  109598. private _makeEffect;
  109599. }
  109600. }
  109601. declare module BABYLON {
  109602. /**
  109603. * Options for compiling materials.
  109604. */
  109605. export interface IMaterialCompilationOptions {
  109606. /**
  109607. * Defines whether clip planes are enabled.
  109608. */
  109609. clipPlane: boolean;
  109610. /**
  109611. * Defines whether instances are enabled.
  109612. */
  109613. useInstances: boolean;
  109614. }
  109615. /**
  109616. * Options passed when calling customShaderNameResolve
  109617. */
  109618. export interface ICustomShaderNameResolveOptions {
  109619. /**
  109620. * 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
  109621. */
  109622. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  109623. }
  109624. /**
  109625. * Base class for the main features of a material in Babylon.js
  109626. */
  109627. export class Material implements IAnimatable {
  109628. /**
  109629. * Returns the triangle fill mode
  109630. */
  109631. static readonly TriangleFillMode: number;
  109632. /**
  109633. * Returns the wireframe mode
  109634. */
  109635. static readonly WireFrameFillMode: number;
  109636. /**
  109637. * Returns the point fill mode
  109638. */
  109639. static readonly PointFillMode: number;
  109640. /**
  109641. * Returns the point list draw mode
  109642. */
  109643. static readonly PointListDrawMode: number;
  109644. /**
  109645. * Returns the line list draw mode
  109646. */
  109647. static readonly LineListDrawMode: number;
  109648. /**
  109649. * Returns the line loop draw mode
  109650. */
  109651. static readonly LineLoopDrawMode: number;
  109652. /**
  109653. * Returns the line strip draw mode
  109654. */
  109655. static readonly LineStripDrawMode: number;
  109656. /**
  109657. * Returns the triangle strip draw mode
  109658. */
  109659. static readonly TriangleStripDrawMode: number;
  109660. /**
  109661. * Returns the triangle fan draw mode
  109662. */
  109663. static readonly TriangleFanDrawMode: number;
  109664. /**
  109665. * Stores the clock-wise side orientation
  109666. */
  109667. static readonly ClockWiseSideOrientation: number;
  109668. /**
  109669. * Stores the counter clock-wise side orientation
  109670. */
  109671. static readonly CounterClockWiseSideOrientation: number;
  109672. /**
  109673. * The dirty texture flag value
  109674. */
  109675. static readonly TextureDirtyFlag: number;
  109676. /**
  109677. * The dirty light flag value
  109678. */
  109679. static readonly LightDirtyFlag: number;
  109680. /**
  109681. * The dirty fresnel flag value
  109682. */
  109683. static readonly FresnelDirtyFlag: number;
  109684. /**
  109685. * The dirty attribute flag value
  109686. */
  109687. static readonly AttributesDirtyFlag: number;
  109688. /**
  109689. * The dirty misc flag value
  109690. */
  109691. static readonly MiscDirtyFlag: number;
  109692. /**
  109693. * The dirty prepass flag value
  109694. */
  109695. static readonly PrePassDirtyFlag: number;
  109696. /**
  109697. * The all dirty flag value
  109698. */
  109699. static readonly AllDirtyFlag: number;
  109700. /**
  109701. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109702. */
  109703. static readonly MATERIAL_OPAQUE: number;
  109704. /**
  109705. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109706. */
  109707. static readonly MATERIAL_ALPHATEST: number;
  109708. /**
  109709. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109710. */
  109711. static readonly MATERIAL_ALPHABLEND: number;
  109712. /**
  109713. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109714. * They are also discarded below the alpha cutoff threshold to improve performances.
  109715. */
  109716. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  109717. /**
  109718. * The Whiteout method is used to blend normals.
  109719. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109720. */
  109721. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  109722. /**
  109723. * The Reoriented Normal Mapping method is used to blend normals.
  109724. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109725. */
  109726. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  109727. /**
  109728. * Custom callback helping to override the default shader used in the material.
  109729. */
  109730. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  109731. /**
  109732. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  109733. */
  109734. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  109735. /**
  109736. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  109737. * This means that the material can keep using a previous shader while a new one is being compiled.
  109738. * This is mostly used when shader parallel compilation is supported (true by default)
  109739. */
  109740. allowShaderHotSwapping: boolean;
  109741. /**
  109742. * The ID of the material
  109743. */
  109744. id: string;
  109745. /**
  109746. * Gets or sets the unique id of the material
  109747. */
  109748. uniqueId: number;
  109749. /**
  109750. * The name of the material
  109751. */
  109752. name: string;
  109753. /**
  109754. * Gets or sets user defined metadata
  109755. */
  109756. metadata: any;
  109757. /**
  109758. * For internal use only. Please do not use.
  109759. */
  109760. reservedDataStore: any;
  109761. /**
  109762. * Specifies if the ready state should be checked on each call
  109763. */
  109764. checkReadyOnEveryCall: boolean;
  109765. /**
  109766. * Specifies if the ready state should be checked once
  109767. */
  109768. checkReadyOnlyOnce: boolean;
  109769. /**
  109770. * The state of the material
  109771. */
  109772. state: string;
  109773. /**
  109774. * If the material can be rendered to several textures with MRT extension
  109775. */
  109776. get canRenderToMRT(): boolean;
  109777. /**
  109778. * The alpha value of the material
  109779. */
  109780. protected _alpha: number;
  109781. /**
  109782. * List of inspectable custom properties (used by the Inspector)
  109783. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109784. */
  109785. inspectableCustomProperties: IInspectable[];
  109786. /**
  109787. * Sets the alpha value of the material
  109788. */
  109789. set alpha(value: number);
  109790. /**
  109791. * Gets the alpha value of the material
  109792. */
  109793. get alpha(): number;
  109794. /**
  109795. * Specifies if back face culling is enabled
  109796. */
  109797. protected _backFaceCulling: boolean;
  109798. /**
  109799. * Sets the back-face culling state
  109800. */
  109801. set backFaceCulling(value: boolean);
  109802. /**
  109803. * Gets the back-face culling state
  109804. */
  109805. get backFaceCulling(): boolean;
  109806. /**
  109807. * Stores the value for side orientation
  109808. */
  109809. sideOrientation: number;
  109810. /**
  109811. * Callback triggered when the material is compiled
  109812. */
  109813. onCompiled: Nullable<(effect: Effect) => void>;
  109814. /**
  109815. * Callback triggered when an error occurs
  109816. */
  109817. onError: Nullable<(effect: Effect, errors: string) => void>;
  109818. /**
  109819. * Callback triggered to get the render target textures
  109820. */
  109821. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  109822. /**
  109823. * Gets a boolean indicating that current material needs to register RTT
  109824. */
  109825. get hasRenderTargetTextures(): boolean;
  109826. /**
  109827. * Specifies if the material should be serialized
  109828. */
  109829. doNotSerialize: boolean;
  109830. /**
  109831. * @hidden
  109832. */
  109833. _storeEffectOnSubMeshes: boolean;
  109834. /**
  109835. * Stores the animations for the material
  109836. */
  109837. animations: Nullable<Array<Animation>>;
  109838. /**
  109839. * An event triggered when the material is disposed
  109840. */
  109841. onDisposeObservable: Observable<Material>;
  109842. /**
  109843. * An observer which watches for dispose events
  109844. */
  109845. private _onDisposeObserver;
  109846. private _onUnBindObservable;
  109847. /**
  109848. * Called during a dispose event
  109849. */
  109850. set onDispose(callback: () => void);
  109851. private _onBindObservable;
  109852. /**
  109853. * An event triggered when the material is bound
  109854. */
  109855. get onBindObservable(): Observable<AbstractMesh>;
  109856. /**
  109857. * An observer which watches for bind events
  109858. */
  109859. private _onBindObserver;
  109860. /**
  109861. * Called during a bind event
  109862. */
  109863. set onBind(callback: (Mesh: AbstractMesh) => void);
  109864. /**
  109865. * An event triggered when the material is unbound
  109866. */
  109867. get onUnBindObservable(): Observable<Material>;
  109868. protected _onEffectCreatedObservable: Nullable<Observable<{
  109869. effect: Effect;
  109870. subMesh: Nullable<SubMesh>;
  109871. }>>;
  109872. /**
  109873. * An event triggered when the effect is (re)created
  109874. */
  109875. get onEffectCreatedObservable(): Observable<{
  109876. effect: Effect;
  109877. subMesh: Nullable<SubMesh>;
  109878. }>;
  109879. /**
  109880. * Stores the value of the alpha mode
  109881. */
  109882. private _alphaMode;
  109883. /**
  109884. * Sets the value of the alpha mode.
  109885. *
  109886. * | Value | Type | Description |
  109887. * | --- | --- | --- |
  109888. * | 0 | ALPHA_DISABLE | |
  109889. * | 1 | ALPHA_ADD | |
  109890. * | 2 | ALPHA_COMBINE | |
  109891. * | 3 | ALPHA_SUBTRACT | |
  109892. * | 4 | ALPHA_MULTIPLY | |
  109893. * | 5 | ALPHA_MAXIMIZED | |
  109894. * | 6 | ALPHA_ONEONE | |
  109895. * | 7 | ALPHA_PREMULTIPLIED | |
  109896. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  109897. * | 9 | ALPHA_INTERPOLATE | |
  109898. * | 10 | ALPHA_SCREENMODE | |
  109899. *
  109900. */
  109901. set alphaMode(value: number);
  109902. /**
  109903. * Gets the value of the alpha mode
  109904. */
  109905. get alphaMode(): number;
  109906. /**
  109907. * Stores the state of the need depth pre-pass value
  109908. */
  109909. private _needDepthPrePass;
  109910. /**
  109911. * Sets the need depth pre-pass value
  109912. */
  109913. set needDepthPrePass(value: boolean);
  109914. /**
  109915. * Gets the depth pre-pass value
  109916. */
  109917. get needDepthPrePass(): boolean;
  109918. /**
  109919. * Specifies if depth writing should be disabled
  109920. */
  109921. disableDepthWrite: boolean;
  109922. /**
  109923. * Specifies if color writing should be disabled
  109924. */
  109925. disableColorWrite: boolean;
  109926. /**
  109927. * Specifies if depth writing should be forced
  109928. */
  109929. forceDepthWrite: boolean;
  109930. /**
  109931. * Specifies the depth function that should be used. 0 means the default engine function
  109932. */
  109933. depthFunction: number;
  109934. /**
  109935. * Specifies if there should be a separate pass for culling
  109936. */
  109937. separateCullingPass: boolean;
  109938. /**
  109939. * Stores the state specifing if fog should be enabled
  109940. */
  109941. private _fogEnabled;
  109942. /**
  109943. * Sets the state for enabling fog
  109944. */
  109945. set fogEnabled(value: boolean);
  109946. /**
  109947. * Gets the value of the fog enabled state
  109948. */
  109949. get fogEnabled(): boolean;
  109950. /**
  109951. * Stores the size of points
  109952. */
  109953. pointSize: number;
  109954. /**
  109955. * Stores the z offset value
  109956. */
  109957. zOffset: number;
  109958. get wireframe(): boolean;
  109959. /**
  109960. * Sets the state of wireframe mode
  109961. */
  109962. set wireframe(value: boolean);
  109963. /**
  109964. * Gets the value specifying if point clouds are enabled
  109965. */
  109966. get pointsCloud(): boolean;
  109967. /**
  109968. * Sets the state of point cloud mode
  109969. */
  109970. set pointsCloud(value: boolean);
  109971. /**
  109972. * Gets the material fill mode
  109973. */
  109974. get fillMode(): number;
  109975. /**
  109976. * Sets the material fill mode
  109977. */
  109978. set fillMode(value: number);
  109979. /**
  109980. * @hidden
  109981. * Stores the effects for the material
  109982. */
  109983. _effect: Nullable<Effect>;
  109984. /**
  109985. * Specifies if uniform buffers should be used
  109986. */
  109987. private _useUBO;
  109988. /**
  109989. * Stores a reference to the scene
  109990. */
  109991. private _scene;
  109992. /**
  109993. * Stores the fill mode state
  109994. */
  109995. private _fillMode;
  109996. /**
  109997. * Specifies if the depth write state should be cached
  109998. */
  109999. private _cachedDepthWriteState;
  110000. /**
  110001. * Specifies if the color write state should be cached
  110002. */
  110003. private _cachedColorWriteState;
  110004. /**
  110005. * Specifies if the depth function state should be cached
  110006. */
  110007. private _cachedDepthFunctionState;
  110008. /**
  110009. * Stores the uniform buffer
  110010. */
  110011. protected _uniformBuffer: UniformBuffer;
  110012. /** @hidden */
  110013. _indexInSceneMaterialArray: number;
  110014. /** @hidden */
  110015. meshMap: Nullable<{
  110016. [id: string]: AbstractMesh | undefined;
  110017. }>;
  110018. /**
  110019. * Creates a material instance
  110020. * @param name defines the name of the material
  110021. * @param scene defines the scene to reference
  110022. * @param doNotAdd specifies if the material should be added to the scene
  110023. */
  110024. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  110025. /**
  110026. * Returns a string representation of the current material
  110027. * @param fullDetails defines a boolean indicating which levels of logging is desired
  110028. * @returns a string with material information
  110029. */
  110030. toString(fullDetails?: boolean): string;
  110031. /**
  110032. * Gets the class name of the material
  110033. * @returns a string with the class name of the material
  110034. */
  110035. getClassName(): string;
  110036. /**
  110037. * Specifies if updates for the material been locked
  110038. */
  110039. get isFrozen(): boolean;
  110040. /**
  110041. * Locks updates for the material
  110042. */
  110043. freeze(): void;
  110044. /**
  110045. * Unlocks updates for the material
  110046. */
  110047. unfreeze(): void;
  110048. /**
  110049. * Specifies if the material is ready to be used
  110050. * @param mesh defines the mesh to check
  110051. * @param useInstances specifies if instances should be used
  110052. * @returns a boolean indicating if the material is ready to be used
  110053. */
  110054. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  110055. /**
  110056. * Specifies that the submesh is ready to be used
  110057. * @param mesh defines the mesh to check
  110058. * @param subMesh defines which submesh to check
  110059. * @param useInstances specifies that instances should be used
  110060. * @returns a boolean indicating that the submesh is ready or not
  110061. */
  110062. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110063. /**
  110064. * Returns the material effect
  110065. * @returns the effect associated with the material
  110066. */
  110067. getEffect(): Nullable<Effect>;
  110068. /**
  110069. * Returns the current scene
  110070. * @returns a Scene
  110071. */
  110072. getScene(): Scene;
  110073. /**
  110074. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110075. */
  110076. protected _forceAlphaTest: boolean;
  110077. /**
  110078. * The transparency mode of the material.
  110079. */
  110080. protected _transparencyMode: Nullable<number>;
  110081. /**
  110082. * Gets the current transparency mode.
  110083. */
  110084. get transparencyMode(): Nullable<number>;
  110085. /**
  110086. * Sets the transparency mode of the material.
  110087. *
  110088. * | Value | Type | Description |
  110089. * | ----- | ----------------------------------- | ----------- |
  110090. * | 0 | OPAQUE | |
  110091. * | 1 | ALPHATEST | |
  110092. * | 2 | ALPHABLEND | |
  110093. * | 3 | ALPHATESTANDBLEND | |
  110094. *
  110095. */
  110096. set transparencyMode(value: Nullable<number>);
  110097. /**
  110098. * Returns true if alpha blending should be disabled.
  110099. */
  110100. protected get _disableAlphaBlending(): boolean;
  110101. /**
  110102. * Specifies whether or not this material should be rendered in alpha blend mode.
  110103. * @returns a boolean specifying if alpha blending is needed
  110104. */
  110105. needAlphaBlending(): boolean;
  110106. /**
  110107. * Specifies if the mesh will require alpha blending
  110108. * @param mesh defines the mesh to check
  110109. * @returns a boolean specifying if alpha blending is needed for the mesh
  110110. */
  110111. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110112. /**
  110113. * Specifies whether or not this material should be rendered in alpha test mode.
  110114. * @returns a boolean specifying if an alpha test is needed.
  110115. */
  110116. needAlphaTesting(): boolean;
  110117. /**
  110118. * Specifies if material alpha testing should be turned on for the mesh
  110119. * @param mesh defines the mesh to check
  110120. */
  110121. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  110122. /**
  110123. * Gets the texture used for the alpha test
  110124. * @returns the texture to use for alpha testing
  110125. */
  110126. getAlphaTestTexture(): Nullable<BaseTexture>;
  110127. /**
  110128. * Marks the material to indicate that it needs to be re-calculated
  110129. */
  110130. markDirty(): void;
  110131. /** @hidden */
  110132. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  110133. /**
  110134. * Binds the material to the mesh
  110135. * @param world defines the world transformation matrix
  110136. * @param mesh defines the mesh to bind the material to
  110137. */
  110138. bind(world: Matrix, mesh?: Mesh): void;
  110139. /**
  110140. * Binds the submesh to the material
  110141. * @param world defines the world transformation matrix
  110142. * @param mesh defines the mesh containing the submesh
  110143. * @param subMesh defines the submesh to bind the material to
  110144. */
  110145. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110146. /**
  110147. * Binds the world matrix to the material
  110148. * @param world defines the world transformation matrix
  110149. */
  110150. bindOnlyWorldMatrix(world: Matrix): void;
  110151. /**
  110152. * Binds the scene's uniform buffer to the effect.
  110153. * @param effect defines the effect to bind to the scene uniform buffer
  110154. * @param sceneUbo defines the uniform buffer storing scene data
  110155. */
  110156. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  110157. /**
  110158. * Binds the view matrix to the effect
  110159. * @param effect defines the effect to bind the view matrix to
  110160. */
  110161. bindView(effect: Effect): void;
  110162. /**
  110163. * Binds the view projection matrix to the effect
  110164. * @param effect defines the effect to bind the view projection matrix to
  110165. */
  110166. bindViewProjection(effect: Effect): void;
  110167. /**
  110168. * Processes to execute after binding the material to a mesh
  110169. * @param mesh defines the rendered mesh
  110170. */
  110171. protected _afterBind(mesh?: Mesh): void;
  110172. /**
  110173. * Unbinds the material from the mesh
  110174. */
  110175. unbind(): void;
  110176. /**
  110177. * Gets the active textures from the material
  110178. * @returns an array of textures
  110179. */
  110180. getActiveTextures(): BaseTexture[];
  110181. /**
  110182. * Specifies if the material uses a texture
  110183. * @param texture defines the texture to check against the material
  110184. * @returns a boolean specifying if the material uses the texture
  110185. */
  110186. hasTexture(texture: BaseTexture): boolean;
  110187. /**
  110188. * Makes a duplicate of the material, and gives it a new name
  110189. * @param name defines the new name for the duplicated material
  110190. * @returns the cloned material
  110191. */
  110192. clone(name: string): Nullable<Material>;
  110193. /**
  110194. * Gets the meshes bound to the material
  110195. * @returns an array of meshes bound to the material
  110196. */
  110197. getBindedMeshes(): AbstractMesh[];
  110198. /**
  110199. * Force shader compilation
  110200. * @param mesh defines the mesh associated with this material
  110201. * @param onCompiled defines a function to execute once the material is compiled
  110202. * @param options defines the options to configure the compilation
  110203. * @param onError defines a function to execute if the material fails compiling
  110204. */
  110205. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  110206. /**
  110207. * Force shader compilation
  110208. * @param mesh defines the mesh that will use this material
  110209. * @param options defines additional options for compiling the shaders
  110210. * @returns a promise that resolves when the compilation completes
  110211. */
  110212. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  110213. private static readonly _AllDirtyCallBack;
  110214. private static readonly _ImageProcessingDirtyCallBack;
  110215. private static readonly _TextureDirtyCallBack;
  110216. private static readonly _FresnelDirtyCallBack;
  110217. private static readonly _MiscDirtyCallBack;
  110218. private static readonly _PrePassDirtyCallBack;
  110219. private static readonly _LightsDirtyCallBack;
  110220. private static readonly _AttributeDirtyCallBack;
  110221. private static _FresnelAndMiscDirtyCallBack;
  110222. private static _TextureAndMiscDirtyCallBack;
  110223. private static readonly _DirtyCallbackArray;
  110224. private static readonly _RunDirtyCallBacks;
  110225. /**
  110226. * Marks a define in the material to indicate that it needs to be re-computed
  110227. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  110228. */
  110229. markAsDirty(flag: number): void;
  110230. /**
  110231. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  110232. * @param func defines a function which checks material defines against the submeshes
  110233. */
  110234. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  110235. /**
  110236. * Indicates that the scene should check if the rendering now needs a prepass
  110237. */
  110238. protected _markScenePrePassDirty(): void;
  110239. /**
  110240. * Indicates that we need to re-calculated for all submeshes
  110241. */
  110242. protected _markAllSubMeshesAsAllDirty(): void;
  110243. /**
  110244. * Indicates that image processing needs to be re-calculated for all submeshes
  110245. */
  110246. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  110247. /**
  110248. * Indicates that textures need to be re-calculated for all submeshes
  110249. */
  110250. protected _markAllSubMeshesAsTexturesDirty(): void;
  110251. /**
  110252. * Indicates that fresnel needs to be re-calculated for all submeshes
  110253. */
  110254. protected _markAllSubMeshesAsFresnelDirty(): void;
  110255. /**
  110256. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110257. */
  110258. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110259. /**
  110260. * Indicates that lights need to be re-calculated for all submeshes
  110261. */
  110262. protected _markAllSubMeshesAsLightsDirty(): void;
  110263. /**
  110264. * Indicates that attributes need to be re-calculated for all submeshes
  110265. */
  110266. protected _markAllSubMeshesAsAttributesDirty(): void;
  110267. /**
  110268. * Indicates that misc needs to be re-calculated for all submeshes
  110269. */
  110270. protected _markAllSubMeshesAsMiscDirty(): void;
  110271. /**
  110272. * Indicates that prepass needs to be re-calculated for all submeshes
  110273. */
  110274. protected _markAllSubMeshesAsPrePassDirty(): void;
  110275. /**
  110276. * Indicates that textures and misc need to be re-calculated for all submeshes
  110277. */
  110278. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  110279. /**
  110280. * Sets the required values to the prepass renderer.
  110281. * @param prePassRenderer defines the prepass renderer to setup.
  110282. * @returns true if the pre pass is needed.
  110283. */
  110284. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  110285. /**
  110286. * Disposes the material
  110287. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110288. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110289. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  110290. */
  110291. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  110292. /** @hidden */
  110293. private releaseVertexArrayObject;
  110294. /**
  110295. * Serializes this material
  110296. * @returns the serialized material object
  110297. */
  110298. serialize(): any;
  110299. /**
  110300. * Creates a material from parsed material data
  110301. * @param parsedMaterial defines parsed material data
  110302. * @param scene defines the hosting scene
  110303. * @param rootUrl defines the root URL to use to load textures
  110304. * @returns a new material
  110305. */
  110306. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  110307. }
  110308. }
  110309. declare module BABYLON {
  110310. /**
  110311. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110312. * separate meshes. This can be use to improve performances.
  110313. * @see https://doc.babylonjs.com/how_to/multi_materials
  110314. */
  110315. export class MultiMaterial extends Material {
  110316. private _subMaterials;
  110317. /**
  110318. * Gets or Sets the list of Materials used within the multi material.
  110319. * They need to be ordered according to the submeshes order in the associated mesh
  110320. */
  110321. get subMaterials(): Nullable<Material>[];
  110322. set subMaterials(value: Nullable<Material>[]);
  110323. /**
  110324. * Function used to align with Node.getChildren()
  110325. * @returns the list of Materials used within the multi material
  110326. */
  110327. getChildren(): Nullable<Material>[];
  110328. /**
  110329. * Instantiates a new Multi Material
  110330. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110331. * separate meshes. This can be use to improve performances.
  110332. * @see https://doc.babylonjs.com/how_to/multi_materials
  110333. * @param name Define the name in the scene
  110334. * @param scene Define the scene the material belongs to
  110335. */
  110336. constructor(name: string, scene: Scene);
  110337. private _hookArray;
  110338. /**
  110339. * Get one of the submaterial by its index in the submaterials array
  110340. * @param index The index to look the sub material at
  110341. * @returns The Material if the index has been defined
  110342. */
  110343. getSubMaterial(index: number): Nullable<Material>;
  110344. /**
  110345. * Get the list of active textures for the whole sub materials list.
  110346. * @returns All the textures that will be used during the rendering
  110347. */
  110348. getActiveTextures(): BaseTexture[];
  110349. /**
  110350. * Gets the current class name of the material e.g. "MultiMaterial"
  110351. * Mainly use in serialization.
  110352. * @returns the class name
  110353. */
  110354. getClassName(): string;
  110355. /**
  110356. * Checks if the material is ready to render the requested sub mesh
  110357. * @param mesh Define the mesh the submesh belongs to
  110358. * @param subMesh Define the sub mesh to look readyness for
  110359. * @param useInstances Define whether or not the material is used with instances
  110360. * @returns true if ready, otherwise false
  110361. */
  110362. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110363. /**
  110364. * Clones the current material and its related sub materials
  110365. * @param name Define the name of the newly cloned material
  110366. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  110367. * @returns the cloned material
  110368. */
  110369. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  110370. /**
  110371. * Serializes the materials into a JSON representation.
  110372. * @returns the JSON representation
  110373. */
  110374. serialize(): any;
  110375. /**
  110376. * Dispose the material and release its associated resources
  110377. * @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)
  110378. * @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)
  110379. * @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)
  110380. */
  110381. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  110382. /**
  110383. * Creates a MultiMaterial from parsed MultiMaterial data.
  110384. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  110385. * @param scene defines the hosting scene
  110386. * @returns a new MultiMaterial
  110387. */
  110388. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  110389. }
  110390. }
  110391. declare module BABYLON {
  110392. /**
  110393. * Defines a subdivision inside a mesh
  110394. */
  110395. export class SubMesh implements ICullable {
  110396. /** the material index to use */
  110397. materialIndex: number;
  110398. /** vertex index start */
  110399. verticesStart: number;
  110400. /** vertices count */
  110401. verticesCount: number;
  110402. /** index start */
  110403. indexStart: number;
  110404. /** indices count */
  110405. indexCount: number;
  110406. /** @hidden */
  110407. _materialDefines: Nullable<MaterialDefines>;
  110408. /** @hidden */
  110409. _materialEffect: Nullable<Effect>;
  110410. /** @hidden */
  110411. _effectOverride: Nullable<Effect>;
  110412. /**
  110413. * Gets material defines used by the effect associated to the sub mesh
  110414. */
  110415. get materialDefines(): Nullable<MaterialDefines>;
  110416. /**
  110417. * Sets material defines used by the effect associated to the sub mesh
  110418. */
  110419. set materialDefines(defines: Nullable<MaterialDefines>);
  110420. /**
  110421. * Gets associated effect
  110422. */
  110423. get effect(): Nullable<Effect>;
  110424. /**
  110425. * Sets associated effect (effect used to render this submesh)
  110426. * @param effect defines the effect to associate with
  110427. * @param defines defines the set of defines used to compile this effect
  110428. */
  110429. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  110430. /** @hidden */
  110431. _linesIndexCount: number;
  110432. private _mesh;
  110433. private _renderingMesh;
  110434. private _boundingInfo;
  110435. private _linesIndexBuffer;
  110436. /** @hidden */
  110437. _lastColliderWorldVertices: Nullable<Vector3[]>;
  110438. /** @hidden */
  110439. _trianglePlanes: Plane[];
  110440. /** @hidden */
  110441. _lastColliderTransformMatrix: Nullable<Matrix>;
  110442. /** @hidden */
  110443. _renderId: number;
  110444. /** @hidden */
  110445. _alphaIndex: number;
  110446. /** @hidden */
  110447. _distanceToCamera: number;
  110448. /** @hidden */
  110449. _id: number;
  110450. private _currentMaterial;
  110451. /**
  110452. * Add a new submesh to a mesh
  110453. * @param materialIndex defines the material index to use
  110454. * @param verticesStart defines vertex index start
  110455. * @param verticesCount defines vertices count
  110456. * @param indexStart defines index start
  110457. * @param indexCount defines indices count
  110458. * @param mesh defines the parent mesh
  110459. * @param renderingMesh defines an optional rendering mesh
  110460. * @param createBoundingBox defines if bounding box should be created for this submesh
  110461. * @returns the new submesh
  110462. */
  110463. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  110464. /**
  110465. * Creates a new submesh
  110466. * @param materialIndex defines the material index to use
  110467. * @param verticesStart defines vertex index start
  110468. * @param verticesCount defines vertices count
  110469. * @param indexStart defines index start
  110470. * @param indexCount defines indices count
  110471. * @param mesh defines the parent mesh
  110472. * @param renderingMesh defines an optional rendering mesh
  110473. * @param createBoundingBox defines if bounding box should be created for this submesh
  110474. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  110475. */
  110476. constructor(
  110477. /** the material index to use */
  110478. materialIndex: number,
  110479. /** vertex index start */
  110480. verticesStart: number,
  110481. /** vertices count */
  110482. verticesCount: number,
  110483. /** index start */
  110484. indexStart: number,
  110485. /** indices count */
  110486. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  110487. /**
  110488. * Returns true if this submesh covers the entire parent mesh
  110489. * @ignorenaming
  110490. */
  110491. get IsGlobal(): boolean;
  110492. /**
  110493. * Returns the submesh BoudingInfo object
  110494. * @returns current bounding info (or mesh's one if the submesh is global)
  110495. */
  110496. getBoundingInfo(): BoundingInfo;
  110497. /**
  110498. * Sets the submesh BoundingInfo
  110499. * @param boundingInfo defines the new bounding info to use
  110500. * @returns the SubMesh
  110501. */
  110502. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  110503. /**
  110504. * Returns the mesh of the current submesh
  110505. * @return the parent mesh
  110506. */
  110507. getMesh(): AbstractMesh;
  110508. /**
  110509. * Returns the rendering mesh of the submesh
  110510. * @returns the rendering mesh (could be different from parent mesh)
  110511. */
  110512. getRenderingMesh(): Mesh;
  110513. /**
  110514. * Returns the replacement mesh of the submesh
  110515. * @returns the replacement mesh (could be different from parent mesh)
  110516. */
  110517. getReplacementMesh(): Nullable<AbstractMesh>;
  110518. /**
  110519. * Returns the effective mesh of the submesh
  110520. * @returns the effective mesh (could be different from parent mesh)
  110521. */
  110522. getEffectiveMesh(): AbstractMesh;
  110523. /**
  110524. * Returns the submesh material
  110525. * @returns null or the current material
  110526. */
  110527. getMaterial(): Nullable<Material>;
  110528. private _IsMultiMaterial;
  110529. /**
  110530. * Sets a new updated BoundingInfo object to the submesh
  110531. * @param data defines an optional position array to use to determine the bounding info
  110532. * @returns the SubMesh
  110533. */
  110534. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  110535. /** @hidden */
  110536. _checkCollision(collider: Collider): boolean;
  110537. /**
  110538. * Updates the submesh BoundingInfo
  110539. * @param world defines the world matrix to use to update the bounding info
  110540. * @returns the submesh
  110541. */
  110542. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  110543. /**
  110544. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  110545. * @param frustumPlanes defines the frustum planes
  110546. * @returns true if the submesh is intersecting with the frustum
  110547. */
  110548. isInFrustum(frustumPlanes: Plane[]): boolean;
  110549. /**
  110550. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  110551. * @param frustumPlanes defines the frustum planes
  110552. * @returns true if the submesh is inside the frustum
  110553. */
  110554. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  110555. /**
  110556. * Renders the submesh
  110557. * @param enableAlphaMode defines if alpha needs to be used
  110558. * @returns the submesh
  110559. */
  110560. render(enableAlphaMode: boolean): SubMesh;
  110561. /**
  110562. * @hidden
  110563. */
  110564. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  110565. /**
  110566. * Checks if the submesh intersects with a ray
  110567. * @param ray defines the ray to test
  110568. * @returns true is the passed ray intersects the submesh bounding box
  110569. */
  110570. canIntersects(ray: Ray): boolean;
  110571. /**
  110572. * Intersects current submesh with a ray
  110573. * @param ray defines the ray to test
  110574. * @param positions defines mesh's positions array
  110575. * @param indices defines mesh's indices array
  110576. * @param fastCheck defines if the first intersection will be used (and not the closest)
  110577. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110578. * @returns intersection info or null if no intersection
  110579. */
  110580. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  110581. /** @hidden */
  110582. private _intersectLines;
  110583. /** @hidden */
  110584. private _intersectUnIndexedLines;
  110585. /** @hidden */
  110586. private _intersectTriangles;
  110587. /** @hidden */
  110588. private _intersectUnIndexedTriangles;
  110589. /** @hidden */
  110590. _rebuild(): void;
  110591. /**
  110592. * Creates a new submesh from the passed mesh
  110593. * @param newMesh defines the new hosting mesh
  110594. * @param newRenderingMesh defines an optional rendering mesh
  110595. * @returns the new submesh
  110596. */
  110597. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  110598. /**
  110599. * Release associated resources
  110600. */
  110601. dispose(): void;
  110602. /**
  110603. * Gets the class name
  110604. * @returns the string "SubMesh".
  110605. */
  110606. getClassName(): string;
  110607. /**
  110608. * Creates a new submesh from indices data
  110609. * @param materialIndex the index of the main mesh material
  110610. * @param startIndex the index where to start the copy in the mesh indices array
  110611. * @param indexCount the number of indices to copy then from the startIndex
  110612. * @param mesh the main mesh to create the submesh from
  110613. * @param renderingMesh the optional rendering mesh
  110614. * @returns a new submesh
  110615. */
  110616. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  110617. }
  110618. }
  110619. declare module BABYLON {
  110620. /**
  110621. * Class used to represent data loading progression
  110622. */
  110623. export class SceneLoaderFlags {
  110624. private static _ForceFullSceneLoadingForIncremental;
  110625. private static _ShowLoadingScreen;
  110626. private static _CleanBoneMatrixWeights;
  110627. private static _loggingLevel;
  110628. /**
  110629. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110630. */
  110631. static get ForceFullSceneLoadingForIncremental(): boolean;
  110632. static set ForceFullSceneLoadingForIncremental(value: boolean);
  110633. /**
  110634. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110635. */
  110636. static get ShowLoadingScreen(): boolean;
  110637. static set ShowLoadingScreen(value: boolean);
  110638. /**
  110639. * Defines the current logging level (while loading the scene)
  110640. * @ignorenaming
  110641. */
  110642. static get loggingLevel(): number;
  110643. static set loggingLevel(value: number);
  110644. /**
  110645. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110646. */
  110647. static get CleanBoneMatrixWeights(): boolean;
  110648. static set CleanBoneMatrixWeights(value: boolean);
  110649. }
  110650. }
  110651. declare module BABYLON {
  110652. /**
  110653. * Class used to store geometry data (vertex buffers + index buffer)
  110654. */
  110655. export class Geometry implements IGetSetVerticesData {
  110656. /**
  110657. * Gets or sets the ID of the geometry
  110658. */
  110659. id: string;
  110660. /**
  110661. * Gets or sets the unique ID of the geometry
  110662. */
  110663. uniqueId: number;
  110664. /**
  110665. * Gets the delay loading state of the geometry (none by default which means not delayed)
  110666. */
  110667. delayLoadState: number;
  110668. /**
  110669. * Gets the file containing the data to load when running in delay load state
  110670. */
  110671. delayLoadingFile: Nullable<string>;
  110672. /**
  110673. * Callback called when the geometry is updated
  110674. */
  110675. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  110676. private _scene;
  110677. private _engine;
  110678. private _meshes;
  110679. private _totalVertices;
  110680. /** @hidden */
  110681. _indices: IndicesArray;
  110682. /** @hidden */
  110683. _vertexBuffers: {
  110684. [key: string]: VertexBuffer;
  110685. };
  110686. private _isDisposed;
  110687. private _extend;
  110688. private _boundingBias;
  110689. /** @hidden */
  110690. _delayInfo: Array<string>;
  110691. private _indexBuffer;
  110692. private _indexBufferIsUpdatable;
  110693. /** @hidden */
  110694. _boundingInfo: Nullable<BoundingInfo>;
  110695. /** @hidden */
  110696. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  110697. /** @hidden */
  110698. _softwareSkinningFrameId: number;
  110699. private _vertexArrayObjects;
  110700. private _updatable;
  110701. /** @hidden */
  110702. _positions: Nullable<Vector3[]>;
  110703. /**
  110704. * 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
  110705. */
  110706. get boundingBias(): Vector2;
  110707. /**
  110708. * 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
  110709. */
  110710. set boundingBias(value: Vector2);
  110711. /**
  110712. * Static function used to attach a new empty geometry to a mesh
  110713. * @param mesh defines the mesh to attach the geometry to
  110714. * @returns the new Geometry
  110715. */
  110716. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  110717. /** Get the list of meshes using this geometry */
  110718. get meshes(): Mesh[];
  110719. /**
  110720. * 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
  110721. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  110722. */
  110723. useBoundingInfoFromGeometry: boolean;
  110724. /**
  110725. * Creates a new geometry
  110726. * @param id defines the unique ID
  110727. * @param scene defines the hosting scene
  110728. * @param vertexData defines the VertexData used to get geometry data
  110729. * @param updatable defines if geometry must be updatable (false by default)
  110730. * @param mesh defines the mesh that will be associated with the geometry
  110731. */
  110732. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  110733. /**
  110734. * Gets the current extend of the geometry
  110735. */
  110736. get extend(): {
  110737. minimum: Vector3;
  110738. maximum: Vector3;
  110739. };
  110740. /**
  110741. * Gets the hosting scene
  110742. * @returns the hosting Scene
  110743. */
  110744. getScene(): Scene;
  110745. /**
  110746. * Gets the hosting engine
  110747. * @returns the hosting Engine
  110748. */
  110749. getEngine(): Engine;
  110750. /**
  110751. * Defines if the geometry is ready to use
  110752. * @returns true if the geometry is ready to be used
  110753. */
  110754. isReady(): boolean;
  110755. /**
  110756. * Gets a value indicating that the geometry should not be serialized
  110757. */
  110758. get doNotSerialize(): boolean;
  110759. /** @hidden */
  110760. _rebuild(): void;
  110761. /**
  110762. * Affects all geometry data in one call
  110763. * @param vertexData defines the geometry data
  110764. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  110765. */
  110766. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  110767. /**
  110768. * Set specific vertex data
  110769. * @param kind defines the data kind (Position, normal, etc...)
  110770. * @param data defines the vertex data to use
  110771. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110772. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110773. */
  110774. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  110775. /**
  110776. * Removes a specific vertex data
  110777. * @param kind defines the data kind (Position, normal, etc...)
  110778. */
  110779. removeVerticesData(kind: string): void;
  110780. /**
  110781. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  110782. * @param buffer defines the vertex buffer to use
  110783. * @param totalVertices defines the total number of vertices for position kind (could be null)
  110784. */
  110785. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  110786. /**
  110787. * Update a specific vertex buffer
  110788. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  110789. * It will do nothing if the buffer is not updatable
  110790. * @param kind defines the data kind (Position, normal, etc...)
  110791. * @param data defines the data to use
  110792. * @param offset defines the offset in the target buffer where to store the data
  110793. * @param useBytes set to true if the offset is in bytes
  110794. */
  110795. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  110796. /**
  110797. * Update a specific vertex buffer
  110798. * This function will create a new buffer if the current one is not updatable
  110799. * @param kind defines the data kind (Position, normal, etc...)
  110800. * @param data defines the data to use
  110801. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  110802. */
  110803. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  110804. private _updateBoundingInfo;
  110805. /** @hidden */
  110806. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  110807. /**
  110808. * Gets total number of vertices
  110809. * @returns the total number of vertices
  110810. */
  110811. getTotalVertices(): number;
  110812. /**
  110813. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110814. * @param kind defines the data kind (Position, normal, etc...)
  110815. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110816. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110817. * @returns a float array containing vertex data
  110818. */
  110819. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110820. /**
  110821. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  110822. * @param kind defines the data kind (Position, normal, etc...)
  110823. * @returns true if the vertex buffer with the specified kind is updatable
  110824. */
  110825. isVertexBufferUpdatable(kind: string): boolean;
  110826. /**
  110827. * Gets a specific vertex buffer
  110828. * @param kind defines the data kind (Position, normal, etc...)
  110829. * @returns a VertexBuffer
  110830. */
  110831. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  110832. /**
  110833. * Returns all vertex buffers
  110834. * @return an object holding all vertex buffers indexed by kind
  110835. */
  110836. getVertexBuffers(): Nullable<{
  110837. [key: string]: VertexBuffer;
  110838. }>;
  110839. /**
  110840. * Gets a boolean indicating if specific vertex buffer is present
  110841. * @param kind defines the data kind (Position, normal, etc...)
  110842. * @returns true if data is present
  110843. */
  110844. isVerticesDataPresent(kind: string): boolean;
  110845. /**
  110846. * Gets a list of all attached data kinds (Position, normal, etc...)
  110847. * @returns a list of string containing all kinds
  110848. */
  110849. getVerticesDataKinds(): string[];
  110850. /**
  110851. * Update index buffer
  110852. * @param indices defines the indices to store in the index buffer
  110853. * @param offset defines the offset in the target buffer where to store the data
  110854. * @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)
  110855. */
  110856. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  110857. /**
  110858. * Creates a new index buffer
  110859. * @param indices defines the indices to store in the index buffer
  110860. * @param totalVertices defines the total number of vertices (could be null)
  110861. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110862. */
  110863. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  110864. /**
  110865. * Return the total number of indices
  110866. * @returns the total number of indices
  110867. */
  110868. getTotalIndices(): number;
  110869. /**
  110870. * Gets the index buffer array
  110871. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110872. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110873. * @returns the index buffer array
  110874. */
  110875. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110876. /**
  110877. * Gets the index buffer
  110878. * @return the index buffer
  110879. */
  110880. getIndexBuffer(): Nullable<DataBuffer>;
  110881. /** @hidden */
  110882. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  110883. /**
  110884. * Release the associated resources for a specific mesh
  110885. * @param mesh defines the source mesh
  110886. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  110887. */
  110888. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  110889. /**
  110890. * Apply current geometry to a given mesh
  110891. * @param mesh defines the mesh to apply geometry to
  110892. */
  110893. applyToMesh(mesh: Mesh): void;
  110894. private _updateExtend;
  110895. private _applyToMesh;
  110896. private notifyUpdate;
  110897. /**
  110898. * Load the geometry if it was flagged as delay loaded
  110899. * @param scene defines the hosting scene
  110900. * @param onLoaded defines a callback called when the geometry is loaded
  110901. */
  110902. load(scene: Scene, onLoaded?: () => void): void;
  110903. private _queueLoad;
  110904. /**
  110905. * Invert the geometry to move from a right handed system to a left handed one.
  110906. */
  110907. toLeftHanded(): void;
  110908. /** @hidden */
  110909. _resetPointsArrayCache(): void;
  110910. /** @hidden */
  110911. _generatePointsArray(): boolean;
  110912. /**
  110913. * Gets a value indicating if the geometry is disposed
  110914. * @returns true if the geometry was disposed
  110915. */
  110916. isDisposed(): boolean;
  110917. private _disposeVertexArrayObjects;
  110918. /**
  110919. * Free all associated resources
  110920. */
  110921. dispose(): void;
  110922. /**
  110923. * Clone the current geometry into a new geometry
  110924. * @param id defines the unique ID of the new geometry
  110925. * @returns a new geometry object
  110926. */
  110927. copy(id: string): Geometry;
  110928. /**
  110929. * Serialize the current geometry info (and not the vertices data) into a JSON object
  110930. * @return a JSON representation of the current geometry data (without the vertices data)
  110931. */
  110932. serialize(): any;
  110933. private toNumberArray;
  110934. /**
  110935. * Serialize all vertices data into a JSON oject
  110936. * @returns a JSON representation of the current geometry data
  110937. */
  110938. serializeVerticeData(): any;
  110939. /**
  110940. * Extracts a clone of a mesh geometry
  110941. * @param mesh defines the source mesh
  110942. * @param id defines the unique ID of the new geometry object
  110943. * @returns the new geometry object
  110944. */
  110945. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  110946. /**
  110947. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  110948. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110949. * Be aware Math.random() could cause collisions, but:
  110950. * "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"
  110951. * @returns a string containing a new GUID
  110952. */
  110953. static RandomId(): string;
  110954. /** @hidden */
  110955. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  110956. private static _CleanMatricesWeights;
  110957. /**
  110958. * Create a new geometry from persisted data (Using .babylon file format)
  110959. * @param parsedVertexData defines the persisted data
  110960. * @param scene defines the hosting scene
  110961. * @param rootUrl defines the root url to use to load assets (like delayed data)
  110962. * @returns the new geometry object
  110963. */
  110964. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  110965. }
  110966. }
  110967. declare module BABYLON {
  110968. /**
  110969. * Define an interface for all classes that will get and set the data on vertices
  110970. */
  110971. export interface IGetSetVerticesData {
  110972. /**
  110973. * Gets a boolean indicating if specific vertex data is present
  110974. * @param kind defines the vertex data kind to use
  110975. * @returns true is data kind is present
  110976. */
  110977. isVerticesDataPresent(kind: string): boolean;
  110978. /**
  110979. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110980. * @param kind defines the data kind (Position, normal, etc...)
  110981. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110982. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110983. * @returns a float array containing vertex data
  110984. */
  110985. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110986. /**
  110987. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  110988. * @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.
  110989. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110990. * @returns the indices array or an empty array if the mesh has no geometry
  110991. */
  110992. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110993. /**
  110994. * Set specific vertex data
  110995. * @param kind defines the data kind (Position, normal, etc...)
  110996. * @param data defines the vertex data to use
  110997. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110998. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110999. */
  111000. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  111001. /**
  111002. * Update a specific associated vertex buffer
  111003. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  111004. * - VertexBuffer.PositionKind
  111005. * - VertexBuffer.UVKind
  111006. * - VertexBuffer.UV2Kind
  111007. * - VertexBuffer.UV3Kind
  111008. * - VertexBuffer.UV4Kind
  111009. * - VertexBuffer.UV5Kind
  111010. * - VertexBuffer.UV6Kind
  111011. * - VertexBuffer.ColorKind
  111012. * - VertexBuffer.MatricesIndicesKind
  111013. * - VertexBuffer.MatricesIndicesExtraKind
  111014. * - VertexBuffer.MatricesWeightsKind
  111015. * - VertexBuffer.MatricesWeightsExtraKind
  111016. * @param data defines the data source
  111017. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  111018. * @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)
  111019. */
  111020. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  111021. /**
  111022. * Creates a new index buffer
  111023. * @param indices defines the indices to store in the index buffer
  111024. * @param totalVertices defines the total number of vertices (could be null)
  111025. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111026. */
  111027. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  111028. }
  111029. /**
  111030. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  111031. */
  111032. export class VertexData {
  111033. /**
  111034. * Mesh side orientation : usually the external or front surface
  111035. */
  111036. static readonly FRONTSIDE: number;
  111037. /**
  111038. * Mesh side orientation : usually the internal or back surface
  111039. */
  111040. static readonly BACKSIDE: number;
  111041. /**
  111042. * Mesh side orientation : both internal and external or front and back surfaces
  111043. */
  111044. static readonly DOUBLESIDE: number;
  111045. /**
  111046. * Mesh side orientation : by default, `FRONTSIDE`
  111047. */
  111048. static readonly DEFAULTSIDE: number;
  111049. /**
  111050. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  111051. */
  111052. positions: Nullable<FloatArray>;
  111053. /**
  111054. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  111055. */
  111056. normals: Nullable<FloatArray>;
  111057. /**
  111058. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  111059. */
  111060. tangents: Nullable<FloatArray>;
  111061. /**
  111062. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111063. */
  111064. uvs: Nullable<FloatArray>;
  111065. /**
  111066. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111067. */
  111068. uvs2: Nullable<FloatArray>;
  111069. /**
  111070. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111071. */
  111072. uvs3: Nullable<FloatArray>;
  111073. /**
  111074. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111075. */
  111076. uvs4: Nullable<FloatArray>;
  111077. /**
  111078. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111079. */
  111080. uvs5: Nullable<FloatArray>;
  111081. /**
  111082. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111083. */
  111084. uvs6: Nullable<FloatArray>;
  111085. /**
  111086. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  111087. */
  111088. colors: Nullable<FloatArray>;
  111089. /**
  111090. * 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).
  111091. */
  111092. matricesIndices: Nullable<FloatArray>;
  111093. /**
  111094. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  111095. */
  111096. matricesWeights: Nullable<FloatArray>;
  111097. /**
  111098. * An array extending the number of possible indices
  111099. */
  111100. matricesIndicesExtra: Nullable<FloatArray>;
  111101. /**
  111102. * An array extending the number of possible weights when the number of indices is extended
  111103. */
  111104. matricesWeightsExtra: Nullable<FloatArray>;
  111105. /**
  111106. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  111107. */
  111108. indices: Nullable<IndicesArray>;
  111109. /**
  111110. * Uses the passed data array to set the set the values for the specified kind of data
  111111. * @param data a linear array of floating numbers
  111112. * @param kind the type of data that is being set, eg positions, colors etc
  111113. */
  111114. set(data: FloatArray, kind: string): void;
  111115. /**
  111116. * Associates the vertexData to the passed Mesh.
  111117. * Sets it as updatable or not (default `false`)
  111118. * @param mesh the mesh the vertexData is applied to
  111119. * @param updatable when used and having the value true allows new data to update the vertexData
  111120. * @returns the VertexData
  111121. */
  111122. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  111123. /**
  111124. * Associates the vertexData to the passed Geometry.
  111125. * Sets it as updatable or not (default `false`)
  111126. * @param geometry the geometry the vertexData is applied to
  111127. * @param updatable when used and having the value true allows new data to update the vertexData
  111128. * @returns VertexData
  111129. */
  111130. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  111131. /**
  111132. * Updates the associated mesh
  111133. * @param mesh the mesh to be updated
  111134. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111135. * @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
  111136. * @returns VertexData
  111137. */
  111138. updateMesh(mesh: Mesh): VertexData;
  111139. /**
  111140. * Updates the associated geometry
  111141. * @param geometry the geometry to be updated
  111142. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111143. * @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
  111144. * @returns VertexData.
  111145. */
  111146. updateGeometry(geometry: Geometry): VertexData;
  111147. private _applyTo;
  111148. private _update;
  111149. /**
  111150. * Transforms each position and each normal of the vertexData according to the passed Matrix
  111151. * @param matrix the transforming matrix
  111152. * @returns the VertexData
  111153. */
  111154. transform(matrix: Matrix): VertexData;
  111155. /**
  111156. * Merges the passed VertexData into the current one
  111157. * @param other the VertexData to be merged into the current one
  111158. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  111159. * @returns the modified VertexData
  111160. */
  111161. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  111162. private _mergeElement;
  111163. private _validate;
  111164. /**
  111165. * Serializes the VertexData
  111166. * @returns a serialized object
  111167. */
  111168. serialize(): any;
  111169. /**
  111170. * Extracts the vertexData from a mesh
  111171. * @param mesh the mesh from which to extract the VertexData
  111172. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  111173. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111174. * @returns the object VertexData associated to the passed mesh
  111175. */
  111176. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111177. /**
  111178. * Extracts the vertexData from the geometry
  111179. * @param geometry the geometry from which to extract the VertexData
  111180. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  111181. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111182. * @returns the object VertexData associated to the passed mesh
  111183. */
  111184. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111185. private static _ExtractFrom;
  111186. /**
  111187. * Creates the VertexData for a Ribbon
  111188. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  111189. * * pathArray array of paths, each of which an array of successive Vector3
  111190. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  111191. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  111192. * * 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
  111193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111194. * * 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)
  111195. * * 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)
  111196. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  111197. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  111198. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  111199. * @returns the VertexData of the ribbon
  111200. */
  111201. static CreateRibbon(options: {
  111202. pathArray: Vector3[][];
  111203. closeArray?: boolean;
  111204. closePath?: boolean;
  111205. offset?: number;
  111206. sideOrientation?: number;
  111207. frontUVs?: Vector4;
  111208. backUVs?: Vector4;
  111209. invertUV?: boolean;
  111210. uvs?: Vector2[];
  111211. colors?: Color4[];
  111212. }): VertexData;
  111213. /**
  111214. * Creates the VertexData for a box
  111215. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111216. * * size sets the width, height and depth of the box to the value of size, optional default 1
  111217. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  111218. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  111219. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  111220. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111221. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111223. * * 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)
  111224. * * 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)
  111225. * @returns the VertexData of the box
  111226. */
  111227. static CreateBox(options: {
  111228. size?: number;
  111229. width?: number;
  111230. height?: number;
  111231. depth?: number;
  111232. faceUV?: Vector4[];
  111233. faceColors?: Color4[];
  111234. sideOrientation?: number;
  111235. frontUVs?: Vector4;
  111236. backUVs?: Vector4;
  111237. }): VertexData;
  111238. /**
  111239. * Creates the VertexData for a tiled box
  111240. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111241. * * faceTiles sets the pattern, tile size and number of tiles for a face
  111242. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111243. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111245. * @returns the VertexData of the box
  111246. */
  111247. static CreateTiledBox(options: {
  111248. pattern?: number;
  111249. width?: number;
  111250. height?: number;
  111251. depth?: number;
  111252. tileSize?: number;
  111253. tileWidth?: number;
  111254. tileHeight?: number;
  111255. alignHorizontal?: number;
  111256. alignVertical?: number;
  111257. faceUV?: Vector4[];
  111258. faceColors?: Color4[];
  111259. sideOrientation?: number;
  111260. }): VertexData;
  111261. /**
  111262. * Creates the VertexData for a tiled plane
  111263. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111264. * * pattern a limited pattern arrangement depending on the number
  111265. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111266. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111267. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111269. * * 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)
  111270. * * 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)
  111271. * @returns the VertexData of the tiled plane
  111272. */
  111273. static CreateTiledPlane(options: {
  111274. pattern?: number;
  111275. tileSize?: number;
  111276. tileWidth?: number;
  111277. tileHeight?: number;
  111278. size?: number;
  111279. width?: number;
  111280. height?: number;
  111281. alignHorizontal?: number;
  111282. alignVertical?: number;
  111283. sideOrientation?: number;
  111284. frontUVs?: Vector4;
  111285. backUVs?: Vector4;
  111286. }): VertexData;
  111287. /**
  111288. * Creates the VertexData for an ellipsoid, defaults to a sphere
  111289. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111290. * * segments sets the number of horizontal strips optional, default 32
  111291. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  111292. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  111293. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  111294. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  111295. * * 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
  111296. * * 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
  111297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111298. * * 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)
  111299. * * 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)
  111300. * @returns the VertexData of the ellipsoid
  111301. */
  111302. static CreateSphere(options: {
  111303. segments?: number;
  111304. diameter?: number;
  111305. diameterX?: number;
  111306. diameterY?: number;
  111307. diameterZ?: number;
  111308. arc?: number;
  111309. slice?: number;
  111310. sideOrientation?: number;
  111311. frontUVs?: Vector4;
  111312. backUVs?: Vector4;
  111313. }): VertexData;
  111314. /**
  111315. * Creates the VertexData for a cylinder, cone or prism
  111316. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111317. * * height sets the height (y direction) of the cylinder, optional, default 2
  111318. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  111319. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  111320. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  111321. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111322. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  111323. * * 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
  111324. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111325. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111326. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  111327. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  111328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111329. * * 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)
  111330. * * 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)
  111331. * @returns the VertexData of the cylinder, cone or prism
  111332. */
  111333. static CreateCylinder(options: {
  111334. height?: number;
  111335. diameterTop?: number;
  111336. diameterBottom?: number;
  111337. diameter?: number;
  111338. tessellation?: number;
  111339. subdivisions?: number;
  111340. arc?: number;
  111341. faceColors?: Color4[];
  111342. faceUV?: Vector4[];
  111343. hasRings?: boolean;
  111344. enclose?: boolean;
  111345. sideOrientation?: number;
  111346. frontUVs?: Vector4;
  111347. backUVs?: Vector4;
  111348. }): VertexData;
  111349. /**
  111350. * Creates the VertexData for a torus
  111351. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111352. * * diameter the diameter of the torus, optional default 1
  111353. * * thickness the diameter of the tube forming the torus, optional default 0.5
  111354. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111356. * * 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)
  111357. * * 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)
  111358. * @returns the VertexData of the torus
  111359. */
  111360. static CreateTorus(options: {
  111361. diameter?: number;
  111362. thickness?: number;
  111363. tessellation?: number;
  111364. sideOrientation?: number;
  111365. frontUVs?: Vector4;
  111366. backUVs?: Vector4;
  111367. }): VertexData;
  111368. /**
  111369. * Creates the VertexData of the LineSystem
  111370. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  111371. * - lines an array of lines, each line being an array of successive Vector3
  111372. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  111373. * @returns the VertexData of the LineSystem
  111374. */
  111375. static CreateLineSystem(options: {
  111376. lines: Vector3[][];
  111377. colors?: Nullable<Color4[][]>;
  111378. }): VertexData;
  111379. /**
  111380. * Create the VertexData for a DashedLines
  111381. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  111382. * - points an array successive Vector3
  111383. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  111384. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  111385. * - dashNb the intended total number of dashes, optional, default 200
  111386. * @returns the VertexData for the DashedLines
  111387. */
  111388. static CreateDashedLines(options: {
  111389. points: Vector3[];
  111390. dashSize?: number;
  111391. gapSize?: number;
  111392. dashNb?: number;
  111393. }): VertexData;
  111394. /**
  111395. * Creates the VertexData for a Ground
  111396. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111397. * - width the width (x direction) of the ground, optional, default 1
  111398. * - height the height (z direction) of the ground, optional, default 1
  111399. * - subdivisions the number of subdivisions per side, optional, default 1
  111400. * @returns the VertexData of the Ground
  111401. */
  111402. static CreateGround(options: {
  111403. width?: number;
  111404. height?: number;
  111405. subdivisions?: number;
  111406. subdivisionsX?: number;
  111407. subdivisionsY?: number;
  111408. }): VertexData;
  111409. /**
  111410. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  111411. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111412. * * xmin the ground minimum X coordinate, optional, default -1
  111413. * * zmin the ground minimum Z coordinate, optional, default -1
  111414. * * xmax the ground maximum X coordinate, optional, default 1
  111415. * * zmax the ground maximum Z coordinate, optional, default 1
  111416. * * 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}
  111417. * * 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}
  111418. * @returns the VertexData of the TiledGround
  111419. */
  111420. static CreateTiledGround(options: {
  111421. xmin: number;
  111422. zmin: number;
  111423. xmax: number;
  111424. zmax: number;
  111425. subdivisions?: {
  111426. w: number;
  111427. h: number;
  111428. };
  111429. precision?: {
  111430. w: number;
  111431. h: number;
  111432. };
  111433. }): VertexData;
  111434. /**
  111435. * Creates the VertexData of the Ground designed from a heightmap
  111436. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  111437. * * width the width (x direction) of the ground
  111438. * * height the height (z direction) of the ground
  111439. * * subdivisions the number of subdivisions per side
  111440. * * minHeight the minimum altitude on the ground, optional, default 0
  111441. * * maxHeight the maximum altitude on the ground, optional default 1
  111442. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  111443. * * buffer the array holding the image color data
  111444. * * bufferWidth the width of image
  111445. * * bufferHeight the height of image
  111446. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  111447. * @returns the VertexData of the Ground designed from a heightmap
  111448. */
  111449. static CreateGroundFromHeightMap(options: {
  111450. width: number;
  111451. height: number;
  111452. subdivisions: number;
  111453. minHeight: number;
  111454. maxHeight: number;
  111455. colorFilter: Color3;
  111456. buffer: Uint8Array;
  111457. bufferWidth: number;
  111458. bufferHeight: number;
  111459. alphaFilter: number;
  111460. }): VertexData;
  111461. /**
  111462. * Creates the VertexData for a Plane
  111463. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  111464. * * size sets the width and height of the plane to the value of size, optional default 1
  111465. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  111466. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  111467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111468. * * 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)
  111469. * * 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)
  111470. * @returns the VertexData of the box
  111471. */
  111472. static CreatePlane(options: {
  111473. size?: number;
  111474. width?: number;
  111475. height?: number;
  111476. sideOrientation?: number;
  111477. frontUVs?: Vector4;
  111478. backUVs?: Vector4;
  111479. }): VertexData;
  111480. /**
  111481. * Creates the VertexData of the Disc or regular Polygon
  111482. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  111483. * * radius the radius of the disc, optional default 0.5
  111484. * * tessellation the number of polygon sides, optional, default 64
  111485. * * 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
  111486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111487. * * 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)
  111488. * * 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)
  111489. * @returns the VertexData of the box
  111490. */
  111491. static CreateDisc(options: {
  111492. radius?: number;
  111493. tessellation?: number;
  111494. arc?: number;
  111495. sideOrientation?: number;
  111496. frontUVs?: Vector4;
  111497. backUVs?: Vector4;
  111498. }): VertexData;
  111499. /**
  111500. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  111501. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  111502. * @param polygon a mesh built from polygonTriangulation.build()
  111503. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111504. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111505. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111506. * @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)
  111507. * @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)
  111508. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  111509. * @returns the VertexData of the Polygon
  111510. */
  111511. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  111512. /**
  111513. * Creates the VertexData of the IcoSphere
  111514. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  111515. * * radius the radius of the IcoSphere, optional default 1
  111516. * * radiusX allows stretching in the x direction, optional, default radius
  111517. * * radiusY allows stretching in the y direction, optional, default radius
  111518. * * radiusZ allows stretching in the z direction, optional, default radius
  111519. * * flat when true creates a flat shaded mesh, optional, default true
  111520. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111521. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111522. * * 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)
  111523. * * 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)
  111524. * @returns the VertexData of the IcoSphere
  111525. */
  111526. static CreateIcoSphere(options: {
  111527. radius?: number;
  111528. radiusX?: number;
  111529. radiusY?: number;
  111530. radiusZ?: number;
  111531. flat?: boolean;
  111532. subdivisions?: number;
  111533. sideOrientation?: number;
  111534. frontUVs?: Vector4;
  111535. backUVs?: Vector4;
  111536. }): VertexData;
  111537. /**
  111538. * Creates the VertexData for a Polyhedron
  111539. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  111540. * * type provided types are:
  111541. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  111542. * * 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)
  111543. * * size the size of the IcoSphere, optional default 1
  111544. * * sizeX allows stretching in the x direction, optional, default size
  111545. * * sizeY allows stretching in the y direction, optional, default size
  111546. * * sizeZ allows stretching in the z direction, optional, default size
  111547. * * 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
  111548. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111549. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111550. * * flat when true creates a flat shaded mesh, optional, default true
  111551. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111553. * * 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)
  111554. * * 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)
  111555. * @returns the VertexData of the Polyhedron
  111556. */
  111557. static CreatePolyhedron(options: {
  111558. type?: number;
  111559. size?: number;
  111560. sizeX?: number;
  111561. sizeY?: number;
  111562. sizeZ?: number;
  111563. custom?: any;
  111564. faceUV?: Vector4[];
  111565. faceColors?: Color4[];
  111566. flat?: boolean;
  111567. sideOrientation?: number;
  111568. frontUVs?: Vector4;
  111569. backUVs?: Vector4;
  111570. }): VertexData;
  111571. /**
  111572. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  111573. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  111574. * @returns the VertexData of the Capsule
  111575. */
  111576. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  111577. /**
  111578. * Creates the VertexData for a TorusKnot
  111579. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  111580. * * radius the radius of the torus knot, optional, default 2
  111581. * * tube the thickness of the tube, optional, default 0.5
  111582. * * radialSegments the number of sides on each tube segments, optional, default 32
  111583. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  111584. * * p the number of windings around the z axis, optional, default 2
  111585. * * q the number of windings around the x axis, optional, default 3
  111586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111587. * * 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)
  111588. * * 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)
  111589. * @returns the VertexData of the Torus Knot
  111590. */
  111591. static CreateTorusKnot(options: {
  111592. radius?: number;
  111593. tube?: number;
  111594. radialSegments?: number;
  111595. tubularSegments?: number;
  111596. p?: number;
  111597. q?: number;
  111598. sideOrientation?: number;
  111599. frontUVs?: Vector4;
  111600. backUVs?: Vector4;
  111601. }): VertexData;
  111602. /**
  111603. * Compute normals for given positions and indices
  111604. * @param positions an array of vertex positions, [...., x, y, z, ......]
  111605. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  111606. * @param normals an array of vertex normals, [...., x, y, z, ......]
  111607. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  111608. * * facetNormals : optional array of facet normals (vector3)
  111609. * * facetPositions : optional array of facet positions (vector3)
  111610. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  111611. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  111612. * * bInfo : optional bounding info, required for facetPartitioning computation
  111613. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  111614. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  111615. * * useRightHandedSystem: optional boolean to for right handed system computation
  111616. * * depthSort : optional boolean to enable the facet depth sort computation
  111617. * * distanceTo : optional Vector3 to compute the facet depth from this location
  111618. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  111619. */
  111620. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  111621. facetNormals?: any;
  111622. facetPositions?: any;
  111623. facetPartitioning?: any;
  111624. ratio?: number;
  111625. bInfo?: any;
  111626. bbSize?: Vector3;
  111627. subDiv?: any;
  111628. useRightHandedSystem?: boolean;
  111629. depthSort?: boolean;
  111630. distanceTo?: Vector3;
  111631. depthSortedFacets?: any;
  111632. }): void;
  111633. /** @hidden */
  111634. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  111635. /**
  111636. * Applies VertexData created from the imported parameters to the geometry
  111637. * @param parsedVertexData the parsed data from an imported file
  111638. * @param geometry the geometry to apply the VertexData to
  111639. */
  111640. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  111641. }
  111642. }
  111643. declare module BABYLON {
  111644. /**
  111645. * Defines a target to use with MorphTargetManager
  111646. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111647. */
  111648. export class MorphTarget implements IAnimatable {
  111649. /** defines the name of the target */
  111650. name: string;
  111651. /**
  111652. * Gets or sets the list of animations
  111653. */
  111654. animations: Animation[];
  111655. private _scene;
  111656. private _positions;
  111657. private _normals;
  111658. private _tangents;
  111659. private _uvs;
  111660. private _influence;
  111661. private _uniqueId;
  111662. /**
  111663. * Observable raised when the influence changes
  111664. */
  111665. onInfluenceChanged: Observable<boolean>;
  111666. /** @hidden */
  111667. _onDataLayoutChanged: Observable<void>;
  111668. /**
  111669. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  111670. */
  111671. get influence(): number;
  111672. set influence(influence: number);
  111673. /**
  111674. * Gets or sets the id of the morph Target
  111675. */
  111676. id: string;
  111677. private _animationPropertiesOverride;
  111678. /**
  111679. * Gets or sets the animation properties override
  111680. */
  111681. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111682. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111683. /**
  111684. * Creates a new MorphTarget
  111685. * @param name defines the name of the target
  111686. * @param influence defines the influence to use
  111687. * @param scene defines the scene the morphtarget belongs to
  111688. */
  111689. constructor(
  111690. /** defines the name of the target */
  111691. name: string, influence?: number, scene?: Nullable<Scene>);
  111692. /**
  111693. * Gets the unique ID of this manager
  111694. */
  111695. get uniqueId(): number;
  111696. /**
  111697. * Gets a boolean defining if the target contains position data
  111698. */
  111699. get hasPositions(): boolean;
  111700. /**
  111701. * Gets a boolean defining if the target contains normal data
  111702. */
  111703. get hasNormals(): boolean;
  111704. /**
  111705. * Gets a boolean defining if the target contains tangent data
  111706. */
  111707. get hasTangents(): boolean;
  111708. /**
  111709. * Gets a boolean defining if the target contains texture coordinates data
  111710. */
  111711. get hasUVs(): boolean;
  111712. /**
  111713. * Affects position data to this target
  111714. * @param data defines the position data to use
  111715. */
  111716. setPositions(data: Nullable<FloatArray>): void;
  111717. /**
  111718. * Gets the position data stored in this target
  111719. * @returns a FloatArray containing the position data (or null if not present)
  111720. */
  111721. getPositions(): Nullable<FloatArray>;
  111722. /**
  111723. * Affects normal data to this target
  111724. * @param data defines the normal data to use
  111725. */
  111726. setNormals(data: Nullable<FloatArray>): void;
  111727. /**
  111728. * Gets the normal data stored in this target
  111729. * @returns a FloatArray containing the normal data (or null if not present)
  111730. */
  111731. getNormals(): Nullable<FloatArray>;
  111732. /**
  111733. * Affects tangent data to this target
  111734. * @param data defines the tangent data to use
  111735. */
  111736. setTangents(data: Nullable<FloatArray>): void;
  111737. /**
  111738. * Gets the tangent data stored in this target
  111739. * @returns a FloatArray containing the tangent data (or null if not present)
  111740. */
  111741. getTangents(): Nullable<FloatArray>;
  111742. /**
  111743. * Affects texture coordinates data to this target
  111744. * @param data defines the texture coordinates data to use
  111745. */
  111746. setUVs(data: Nullable<FloatArray>): void;
  111747. /**
  111748. * Gets the texture coordinates data stored in this target
  111749. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  111750. */
  111751. getUVs(): Nullable<FloatArray>;
  111752. /**
  111753. * Clone the current target
  111754. * @returns a new MorphTarget
  111755. */
  111756. clone(): MorphTarget;
  111757. /**
  111758. * Serializes the current target into a Serialization object
  111759. * @returns the serialized object
  111760. */
  111761. serialize(): any;
  111762. /**
  111763. * Returns the string "MorphTarget"
  111764. * @returns "MorphTarget"
  111765. */
  111766. getClassName(): string;
  111767. /**
  111768. * Creates a new target from serialized data
  111769. * @param serializationObject defines the serialized data to use
  111770. * @returns a new MorphTarget
  111771. */
  111772. static Parse(serializationObject: any): MorphTarget;
  111773. /**
  111774. * Creates a MorphTarget from mesh data
  111775. * @param mesh defines the source mesh
  111776. * @param name defines the name to use for the new target
  111777. * @param influence defines the influence to attach to the target
  111778. * @returns a new MorphTarget
  111779. */
  111780. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  111781. }
  111782. }
  111783. declare module BABYLON {
  111784. /**
  111785. * This class is used to deform meshes using morphing between different targets
  111786. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111787. */
  111788. export class MorphTargetManager {
  111789. private _targets;
  111790. private _targetInfluenceChangedObservers;
  111791. private _targetDataLayoutChangedObservers;
  111792. private _activeTargets;
  111793. private _scene;
  111794. private _influences;
  111795. private _supportsNormals;
  111796. private _supportsTangents;
  111797. private _supportsUVs;
  111798. private _vertexCount;
  111799. private _uniqueId;
  111800. private _tempInfluences;
  111801. /**
  111802. * Gets or sets a boolean indicating if normals must be morphed
  111803. */
  111804. enableNormalMorphing: boolean;
  111805. /**
  111806. * Gets or sets a boolean indicating if tangents must be morphed
  111807. */
  111808. enableTangentMorphing: boolean;
  111809. /**
  111810. * Gets or sets a boolean indicating if UV must be morphed
  111811. */
  111812. enableUVMorphing: boolean;
  111813. /**
  111814. * Creates a new MorphTargetManager
  111815. * @param scene defines the current scene
  111816. */
  111817. constructor(scene?: Nullable<Scene>);
  111818. /**
  111819. * Gets the unique ID of this manager
  111820. */
  111821. get uniqueId(): number;
  111822. /**
  111823. * Gets the number of vertices handled by this manager
  111824. */
  111825. get vertexCount(): number;
  111826. /**
  111827. * Gets a boolean indicating if this manager supports morphing of normals
  111828. */
  111829. get supportsNormals(): boolean;
  111830. /**
  111831. * Gets a boolean indicating if this manager supports morphing of tangents
  111832. */
  111833. get supportsTangents(): boolean;
  111834. /**
  111835. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  111836. */
  111837. get supportsUVs(): boolean;
  111838. /**
  111839. * Gets the number of targets stored in this manager
  111840. */
  111841. get numTargets(): number;
  111842. /**
  111843. * Gets the number of influencers (ie. the number of targets with influences > 0)
  111844. */
  111845. get numInfluencers(): number;
  111846. /**
  111847. * Gets the list of influences (one per target)
  111848. */
  111849. get influences(): Float32Array;
  111850. /**
  111851. * Gets the active target at specified index. An active target is a target with an influence > 0
  111852. * @param index defines the index to check
  111853. * @returns the requested target
  111854. */
  111855. getActiveTarget(index: number): MorphTarget;
  111856. /**
  111857. * Gets the target at specified index
  111858. * @param index defines the index to check
  111859. * @returns the requested target
  111860. */
  111861. getTarget(index: number): MorphTarget;
  111862. /**
  111863. * Add a new target to this manager
  111864. * @param target defines the target to add
  111865. */
  111866. addTarget(target: MorphTarget): void;
  111867. /**
  111868. * Removes a target from the manager
  111869. * @param target defines the target to remove
  111870. */
  111871. removeTarget(target: MorphTarget): void;
  111872. /**
  111873. * Clone the current manager
  111874. * @returns a new MorphTargetManager
  111875. */
  111876. clone(): MorphTargetManager;
  111877. /**
  111878. * Serializes the current manager into a Serialization object
  111879. * @returns the serialized object
  111880. */
  111881. serialize(): any;
  111882. private _syncActiveTargets;
  111883. /**
  111884. * Syncrhonize the targets with all the meshes using this morph target manager
  111885. */
  111886. synchronize(): void;
  111887. /**
  111888. * Creates a new MorphTargetManager from serialized data
  111889. * @param serializationObject defines the serialized data
  111890. * @param scene defines the hosting scene
  111891. * @returns the new MorphTargetManager
  111892. */
  111893. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  111894. }
  111895. }
  111896. declare module BABYLON {
  111897. /**
  111898. * Class used to represent a specific level of detail of a mesh
  111899. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  111900. */
  111901. export class MeshLODLevel {
  111902. /** Defines the distance where this level should start being displayed */
  111903. distance: number;
  111904. /** Defines the mesh to use to render this level */
  111905. mesh: Nullable<Mesh>;
  111906. /**
  111907. * Creates a new LOD level
  111908. * @param distance defines the distance where this level should star being displayed
  111909. * @param mesh defines the mesh to use to render this level
  111910. */
  111911. constructor(
  111912. /** Defines the distance where this level should start being displayed */
  111913. distance: number,
  111914. /** Defines the mesh to use to render this level */
  111915. mesh: Nullable<Mesh>);
  111916. }
  111917. }
  111918. declare module BABYLON {
  111919. /**
  111920. * Helper class used to generate a canvas to manipulate images
  111921. */
  111922. export class CanvasGenerator {
  111923. /**
  111924. * Create a new canvas (or offscreen canvas depending on the context)
  111925. * @param width defines the expected width
  111926. * @param height defines the expected height
  111927. * @return a new canvas or offscreen canvas
  111928. */
  111929. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  111930. }
  111931. }
  111932. declare module BABYLON {
  111933. /**
  111934. * Mesh representing the gorund
  111935. */
  111936. export class GroundMesh extends Mesh {
  111937. /** If octree should be generated */
  111938. generateOctree: boolean;
  111939. private _heightQuads;
  111940. /** @hidden */
  111941. _subdivisionsX: number;
  111942. /** @hidden */
  111943. _subdivisionsY: number;
  111944. /** @hidden */
  111945. _width: number;
  111946. /** @hidden */
  111947. _height: number;
  111948. /** @hidden */
  111949. _minX: number;
  111950. /** @hidden */
  111951. _maxX: number;
  111952. /** @hidden */
  111953. _minZ: number;
  111954. /** @hidden */
  111955. _maxZ: number;
  111956. constructor(name: string, scene: Scene);
  111957. /**
  111958. * "GroundMesh"
  111959. * @returns "GroundMesh"
  111960. */
  111961. getClassName(): string;
  111962. /**
  111963. * The minimum of x and y subdivisions
  111964. */
  111965. get subdivisions(): number;
  111966. /**
  111967. * X subdivisions
  111968. */
  111969. get subdivisionsX(): number;
  111970. /**
  111971. * Y subdivisions
  111972. */
  111973. get subdivisionsY(): number;
  111974. /**
  111975. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  111976. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111977. * @param chunksCount the number of subdivisions for x and y
  111978. * @param octreeBlocksSize (Default: 32)
  111979. */
  111980. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  111981. /**
  111982. * Returns a height (y) value in the Worl system :
  111983. * the ground altitude at the coordinates (x, z) expressed in the World system.
  111984. * @param x x coordinate
  111985. * @param z z coordinate
  111986. * @returns the ground y position if (x, z) are outside the ground surface.
  111987. */
  111988. getHeightAtCoordinates(x: number, z: number): number;
  111989. /**
  111990. * Returns a normalized vector (Vector3) orthogonal to the ground
  111991. * at the ground coordinates (x, z) expressed in the World system.
  111992. * @param x x coordinate
  111993. * @param z z coordinate
  111994. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  111995. */
  111996. getNormalAtCoordinates(x: number, z: number): Vector3;
  111997. /**
  111998. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  111999. * at the ground coordinates (x, z) expressed in the World system.
  112000. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112001. * @param x x coordinate
  112002. * @param z z coordinate
  112003. * @param ref vector to store the result
  112004. * @returns the GroundMesh.
  112005. */
  112006. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112007. /**
  112008. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112009. * if the ground has been updated.
  112010. * This can be used in the render loop.
  112011. * @returns the GroundMesh.
  112012. */
  112013. updateCoordinateHeights(): GroundMesh;
  112014. private _getFacetAt;
  112015. private _initHeightQuads;
  112016. private _computeHeightQuads;
  112017. /**
  112018. * Serializes this ground mesh
  112019. * @param serializationObject object to write serialization to
  112020. */
  112021. serialize(serializationObject: any): void;
  112022. /**
  112023. * Parses a serialized ground mesh
  112024. * @param parsedMesh the serialized mesh
  112025. * @param scene the scene to create the ground mesh in
  112026. * @returns the created ground mesh
  112027. */
  112028. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112029. }
  112030. }
  112031. declare module BABYLON {
  112032. /**
  112033. * Interface for Physics-Joint data
  112034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112035. */
  112036. export interface PhysicsJointData {
  112037. /**
  112038. * The main pivot of the joint
  112039. */
  112040. mainPivot?: Vector3;
  112041. /**
  112042. * The connected pivot of the joint
  112043. */
  112044. connectedPivot?: Vector3;
  112045. /**
  112046. * The main axis of the joint
  112047. */
  112048. mainAxis?: Vector3;
  112049. /**
  112050. * The connected axis of the joint
  112051. */
  112052. connectedAxis?: Vector3;
  112053. /**
  112054. * The collision of the joint
  112055. */
  112056. collision?: boolean;
  112057. /**
  112058. * Native Oimo/Cannon/Energy data
  112059. */
  112060. nativeParams?: any;
  112061. }
  112062. /**
  112063. * This is a holder class for the physics joint created by the physics plugin
  112064. * It holds a set of functions to control the underlying joint
  112065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112066. */
  112067. export class PhysicsJoint {
  112068. /**
  112069. * The type of the physics joint
  112070. */
  112071. type: number;
  112072. /**
  112073. * The data for the physics joint
  112074. */
  112075. jointData: PhysicsJointData;
  112076. private _physicsJoint;
  112077. protected _physicsPlugin: IPhysicsEnginePlugin;
  112078. /**
  112079. * Initializes the physics joint
  112080. * @param type The type of the physics joint
  112081. * @param jointData The data for the physics joint
  112082. */
  112083. constructor(
  112084. /**
  112085. * The type of the physics joint
  112086. */
  112087. type: number,
  112088. /**
  112089. * The data for the physics joint
  112090. */
  112091. jointData: PhysicsJointData);
  112092. /**
  112093. * Gets the physics joint
  112094. */
  112095. get physicsJoint(): any;
  112096. /**
  112097. * Sets the physics joint
  112098. */
  112099. set physicsJoint(newJoint: any);
  112100. /**
  112101. * Sets the physics plugin
  112102. */
  112103. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112104. /**
  112105. * Execute a function that is physics-plugin specific.
  112106. * @param {Function} func the function that will be executed.
  112107. * It accepts two parameters: the physics world and the physics joint
  112108. */
  112109. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112110. /**
  112111. * Distance-Joint type
  112112. */
  112113. static DistanceJoint: number;
  112114. /**
  112115. * Hinge-Joint type
  112116. */
  112117. static HingeJoint: number;
  112118. /**
  112119. * Ball-and-Socket joint type
  112120. */
  112121. static BallAndSocketJoint: number;
  112122. /**
  112123. * Wheel-Joint type
  112124. */
  112125. static WheelJoint: number;
  112126. /**
  112127. * Slider-Joint type
  112128. */
  112129. static SliderJoint: number;
  112130. /**
  112131. * Prismatic-Joint type
  112132. */
  112133. static PrismaticJoint: number;
  112134. /**
  112135. * Universal-Joint type
  112136. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112137. */
  112138. static UniversalJoint: number;
  112139. /**
  112140. * Hinge-Joint 2 type
  112141. */
  112142. static Hinge2Joint: number;
  112143. /**
  112144. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112145. */
  112146. static PointToPointJoint: number;
  112147. /**
  112148. * Spring-Joint type
  112149. */
  112150. static SpringJoint: number;
  112151. /**
  112152. * Lock-Joint type
  112153. */
  112154. static LockJoint: number;
  112155. }
  112156. /**
  112157. * A class representing a physics distance joint
  112158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112159. */
  112160. export class DistanceJoint extends PhysicsJoint {
  112161. /**
  112162. *
  112163. * @param jointData The data for the Distance-Joint
  112164. */
  112165. constructor(jointData: DistanceJointData);
  112166. /**
  112167. * Update the predefined distance.
  112168. * @param maxDistance The maximum preferred distance
  112169. * @param minDistance The minimum preferred distance
  112170. */
  112171. updateDistance(maxDistance: number, minDistance?: number): void;
  112172. }
  112173. /**
  112174. * Represents a Motor-Enabled Joint
  112175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112176. */
  112177. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112178. /**
  112179. * Initializes the Motor-Enabled Joint
  112180. * @param type The type of the joint
  112181. * @param jointData The physica joint data for the joint
  112182. */
  112183. constructor(type: number, jointData: PhysicsJointData);
  112184. /**
  112185. * Set the motor values.
  112186. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112187. * @param force the force to apply
  112188. * @param maxForce max force for this motor.
  112189. */
  112190. setMotor(force?: number, maxForce?: number): void;
  112191. /**
  112192. * Set the motor's limits.
  112193. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112194. * @param upperLimit The upper limit of the motor
  112195. * @param lowerLimit The lower limit of the motor
  112196. */
  112197. setLimit(upperLimit: number, lowerLimit?: number): void;
  112198. }
  112199. /**
  112200. * This class represents a single physics Hinge-Joint
  112201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112202. */
  112203. export class HingeJoint extends MotorEnabledJoint {
  112204. /**
  112205. * Initializes the Hinge-Joint
  112206. * @param jointData The joint data for the Hinge-Joint
  112207. */
  112208. constructor(jointData: PhysicsJointData);
  112209. /**
  112210. * Set the motor values.
  112211. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112212. * @param {number} force the force to apply
  112213. * @param {number} maxForce max force for this motor.
  112214. */
  112215. setMotor(force?: number, maxForce?: number): void;
  112216. /**
  112217. * Set the motor's limits.
  112218. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112219. * @param upperLimit The upper limit of the motor
  112220. * @param lowerLimit The lower limit of the motor
  112221. */
  112222. setLimit(upperLimit: number, lowerLimit?: number): void;
  112223. }
  112224. /**
  112225. * This class represents a dual hinge physics joint (same as wheel joint)
  112226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112227. */
  112228. export class Hinge2Joint extends MotorEnabledJoint {
  112229. /**
  112230. * Initializes the Hinge2-Joint
  112231. * @param jointData The joint data for the Hinge2-Joint
  112232. */
  112233. constructor(jointData: PhysicsJointData);
  112234. /**
  112235. * Set the motor values.
  112236. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112237. * @param {number} targetSpeed the speed the motor is to reach
  112238. * @param {number} maxForce max force for this motor.
  112239. * @param {motorIndex} the motor's index, 0 or 1.
  112240. */
  112241. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112242. /**
  112243. * Set the motor limits.
  112244. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112245. * @param {number} upperLimit the upper limit
  112246. * @param {number} lowerLimit lower limit
  112247. * @param {motorIndex} the motor's index, 0 or 1.
  112248. */
  112249. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112250. }
  112251. /**
  112252. * Interface for a motor enabled joint
  112253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112254. */
  112255. export interface IMotorEnabledJoint {
  112256. /**
  112257. * Physics joint
  112258. */
  112259. physicsJoint: any;
  112260. /**
  112261. * Sets the motor of the motor-enabled joint
  112262. * @param force The force of the motor
  112263. * @param maxForce The maximum force of the motor
  112264. * @param motorIndex The index of the motor
  112265. */
  112266. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112267. /**
  112268. * Sets the limit of the motor
  112269. * @param upperLimit The upper limit of the motor
  112270. * @param lowerLimit The lower limit of the motor
  112271. * @param motorIndex The index of the motor
  112272. */
  112273. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112274. }
  112275. /**
  112276. * Joint data for a Distance-Joint
  112277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112278. */
  112279. export interface DistanceJointData extends PhysicsJointData {
  112280. /**
  112281. * Max distance the 2 joint objects can be apart
  112282. */
  112283. maxDistance: number;
  112284. }
  112285. /**
  112286. * Joint data from a spring joint
  112287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112288. */
  112289. export interface SpringJointData extends PhysicsJointData {
  112290. /**
  112291. * Length of the spring
  112292. */
  112293. length: number;
  112294. /**
  112295. * Stiffness of the spring
  112296. */
  112297. stiffness: number;
  112298. /**
  112299. * Damping of the spring
  112300. */
  112301. damping: number;
  112302. /** this callback will be called when applying the force to the impostors. */
  112303. forceApplicationCallback: () => void;
  112304. }
  112305. }
  112306. declare module BABYLON {
  112307. /**
  112308. * Holds the data for the raycast result
  112309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112310. */
  112311. export class PhysicsRaycastResult {
  112312. private _hasHit;
  112313. private _hitDistance;
  112314. private _hitNormalWorld;
  112315. private _hitPointWorld;
  112316. private _rayFromWorld;
  112317. private _rayToWorld;
  112318. /**
  112319. * Gets if there was a hit
  112320. */
  112321. get hasHit(): boolean;
  112322. /**
  112323. * Gets the distance from the hit
  112324. */
  112325. get hitDistance(): number;
  112326. /**
  112327. * Gets the hit normal/direction in the world
  112328. */
  112329. get hitNormalWorld(): Vector3;
  112330. /**
  112331. * Gets the hit point in the world
  112332. */
  112333. get hitPointWorld(): Vector3;
  112334. /**
  112335. * Gets the ray "start point" of the ray in the world
  112336. */
  112337. get rayFromWorld(): Vector3;
  112338. /**
  112339. * Gets the ray "end point" of the ray in the world
  112340. */
  112341. get rayToWorld(): Vector3;
  112342. /**
  112343. * Sets the hit data (normal & point in world space)
  112344. * @param hitNormalWorld defines the normal in world space
  112345. * @param hitPointWorld defines the point in world space
  112346. */
  112347. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112348. /**
  112349. * Sets the distance from the start point to the hit point
  112350. * @param distance
  112351. */
  112352. setHitDistance(distance: number): void;
  112353. /**
  112354. * Calculates the distance manually
  112355. */
  112356. calculateHitDistance(): void;
  112357. /**
  112358. * Resets all the values to default
  112359. * @param from The from point on world space
  112360. * @param to The to point on world space
  112361. */
  112362. reset(from?: Vector3, to?: Vector3): void;
  112363. }
  112364. /**
  112365. * Interface for the size containing width and height
  112366. */
  112367. interface IXYZ {
  112368. /**
  112369. * X
  112370. */
  112371. x: number;
  112372. /**
  112373. * Y
  112374. */
  112375. y: number;
  112376. /**
  112377. * Z
  112378. */
  112379. z: number;
  112380. }
  112381. }
  112382. declare module BABYLON {
  112383. /**
  112384. * Interface used to describe a physics joint
  112385. */
  112386. export interface PhysicsImpostorJoint {
  112387. /** Defines the main impostor to which the joint is linked */
  112388. mainImpostor: PhysicsImpostor;
  112389. /** Defines the impostor that is connected to the main impostor using this joint */
  112390. connectedImpostor: PhysicsImpostor;
  112391. /** Defines the joint itself */
  112392. joint: PhysicsJoint;
  112393. }
  112394. /** @hidden */
  112395. export interface IPhysicsEnginePlugin {
  112396. world: any;
  112397. name: string;
  112398. setGravity(gravity: Vector3): void;
  112399. setTimeStep(timeStep: number): void;
  112400. getTimeStep(): number;
  112401. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112402. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112403. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112404. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112405. removePhysicsBody(impostor: PhysicsImpostor): void;
  112406. generateJoint(joint: PhysicsImpostorJoint): void;
  112407. removeJoint(joint: PhysicsImpostorJoint): void;
  112408. isSupported(): boolean;
  112409. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112410. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112411. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112412. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112413. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112414. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112415. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112416. getBodyMass(impostor: PhysicsImpostor): number;
  112417. getBodyFriction(impostor: PhysicsImpostor): number;
  112418. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112419. getBodyRestitution(impostor: PhysicsImpostor): number;
  112420. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112421. getBodyPressure?(impostor: PhysicsImpostor): number;
  112422. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  112423. getBodyStiffness?(impostor: PhysicsImpostor): number;
  112424. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  112425. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  112426. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  112427. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  112428. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  112429. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112430. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112431. sleepBody(impostor: PhysicsImpostor): void;
  112432. wakeUpBody(impostor: PhysicsImpostor): void;
  112433. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112434. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112435. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  112436. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112437. getRadius(impostor: PhysicsImpostor): number;
  112438. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112439. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112440. dispose(): void;
  112441. }
  112442. /**
  112443. * Interface used to define a physics engine
  112444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112445. */
  112446. export interface IPhysicsEngine {
  112447. /**
  112448. * Gets the gravity vector used by the simulation
  112449. */
  112450. gravity: Vector3;
  112451. /**
  112452. * Sets the gravity vector used by the simulation
  112453. * @param gravity defines the gravity vector to use
  112454. */
  112455. setGravity(gravity: Vector3): void;
  112456. /**
  112457. * Set the time step of the physics engine.
  112458. * Default is 1/60.
  112459. * To slow it down, enter 1/600 for example.
  112460. * To speed it up, 1/30
  112461. * @param newTimeStep the new timestep to apply to this world.
  112462. */
  112463. setTimeStep(newTimeStep: number): void;
  112464. /**
  112465. * Get the time step of the physics engine.
  112466. * @returns the current time step
  112467. */
  112468. getTimeStep(): number;
  112469. /**
  112470. * Set the sub time step of the physics engine.
  112471. * Default is 0 meaning there is no sub steps
  112472. * To increase physics resolution precision, set a small value (like 1 ms)
  112473. * @param subTimeStep defines the new sub timestep used for physics resolution.
  112474. */
  112475. setSubTimeStep(subTimeStep: number): void;
  112476. /**
  112477. * Get the sub time step of the physics engine.
  112478. * @returns the current sub time step
  112479. */
  112480. getSubTimeStep(): number;
  112481. /**
  112482. * Release all resources
  112483. */
  112484. dispose(): void;
  112485. /**
  112486. * Gets the name of the current physics plugin
  112487. * @returns the name of the plugin
  112488. */
  112489. getPhysicsPluginName(): string;
  112490. /**
  112491. * Adding a new impostor for the impostor tracking.
  112492. * This will be done by the impostor itself.
  112493. * @param impostor the impostor to add
  112494. */
  112495. addImpostor(impostor: PhysicsImpostor): void;
  112496. /**
  112497. * Remove an impostor from the engine.
  112498. * This impostor and its mesh will not longer be updated by the physics engine.
  112499. * @param impostor the impostor to remove
  112500. */
  112501. removeImpostor(impostor: PhysicsImpostor): void;
  112502. /**
  112503. * Add a joint to the physics engine
  112504. * @param mainImpostor defines the main impostor to which the joint is added.
  112505. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112506. * @param joint defines the joint that will connect both impostors.
  112507. */
  112508. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112509. /**
  112510. * Removes a joint from the simulation
  112511. * @param mainImpostor defines the impostor used with the joint
  112512. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112513. * @param joint defines the joint to remove
  112514. */
  112515. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112516. /**
  112517. * Gets the current plugin used to run the simulation
  112518. * @returns current plugin
  112519. */
  112520. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112521. /**
  112522. * Gets the list of physic impostors
  112523. * @returns an array of PhysicsImpostor
  112524. */
  112525. getImpostors(): Array<PhysicsImpostor>;
  112526. /**
  112527. * Gets the impostor for a physics enabled object
  112528. * @param object defines the object impersonated by the impostor
  112529. * @returns the PhysicsImpostor or null if not found
  112530. */
  112531. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112532. /**
  112533. * Gets the impostor for a physics body object
  112534. * @param body defines physics body used by the impostor
  112535. * @returns the PhysicsImpostor or null if not found
  112536. */
  112537. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112538. /**
  112539. * Does a raycast in the physics world
  112540. * @param from when should the ray start?
  112541. * @param to when should the ray end?
  112542. * @returns PhysicsRaycastResult
  112543. */
  112544. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112545. /**
  112546. * Called by the scene. No need to call it.
  112547. * @param delta defines the timespam between frames
  112548. */
  112549. _step(delta: number): void;
  112550. }
  112551. }
  112552. declare module BABYLON {
  112553. /**
  112554. * The interface for the physics imposter parameters
  112555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112556. */
  112557. export interface PhysicsImpostorParameters {
  112558. /**
  112559. * The mass of the physics imposter
  112560. */
  112561. mass: number;
  112562. /**
  112563. * The friction of the physics imposter
  112564. */
  112565. friction?: number;
  112566. /**
  112567. * The coefficient of restitution of the physics imposter
  112568. */
  112569. restitution?: number;
  112570. /**
  112571. * The native options of the physics imposter
  112572. */
  112573. nativeOptions?: any;
  112574. /**
  112575. * Specifies if the parent should be ignored
  112576. */
  112577. ignoreParent?: boolean;
  112578. /**
  112579. * Specifies if bi-directional transformations should be disabled
  112580. */
  112581. disableBidirectionalTransformation?: boolean;
  112582. /**
  112583. * The pressure inside the physics imposter, soft object only
  112584. */
  112585. pressure?: number;
  112586. /**
  112587. * The stiffness the physics imposter, soft object only
  112588. */
  112589. stiffness?: number;
  112590. /**
  112591. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  112592. */
  112593. velocityIterations?: number;
  112594. /**
  112595. * The number of iterations used in maintaining consistent vertex positions, soft object only
  112596. */
  112597. positionIterations?: number;
  112598. /**
  112599. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  112600. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  112601. * Add to fix multiple points
  112602. */
  112603. fixedPoints?: number;
  112604. /**
  112605. * The collision margin around a soft object
  112606. */
  112607. margin?: number;
  112608. /**
  112609. * The collision margin around a soft object
  112610. */
  112611. damping?: number;
  112612. /**
  112613. * The path for a rope based on an extrusion
  112614. */
  112615. path?: any;
  112616. /**
  112617. * The shape of an extrusion used for a rope based on an extrusion
  112618. */
  112619. shape?: any;
  112620. }
  112621. /**
  112622. * Interface for a physics-enabled object
  112623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112624. */
  112625. export interface IPhysicsEnabledObject {
  112626. /**
  112627. * The position of the physics-enabled object
  112628. */
  112629. position: Vector3;
  112630. /**
  112631. * The rotation of the physics-enabled object
  112632. */
  112633. rotationQuaternion: Nullable<Quaternion>;
  112634. /**
  112635. * The scale of the physics-enabled object
  112636. */
  112637. scaling: Vector3;
  112638. /**
  112639. * The rotation of the physics-enabled object
  112640. */
  112641. rotation?: Vector3;
  112642. /**
  112643. * The parent of the physics-enabled object
  112644. */
  112645. parent?: any;
  112646. /**
  112647. * The bounding info of the physics-enabled object
  112648. * @returns The bounding info of the physics-enabled object
  112649. */
  112650. getBoundingInfo(): BoundingInfo;
  112651. /**
  112652. * Computes the world matrix
  112653. * @param force Specifies if the world matrix should be computed by force
  112654. * @returns A world matrix
  112655. */
  112656. computeWorldMatrix(force: boolean): Matrix;
  112657. /**
  112658. * Gets the world matrix
  112659. * @returns A world matrix
  112660. */
  112661. getWorldMatrix?(): Matrix;
  112662. /**
  112663. * Gets the child meshes
  112664. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  112665. * @returns An array of abstract meshes
  112666. */
  112667. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  112668. /**
  112669. * Gets the vertex data
  112670. * @param kind The type of vertex data
  112671. * @returns A nullable array of numbers, or a float32 array
  112672. */
  112673. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  112674. /**
  112675. * Gets the indices from the mesh
  112676. * @returns A nullable array of index arrays
  112677. */
  112678. getIndices?(): Nullable<IndicesArray>;
  112679. /**
  112680. * Gets the scene from the mesh
  112681. * @returns the indices array or null
  112682. */
  112683. getScene?(): Scene;
  112684. /**
  112685. * Gets the absolute position from the mesh
  112686. * @returns the absolute position
  112687. */
  112688. getAbsolutePosition(): Vector3;
  112689. /**
  112690. * Gets the absolute pivot point from the mesh
  112691. * @returns the absolute pivot point
  112692. */
  112693. getAbsolutePivotPoint(): Vector3;
  112694. /**
  112695. * Rotates the mesh
  112696. * @param axis The axis of rotation
  112697. * @param amount The amount of rotation
  112698. * @param space The space of the rotation
  112699. * @returns The rotation transform node
  112700. */
  112701. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  112702. /**
  112703. * Translates the mesh
  112704. * @param axis The axis of translation
  112705. * @param distance The distance of translation
  112706. * @param space The space of the translation
  112707. * @returns The transform node
  112708. */
  112709. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  112710. /**
  112711. * Sets the absolute position of the mesh
  112712. * @param absolutePosition The absolute position of the mesh
  112713. * @returns The transform node
  112714. */
  112715. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  112716. /**
  112717. * Gets the class name of the mesh
  112718. * @returns The class name
  112719. */
  112720. getClassName(): string;
  112721. }
  112722. /**
  112723. * Represents a physics imposter
  112724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112725. */
  112726. export class PhysicsImpostor {
  112727. /**
  112728. * The physics-enabled object used as the physics imposter
  112729. */
  112730. object: IPhysicsEnabledObject;
  112731. /**
  112732. * The type of the physics imposter
  112733. */
  112734. type: number;
  112735. private _options;
  112736. private _scene?;
  112737. /**
  112738. * The default object size of the imposter
  112739. */
  112740. static DEFAULT_OBJECT_SIZE: Vector3;
  112741. /**
  112742. * The identity quaternion of the imposter
  112743. */
  112744. static IDENTITY_QUATERNION: Quaternion;
  112745. /** @hidden */
  112746. _pluginData: any;
  112747. private _physicsEngine;
  112748. private _physicsBody;
  112749. private _bodyUpdateRequired;
  112750. private _onBeforePhysicsStepCallbacks;
  112751. private _onAfterPhysicsStepCallbacks;
  112752. /** @hidden */
  112753. _onPhysicsCollideCallbacks: Array<{
  112754. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  112755. otherImpostors: Array<PhysicsImpostor>;
  112756. }>;
  112757. private _deltaPosition;
  112758. private _deltaRotation;
  112759. private _deltaRotationConjugated;
  112760. /** @hidden */
  112761. _isFromLine: boolean;
  112762. private _parent;
  112763. private _isDisposed;
  112764. private static _tmpVecs;
  112765. private static _tmpQuat;
  112766. /**
  112767. * Specifies if the physics imposter is disposed
  112768. */
  112769. get isDisposed(): boolean;
  112770. /**
  112771. * Gets the mass of the physics imposter
  112772. */
  112773. get mass(): number;
  112774. set mass(value: number);
  112775. /**
  112776. * Gets the coefficient of friction
  112777. */
  112778. get friction(): number;
  112779. /**
  112780. * Sets the coefficient of friction
  112781. */
  112782. set friction(value: number);
  112783. /**
  112784. * Gets the coefficient of restitution
  112785. */
  112786. get restitution(): number;
  112787. /**
  112788. * Sets the coefficient of restitution
  112789. */
  112790. set restitution(value: number);
  112791. /**
  112792. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  112793. */
  112794. get pressure(): number;
  112795. /**
  112796. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  112797. */
  112798. set pressure(value: number);
  112799. /**
  112800. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112801. */
  112802. get stiffness(): number;
  112803. /**
  112804. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112805. */
  112806. set stiffness(value: number);
  112807. /**
  112808. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112809. */
  112810. get velocityIterations(): number;
  112811. /**
  112812. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112813. */
  112814. set velocityIterations(value: number);
  112815. /**
  112816. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112817. */
  112818. get positionIterations(): number;
  112819. /**
  112820. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112821. */
  112822. set positionIterations(value: number);
  112823. /**
  112824. * The unique id of the physics imposter
  112825. * set by the physics engine when adding this impostor to the array
  112826. */
  112827. uniqueId: number;
  112828. /**
  112829. * @hidden
  112830. */
  112831. soft: boolean;
  112832. /**
  112833. * @hidden
  112834. */
  112835. segments: number;
  112836. private _joints;
  112837. /**
  112838. * Initializes the physics imposter
  112839. * @param object The physics-enabled object used as the physics imposter
  112840. * @param type The type of the physics imposter
  112841. * @param _options The options for the physics imposter
  112842. * @param _scene The Babylon scene
  112843. */
  112844. constructor(
  112845. /**
  112846. * The physics-enabled object used as the physics imposter
  112847. */
  112848. object: IPhysicsEnabledObject,
  112849. /**
  112850. * The type of the physics imposter
  112851. */
  112852. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  112853. /**
  112854. * This function will completly initialize this impostor.
  112855. * It will create a new body - but only if this mesh has no parent.
  112856. * If it has, this impostor will not be used other than to define the impostor
  112857. * of the child mesh.
  112858. * @hidden
  112859. */
  112860. _init(): void;
  112861. private _getPhysicsParent;
  112862. /**
  112863. * Should a new body be generated.
  112864. * @returns boolean specifying if body initialization is required
  112865. */
  112866. isBodyInitRequired(): boolean;
  112867. /**
  112868. * Sets the updated scaling
  112869. * @param updated Specifies if the scaling is updated
  112870. */
  112871. setScalingUpdated(): void;
  112872. /**
  112873. * Force a regeneration of this or the parent's impostor's body.
  112874. * Use under cautious - This will remove all joints already implemented.
  112875. */
  112876. forceUpdate(): void;
  112877. /**
  112878. * Gets the body that holds this impostor. Either its own, or its parent.
  112879. */
  112880. get physicsBody(): any;
  112881. /**
  112882. * Get the parent of the physics imposter
  112883. * @returns Physics imposter or null
  112884. */
  112885. get parent(): Nullable<PhysicsImpostor>;
  112886. /**
  112887. * Sets the parent of the physics imposter
  112888. */
  112889. set parent(value: Nullable<PhysicsImpostor>);
  112890. /**
  112891. * Set the physics body. Used mainly by the physics engine/plugin
  112892. */
  112893. set physicsBody(physicsBody: any);
  112894. /**
  112895. * Resets the update flags
  112896. */
  112897. resetUpdateFlags(): void;
  112898. /**
  112899. * Gets the object extend size
  112900. * @returns the object extend size
  112901. */
  112902. getObjectExtendSize(): Vector3;
  112903. /**
  112904. * Gets the object center
  112905. * @returns The object center
  112906. */
  112907. getObjectCenter(): Vector3;
  112908. /**
  112909. * Get a specific parameter from the options parameters
  112910. * @param paramName The object parameter name
  112911. * @returns The object parameter
  112912. */
  112913. getParam(paramName: string): any;
  112914. /**
  112915. * Sets a specific parameter in the options given to the physics plugin
  112916. * @param paramName The parameter name
  112917. * @param value The value of the parameter
  112918. */
  112919. setParam(paramName: string, value: number): void;
  112920. /**
  112921. * Specifically change the body's mass option. Won't recreate the physics body object
  112922. * @param mass The mass of the physics imposter
  112923. */
  112924. setMass(mass: number): void;
  112925. /**
  112926. * Gets the linear velocity
  112927. * @returns linear velocity or null
  112928. */
  112929. getLinearVelocity(): Nullable<Vector3>;
  112930. /**
  112931. * Sets the linear velocity
  112932. * @param velocity linear velocity or null
  112933. */
  112934. setLinearVelocity(velocity: Nullable<Vector3>): void;
  112935. /**
  112936. * Gets the angular velocity
  112937. * @returns angular velocity or null
  112938. */
  112939. getAngularVelocity(): Nullable<Vector3>;
  112940. /**
  112941. * Sets the angular velocity
  112942. * @param velocity The velocity or null
  112943. */
  112944. setAngularVelocity(velocity: Nullable<Vector3>): void;
  112945. /**
  112946. * Execute a function with the physics plugin native code
  112947. * Provide a function the will have two variables - the world object and the physics body object
  112948. * @param func The function to execute with the physics plugin native code
  112949. */
  112950. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  112951. /**
  112952. * Register a function that will be executed before the physics world is stepping forward
  112953. * @param func The function to execute before the physics world is stepped forward
  112954. */
  112955. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112956. /**
  112957. * Unregister a function that will be executed before the physics world is stepping forward
  112958. * @param func The function to execute before the physics world is stepped forward
  112959. */
  112960. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112961. /**
  112962. * Register a function that will be executed after the physics step
  112963. * @param func The function to execute after physics step
  112964. */
  112965. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112966. /**
  112967. * Unregisters a function that will be executed after the physics step
  112968. * @param func The function to execute after physics step
  112969. */
  112970. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112971. /**
  112972. * register a function that will be executed when this impostor collides against a different body
  112973. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  112974. * @param func Callback that is executed on collision
  112975. */
  112976. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  112977. /**
  112978. * Unregisters the physics imposter on contact
  112979. * @param collideAgainst The physics object to collide against
  112980. * @param func Callback to execute on collision
  112981. */
  112982. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  112983. private _tmpQuat;
  112984. private _tmpQuat2;
  112985. /**
  112986. * Get the parent rotation
  112987. * @returns The parent rotation
  112988. */
  112989. getParentsRotation(): Quaternion;
  112990. /**
  112991. * this function is executed by the physics engine.
  112992. */
  112993. beforeStep: () => void;
  112994. /**
  112995. * this function is executed by the physics engine
  112996. */
  112997. afterStep: () => void;
  112998. /**
  112999. * Legacy collision detection event support
  113000. */
  113001. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113002. /**
  113003. * event and body object due to cannon's event-based architecture.
  113004. */
  113005. onCollide: (e: {
  113006. body: any;
  113007. point: Nullable<Vector3>;
  113008. }) => void;
  113009. /**
  113010. * Apply a force
  113011. * @param force The force to apply
  113012. * @param contactPoint The contact point for the force
  113013. * @returns The physics imposter
  113014. */
  113015. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113016. /**
  113017. * Apply an impulse
  113018. * @param force The impulse force
  113019. * @param contactPoint The contact point for the impulse force
  113020. * @returns The physics imposter
  113021. */
  113022. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113023. /**
  113024. * A help function to create a joint
  113025. * @param otherImpostor A physics imposter used to create a joint
  113026. * @param jointType The type of joint
  113027. * @param jointData The data for the joint
  113028. * @returns The physics imposter
  113029. */
  113030. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113031. /**
  113032. * Add a joint to this impostor with a different impostor
  113033. * @param otherImpostor A physics imposter used to add a joint
  113034. * @param joint The joint to add
  113035. * @returns The physics imposter
  113036. */
  113037. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113038. /**
  113039. * Add an anchor to a cloth impostor
  113040. * @param otherImpostor rigid impostor to anchor to
  113041. * @param width ratio across width from 0 to 1
  113042. * @param height ratio up height from 0 to 1
  113043. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113044. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113045. * @returns impostor the soft imposter
  113046. */
  113047. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113048. /**
  113049. * Add a hook to a rope impostor
  113050. * @param otherImpostor rigid impostor to anchor to
  113051. * @param length ratio across rope from 0 to 1
  113052. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113053. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113054. * @returns impostor the rope imposter
  113055. */
  113056. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113057. /**
  113058. * Will keep this body still, in a sleep mode.
  113059. * @returns the physics imposter
  113060. */
  113061. sleep(): PhysicsImpostor;
  113062. /**
  113063. * Wake the body up.
  113064. * @returns The physics imposter
  113065. */
  113066. wakeUp(): PhysicsImpostor;
  113067. /**
  113068. * Clones the physics imposter
  113069. * @param newObject The physics imposter clones to this physics-enabled object
  113070. * @returns A nullable physics imposter
  113071. */
  113072. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113073. /**
  113074. * Disposes the physics imposter
  113075. */
  113076. dispose(): void;
  113077. /**
  113078. * Sets the delta position
  113079. * @param position The delta position amount
  113080. */
  113081. setDeltaPosition(position: Vector3): void;
  113082. /**
  113083. * Sets the delta rotation
  113084. * @param rotation The delta rotation amount
  113085. */
  113086. setDeltaRotation(rotation: Quaternion): void;
  113087. /**
  113088. * Gets the box size of the physics imposter and stores the result in the input parameter
  113089. * @param result Stores the box size
  113090. * @returns The physics imposter
  113091. */
  113092. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113093. /**
  113094. * Gets the radius of the physics imposter
  113095. * @returns Radius of the physics imposter
  113096. */
  113097. getRadius(): number;
  113098. /**
  113099. * Sync a bone with this impostor
  113100. * @param bone The bone to sync to the impostor.
  113101. * @param boneMesh The mesh that the bone is influencing.
  113102. * @param jointPivot The pivot of the joint / bone in local space.
  113103. * @param distToJoint Optional distance from the impostor to the joint.
  113104. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113105. */
  113106. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113107. /**
  113108. * Sync impostor to a bone
  113109. * @param bone The bone that the impostor will be synced to.
  113110. * @param boneMesh The mesh that the bone is influencing.
  113111. * @param jointPivot The pivot of the joint / bone in local space.
  113112. * @param distToJoint Optional distance from the impostor to the joint.
  113113. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113114. * @param boneAxis Optional vector3 axis the bone is aligned with
  113115. */
  113116. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113117. /**
  113118. * No-Imposter type
  113119. */
  113120. static NoImpostor: number;
  113121. /**
  113122. * Sphere-Imposter type
  113123. */
  113124. static SphereImpostor: number;
  113125. /**
  113126. * Box-Imposter type
  113127. */
  113128. static BoxImpostor: number;
  113129. /**
  113130. * Plane-Imposter type
  113131. */
  113132. static PlaneImpostor: number;
  113133. /**
  113134. * Mesh-imposter type
  113135. */
  113136. static MeshImpostor: number;
  113137. /**
  113138. * Capsule-Impostor type (Ammo.js plugin only)
  113139. */
  113140. static CapsuleImpostor: number;
  113141. /**
  113142. * Cylinder-Imposter type
  113143. */
  113144. static CylinderImpostor: number;
  113145. /**
  113146. * Particle-Imposter type
  113147. */
  113148. static ParticleImpostor: number;
  113149. /**
  113150. * Heightmap-Imposter type
  113151. */
  113152. static HeightmapImpostor: number;
  113153. /**
  113154. * ConvexHull-Impostor type (Ammo.js plugin only)
  113155. */
  113156. static ConvexHullImpostor: number;
  113157. /**
  113158. * Custom-Imposter type (Ammo.js plugin only)
  113159. */
  113160. static CustomImpostor: number;
  113161. /**
  113162. * Rope-Imposter type
  113163. */
  113164. static RopeImpostor: number;
  113165. /**
  113166. * Cloth-Imposter type
  113167. */
  113168. static ClothImpostor: number;
  113169. /**
  113170. * Softbody-Imposter type
  113171. */
  113172. static SoftbodyImpostor: number;
  113173. }
  113174. }
  113175. declare module BABYLON {
  113176. /**
  113177. * @hidden
  113178. **/
  113179. export class _CreationDataStorage {
  113180. closePath?: boolean;
  113181. closeArray?: boolean;
  113182. idx: number[];
  113183. dashSize: number;
  113184. gapSize: number;
  113185. path3D: Path3D;
  113186. pathArray: Vector3[][];
  113187. arc: number;
  113188. radius: number;
  113189. cap: number;
  113190. tessellation: number;
  113191. }
  113192. /**
  113193. * @hidden
  113194. **/
  113195. class _InstanceDataStorage {
  113196. visibleInstances: any;
  113197. batchCache: _InstancesBatch;
  113198. instancesBufferSize: number;
  113199. instancesBuffer: Nullable<Buffer>;
  113200. instancesData: Float32Array;
  113201. overridenInstanceCount: number;
  113202. isFrozen: boolean;
  113203. previousBatch: Nullable<_InstancesBatch>;
  113204. hardwareInstancedRendering: boolean;
  113205. sideOrientation: number;
  113206. manualUpdate: boolean;
  113207. previousRenderId: number;
  113208. }
  113209. /**
  113210. * @hidden
  113211. **/
  113212. export class _InstancesBatch {
  113213. mustReturn: boolean;
  113214. visibleInstances: Nullable<InstancedMesh[]>[];
  113215. renderSelf: boolean[];
  113216. hardwareInstancedRendering: boolean[];
  113217. }
  113218. /**
  113219. * @hidden
  113220. **/
  113221. class _ThinInstanceDataStorage {
  113222. instancesCount: number;
  113223. matrixBuffer: Nullable<Buffer>;
  113224. matrixBufferSize: number;
  113225. matrixData: Nullable<Float32Array>;
  113226. boundingVectors: Array<Vector3>;
  113227. worldMatrices: Nullable<Matrix[]>;
  113228. }
  113229. /**
  113230. * Class used to represent renderable models
  113231. */
  113232. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113233. /**
  113234. * Mesh side orientation : usually the external or front surface
  113235. */
  113236. static readonly FRONTSIDE: number;
  113237. /**
  113238. * Mesh side orientation : usually the internal or back surface
  113239. */
  113240. static readonly BACKSIDE: number;
  113241. /**
  113242. * Mesh side orientation : both internal and external or front and back surfaces
  113243. */
  113244. static readonly DOUBLESIDE: number;
  113245. /**
  113246. * Mesh side orientation : by default, `FRONTSIDE`
  113247. */
  113248. static readonly DEFAULTSIDE: number;
  113249. /**
  113250. * Mesh cap setting : no cap
  113251. */
  113252. static readonly NO_CAP: number;
  113253. /**
  113254. * Mesh cap setting : one cap at the beginning of the mesh
  113255. */
  113256. static readonly CAP_START: number;
  113257. /**
  113258. * Mesh cap setting : one cap at the end of the mesh
  113259. */
  113260. static readonly CAP_END: number;
  113261. /**
  113262. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113263. */
  113264. static readonly CAP_ALL: number;
  113265. /**
  113266. * Mesh pattern setting : no flip or rotate
  113267. */
  113268. static readonly NO_FLIP: number;
  113269. /**
  113270. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113271. */
  113272. static readonly FLIP_TILE: number;
  113273. /**
  113274. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113275. */
  113276. static readonly ROTATE_TILE: number;
  113277. /**
  113278. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113279. */
  113280. static readonly FLIP_ROW: number;
  113281. /**
  113282. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113283. */
  113284. static readonly ROTATE_ROW: number;
  113285. /**
  113286. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113287. */
  113288. static readonly FLIP_N_ROTATE_TILE: number;
  113289. /**
  113290. * Mesh pattern setting : rotate pattern and rotate
  113291. */
  113292. static readonly FLIP_N_ROTATE_ROW: number;
  113293. /**
  113294. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113295. */
  113296. static readonly CENTER: number;
  113297. /**
  113298. * Mesh tile positioning : part tiles on left
  113299. */
  113300. static readonly LEFT: number;
  113301. /**
  113302. * Mesh tile positioning : part tiles on right
  113303. */
  113304. static readonly RIGHT: number;
  113305. /**
  113306. * Mesh tile positioning : part tiles on top
  113307. */
  113308. static readonly TOP: number;
  113309. /**
  113310. * Mesh tile positioning : part tiles on bottom
  113311. */
  113312. static readonly BOTTOM: number;
  113313. /**
  113314. * Gets the default side orientation.
  113315. * @param orientation the orientation to value to attempt to get
  113316. * @returns the default orientation
  113317. * @hidden
  113318. */
  113319. static _GetDefaultSideOrientation(orientation?: number): number;
  113320. private _internalMeshDataInfo;
  113321. get computeBonesUsingShaders(): boolean;
  113322. set computeBonesUsingShaders(value: boolean);
  113323. /**
  113324. * An event triggered before rendering the mesh
  113325. */
  113326. get onBeforeRenderObservable(): Observable<Mesh>;
  113327. /**
  113328. * An event triggered before binding the mesh
  113329. */
  113330. get onBeforeBindObservable(): Observable<Mesh>;
  113331. /**
  113332. * An event triggered after rendering the mesh
  113333. */
  113334. get onAfterRenderObservable(): Observable<Mesh>;
  113335. /**
  113336. * An event triggered before drawing the mesh
  113337. */
  113338. get onBeforeDrawObservable(): Observable<Mesh>;
  113339. private _onBeforeDrawObserver;
  113340. /**
  113341. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113342. */
  113343. set onBeforeDraw(callback: () => void);
  113344. get hasInstances(): boolean;
  113345. get hasThinInstances(): boolean;
  113346. /**
  113347. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113348. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113349. */
  113350. delayLoadState: number;
  113351. /**
  113352. * Gets the list of instances created from this mesh
  113353. * it is not supposed to be modified manually.
  113354. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113355. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113356. */
  113357. instances: InstancedMesh[];
  113358. /**
  113359. * Gets the file containing delay loading data for this mesh
  113360. */
  113361. delayLoadingFile: string;
  113362. /** @hidden */
  113363. _binaryInfo: any;
  113364. /**
  113365. * User defined function used to change how LOD level selection is done
  113366. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113367. */
  113368. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113369. /**
  113370. * Gets or sets the morph target manager
  113371. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113372. */
  113373. get morphTargetManager(): Nullable<MorphTargetManager>;
  113374. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113375. /** @hidden */
  113376. _creationDataStorage: Nullable<_CreationDataStorage>;
  113377. /** @hidden */
  113378. _geometry: Nullable<Geometry>;
  113379. /** @hidden */
  113380. _delayInfo: Array<string>;
  113381. /** @hidden */
  113382. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  113383. /** @hidden */
  113384. _instanceDataStorage: _InstanceDataStorage;
  113385. /** @hidden */
  113386. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  113387. private _effectiveMaterial;
  113388. /** @hidden */
  113389. _shouldGenerateFlatShading: boolean;
  113390. /** @hidden */
  113391. _originalBuilderSideOrientation: number;
  113392. /**
  113393. * Use this property to change the original side orientation defined at construction time
  113394. */
  113395. overrideMaterialSideOrientation: Nullable<number>;
  113396. /**
  113397. * Gets the source mesh (the one used to clone this one from)
  113398. */
  113399. get source(): Nullable<Mesh>;
  113400. /**
  113401. * Gets the list of clones of this mesh
  113402. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  113403. * Note that useClonedMeshMap=true is the default setting
  113404. */
  113405. get cloneMeshMap(): Nullable<{
  113406. [id: string]: Mesh | undefined;
  113407. }>;
  113408. /**
  113409. * Gets or sets a boolean indicating that this mesh does not use index buffer
  113410. */
  113411. get isUnIndexed(): boolean;
  113412. set isUnIndexed(value: boolean);
  113413. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  113414. get worldMatrixInstancedBuffer(): Float32Array;
  113415. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  113416. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  113417. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  113418. /**
  113419. * @constructor
  113420. * @param name The value used by scene.getMeshByName() to do a lookup.
  113421. * @param scene The scene to add this mesh to.
  113422. * @param parent The parent of this mesh, if it has one
  113423. * @param source An optional Mesh from which geometry is shared, cloned.
  113424. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113425. * When false, achieved by calling a clone(), also passing False.
  113426. * This will make creation of children, recursive.
  113427. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  113428. */
  113429. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  113430. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  113431. doNotInstantiate: boolean;
  113432. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  113433. /**
  113434. * Gets the class name
  113435. * @returns the string "Mesh".
  113436. */
  113437. getClassName(): string;
  113438. /** @hidden */
  113439. get _isMesh(): boolean;
  113440. /**
  113441. * Returns a description of this mesh
  113442. * @param fullDetails define if full details about this mesh must be used
  113443. * @returns a descriptive string representing this mesh
  113444. */
  113445. toString(fullDetails?: boolean): string;
  113446. /** @hidden */
  113447. _unBindEffect(): void;
  113448. /**
  113449. * Gets a boolean indicating if this mesh has LOD
  113450. */
  113451. get hasLODLevels(): boolean;
  113452. /**
  113453. * Gets the list of MeshLODLevel associated with the current mesh
  113454. * @returns an array of MeshLODLevel
  113455. */
  113456. getLODLevels(): MeshLODLevel[];
  113457. private _sortLODLevels;
  113458. /**
  113459. * Add a mesh as LOD level triggered at the given distance.
  113460. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113461. * @param distance The distance from the center of the object to show this level
  113462. * @param mesh The mesh to be added as LOD level (can be null)
  113463. * @return This mesh (for chaining)
  113464. */
  113465. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  113466. /**
  113467. * Returns the LOD level mesh at the passed distance or null if not found.
  113468. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113469. * @param distance The distance from the center of the object to show this level
  113470. * @returns a Mesh or `null`
  113471. */
  113472. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  113473. /**
  113474. * Remove a mesh from the LOD array
  113475. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113476. * @param mesh defines the mesh to be removed
  113477. * @return This mesh (for chaining)
  113478. */
  113479. removeLODLevel(mesh: Mesh): Mesh;
  113480. /**
  113481. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  113482. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113483. * @param camera defines the camera to use to compute distance
  113484. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  113485. * @return This mesh (for chaining)
  113486. */
  113487. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  113488. /**
  113489. * Gets the mesh internal Geometry object
  113490. */
  113491. get geometry(): Nullable<Geometry>;
  113492. /**
  113493. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  113494. * @returns the total number of vertices
  113495. */
  113496. getTotalVertices(): number;
  113497. /**
  113498. * Returns the content of an associated vertex buffer
  113499. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113500. * - VertexBuffer.PositionKind
  113501. * - VertexBuffer.UVKind
  113502. * - VertexBuffer.UV2Kind
  113503. * - VertexBuffer.UV3Kind
  113504. * - VertexBuffer.UV4Kind
  113505. * - VertexBuffer.UV5Kind
  113506. * - VertexBuffer.UV6Kind
  113507. * - VertexBuffer.ColorKind
  113508. * - VertexBuffer.MatricesIndicesKind
  113509. * - VertexBuffer.MatricesIndicesExtraKind
  113510. * - VertexBuffer.MatricesWeightsKind
  113511. * - VertexBuffer.MatricesWeightsExtraKind
  113512. * @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
  113513. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  113514. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  113515. */
  113516. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  113517. /**
  113518. * Returns the mesh VertexBuffer object from the requested `kind`
  113519. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113520. * - VertexBuffer.PositionKind
  113521. * - VertexBuffer.NormalKind
  113522. * - VertexBuffer.UVKind
  113523. * - VertexBuffer.UV2Kind
  113524. * - VertexBuffer.UV3Kind
  113525. * - VertexBuffer.UV4Kind
  113526. * - VertexBuffer.UV5Kind
  113527. * - VertexBuffer.UV6Kind
  113528. * - VertexBuffer.ColorKind
  113529. * - VertexBuffer.MatricesIndicesKind
  113530. * - VertexBuffer.MatricesIndicesExtraKind
  113531. * - VertexBuffer.MatricesWeightsKind
  113532. * - VertexBuffer.MatricesWeightsExtraKind
  113533. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  113534. */
  113535. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  113536. /**
  113537. * Tests if a specific vertex buffer is associated with this mesh
  113538. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113539. * - VertexBuffer.PositionKind
  113540. * - VertexBuffer.NormalKind
  113541. * - VertexBuffer.UVKind
  113542. * - VertexBuffer.UV2Kind
  113543. * - VertexBuffer.UV3Kind
  113544. * - VertexBuffer.UV4Kind
  113545. * - VertexBuffer.UV5Kind
  113546. * - VertexBuffer.UV6Kind
  113547. * - VertexBuffer.ColorKind
  113548. * - VertexBuffer.MatricesIndicesKind
  113549. * - VertexBuffer.MatricesIndicesExtraKind
  113550. * - VertexBuffer.MatricesWeightsKind
  113551. * - VertexBuffer.MatricesWeightsExtraKind
  113552. * @returns a boolean
  113553. */
  113554. isVerticesDataPresent(kind: string): boolean;
  113555. /**
  113556. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  113557. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113558. * - VertexBuffer.PositionKind
  113559. * - VertexBuffer.UVKind
  113560. * - VertexBuffer.UV2Kind
  113561. * - VertexBuffer.UV3Kind
  113562. * - VertexBuffer.UV4Kind
  113563. * - VertexBuffer.UV5Kind
  113564. * - VertexBuffer.UV6Kind
  113565. * - VertexBuffer.ColorKind
  113566. * - VertexBuffer.MatricesIndicesKind
  113567. * - VertexBuffer.MatricesIndicesExtraKind
  113568. * - VertexBuffer.MatricesWeightsKind
  113569. * - VertexBuffer.MatricesWeightsExtraKind
  113570. * @returns a boolean
  113571. */
  113572. isVertexBufferUpdatable(kind: string): boolean;
  113573. /**
  113574. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  113575. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113576. * - VertexBuffer.PositionKind
  113577. * - VertexBuffer.NormalKind
  113578. * - VertexBuffer.UVKind
  113579. * - VertexBuffer.UV2Kind
  113580. * - VertexBuffer.UV3Kind
  113581. * - VertexBuffer.UV4Kind
  113582. * - VertexBuffer.UV5Kind
  113583. * - VertexBuffer.UV6Kind
  113584. * - VertexBuffer.ColorKind
  113585. * - VertexBuffer.MatricesIndicesKind
  113586. * - VertexBuffer.MatricesIndicesExtraKind
  113587. * - VertexBuffer.MatricesWeightsKind
  113588. * - VertexBuffer.MatricesWeightsExtraKind
  113589. * @returns an array of strings
  113590. */
  113591. getVerticesDataKinds(): string[];
  113592. /**
  113593. * Returns a positive integer : the total number of indices in this mesh geometry.
  113594. * @returns the numner of indices or zero if the mesh has no geometry.
  113595. */
  113596. getTotalIndices(): number;
  113597. /**
  113598. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113599. * @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.
  113600. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  113601. * @returns the indices array or an empty array if the mesh has no geometry
  113602. */
  113603. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  113604. get isBlocked(): boolean;
  113605. /**
  113606. * Determine if the current mesh is ready to be rendered
  113607. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113608. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  113609. * @returns true if all associated assets are ready (material, textures, shaders)
  113610. */
  113611. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  113612. /**
  113613. * 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.
  113614. */
  113615. get areNormalsFrozen(): boolean;
  113616. /**
  113617. * 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.
  113618. * @returns the current mesh
  113619. */
  113620. freezeNormals(): Mesh;
  113621. /**
  113622. * 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
  113623. * @returns the current mesh
  113624. */
  113625. unfreezeNormals(): Mesh;
  113626. /**
  113627. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  113628. */
  113629. set overridenInstanceCount(count: number);
  113630. /** @hidden */
  113631. _preActivate(): Mesh;
  113632. /** @hidden */
  113633. _preActivateForIntermediateRendering(renderId: number): Mesh;
  113634. /** @hidden */
  113635. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  113636. protected _afterComputeWorldMatrix(): void;
  113637. /** @hidden */
  113638. _postActivate(): void;
  113639. /**
  113640. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113641. * This means the mesh underlying bounding box and sphere are recomputed.
  113642. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113643. * @returns the current mesh
  113644. */
  113645. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  113646. /** @hidden */
  113647. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  113648. /**
  113649. * This function will subdivide the mesh into multiple submeshes
  113650. * @param count defines the expected number of submeshes
  113651. */
  113652. subdivide(count: number): void;
  113653. /**
  113654. * Copy a FloatArray into a specific associated vertex buffer
  113655. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113656. * - VertexBuffer.PositionKind
  113657. * - VertexBuffer.UVKind
  113658. * - VertexBuffer.UV2Kind
  113659. * - VertexBuffer.UV3Kind
  113660. * - VertexBuffer.UV4Kind
  113661. * - VertexBuffer.UV5Kind
  113662. * - VertexBuffer.UV6Kind
  113663. * - VertexBuffer.ColorKind
  113664. * - VertexBuffer.MatricesIndicesKind
  113665. * - VertexBuffer.MatricesIndicesExtraKind
  113666. * - VertexBuffer.MatricesWeightsKind
  113667. * - VertexBuffer.MatricesWeightsExtraKind
  113668. * @param data defines the data source
  113669. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113670. * @param stride defines the data stride size (can be null)
  113671. * @returns the current mesh
  113672. */
  113673. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113674. /**
  113675. * Delete a vertex buffer associated with this mesh
  113676. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  113677. * - VertexBuffer.PositionKind
  113678. * - VertexBuffer.UVKind
  113679. * - VertexBuffer.UV2Kind
  113680. * - VertexBuffer.UV3Kind
  113681. * - VertexBuffer.UV4Kind
  113682. * - VertexBuffer.UV5Kind
  113683. * - VertexBuffer.UV6Kind
  113684. * - VertexBuffer.ColorKind
  113685. * - VertexBuffer.MatricesIndicesKind
  113686. * - VertexBuffer.MatricesIndicesExtraKind
  113687. * - VertexBuffer.MatricesWeightsKind
  113688. * - VertexBuffer.MatricesWeightsExtraKind
  113689. */
  113690. removeVerticesData(kind: string): void;
  113691. /**
  113692. * Flags an associated vertex buffer as updatable
  113693. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  113694. * - VertexBuffer.PositionKind
  113695. * - VertexBuffer.UVKind
  113696. * - VertexBuffer.UV2Kind
  113697. * - VertexBuffer.UV3Kind
  113698. * - VertexBuffer.UV4Kind
  113699. * - VertexBuffer.UV5Kind
  113700. * - VertexBuffer.UV6Kind
  113701. * - VertexBuffer.ColorKind
  113702. * - VertexBuffer.MatricesIndicesKind
  113703. * - VertexBuffer.MatricesIndicesExtraKind
  113704. * - VertexBuffer.MatricesWeightsKind
  113705. * - VertexBuffer.MatricesWeightsExtraKind
  113706. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113707. */
  113708. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  113709. /**
  113710. * Sets the mesh global Vertex Buffer
  113711. * @param buffer defines the buffer to use
  113712. * @returns the current mesh
  113713. */
  113714. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  113715. /**
  113716. * Update a specific associated vertex buffer
  113717. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113718. * - VertexBuffer.PositionKind
  113719. * - VertexBuffer.UVKind
  113720. * - VertexBuffer.UV2Kind
  113721. * - VertexBuffer.UV3Kind
  113722. * - VertexBuffer.UV4Kind
  113723. * - VertexBuffer.UV5Kind
  113724. * - VertexBuffer.UV6Kind
  113725. * - VertexBuffer.ColorKind
  113726. * - VertexBuffer.MatricesIndicesKind
  113727. * - VertexBuffer.MatricesIndicesExtraKind
  113728. * - VertexBuffer.MatricesWeightsKind
  113729. * - VertexBuffer.MatricesWeightsExtraKind
  113730. * @param data defines the data source
  113731. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  113732. * @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)
  113733. * @returns the current mesh
  113734. */
  113735. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  113736. /**
  113737. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  113738. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  113739. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  113740. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  113741. * @returns the current mesh
  113742. */
  113743. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  113744. /**
  113745. * Creates a un-shared specific occurence of the geometry for the mesh.
  113746. * @returns the current mesh
  113747. */
  113748. makeGeometryUnique(): Mesh;
  113749. /**
  113750. * Set the index buffer of this mesh
  113751. * @param indices defines the source data
  113752. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  113753. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  113754. * @returns the current mesh
  113755. */
  113756. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  113757. /**
  113758. * Update the current index buffer
  113759. * @param indices defines the source data
  113760. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113761. * @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)
  113762. * @returns the current mesh
  113763. */
  113764. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113765. /**
  113766. * Invert the geometry to move from a right handed system to a left handed one.
  113767. * @returns the current mesh
  113768. */
  113769. toLeftHanded(): Mesh;
  113770. /** @hidden */
  113771. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113772. /** @hidden */
  113773. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113774. /**
  113775. * Registers for this mesh a javascript function called just before the rendering process
  113776. * @param func defines the function to call before rendering this mesh
  113777. * @returns the current mesh
  113778. */
  113779. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113780. /**
  113781. * Disposes a previously registered javascript function called before the rendering
  113782. * @param func defines the function to remove
  113783. * @returns the current mesh
  113784. */
  113785. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113786. /**
  113787. * Registers for this mesh a javascript function called just after the rendering is complete
  113788. * @param func defines the function to call after rendering this mesh
  113789. * @returns the current mesh
  113790. */
  113791. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113792. /**
  113793. * Disposes a previously registered javascript function called after the rendering.
  113794. * @param func defines the function to remove
  113795. * @returns the current mesh
  113796. */
  113797. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113798. /** @hidden */
  113799. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  113800. /** @hidden */
  113801. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  113802. /** @hidden */
  113803. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  113804. /** @hidden */
  113805. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  113806. /** @hidden */
  113807. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  113808. /** @hidden */
  113809. _rebuild(): void;
  113810. /** @hidden */
  113811. _freeze(): void;
  113812. /** @hidden */
  113813. _unFreeze(): void;
  113814. /**
  113815. * 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
  113816. * @param subMesh defines the subMesh to render
  113817. * @param enableAlphaMode defines if alpha mode can be changed
  113818. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  113819. * @returns the current mesh
  113820. */
  113821. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  113822. private _onBeforeDraw;
  113823. /**
  113824. * Renormalize the mesh and patch it up if there are no weights
  113825. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  113826. * However in the case of zero weights then we set just a single influence to 1.
  113827. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  113828. */
  113829. cleanMatrixWeights(): void;
  113830. private normalizeSkinFourWeights;
  113831. private normalizeSkinWeightsAndExtra;
  113832. /**
  113833. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  113834. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  113835. * the user know there was an issue with importing the mesh
  113836. * @returns a validation object with skinned, valid and report string
  113837. */
  113838. validateSkinning(): {
  113839. skinned: boolean;
  113840. valid: boolean;
  113841. report: string;
  113842. };
  113843. /** @hidden */
  113844. _checkDelayState(): Mesh;
  113845. private _queueLoad;
  113846. /**
  113847. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  113848. * A mesh is in the frustum if its bounding box intersects the frustum
  113849. * @param frustumPlanes defines the frustum to test
  113850. * @returns true if the mesh is in the frustum planes
  113851. */
  113852. isInFrustum(frustumPlanes: Plane[]): boolean;
  113853. /**
  113854. * Sets the mesh material by the material or multiMaterial `id` property
  113855. * @param id is a string identifying the material or the multiMaterial
  113856. * @returns the current mesh
  113857. */
  113858. setMaterialByID(id: string): Mesh;
  113859. /**
  113860. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  113861. * @returns an array of IAnimatable
  113862. */
  113863. getAnimatables(): IAnimatable[];
  113864. /**
  113865. * Modifies the mesh geometry according to the passed transformation matrix.
  113866. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  113867. * The mesh normals are modified using the same transformation.
  113868. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113869. * @param transform defines the transform matrix to use
  113870. * @see https://doc.babylonjs.com/resources/baking_transformations
  113871. * @returns the current mesh
  113872. */
  113873. bakeTransformIntoVertices(transform: Matrix): Mesh;
  113874. /**
  113875. * Modifies the mesh geometry according to its own current World Matrix.
  113876. * The mesh World Matrix is then reset.
  113877. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  113878. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113879. * @see https://doc.babylonjs.com/resources/baking_transformations
  113880. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  113881. * @returns the current mesh
  113882. */
  113883. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  113884. /** @hidden */
  113885. get _positions(): Nullable<Vector3[]>;
  113886. /** @hidden */
  113887. _resetPointsArrayCache(): Mesh;
  113888. /** @hidden */
  113889. _generatePointsArray(): boolean;
  113890. /**
  113891. * Returns a new Mesh object generated from the current mesh properties.
  113892. * This method must not get confused with createInstance()
  113893. * @param name is a string, the name given to the new mesh
  113894. * @param newParent can be any Node object (default `null`)
  113895. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  113896. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  113897. * @returns a new mesh
  113898. */
  113899. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  113900. /**
  113901. * Releases resources associated with this mesh.
  113902. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113903. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113904. */
  113905. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113906. /** @hidden */
  113907. _disposeInstanceSpecificData(): void;
  113908. /** @hidden */
  113909. _disposeThinInstanceSpecificData(): void;
  113910. /**
  113911. * Modifies the mesh geometry according to a displacement map.
  113912. * 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.
  113913. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113914. * @param url is a string, the URL from the image file is to be downloaded.
  113915. * @param minHeight is the lower limit of the displacement.
  113916. * @param maxHeight is the upper limit of the displacement.
  113917. * @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.
  113918. * @param uvOffset is an optional vector2 used to offset UV.
  113919. * @param uvScale is an optional vector2 used to scale UV.
  113920. * @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.
  113921. * @returns the Mesh.
  113922. */
  113923. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113924. /**
  113925. * Modifies the mesh geometry according to a displacementMap buffer.
  113926. * 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.
  113927. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113928. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  113929. * @param heightMapWidth is the width of the buffer image.
  113930. * @param heightMapHeight is the height of the buffer image.
  113931. * @param minHeight is the lower limit of the displacement.
  113932. * @param maxHeight is the upper limit of the displacement.
  113933. * @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.
  113934. * @param uvOffset is an optional vector2 used to offset UV.
  113935. * @param uvScale is an optional vector2 used to scale UV.
  113936. * @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.
  113937. * @returns the Mesh.
  113938. */
  113939. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113940. /**
  113941. * Modify the mesh to get a flat shading rendering.
  113942. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  113943. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  113944. * @returns current mesh
  113945. */
  113946. convertToFlatShadedMesh(): Mesh;
  113947. /**
  113948. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  113949. * In other words, more vertices, no more indices and a single bigger VBO.
  113950. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  113951. * @returns current mesh
  113952. */
  113953. convertToUnIndexedMesh(): Mesh;
  113954. /**
  113955. * Inverses facet orientations.
  113956. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113957. * @param flipNormals will also inverts the normals
  113958. * @returns current mesh
  113959. */
  113960. flipFaces(flipNormals?: boolean): Mesh;
  113961. /**
  113962. * Increase the number of facets and hence vertices in a mesh
  113963. * Vertex normals are interpolated from existing vertex normals
  113964. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113965. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  113966. */
  113967. increaseVertices(numberPerEdge: number): void;
  113968. /**
  113969. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  113970. * This will undo any application of covertToFlatShadedMesh
  113971. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113972. */
  113973. forceSharedVertices(): void;
  113974. /** @hidden */
  113975. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  113976. /** @hidden */
  113977. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  113978. /**
  113979. * Creates a new InstancedMesh object from the mesh model.
  113980. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113981. * @param name defines the name of the new instance
  113982. * @returns a new InstancedMesh
  113983. */
  113984. createInstance(name: string): InstancedMesh;
  113985. /**
  113986. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  113987. * After this call, all the mesh instances have the same submeshes than the current mesh.
  113988. * @returns the current mesh
  113989. */
  113990. synchronizeInstances(): Mesh;
  113991. /**
  113992. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  113993. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  113994. * This should be used together with the simplification to avoid disappearing triangles.
  113995. * @param successCallback an optional success callback to be called after the optimization finished.
  113996. * @returns the current mesh
  113997. */
  113998. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  113999. /**
  114000. * Serialize current mesh
  114001. * @param serializationObject defines the object which will receive the serialization data
  114002. */
  114003. serialize(serializationObject: any): void;
  114004. /** @hidden */
  114005. _syncGeometryWithMorphTargetManager(): void;
  114006. /** @hidden */
  114007. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114008. /**
  114009. * Returns a new Mesh object parsed from the source provided.
  114010. * @param parsedMesh is the source
  114011. * @param scene defines the hosting scene
  114012. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114013. * @returns a new Mesh
  114014. */
  114015. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114016. /**
  114017. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114018. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114019. * @param name defines the name of the mesh to create
  114020. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114021. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114022. * @param closePath creates a seam between the first and the last points of each path of the path array
  114023. * @param offset is taken in account only if the `pathArray` is containing a single path
  114024. * @param scene defines the hosting scene
  114025. * @param updatable defines if the mesh must be flagged as updatable
  114026. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114027. * @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)
  114028. * @returns a new Mesh
  114029. */
  114030. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114031. /**
  114032. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114033. * @param name defines the name of the mesh to create
  114034. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114035. * @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
  114036. * @param scene defines the hosting scene
  114037. * @param updatable defines if the mesh must be flagged as updatable
  114038. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114039. * @returns a new Mesh
  114040. */
  114041. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114042. /**
  114043. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114044. * @param name defines the name of the mesh to create
  114045. * @param size sets the size (float) of each box side (default 1)
  114046. * @param scene defines the hosting scene
  114047. * @param updatable defines if the mesh must be flagged as updatable
  114048. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114049. * @returns a new Mesh
  114050. */
  114051. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114052. /**
  114053. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114054. * @param name defines the name of the mesh to create
  114055. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114056. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114057. * @param scene defines the hosting scene
  114058. * @param updatable defines if the mesh must be flagged as updatable
  114059. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114060. * @returns a new Mesh
  114061. */
  114062. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114063. /**
  114064. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114065. * @param name defines the name of the mesh to create
  114066. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114067. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114068. * @param scene defines the hosting scene
  114069. * @returns a new Mesh
  114070. */
  114071. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114072. /**
  114073. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114074. * @param name defines the name of the mesh to create
  114075. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114076. * @param diameterTop set the top cap diameter (floats, default 1)
  114077. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114078. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114079. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114080. * @param scene defines the hosting scene
  114081. * @param updatable defines if the mesh must be flagged as updatable
  114082. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114083. * @returns a new Mesh
  114084. */
  114085. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114086. /**
  114087. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114088. * @param name defines the name of the mesh to create
  114089. * @param diameter sets the diameter size (float) of the torus (default 1)
  114090. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114091. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114092. * @param scene defines the hosting scene
  114093. * @param updatable defines if the mesh must be flagged as updatable
  114094. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114095. * @returns a new Mesh
  114096. */
  114097. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114098. /**
  114099. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114100. * @param name defines the name of the mesh to create
  114101. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114102. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114103. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114104. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114105. * @param p the number of windings on X axis (positive integers, default 2)
  114106. * @param q the number of windings on Y axis (positive integers, default 3)
  114107. * @param scene defines the hosting scene
  114108. * @param updatable defines if the mesh must be flagged as updatable
  114109. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114110. * @returns a new Mesh
  114111. */
  114112. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114113. /**
  114114. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114115. * @param name defines the name of the mesh to create
  114116. * @param points is an array successive Vector3
  114117. * @param scene defines the hosting scene
  114118. * @param updatable defines if the mesh must be flagged as updatable
  114119. * @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).
  114120. * @returns a new Mesh
  114121. */
  114122. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114123. /**
  114124. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114125. * @param name defines the name of the mesh to create
  114126. * @param points is an array successive Vector3
  114127. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114128. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114129. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114130. * @param scene defines the hosting scene
  114131. * @param updatable defines if the mesh must be flagged as updatable
  114132. * @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)
  114133. * @returns a new Mesh
  114134. */
  114135. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114136. /**
  114137. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114138. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114139. * 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.
  114140. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114141. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114142. * Remember you can only change the shape positions, not their number when updating a polygon.
  114143. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114144. * @param name defines the name of the mesh to create
  114145. * @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
  114146. * @param scene defines the hosting scene
  114147. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114148. * @param updatable defines if the mesh must be flagged as updatable
  114149. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114150. * @param earcutInjection can be used to inject your own earcut reference
  114151. * @returns a new Mesh
  114152. */
  114153. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114154. /**
  114155. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114157. * @param name defines the name of the mesh to create
  114158. * @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
  114159. * @param depth defines the height of extrusion
  114160. * @param scene defines the hosting scene
  114161. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114162. * @param updatable defines if the mesh must be flagged as updatable
  114163. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114164. * @param earcutInjection can be used to inject your own earcut reference
  114165. * @returns a new Mesh
  114166. */
  114167. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114168. /**
  114169. * Creates an extruded shape mesh.
  114170. * 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
  114171. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114173. * @param name defines the name of the mesh to create
  114174. * @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
  114175. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114176. * @param scale is the value to scale the shape
  114177. * @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
  114178. * @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
  114179. * @param scene defines the hosting scene
  114180. * @param updatable defines if the mesh must be flagged as updatable
  114181. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114182. * @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)
  114183. * @returns a new Mesh
  114184. */
  114185. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114186. /**
  114187. * Creates an custom extruded shape mesh.
  114188. * The custom extrusion is a parametric shape.
  114189. * It has no predefined shape. Its final shape will depend on the input parameters.
  114190. * Please consider using the same method from the MeshBuilder class instead
  114191. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114192. * @param name defines the name of the mesh to create
  114193. * @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
  114194. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114195. * @param scaleFunction is a custom Javascript function called on each path point
  114196. * @param rotationFunction is a custom Javascript function called on each path point
  114197. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114198. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114199. * @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
  114200. * @param scene defines the hosting scene
  114201. * @param updatable defines if the mesh must be flagged as updatable
  114202. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114203. * @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)
  114204. * @returns a new Mesh
  114205. */
  114206. 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;
  114207. /**
  114208. * Creates lathe mesh.
  114209. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114210. * Please consider using the same method from the MeshBuilder class instead
  114211. * @param name defines the name of the mesh to create
  114212. * @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
  114213. * @param radius is the radius value of the lathe
  114214. * @param tessellation is the side number of the lathe.
  114215. * @param scene defines the hosting scene
  114216. * @param updatable defines if the mesh must be flagged as updatable
  114217. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114218. * @returns a new Mesh
  114219. */
  114220. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114221. /**
  114222. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114223. * @param name defines the name of the mesh to create
  114224. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114225. * @param scene defines the hosting scene
  114226. * @param updatable defines if the mesh must be flagged as updatable
  114227. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114228. * @returns a new Mesh
  114229. */
  114230. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114231. /**
  114232. * Creates a ground mesh.
  114233. * Please consider using the same method from the MeshBuilder class instead
  114234. * @param name defines the name of the mesh to create
  114235. * @param width set the width of the ground
  114236. * @param height set the height of the ground
  114237. * @param subdivisions sets the number of subdivisions per side
  114238. * @param scene defines the hosting scene
  114239. * @param updatable defines if the mesh must be flagged as updatable
  114240. * @returns a new Mesh
  114241. */
  114242. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114243. /**
  114244. * Creates a tiled ground mesh.
  114245. * Please consider using the same method from the MeshBuilder class instead
  114246. * @param name defines the name of the mesh to create
  114247. * @param xmin set the ground minimum X coordinate
  114248. * @param zmin set the ground minimum Y coordinate
  114249. * @param xmax set the ground maximum X coordinate
  114250. * @param zmax set the ground maximum Z coordinate
  114251. * @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
  114252. * @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
  114253. * @param scene defines the hosting scene
  114254. * @param updatable defines if the mesh must be flagged as updatable
  114255. * @returns a new Mesh
  114256. */
  114257. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114258. w: number;
  114259. h: number;
  114260. }, precision: {
  114261. w: number;
  114262. h: number;
  114263. }, scene: Scene, updatable?: boolean): Mesh;
  114264. /**
  114265. * Creates a ground mesh from a height map.
  114266. * Please consider using the same method from the MeshBuilder class instead
  114267. * @see https://doc.babylonjs.com/babylon101/height_map
  114268. * @param name defines the name of the mesh to create
  114269. * @param url sets the URL of the height map image resource
  114270. * @param width set the ground width size
  114271. * @param height set the ground height size
  114272. * @param subdivisions sets the number of subdivision per side
  114273. * @param minHeight is the minimum altitude on the ground
  114274. * @param maxHeight is the maximum altitude on the ground
  114275. * @param scene defines the hosting scene
  114276. * @param updatable defines if the mesh must be flagged as updatable
  114277. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114278. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114279. * @returns a new Mesh
  114280. */
  114281. 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;
  114282. /**
  114283. * Creates a tube mesh.
  114284. * The tube is a parametric shape.
  114285. * It has no predefined shape. Its final shape will depend on the input parameters.
  114286. * Please consider using the same method from the MeshBuilder class instead
  114287. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114288. * @param name defines the name of the mesh to create
  114289. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114290. * @param radius sets the tube radius size
  114291. * @param tessellation is the number of sides on the tubular surface
  114292. * @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
  114293. * @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
  114294. * @param scene defines the hosting scene
  114295. * @param updatable defines if the mesh must be flagged as updatable
  114296. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114297. * @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)
  114298. * @returns a new Mesh
  114299. */
  114300. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114301. (i: number, distance: number): number;
  114302. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114303. /**
  114304. * Creates a polyhedron mesh.
  114305. * Please consider using the same method from the MeshBuilder class instead.
  114306. * * 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
  114307. * * The parameter `size` (positive float, default 1) sets the polygon size
  114308. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114309. * * 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`
  114310. * * 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
  114311. * * 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)`)
  114312. * * 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
  114313. * * 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
  114314. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114317. * @param name defines the name of the mesh to create
  114318. * @param options defines the options used to create the mesh
  114319. * @param scene defines the hosting scene
  114320. * @returns a new Mesh
  114321. */
  114322. static CreatePolyhedron(name: string, options: {
  114323. type?: number;
  114324. size?: number;
  114325. sizeX?: number;
  114326. sizeY?: number;
  114327. sizeZ?: number;
  114328. custom?: any;
  114329. faceUV?: Vector4[];
  114330. faceColors?: Color4[];
  114331. updatable?: boolean;
  114332. sideOrientation?: number;
  114333. }, scene: Scene): Mesh;
  114334. /**
  114335. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114336. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114337. * * 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`)
  114338. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114339. * * 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
  114340. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114343. * @param name defines the name of the mesh
  114344. * @param options defines the options used to create the mesh
  114345. * @param scene defines the hosting scene
  114346. * @returns a new Mesh
  114347. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114348. */
  114349. static CreateIcoSphere(name: string, options: {
  114350. radius?: number;
  114351. flat?: boolean;
  114352. subdivisions?: number;
  114353. sideOrientation?: number;
  114354. updatable?: boolean;
  114355. }, scene: Scene): Mesh;
  114356. /**
  114357. * Creates a decal mesh.
  114358. * Please consider using the same method from the MeshBuilder class instead.
  114359. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114360. * @param name defines the name of the mesh
  114361. * @param sourceMesh defines the mesh receiving the decal
  114362. * @param position sets the position of the decal in world coordinates
  114363. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114364. * @param size sets the decal scaling
  114365. * @param angle sets the angle to rotate the decal
  114366. * @returns a new Mesh
  114367. */
  114368. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114369. /** Creates a Capsule Mesh
  114370. * @param name defines the name of the mesh.
  114371. * @param options the constructors options used to shape the mesh.
  114372. * @param scene defines the scene the mesh is scoped to.
  114373. * @returns the capsule mesh
  114374. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114375. */
  114376. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114377. /**
  114378. * Prepare internal position array for software CPU skinning
  114379. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114380. */
  114381. setPositionsForCPUSkinning(): Float32Array;
  114382. /**
  114383. * Prepare internal normal array for software CPU skinning
  114384. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  114385. */
  114386. setNormalsForCPUSkinning(): Float32Array;
  114387. /**
  114388. * Updates the vertex buffer by applying transformation from the bones
  114389. * @param skeleton defines the skeleton to apply to current mesh
  114390. * @returns the current mesh
  114391. */
  114392. applySkeleton(skeleton: Skeleton): Mesh;
  114393. /**
  114394. * 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
  114395. * @param meshes defines the list of meshes to scan
  114396. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  114397. */
  114398. static MinMax(meshes: AbstractMesh[]): {
  114399. min: Vector3;
  114400. max: Vector3;
  114401. };
  114402. /**
  114403. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  114404. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  114405. * @returns a vector3
  114406. */
  114407. static Center(meshesOrMinMaxVector: {
  114408. min: Vector3;
  114409. max: Vector3;
  114410. } | AbstractMesh[]): Vector3;
  114411. /**
  114412. * Merge the array of meshes into a single mesh for performance reasons.
  114413. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  114414. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  114415. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  114416. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  114417. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  114418. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  114419. * @returns a new mesh
  114420. */
  114421. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  114422. /** @hidden */
  114423. addInstance(instance: InstancedMesh): void;
  114424. /** @hidden */
  114425. removeInstance(instance: InstancedMesh): void;
  114426. }
  114427. }
  114428. declare module BABYLON {
  114429. /**
  114430. * This is the base class of all the camera used in the application.
  114431. * @see https://doc.babylonjs.com/features/cameras
  114432. */
  114433. export class Camera extends Node {
  114434. /** @hidden */
  114435. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  114436. /**
  114437. * This is the default projection mode used by the cameras.
  114438. * It helps recreating a feeling of perspective and better appreciate depth.
  114439. * This is the best way to simulate real life cameras.
  114440. */
  114441. static readonly PERSPECTIVE_CAMERA: number;
  114442. /**
  114443. * This helps creating camera with an orthographic mode.
  114444. * 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.
  114445. */
  114446. static readonly ORTHOGRAPHIC_CAMERA: number;
  114447. /**
  114448. * This is the default FOV mode for perspective cameras.
  114449. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  114450. */
  114451. static readonly FOVMODE_VERTICAL_FIXED: number;
  114452. /**
  114453. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  114454. */
  114455. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  114456. /**
  114457. * This specifies ther is no need for a camera rig.
  114458. * Basically only one eye is rendered corresponding to the camera.
  114459. */
  114460. static readonly RIG_MODE_NONE: number;
  114461. /**
  114462. * Simulates a camera Rig with one blue eye and one red eye.
  114463. * This can be use with 3d blue and red glasses.
  114464. */
  114465. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  114466. /**
  114467. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  114468. */
  114469. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  114470. /**
  114471. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  114472. */
  114473. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  114474. /**
  114475. * Defines that both eyes of the camera will be rendered over under each other.
  114476. */
  114477. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  114478. /**
  114479. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  114480. */
  114481. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  114482. /**
  114483. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  114484. */
  114485. static readonly RIG_MODE_VR: number;
  114486. /**
  114487. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  114488. */
  114489. static readonly RIG_MODE_WEBVR: number;
  114490. /**
  114491. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  114492. */
  114493. static readonly RIG_MODE_CUSTOM: number;
  114494. /**
  114495. * Defines if by default attaching controls should prevent the default javascript event to continue.
  114496. */
  114497. static ForceAttachControlToAlwaysPreventDefault: boolean;
  114498. /**
  114499. * Define the input manager associated with the camera.
  114500. */
  114501. inputs: CameraInputsManager<Camera>;
  114502. /** @hidden */
  114503. _position: Vector3;
  114504. /**
  114505. * Define the current local position of the camera in the scene
  114506. */
  114507. get position(): Vector3;
  114508. set position(newPosition: Vector3);
  114509. protected _upVector: Vector3;
  114510. /**
  114511. * The vector the camera should consider as up.
  114512. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  114513. */
  114514. set upVector(vec: Vector3);
  114515. get upVector(): Vector3;
  114516. /**
  114517. * Define the current limit on the left side for an orthographic camera
  114518. * In scene unit
  114519. */
  114520. orthoLeft: Nullable<number>;
  114521. /**
  114522. * Define the current limit on the right side for an orthographic camera
  114523. * In scene unit
  114524. */
  114525. orthoRight: Nullable<number>;
  114526. /**
  114527. * Define the current limit on the bottom side for an orthographic camera
  114528. * In scene unit
  114529. */
  114530. orthoBottom: Nullable<number>;
  114531. /**
  114532. * Define the current limit on the top side for an orthographic camera
  114533. * In scene unit
  114534. */
  114535. orthoTop: Nullable<number>;
  114536. /**
  114537. * Field Of View is set in Radians. (default is 0.8)
  114538. */
  114539. fov: number;
  114540. /**
  114541. * Define the minimum distance the camera can see from.
  114542. * This is important to note that the depth buffer are not infinite and the closer it starts
  114543. * the more your scene might encounter depth fighting issue.
  114544. */
  114545. minZ: number;
  114546. /**
  114547. * Define the maximum distance the camera can see to.
  114548. * This is important to note that the depth buffer are not infinite and the further it end
  114549. * the more your scene might encounter depth fighting issue.
  114550. */
  114551. maxZ: number;
  114552. /**
  114553. * Define the default inertia of the camera.
  114554. * This helps giving a smooth feeling to the camera movement.
  114555. */
  114556. inertia: number;
  114557. /**
  114558. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  114559. */
  114560. mode: number;
  114561. /**
  114562. * Define whether the camera is intermediate.
  114563. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  114564. */
  114565. isIntermediate: boolean;
  114566. /**
  114567. * Define the viewport of the camera.
  114568. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  114569. */
  114570. viewport: Viewport;
  114571. /**
  114572. * Restricts the camera to viewing objects with the same layerMask.
  114573. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  114574. */
  114575. layerMask: number;
  114576. /**
  114577. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  114578. */
  114579. fovMode: number;
  114580. /**
  114581. * Rig mode of the camera.
  114582. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  114583. * This is normally controlled byt the camera themselves as internal use.
  114584. */
  114585. cameraRigMode: number;
  114586. /**
  114587. * Defines the distance between both "eyes" in case of a RIG
  114588. */
  114589. interaxialDistance: number;
  114590. /**
  114591. * Defines if stereoscopic rendering is done side by side or over under.
  114592. */
  114593. isStereoscopicSideBySide: boolean;
  114594. /**
  114595. * 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
  114596. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  114597. * else in the scene. (Eg. security camera)
  114598. *
  114599. * 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)
  114600. */
  114601. customRenderTargets: RenderTargetTexture[];
  114602. /**
  114603. * When set, the camera will render to this render target instead of the default canvas
  114604. *
  114605. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  114606. */
  114607. outputRenderTarget: Nullable<RenderTargetTexture>;
  114608. /**
  114609. * Observable triggered when the camera view matrix has changed.
  114610. */
  114611. onViewMatrixChangedObservable: Observable<Camera>;
  114612. /**
  114613. * Observable triggered when the camera Projection matrix has changed.
  114614. */
  114615. onProjectionMatrixChangedObservable: Observable<Camera>;
  114616. /**
  114617. * Observable triggered when the inputs have been processed.
  114618. */
  114619. onAfterCheckInputsObservable: Observable<Camera>;
  114620. /**
  114621. * Observable triggered when reset has been called and applied to the camera.
  114622. */
  114623. onRestoreStateObservable: Observable<Camera>;
  114624. /**
  114625. * Is this camera a part of a rig system?
  114626. */
  114627. isRigCamera: boolean;
  114628. /**
  114629. * If isRigCamera set to true this will be set with the parent camera.
  114630. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  114631. */
  114632. rigParent?: Camera;
  114633. /** @hidden */
  114634. _cameraRigParams: any;
  114635. /** @hidden */
  114636. _rigCameras: Camera[];
  114637. /** @hidden */
  114638. _rigPostProcess: Nullable<PostProcess>;
  114639. protected _webvrViewMatrix: Matrix;
  114640. /** @hidden */
  114641. _skipRendering: boolean;
  114642. /** @hidden */
  114643. _projectionMatrix: Matrix;
  114644. /** @hidden */
  114645. _postProcesses: Nullable<PostProcess>[];
  114646. /** @hidden */
  114647. _activeMeshes: SmartArray<AbstractMesh>;
  114648. protected _globalPosition: Vector3;
  114649. /** @hidden */
  114650. _computedViewMatrix: Matrix;
  114651. private _doNotComputeProjectionMatrix;
  114652. private _transformMatrix;
  114653. private _frustumPlanes;
  114654. private _refreshFrustumPlanes;
  114655. private _storedFov;
  114656. private _stateStored;
  114657. /**
  114658. * Instantiates a new camera object.
  114659. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  114660. * @see https://doc.babylonjs.com/features/cameras
  114661. * @param name Defines the name of the camera in the scene
  114662. * @param position Defines the position of the camera
  114663. * @param scene Defines the scene the camera belongs too
  114664. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  114665. */
  114666. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114667. /**
  114668. * Store current camera state (fov, position, etc..)
  114669. * @returns the camera
  114670. */
  114671. storeState(): Camera;
  114672. /**
  114673. * Restores the camera state values if it has been stored. You must call storeState() first
  114674. */
  114675. protected _restoreStateValues(): boolean;
  114676. /**
  114677. * Restored camera state. You must call storeState() first.
  114678. * @returns true if restored and false otherwise
  114679. */
  114680. restoreState(): boolean;
  114681. /**
  114682. * Gets the class name of the camera.
  114683. * @returns the class name
  114684. */
  114685. getClassName(): string;
  114686. /** @hidden */
  114687. readonly _isCamera: boolean;
  114688. /**
  114689. * Gets a string representation of the camera useful for debug purpose.
  114690. * @param fullDetails Defines that a more verboe level of logging is required
  114691. * @returns the string representation
  114692. */
  114693. toString(fullDetails?: boolean): string;
  114694. /**
  114695. * Gets the current world space position of the camera.
  114696. */
  114697. get globalPosition(): Vector3;
  114698. /**
  114699. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  114700. * @returns the active meshe list
  114701. */
  114702. getActiveMeshes(): SmartArray<AbstractMesh>;
  114703. /**
  114704. * Check whether a mesh is part of the current active mesh list of the camera
  114705. * @param mesh Defines the mesh to check
  114706. * @returns true if active, false otherwise
  114707. */
  114708. isActiveMesh(mesh: Mesh): boolean;
  114709. /**
  114710. * Is this camera ready to be used/rendered
  114711. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  114712. * @return true if the camera is ready
  114713. */
  114714. isReady(completeCheck?: boolean): boolean;
  114715. /** @hidden */
  114716. _initCache(): void;
  114717. /** @hidden */
  114718. _updateCache(ignoreParentClass?: boolean): void;
  114719. /** @hidden */
  114720. _isSynchronized(): boolean;
  114721. /** @hidden */
  114722. _isSynchronizedViewMatrix(): boolean;
  114723. /** @hidden */
  114724. _isSynchronizedProjectionMatrix(): boolean;
  114725. /**
  114726. * Attach the input controls to a specific dom element to get the input from.
  114727. * @param element Defines the element the controls should be listened from
  114728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114729. */
  114730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114731. /**
  114732. * Detach the current controls from the specified dom element.
  114733. * @param element Defines the element to stop listening the inputs from
  114734. */
  114735. detachControl(element: HTMLElement): void;
  114736. /**
  114737. * Update the camera state according to the different inputs gathered during the frame.
  114738. */
  114739. update(): void;
  114740. /** @hidden */
  114741. _checkInputs(): void;
  114742. /** @hidden */
  114743. get rigCameras(): Camera[];
  114744. /**
  114745. * Gets the post process used by the rig cameras
  114746. */
  114747. get rigPostProcess(): Nullable<PostProcess>;
  114748. /**
  114749. * Internal, gets the first post proces.
  114750. * @returns the first post process to be run on this camera.
  114751. */
  114752. _getFirstPostProcess(): Nullable<PostProcess>;
  114753. private _cascadePostProcessesToRigCams;
  114754. /**
  114755. * Attach a post process to the camera.
  114756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114757. * @param postProcess The post process to attach to the camera
  114758. * @param insertAt The position of the post process in case several of them are in use in the scene
  114759. * @returns the position the post process has been inserted at
  114760. */
  114761. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  114762. /**
  114763. * Detach a post process to the camera.
  114764. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114765. * @param postProcess The post process to detach from the camera
  114766. */
  114767. detachPostProcess(postProcess: PostProcess): void;
  114768. /**
  114769. * Gets the current world matrix of the camera
  114770. */
  114771. getWorldMatrix(): Matrix;
  114772. /** @hidden */
  114773. _getViewMatrix(): Matrix;
  114774. /**
  114775. * Gets the current view matrix of the camera.
  114776. * @param force forces the camera to recompute the matrix without looking at the cached state
  114777. * @returns the view matrix
  114778. */
  114779. getViewMatrix(force?: boolean): Matrix;
  114780. /**
  114781. * Freeze the projection matrix.
  114782. * It will prevent the cache check of the camera projection compute and can speed up perf
  114783. * if no parameter of the camera are meant to change
  114784. * @param projection Defines manually a projection if necessary
  114785. */
  114786. freezeProjectionMatrix(projection?: Matrix): void;
  114787. /**
  114788. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  114789. */
  114790. unfreezeProjectionMatrix(): void;
  114791. /**
  114792. * Gets the current projection matrix of the camera.
  114793. * @param force forces the camera to recompute the matrix without looking at the cached state
  114794. * @returns the projection matrix
  114795. */
  114796. getProjectionMatrix(force?: boolean): Matrix;
  114797. /**
  114798. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  114799. * @returns a Matrix
  114800. */
  114801. getTransformationMatrix(): Matrix;
  114802. private _updateFrustumPlanes;
  114803. /**
  114804. * Checks if a cullable object (mesh...) is in the camera frustum
  114805. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  114806. * @param target The object to check
  114807. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  114808. * @returns true if the object is in frustum otherwise false
  114809. */
  114810. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  114811. /**
  114812. * Checks if a cullable object (mesh...) is in the camera frustum
  114813. * Unlike isInFrustum this cheks the full bounding box
  114814. * @param target The object to check
  114815. * @returns true if the object is in frustum otherwise false
  114816. */
  114817. isCompletelyInFrustum(target: ICullable): boolean;
  114818. /**
  114819. * Gets a ray in the forward direction from the camera.
  114820. * @param length Defines the length of the ray to create
  114821. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114822. * @param origin Defines the start point of the ray which defaults to the camera position
  114823. * @returns the forward ray
  114824. */
  114825. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114826. /**
  114827. * Gets a ray in the forward direction from the camera.
  114828. * @param refRay the ray to (re)use when setting the values
  114829. * @param length Defines the length of the ray to create
  114830. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114831. * @param origin Defines the start point of the ray which defaults to the camera position
  114832. * @returns the forward ray
  114833. */
  114834. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114835. /**
  114836. * Releases resources associated with this node.
  114837. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114838. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114839. */
  114840. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114841. /** @hidden */
  114842. _isLeftCamera: boolean;
  114843. /**
  114844. * Gets the left camera of a rig setup in case of Rigged Camera
  114845. */
  114846. get isLeftCamera(): boolean;
  114847. /** @hidden */
  114848. _isRightCamera: boolean;
  114849. /**
  114850. * Gets the right camera of a rig setup in case of Rigged Camera
  114851. */
  114852. get isRightCamera(): boolean;
  114853. /**
  114854. * Gets the left camera of a rig setup in case of Rigged Camera
  114855. */
  114856. get leftCamera(): Nullable<FreeCamera>;
  114857. /**
  114858. * Gets the right camera of a rig setup in case of Rigged Camera
  114859. */
  114860. get rightCamera(): Nullable<FreeCamera>;
  114861. /**
  114862. * Gets the left camera target of a rig setup in case of Rigged Camera
  114863. * @returns the target position
  114864. */
  114865. getLeftTarget(): Nullable<Vector3>;
  114866. /**
  114867. * Gets the right camera target of a rig setup in case of Rigged Camera
  114868. * @returns the target position
  114869. */
  114870. getRightTarget(): Nullable<Vector3>;
  114871. /**
  114872. * @hidden
  114873. */
  114874. setCameraRigMode(mode: number, rigParams: any): void;
  114875. /** @hidden */
  114876. static _setStereoscopicRigMode(camera: Camera): void;
  114877. /** @hidden */
  114878. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  114879. /** @hidden */
  114880. static _setVRRigMode(camera: Camera, rigParams: any): void;
  114881. /** @hidden */
  114882. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  114883. /** @hidden */
  114884. _getVRProjectionMatrix(): Matrix;
  114885. protected _updateCameraRotationMatrix(): void;
  114886. protected _updateWebVRCameraRotationMatrix(): void;
  114887. /**
  114888. * This function MUST be overwritten by the different WebVR cameras available.
  114889. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114890. * @hidden
  114891. */
  114892. _getWebVRProjectionMatrix(): Matrix;
  114893. /**
  114894. * This function MUST be overwritten by the different WebVR cameras available.
  114895. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114896. * @hidden
  114897. */
  114898. _getWebVRViewMatrix(): Matrix;
  114899. /** @hidden */
  114900. setCameraRigParameter(name: string, value: any): void;
  114901. /**
  114902. * needs to be overridden by children so sub has required properties to be copied
  114903. * @hidden
  114904. */
  114905. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  114906. /**
  114907. * May need to be overridden by children
  114908. * @hidden
  114909. */
  114910. _updateRigCameras(): void;
  114911. /** @hidden */
  114912. _setupInputs(): void;
  114913. /**
  114914. * Serialiaze the camera setup to a json represention
  114915. * @returns the JSON representation
  114916. */
  114917. serialize(): any;
  114918. /**
  114919. * Clones the current camera.
  114920. * @param name The cloned camera name
  114921. * @returns the cloned camera
  114922. */
  114923. clone(name: string): Camera;
  114924. /**
  114925. * Gets the direction of the camera relative to a given local axis.
  114926. * @param localAxis Defines the reference axis to provide a relative direction.
  114927. * @return the direction
  114928. */
  114929. getDirection(localAxis: Vector3): Vector3;
  114930. /**
  114931. * Returns the current camera absolute rotation
  114932. */
  114933. get absoluteRotation(): Quaternion;
  114934. /**
  114935. * Gets the direction of the camera relative to a given local axis into a passed vector.
  114936. * @param localAxis Defines the reference axis to provide a relative direction.
  114937. * @param result Defines the vector to store the result in
  114938. */
  114939. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  114940. /**
  114941. * Gets a camera constructor for a given camera type
  114942. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  114943. * @param name The name of the camera the result will be able to instantiate
  114944. * @param scene The scene the result will construct the camera in
  114945. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  114946. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  114947. * @returns a factory method to construc the camera
  114948. */
  114949. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  114950. /**
  114951. * Compute the world matrix of the camera.
  114952. * @returns the camera world matrix
  114953. */
  114954. computeWorldMatrix(): Matrix;
  114955. /**
  114956. * Parse a JSON and creates the camera from the parsed information
  114957. * @param parsedCamera The JSON to parse
  114958. * @param scene The scene to instantiate the camera in
  114959. * @returns the newly constructed camera
  114960. */
  114961. static Parse(parsedCamera: any, scene: Scene): Camera;
  114962. }
  114963. }
  114964. declare module BABYLON {
  114965. /**
  114966. * Class containing static functions to help procedurally build meshes
  114967. */
  114968. export class DiscBuilder {
  114969. /**
  114970. * Creates a plane polygonal mesh. By default, this is a disc
  114971. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114972. * * 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
  114973. * * 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
  114974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114977. * @param name defines the name of the mesh
  114978. * @param options defines the options used to create the mesh
  114979. * @param scene defines the hosting scene
  114980. * @returns the plane polygonal mesh
  114981. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  114982. */
  114983. static CreateDisc(name: string, options: {
  114984. radius?: number;
  114985. tessellation?: number;
  114986. arc?: number;
  114987. updatable?: boolean;
  114988. sideOrientation?: number;
  114989. frontUVs?: Vector4;
  114990. backUVs?: Vector4;
  114991. }, scene?: Nullable<Scene>): Mesh;
  114992. }
  114993. }
  114994. declare module BABYLON {
  114995. /**
  114996. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  114997. *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.
  114998. * The SPS is also a particle system. It provides some methods to manage the particles.
  114999. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115000. *
  115001. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115002. */
  115003. export class SolidParticleSystem implements IDisposable {
  115004. /**
  115005. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115006. * Example : var p = SPS.particles[i];
  115007. */
  115008. particles: SolidParticle[];
  115009. /**
  115010. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115011. */
  115012. nbParticles: number;
  115013. /**
  115014. * If the particles must ever face the camera (default false). Useful for planar particles.
  115015. */
  115016. billboard: boolean;
  115017. /**
  115018. * Recompute normals when adding a shape
  115019. */
  115020. recomputeNormals: boolean;
  115021. /**
  115022. * This a counter ofr your own usage. It's not set by any SPS functions.
  115023. */
  115024. counter: number;
  115025. /**
  115026. * The SPS name. This name is also given to the underlying mesh.
  115027. */
  115028. name: string;
  115029. /**
  115030. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115031. */
  115032. mesh: Mesh;
  115033. /**
  115034. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115035. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115036. */
  115037. vars: any;
  115038. /**
  115039. * This array is populated when the SPS is set as 'pickable'.
  115040. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115041. * Each element of this array is an object `{idx: int, faceId: int}`.
  115042. * `idx` is the picked particle index in the `SPS.particles` array
  115043. * `faceId` is the picked face index counted within this particle.
  115044. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115045. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115046. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115047. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115048. */
  115049. pickedParticles: {
  115050. idx: number;
  115051. faceId: number;
  115052. }[];
  115053. /**
  115054. * This array is populated when the SPS is set as 'pickable'
  115055. * Each key of this array is a submesh index.
  115056. * Each element of this array is a second array defined like this :
  115057. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115058. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115059. * `idx` is the picked particle index in the `SPS.particles` array
  115060. * `faceId` is the picked face index counted within this particle.
  115061. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115062. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115063. */
  115064. pickedBySubMesh: {
  115065. idx: number;
  115066. faceId: number;
  115067. }[][];
  115068. /**
  115069. * This array is populated when `enableDepthSort` is set to true.
  115070. * Each element of this array is an instance of the class DepthSortedParticle.
  115071. */
  115072. depthSortedParticles: DepthSortedParticle[];
  115073. /**
  115074. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115075. * @hidden
  115076. */
  115077. _bSphereOnly: boolean;
  115078. /**
  115079. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115080. * @hidden
  115081. */
  115082. _bSphereRadiusFactor: number;
  115083. private _scene;
  115084. private _positions;
  115085. private _indices;
  115086. private _normals;
  115087. private _colors;
  115088. private _uvs;
  115089. private _indices32;
  115090. private _positions32;
  115091. private _normals32;
  115092. private _fixedNormal32;
  115093. private _colors32;
  115094. private _uvs32;
  115095. private _index;
  115096. private _updatable;
  115097. private _pickable;
  115098. private _isVisibilityBoxLocked;
  115099. private _alwaysVisible;
  115100. private _depthSort;
  115101. private _expandable;
  115102. private _shapeCounter;
  115103. private _copy;
  115104. private _color;
  115105. private _computeParticleColor;
  115106. private _computeParticleTexture;
  115107. private _computeParticleRotation;
  115108. private _computeParticleVertex;
  115109. private _computeBoundingBox;
  115110. private _depthSortParticles;
  115111. private _camera;
  115112. private _mustUnrotateFixedNormals;
  115113. private _particlesIntersect;
  115114. private _needs32Bits;
  115115. private _isNotBuilt;
  115116. private _lastParticleId;
  115117. private _idxOfId;
  115118. private _multimaterialEnabled;
  115119. private _useModelMaterial;
  115120. private _indicesByMaterial;
  115121. private _materialIndexes;
  115122. private _depthSortFunction;
  115123. private _materialSortFunction;
  115124. private _materials;
  115125. private _multimaterial;
  115126. private _materialIndexesById;
  115127. private _defaultMaterial;
  115128. private _autoUpdateSubMeshes;
  115129. private _tmpVertex;
  115130. /**
  115131. * Creates a SPS (Solid Particle System) object.
  115132. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115133. * @param scene (Scene) is the scene in which the SPS is added.
  115134. * @param options defines the options of the sps e.g.
  115135. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115136. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115137. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115138. * * 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.
  115139. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115140. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115141. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115142. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115143. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115144. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115145. */
  115146. constructor(name: string, scene: Scene, options?: {
  115147. updatable?: boolean;
  115148. isPickable?: boolean;
  115149. enableDepthSort?: boolean;
  115150. particleIntersection?: boolean;
  115151. boundingSphereOnly?: boolean;
  115152. bSphereRadiusFactor?: number;
  115153. expandable?: boolean;
  115154. useModelMaterial?: boolean;
  115155. enableMultiMaterial?: boolean;
  115156. });
  115157. /**
  115158. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115159. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115160. * @returns the created mesh
  115161. */
  115162. buildMesh(): Mesh;
  115163. /**
  115164. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115165. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115166. * Thus the particles generated from `digest()` have their property `position` set yet.
  115167. * @param mesh ( Mesh ) is the mesh to be digested
  115168. * @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
  115169. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115170. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115171. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115172. * @returns the current SPS
  115173. */
  115174. digest(mesh: Mesh, options?: {
  115175. facetNb?: number;
  115176. number?: number;
  115177. delta?: number;
  115178. storage?: [];
  115179. }): SolidParticleSystem;
  115180. /**
  115181. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115182. * @hidden
  115183. */
  115184. private _unrotateFixedNormals;
  115185. /**
  115186. * Resets the temporary working copy particle
  115187. * @hidden
  115188. */
  115189. private _resetCopy;
  115190. /**
  115191. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115192. * @param p the current index in the positions array to be updated
  115193. * @param ind the current index in the indices array
  115194. * @param shape a Vector3 array, the shape geometry
  115195. * @param positions the positions array to be updated
  115196. * @param meshInd the shape indices array
  115197. * @param indices the indices array to be updated
  115198. * @param meshUV the shape uv array
  115199. * @param uvs the uv array to be updated
  115200. * @param meshCol the shape color array
  115201. * @param colors the color array to be updated
  115202. * @param meshNor the shape normals array
  115203. * @param normals the normals array to be updated
  115204. * @param idx the particle index
  115205. * @param idxInShape the particle index in its shape
  115206. * @param options the addShape() method passed options
  115207. * @model the particle model
  115208. * @hidden
  115209. */
  115210. private _meshBuilder;
  115211. /**
  115212. * Returns a shape Vector3 array from positions float array
  115213. * @param positions float array
  115214. * @returns a vector3 array
  115215. * @hidden
  115216. */
  115217. private _posToShape;
  115218. /**
  115219. * Returns a shapeUV array from a float uvs (array deep copy)
  115220. * @param uvs as a float array
  115221. * @returns a shapeUV array
  115222. * @hidden
  115223. */
  115224. private _uvsToShapeUV;
  115225. /**
  115226. * Adds a new particle object in the particles array
  115227. * @param idx particle index in particles array
  115228. * @param id particle id
  115229. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115230. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115231. * @param model particle ModelShape object
  115232. * @param shapeId model shape identifier
  115233. * @param idxInShape index of the particle in the current model
  115234. * @param bInfo model bounding info object
  115235. * @param storage target storage array, if any
  115236. * @hidden
  115237. */
  115238. private _addParticle;
  115239. /**
  115240. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115241. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115242. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115243. * @param nb (positive integer) the number of particles to be created from this model
  115244. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115245. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115246. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115247. * @returns the number of shapes in the system
  115248. */
  115249. addShape(mesh: Mesh, nb: number, options?: {
  115250. positionFunction?: any;
  115251. vertexFunction?: any;
  115252. storage?: [];
  115253. }): number;
  115254. /**
  115255. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115256. * @hidden
  115257. */
  115258. private _rebuildParticle;
  115259. /**
  115260. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115261. * @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.
  115262. * @returns the SPS.
  115263. */
  115264. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115265. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115266. * Returns an array with the removed particles.
  115267. * 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.
  115268. * The SPS can't be empty so at least one particle needs to remain in place.
  115269. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115270. * @param start index of the first particle to remove
  115271. * @param end index of the last particle to remove (included)
  115272. * @returns an array populated with the removed particles
  115273. */
  115274. removeParticles(start: number, end: number): SolidParticle[];
  115275. /**
  115276. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115277. * @param solidParticleArray an array populated with Solid Particles objects
  115278. * @returns the SPS
  115279. */
  115280. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115281. /**
  115282. * Creates a new particle and modifies the SPS mesh geometry :
  115283. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115284. * - calls _addParticle() to populate the particle array
  115285. * factorized code from addShape() and insertParticlesFromArray()
  115286. * @param idx particle index in the particles array
  115287. * @param i particle index in its shape
  115288. * @param modelShape particle ModelShape object
  115289. * @param shape shape vertex array
  115290. * @param meshInd shape indices array
  115291. * @param meshUV shape uv array
  115292. * @param meshCol shape color array
  115293. * @param meshNor shape normals array
  115294. * @param bbInfo shape bounding info
  115295. * @param storage target particle storage
  115296. * @options addShape() passed options
  115297. * @hidden
  115298. */
  115299. private _insertNewParticle;
  115300. /**
  115301. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115302. * This method calls `updateParticle()` for each particle of the SPS.
  115303. * For an animated SPS, it is usually called within the render loop.
  115304. * 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.
  115305. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115306. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115307. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115308. * @returns the SPS.
  115309. */
  115310. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115311. /**
  115312. * Disposes the SPS.
  115313. */
  115314. dispose(): void;
  115315. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115316. * idx is the particle index in the SPS
  115317. * faceId is the picked face index counted within this particle.
  115318. * Returns null if the pickInfo can't identify a picked particle.
  115319. * @param pickingInfo (PickingInfo object)
  115320. * @returns {idx: number, faceId: number} or null
  115321. */
  115322. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115323. idx: number;
  115324. faceId: number;
  115325. }>;
  115326. /**
  115327. * Returns a SolidParticle object from its identifier : particle.id
  115328. * @param id (integer) the particle Id
  115329. * @returns the searched particle or null if not found in the SPS.
  115330. */
  115331. getParticleById(id: number): Nullable<SolidParticle>;
  115332. /**
  115333. * Returns a new array populated with the particles having the passed shapeId.
  115334. * @param shapeId (integer) the shape identifier
  115335. * @returns a new solid particle array
  115336. */
  115337. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115338. /**
  115339. * Populates the passed array "ref" with the particles having the passed shapeId.
  115340. * @param shapeId the shape identifier
  115341. * @returns the SPS
  115342. * @param ref
  115343. */
  115344. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115345. /**
  115346. * Computes the required SubMeshes according the materials assigned to the particles.
  115347. * @returns the solid particle system.
  115348. * Does nothing if called before the SPS mesh is built.
  115349. */
  115350. computeSubMeshes(): SolidParticleSystem;
  115351. /**
  115352. * Sorts the solid particles by material when MultiMaterial is enabled.
  115353. * Updates the indices32 array.
  115354. * Updates the indicesByMaterial array.
  115355. * Updates the mesh indices array.
  115356. * @returns the SPS
  115357. * @hidden
  115358. */
  115359. private _sortParticlesByMaterial;
  115360. /**
  115361. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115362. * @hidden
  115363. */
  115364. private _setMaterialIndexesById;
  115365. /**
  115366. * Returns an array with unique values of Materials from the passed array
  115367. * @param array the material array to be checked and filtered
  115368. * @hidden
  115369. */
  115370. private _filterUniqueMaterialId;
  115371. /**
  115372. * Sets a new Standard Material as _defaultMaterial if not already set.
  115373. * @hidden
  115374. */
  115375. private _setDefaultMaterial;
  115376. /**
  115377. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  115378. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115379. * @returns the SPS.
  115380. */
  115381. refreshVisibleSize(): SolidParticleSystem;
  115382. /**
  115383. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  115384. * @param size the size (float) of the visibility box
  115385. * note : this doesn't lock the SPS mesh bounding box.
  115386. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115387. */
  115388. setVisibilityBox(size: number): void;
  115389. /**
  115390. * Gets whether the SPS as always visible or not
  115391. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115392. */
  115393. get isAlwaysVisible(): boolean;
  115394. /**
  115395. * Sets the SPS as always visible or not
  115396. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115397. */
  115398. set isAlwaysVisible(val: boolean);
  115399. /**
  115400. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115401. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115402. */
  115403. set isVisibilityBoxLocked(val: boolean);
  115404. /**
  115405. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115406. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115407. */
  115408. get isVisibilityBoxLocked(): boolean;
  115409. /**
  115410. * Tells to `setParticles()` to compute the particle rotations or not.
  115411. * Default value : true. The SPS is faster when it's set to false.
  115412. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115413. */
  115414. set computeParticleRotation(val: boolean);
  115415. /**
  115416. * Tells to `setParticles()` to compute the particle colors or not.
  115417. * Default value : true. The SPS is faster when it's set to false.
  115418. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115419. */
  115420. set computeParticleColor(val: boolean);
  115421. set computeParticleTexture(val: boolean);
  115422. /**
  115423. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  115424. * Default value : false. The SPS is faster when it's set to false.
  115425. * Note : the particle custom vertex positions aren't stored values.
  115426. */
  115427. set computeParticleVertex(val: boolean);
  115428. /**
  115429. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  115430. */
  115431. set computeBoundingBox(val: boolean);
  115432. /**
  115433. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  115434. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115435. * Default : `true`
  115436. */
  115437. set depthSortParticles(val: boolean);
  115438. /**
  115439. * Gets if `setParticles()` computes the particle rotations or not.
  115440. * Default value : true. The SPS is faster when it's set to false.
  115441. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115442. */
  115443. get computeParticleRotation(): boolean;
  115444. /**
  115445. * Gets if `setParticles()` computes the particle colors or not.
  115446. * Default value : true. The SPS is faster when it's set to false.
  115447. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115448. */
  115449. get computeParticleColor(): boolean;
  115450. /**
  115451. * Gets if `setParticles()` computes the particle textures or not.
  115452. * Default value : true. The SPS is faster when it's set to false.
  115453. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  115454. */
  115455. get computeParticleTexture(): boolean;
  115456. /**
  115457. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  115458. * Default value : false. The SPS is faster when it's set to false.
  115459. * Note : the particle custom vertex positions aren't stored values.
  115460. */
  115461. get computeParticleVertex(): boolean;
  115462. /**
  115463. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  115464. */
  115465. get computeBoundingBox(): boolean;
  115466. /**
  115467. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  115468. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115469. * Default : `true`
  115470. */
  115471. get depthSortParticles(): boolean;
  115472. /**
  115473. * Gets if the SPS is created as expandable at construction time.
  115474. * Default : `false`
  115475. */
  115476. get expandable(): boolean;
  115477. /**
  115478. * Gets if the SPS supports the Multi Materials
  115479. */
  115480. get multimaterialEnabled(): boolean;
  115481. /**
  115482. * Gets if the SPS uses the model materials for its own multimaterial.
  115483. */
  115484. get useModelMaterial(): boolean;
  115485. /**
  115486. * The SPS used material array.
  115487. */
  115488. get materials(): Material[];
  115489. /**
  115490. * Sets the SPS MultiMaterial from the passed materials.
  115491. * Note : the passed array is internally copied and not used then by reference.
  115492. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  115493. */
  115494. setMultiMaterial(materials: Material[]): void;
  115495. /**
  115496. * The SPS computed multimaterial object
  115497. */
  115498. get multimaterial(): MultiMaterial;
  115499. set multimaterial(mm: MultiMaterial);
  115500. /**
  115501. * If the subMeshes must be updated on the next call to setParticles()
  115502. */
  115503. get autoUpdateSubMeshes(): boolean;
  115504. set autoUpdateSubMeshes(val: boolean);
  115505. /**
  115506. * This function does nothing. It may be overwritten to set all the particle first values.
  115507. * The SPS doesn't call this function, you may have to call it by your own.
  115508. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115509. */
  115510. initParticles(): void;
  115511. /**
  115512. * This function does nothing. It may be overwritten to recycle a particle.
  115513. * The SPS doesn't call this function, you may have to call it by your own.
  115514. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115515. * @param particle The particle to recycle
  115516. * @returns the recycled particle
  115517. */
  115518. recycleParticle(particle: SolidParticle): SolidParticle;
  115519. /**
  115520. * Updates a particle : this function should be overwritten by the user.
  115521. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  115522. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115523. * @example : just set a particle position or velocity and recycle conditions
  115524. * @param particle The particle to update
  115525. * @returns the updated particle
  115526. */
  115527. updateParticle(particle: SolidParticle): SolidParticle;
  115528. /**
  115529. * Updates a vertex of a particle : it can be overwritten by the user.
  115530. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  115531. * @param particle the current particle
  115532. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  115533. * @param pt the index of the current vertex in the particle shape
  115534. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  115535. * @example : just set a vertex particle position or color
  115536. * @returns the sps
  115537. */
  115538. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  115539. /**
  115540. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  115541. * This does nothing and may be overwritten by the user.
  115542. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115543. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115544. * @param update the boolean update value actually passed to setParticles()
  115545. */
  115546. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115547. /**
  115548. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  115549. * This will be passed three parameters.
  115550. * This does nothing and may be overwritten by the user.
  115551. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115552. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115553. * @param update the boolean update value actually passed to setParticles()
  115554. */
  115555. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115556. }
  115557. }
  115558. declare module BABYLON {
  115559. /**
  115560. * Represents one particle of a solid particle system.
  115561. */
  115562. export class SolidParticle {
  115563. /**
  115564. * particle global index
  115565. */
  115566. idx: number;
  115567. /**
  115568. * particle identifier
  115569. */
  115570. id: number;
  115571. /**
  115572. * The color of the particle
  115573. */
  115574. color: Nullable<Color4>;
  115575. /**
  115576. * The world space position of the particle.
  115577. */
  115578. position: Vector3;
  115579. /**
  115580. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  115581. */
  115582. rotation: Vector3;
  115583. /**
  115584. * The world space rotation quaternion of the particle.
  115585. */
  115586. rotationQuaternion: Nullable<Quaternion>;
  115587. /**
  115588. * The scaling of the particle.
  115589. */
  115590. scaling: Vector3;
  115591. /**
  115592. * The uvs of the particle.
  115593. */
  115594. uvs: Vector4;
  115595. /**
  115596. * The current speed of the particle.
  115597. */
  115598. velocity: Vector3;
  115599. /**
  115600. * The pivot point in the particle local space.
  115601. */
  115602. pivot: Vector3;
  115603. /**
  115604. * Must the particle be translated from its pivot point in its local space ?
  115605. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  115606. * Default : false
  115607. */
  115608. translateFromPivot: boolean;
  115609. /**
  115610. * Is the particle active or not ?
  115611. */
  115612. alive: boolean;
  115613. /**
  115614. * Is the particle visible or not ?
  115615. */
  115616. isVisible: boolean;
  115617. /**
  115618. * Index of this particle in the global "positions" array (Internal use)
  115619. * @hidden
  115620. */
  115621. _pos: number;
  115622. /**
  115623. * @hidden Index of this particle in the global "indices" array (Internal use)
  115624. */
  115625. _ind: number;
  115626. /**
  115627. * @hidden ModelShape of this particle (Internal use)
  115628. */
  115629. _model: ModelShape;
  115630. /**
  115631. * ModelShape id of this particle
  115632. */
  115633. shapeId: number;
  115634. /**
  115635. * Index of the particle in its shape id
  115636. */
  115637. idxInShape: number;
  115638. /**
  115639. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  115640. */
  115641. _modelBoundingInfo: BoundingInfo;
  115642. /**
  115643. * @hidden Particle BoundingInfo object (Internal use)
  115644. */
  115645. _boundingInfo: BoundingInfo;
  115646. /**
  115647. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  115648. */
  115649. _sps: SolidParticleSystem;
  115650. /**
  115651. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  115652. */
  115653. _stillInvisible: boolean;
  115654. /**
  115655. * @hidden Last computed particle rotation matrix
  115656. */
  115657. _rotationMatrix: number[];
  115658. /**
  115659. * Parent particle Id, if any.
  115660. * Default null.
  115661. */
  115662. parentId: Nullable<number>;
  115663. /**
  115664. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  115665. */
  115666. materialIndex: Nullable<number>;
  115667. /**
  115668. * Custom object or properties.
  115669. */
  115670. props: Nullable<any>;
  115671. /**
  115672. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  115673. * The possible values are :
  115674. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115675. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115676. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115677. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115678. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115679. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  115680. * */
  115681. cullingStrategy: number;
  115682. /**
  115683. * @hidden Internal global position in the SPS.
  115684. */
  115685. _globalPosition: Vector3;
  115686. /**
  115687. * Creates a Solid Particle object.
  115688. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  115689. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  115690. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  115691. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  115692. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  115693. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  115694. * @param shapeId (integer) is the model shape identifier in the SPS.
  115695. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  115696. * @param sps defines the sps it is associated to
  115697. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  115698. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  115699. */
  115700. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  115701. /**
  115702. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  115703. * @param target the particle target
  115704. * @returns the current particle
  115705. */
  115706. copyToRef(target: SolidParticle): SolidParticle;
  115707. /**
  115708. * Legacy support, changed scale to scaling
  115709. */
  115710. get scale(): Vector3;
  115711. /**
  115712. * Legacy support, changed scale to scaling
  115713. */
  115714. set scale(scale: Vector3);
  115715. /**
  115716. * Legacy support, changed quaternion to rotationQuaternion
  115717. */
  115718. get quaternion(): Nullable<Quaternion>;
  115719. /**
  115720. * Legacy support, changed quaternion to rotationQuaternion
  115721. */
  115722. set quaternion(q: Nullable<Quaternion>);
  115723. /**
  115724. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  115725. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  115726. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  115727. * @returns true if it intersects
  115728. */
  115729. intersectsMesh(target: Mesh | SolidParticle): boolean;
  115730. /**
  115731. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  115732. * A particle is in the frustum if its bounding box intersects the frustum
  115733. * @param frustumPlanes defines the frustum to test
  115734. * @returns true if the particle is in the frustum planes
  115735. */
  115736. isInFrustum(frustumPlanes: Plane[]): boolean;
  115737. /**
  115738. * get the rotation matrix of the particle
  115739. * @hidden
  115740. */
  115741. getRotationMatrix(m: Matrix): void;
  115742. }
  115743. /**
  115744. * Represents the shape of the model used by one particle of a solid particle system.
  115745. * SPS internal tool, don't use it manually.
  115746. */
  115747. export class ModelShape {
  115748. /**
  115749. * The shape id
  115750. * @hidden
  115751. */
  115752. shapeID: number;
  115753. /**
  115754. * flat array of model positions (internal use)
  115755. * @hidden
  115756. */
  115757. _shape: Vector3[];
  115758. /**
  115759. * flat array of model UVs (internal use)
  115760. * @hidden
  115761. */
  115762. _shapeUV: number[];
  115763. /**
  115764. * color array of the model
  115765. * @hidden
  115766. */
  115767. _shapeColors: number[];
  115768. /**
  115769. * indices array of the model
  115770. * @hidden
  115771. */
  115772. _indices: number[];
  115773. /**
  115774. * normals array of the model
  115775. * @hidden
  115776. */
  115777. _normals: number[];
  115778. /**
  115779. * length of the shape in the model indices array (internal use)
  115780. * @hidden
  115781. */
  115782. _indicesLength: number;
  115783. /**
  115784. * Custom position function (internal use)
  115785. * @hidden
  115786. */
  115787. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  115788. /**
  115789. * Custom vertex function (internal use)
  115790. * @hidden
  115791. */
  115792. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  115793. /**
  115794. * Model material (internal use)
  115795. * @hidden
  115796. */
  115797. _material: Nullable<Material>;
  115798. /**
  115799. * 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.
  115800. * SPS internal tool, don't use it manually.
  115801. * @hidden
  115802. */
  115803. 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>);
  115804. }
  115805. /**
  115806. * Represents a Depth Sorted Particle in the solid particle system.
  115807. * @hidden
  115808. */
  115809. export class DepthSortedParticle {
  115810. /**
  115811. * Particle index
  115812. */
  115813. idx: number;
  115814. /**
  115815. * Index of the particle in the "indices" array
  115816. */
  115817. ind: number;
  115818. /**
  115819. * Length of the particle shape in the "indices" array
  115820. */
  115821. indicesLength: number;
  115822. /**
  115823. * Squared distance from the particle to the camera
  115824. */
  115825. sqDistance: number;
  115826. /**
  115827. * Material index when used with MultiMaterials
  115828. */
  115829. materialIndex: number;
  115830. /**
  115831. * Creates a new sorted particle
  115832. * @param materialIndex
  115833. */
  115834. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  115835. }
  115836. /**
  115837. * Represents a solid particle vertex
  115838. */
  115839. export class SolidParticleVertex {
  115840. /**
  115841. * Vertex position
  115842. */
  115843. position: Vector3;
  115844. /**
  115845. * Vertex color
  115846. */
  115847. color: Color4;
  115848. /**
  115849. * Vertex UV
  115850. */
  115851. uv: Vector2;
  115852. /**
  115853. * Creates a new solid particle vertex
  115854. */
  115855. constructor();
  115856. /** Vertex x coordinate */
  115857. get x(): number;
  115858. set x(val: number);
  115859. /** Vertex y coordinate */
  115860. get y(): number;
  115861. set y(val: number);
  115862. /** Vertex z coordinate */
  115863. get z(): number;
  115864. set z(val: number);
  115865. }
  115866. }
  115867. declare module BABYLON {
  115868. /**
  115869. * @hidden
  115870. */
  115871. export class _MeshCollisionData {
  115872. _checkCollisions: boolean;
  115873. _collisionMask: number;
  115874. _collisionGroup: number;
  115875. _surroundingMeshes: Nullable<AbstractMesh[]>;
  115876. _collider: Nullable<Collider>;
  115877. _oldPositionForCollisions: Vector3;
  115878. _diffPositionForCollisions: Vector3;
  115879. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  115880. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  115881. _collisionResponse: boolean;
  115882. }
  115883. }
  115884. declare module BABYLON {
  115885. /** @hidden */
  115886. class _FacetDataStorage {
  115887. facetPositions: Vector3[];
  115888. facetNormals: Vector3[];
  115889. facetPartitioning: number[][];
  115890. facetNb: number;
  115891. partitioningSubdivisions: number;
  115892. partitioningBBoxRatio: number;
  115893. facetDataEnabled: boolean;
  115894. facetParameters: any;
  115895. bbSize: Vector3;
  115896. subDiv: {
  115897. max: number;
  115898. X: number;
  115899. Y: number;
  115900. Z: number;
  115901. };
  115902. facetDepthSort: boolean;
  115903. facetDepthSortEnabled: boolean;
  115904. depthSortedIndices: IndicesArray;
  115905. depthSortedFacets: {
  115906. ind: number;
  115907. sqDistance: number;
  115908. }[];
  115909. facetDepthSortFunction: (f1: {
  115910. ind: number;
  115911. sqDistance: number;
  115912. }, f2: {
  115913. ind: number;
  115914. sqDistance: number;
  115915. }) => number;
  115916. facetDepthSortFrom: Vector3;
  115917. facetDepthSortOrigin: Vector3;
  115918. invertedMatrix: Matrix;
  115919. }
  115920. /**
  115921. * @hidden
  115922. **/
  115923. class _InternalAbstractMeshDataInfo {
  115924. _hasVertexAlpha: boolean;
  115925. _useVertexColors: boolean;
  115926. _numBoneInfluencers: number;
  115927. _applyFog: boolean;
  115928. _receiveShadows: boolean;
  115929. _facetData: _FacetDataStorage;
  115930. _visibility: number;
  115931. _skeleton: Nullable<Skeleton>;
  115932. _layerMask: number;
  115933. _computeBonesUsingShaders: boolean;
  115934. _isActive: boolean;
  115935. _onlyForInstances: boolean;
  115936. _isActiveIntermediate: boolean;
  115937. _onlyForInstancesIntermediate: boolean;
  115938. _actAsRegularMesh: boolean;
  115939. _currentLOD: Nullable<AbstractMesh>;
  115940. }
  115941. /**
  115942. * Class used to store all common mesh properties
  115943. */
  115944. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  115945. /** No occlusion */
  115946. static OCCLUSION_TYPE_NONE: number;
  115947. /** Occlusion set to optimisitic */
  115948. static OCCLUSION_TYPE_OPTIMISTIC: number;
  115949. /** Occlusion set to strict */
  115950. static OCCLUSION_TYPE_STRICT: number;
  115951. /** Use an accurante occlusion algorithm */
  115952. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  115953. /** Use a conservative occlusion algorithm */
  115954. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  115955. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  115956. * Test order :
  115957. * Is the bounding sphere outside the frustum ?
  115958. * If not, are the bounding box vertices outside the frustum ?
  115959. * It not, then the cullable object is in the frustum.
  115960. */
  115961. static readonly CULLINGSTRATEGY_STANDARD: number;
  115962. /** Culling strategy : Bounding Sphere Only.
  115963. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  115964. * It's also less accurate than the standard because some not visible objects can still be selected.
  115965. * Test : is the bounding sphere outside the frustum ?
  115966. * If not, then the cullable object is in the frustum.
  115967. */
  115968. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  115969. /** Culling strategy : Optimistic Inclusion.
  115970. * This in an inclusion test first, then the standard exclusion test.
  115971. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  115972. * 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.
  115973. * Anyway, it's as accurate as the standard strategy.
  115974. * Test :
  115975. * Is the cullable object bounding sphere center in the frustum ?
  115976. * If not, apply the default culling strategy.
  115977. */
  115978. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  115979. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  115980. * This in an inclusion test first, then the bounding sphere only exclusion test.
  115981. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  115982. * 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.
  115983. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  115984. * Test :
  115985. * Is the cullable object bounding sphere center in the frustum ?
  115986. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  115987. */
  115988. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  115989. /**
  115990. * No billboard
  115991. */
  115992. static get BILLBOARDMODE_NONE(): number;
  115993. /** Billboard on X axis */
  115994. static get BILLBOARDMODE_X(): number;
  115995. /** Billboard on Y axis */
  115996. static get BILLBOARDMODE_Y(): number;
  115997. /** Billboard on Z axis */
  115998. static get BILLBOARDMODE_Z(): number;
  115999. /** Billboard on all axes */
  116000. static get BILLBOARDMODE_ALL(): number;
  116001. /** Billboard on using position instead of orientation */
  116002. static get BILLBOARDMODE_USE_POSITION(): number;
  116003. /** @hidden */
  116004. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116005. /**
  116006. * The culling strategy to use to check whether the mesh must be rendered or not.
  116007. * This value can be changed at any time and will be used on the next render mesh selection.
  116008. * The possible values are :
  116009. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116010. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116011. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116012. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116013. * Please read each static variable documentation to get details about the culling process.
  116014. * */
  116015. cullingStrategy: number;
  116016. /**
  116017. * Gets the number of facets in the mesh
  116018. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116019. */
  116020. get facetNb(): number;
  116021. /**
  116022. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116023. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116024. */
  116025. get partitioningSubdivisions(): number;
  116026. set partitioningSubdivisions(nb: number);
  116027. /**
  116028. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116029. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116030. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116031. */
  116032. get partitioningBBoxRatio(): number;
  116033. set partitioningBBoxRatio(ratio: number);
  116034. /**
  116035. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116036. * Works only for updatable meshes.
  116037. * Doesn't work with multi-materials
  116038. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116039. */
  116040. get mustDepthSortFacets(): boolean;
  116041. set mustDepthSortFacets(sort: boolean);
  116042. /**
  116043. * The location (Vector3) where the facet depth sort must be computed from.
  116044. * By default, the active camera position.
  116045. * Used only when facet depth sort is enabled
  116046. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116047. */
  116048. get facetDepthSortFrom(): Vector3;
  116049. set facetDepthSortFrom(location: Vector3);
  116050. /**
  116051. * gets a boolean indicating if facetData is enabled
  116052. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116053. */
  116054. get isFacetDataEnabled(): boolean;
  116055. /** @hidden */
  116056. _updateNonUniformScalingState(value: boolean): boolean;
  116057. /**
  116058. * An event triggered when this mesh collides with another one
  116059. */
  116060. onCollideObservable: Observable<AbstractMesh>;
  116061. /** Set a function to call when this mesh collides with another one */
  116062. set onCollide(callback: () => void);
  116063. /**
  116064. * An event triggered when the collision's position changes
  116065. */
  116066. onCollisionPositionChangeObservable: Observable<Vector3>;
  116067. /** Set a function to call when the collision's position changes */
  116068. set onCollisionPositionChange(callback: () => void);
  116069. /**
  116070. * An event triggered when material is changed
  116071. */
  116072. onMaterialChangedObservable: Observable<AbstractMesh>;
  116073. /**
  116074. * Gets or sets the orientation for POV movement & rotation
  116075. */
  116076. definedFacingForward: boolean;
  116077. /** @hidden */
  116078. _occlusionQuery: Nullable<WebGLQuery>;
  116079. /** @hidden */
  116080. _renderingGroup: Nullable<RenderingGroup>;
  116081. /**
  116082. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116083. */
  116084. get visibility(): number;
  116085. /**
  116086. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116087. */
  116088. set visibility(value: number);
  116089. /** Gets or sets the alpha index used to sort transparent meshes
  116090. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116091. */
  116092. alphaIndex: number;
  116093. /**
  116094. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116095. */
  116096. isVisible: boolean;
  116097. /**
  116098. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116099. */
  116100. isPickable: boolean;
  116101. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116102. showSubMeshesBoundingBox: boolean;
  116103. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116104. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116105. */
  116106. isBlocker: boolean;
  116107. /**
  116108. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116109. */
  116110. enablePointerMoveEvents: boolean;
  116111. private _renderingGroupId;
  116112. /**
  116113. * Specifies the rendering group id for this mesh (0 by default)
  116114. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116115. */
  116116. get renderingGroupId(): number;
  116117. set renderingGroupId(value: number);
  116118. private _material;
  116119. /** Gets or sets current material */
  116120. get material(): Nullable<Material>;
  116121. set material(value: Nullable<Material>);
  116122. /**
  116123. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116124. * @see https://doc.babylonjs.com/babylon101/shadows
  116125. */
  116126. get receiveShadows(): boolean;
  116127. set receiveShadows(value: boolean);
  116128. /** Defines color to use when rendering outline */
  116129. outlineColor: Color3;
  116130. /** Define width to use when rendering outline */
  116131. outlineWidth: number;
  116132. /** Defines color to use when rendering overlay */
  116133. overlayColor: Color3;
  116134. /** Defines alpha to use when rendering overlay */
  116135. overlayAlpha: number;
  116136. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116137. get hasVertexAlpha(): boolean;
  116138. set hasVertexAlpha(value: boolean);
  116139. /** 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) */
  116140. get useVertexColors(): boolean;
  116141. set useVertexColors(value: boolean);
  116142. /**
  116143. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116144. */
  116145. get computeBonesUsingShaders(): boolean;
  116146. set computeBonesUsingShaders(value: boolean);
  116147. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116148. get numBoneInfluencers(): number;
  116149. set numBoneInfluencers(value: number);
  116150. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116151. get applyFog(): boolean;
  116152. set applyFog(value: boolean);
  116153. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116154. useOctreeForRenderingSelection: boolean;
  116155. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116156. useOctreeForPicking: boolean;
  116157. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116158. useOctreeForCollisions: boolean;
  116159. /**
  116160. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116161. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116162. */
  116163. get layerMask(): number;
  116164. set layerMask(value: number);
  116165. /**
  116166. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116167. */
  116168. alwaysSelectAsActiveMesh: boolean;
  116169. /**
  116170. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116171. */
  116172. doNotSyncBoundingInfo: boolean;
  116173. /**
  116174. * Gets or sets the current action manager
  116175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116176. */
  116177. actionManager: Nullable<AbstractActionManager>;
  116178. private _meshCollisionData;
  116179. /**
  116180. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116181. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116182. */
  116183. ellipsoid: Vector3;
  116184. /**
  116185. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116186. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116187. */
  116188. ellipsoidOffset: Vector3;
  116189. /**
  116190. * Gets or sets a collision mask used to mask collisions (default is -1).
  116191. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116192. */
  116193. get collisionMask(): number;
  116194. set collisionMask(mask: number);
  116195. /**
  116196. * Gets or sets a collision response flag (default is true).
  116197. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116198. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116199. * to respond to the collision.
  116200. */
  116201. get collisionResponse(): boolean;
  116202. set collisionResponse(response: boolean);
  116203. /**
  116204. * Gets or sets the current collision group mask (-1 by default).
  116205. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116206. */
  116207. get collisionGroup(): number;
  116208. set collisionGroup(mask: number);
  116209. /**
  116210. * Gets or sets current surrounding meshes (null by default).
  116211. *
  116212. * By default collision detection is tested against every mesh in the scene.
  116213. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116214. * meshes will be tested for the collision.
  116215. *
  116216. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116217. */
  116218. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116219. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116220. /**
  116221. * Defines edge width used when edgesRenderer is enabled
  116222. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116223. */
  116224. edgesWidth: number;
  116225. /**
  116226. * Defines edge color used when edgesRenderer is enabled
  116227. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116228. */
  116229. edgesColor: Color4;
  116230. /** @hidden */
  116231. _edgesRenderer: Nullable<IEdgesRenderer>;
  116232. /** @hidden */
  116233. _masterMesh: Nullable<AbstractMesh>;
  116234. /** @hidden */
  116235. _boundingInfo: Nullable<BoundingInfo>;
  116236. /** @hidden */
  116237. _renderId: number;
  116238. /**
  116239. * Gets or sets the list of subMeshes
  116240. * @see https://doc.babylonjs.com/how_to/multi_materials
  116241. */
  116242. subMeshes: SubMesh[];
  116243. /** @hidden */
  116244. _intersectionsInProgress: AbstractMesh[];
  116245. /** @hidden */
  116246. _unIndexed: boolean;
  116247. /** @hidden */
  116248. _lightSources: Light[];
  116249. /** Gets the list of lights affecting that mesh */
  116250. get lightSources(): Light[];
  116251. /** @hidden */
  116252. get _positions(): Nullable<Vector3[]>;
  116253. /** @hidden */
  116254. _waitingData: {
  116255. lods: Nullable<any>;
  116256. actions: Nullable<any>;
  116257. freezeWorldMatrix: Nullable<boolean>;
  116258. };
  116259. /** @hidden */
  116260. _bonesTransformMatrices: Nullable<Float32Array>;
  116261. /** @hidden */
  116262. _transformMatrixTexture: Nullable<RawTexture>;
  116263. /**
  116264. * Gets or sets a skeleton to apply skining transformations
  116265. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116266. */
  116267. set skeleton(value: Nullable<Skeleton>);
  116268. get skeleton(): Nullable<Skeleton>;
  116269. /**
  116270. * An event triggered when the mesh is rebuilt.
  116271. */
  116272. onRebuildObservable: Observable<AbstractMesh>;
  116273. /**
  116274. * Creates a new AbstractMesh
  116275. * @param name defines the name of the mesh
  116276. * @param scene defines the hosting scene
  116277. */
  116278. constructor(name: string, scene?: Nullable<Scene>);
  116279. /**
  116280. * Returns the string "AbstractMesh"
  116281. * @returns "AbstractMesh"
  116282. */
  116283. getClassName(): string;
  116284. /**
  116285. * Gets a string representation of the current mesh
  116286. * @param fullDetails defines a boolean indicating if full details must be included
  116287. * @returns a string representation of the current mesh
  116288. */
  116289. toString(fullDetails?: boolean): string;
  116290. /**
  116291. * @hidden
  116292. */
  116293. protected _getEffectiveParent(): Nullable<Node>;
  116294. /** @hidden */
  116295. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116296. /** @hidden */
  116297. _rebuild(): void;
  116298. /** @hidden */
  116299. _resyncLightSources(): void;
  116300. /** @hidden */
  116301. _resyncLightSource(light: Light): void;
  116302. /** @hidden */
  116303. _unBindEffect(): void;
  116304. /** @hidden */
  116305. _removeLightSource(light: Light, dispose: boolean): void;
  116306. private _markSubMeshesAsDirty;
  116307. /** @hidden */
  116308. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116309. /** @hidden */
  116310. _markSubMeshesAsAttributesDirty(): void;
  116311. /** @hidden */
  116312. _markSubMeshesAsMiscDirty(): void;
  116313. /**
  116314. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116315. */
  116316. get scaling(): Vector3;
  116317. set scaling(newScaling: Vector3);
  116318. /**
  116319. * Returns true if the mesh is blocked. Implemented by child classes
  116320. */
  116321. get isBlocked(): boolean;
  116322. /**
  116323. * Returns the mesh itself by default. Implemented by child classes
  116324. * @param camera defines the camera to use to pick the right LOD level
  116325. * @returns the currentAbstractMesh
  116326. */
  116327. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116328. /**
  116329. * Returns 0 by default. Implemented by child classes
  116330. * @returns an integer
  116331. */
  116332. getTotalVertices(): number;
  116333. /**
  116334. * Returns a positive integer : the total number of indices in this mesh geometry.
  116335. * @returns the numner of indices or zero if the mesh has no geometry.
  116336. */
  116337. getTotalIndices(): number;
  116338. /**
  116339. * Returns null by default. Implemented by child classes
  116340. * @returns null
  116341. */
  116342. getIndices(): Nullable<IndicesArray>;
  116343. /**
  116344. * Returns the array of the requested vertex data kind. Implemented by child classes
  116345. * @param kind defines the vertex data kind to use
  116346. * @returns null
  116347. */
  116348. getVerticesData(kind: string): Nullable<FloatArray>;
  116349. /**
  116350. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116351. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116352. * Note that a new underlying VertexBuffer object is created each call.
  116353. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116354. * @param kind defines vertex data kind:
  116355. * * VertexBuffer.PositionKind
  116356. * * VertexBuffer.UVKind
  116357. * * VertexBuffer.UV2Kind
  116358. * * VertexBuffer.UV3Kind
  116359. * * VertexBuffer.UV4Kind
  116360. * * VertexBuffer.UV5Kind
  116361. * * VertexBuffer.UV6Kind
  116362. * * VertexBuffer.ColorKind
  116363. * * VertexBuffer.MatricesIndicesKind
  116364. * * VertexBuffer.MatricesIndicesExtraKind
  116365. * * VertexBuffer.MatricesWeightsKind
  116366. * * VertexBuffer.MatricesWeightsExtraKind
  116367. * @param data defines the data source
  116368. * @param updatable defines if the data must be flagged as updatable (or static)
  116369. * @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
  116370. * @returns the current mesh
  116371. */
  116372. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  116373. /**
  116374. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  116375. * If the mesh has no geometry, it is simply returned as it is.
  116376. * @param kind defines vertex data kind:
  116377. * * VertexBuffer.PositionKind
  116378. * * VertexBuffer.UVKind
  116379. * * VertexBuffer.UV2Kind
  116380. * * VertexBuffer.UV3Kind
  116381. * * VertexBuffer.UV4Kind
  116382. * * VertexBuffer.UV5Kind
  116383. * * VertexBuffer.UV6Kind
  116384. * * VertexBuffer.ColorKind
  116385. * * VertexBuffer.MatricesIndicesKind
  116386. * * VertexBuffer.MatricesIndicesExtraKind
  116387. * * VertexBuffer.MatricesWeightsKind
  116388. * * VertexBuffer.MatricesWeightsExtraKind
  116389. * @param data defines the data source
  116390. * @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
  116391. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  116392. * @returns the current mesh
  116393. */
  116394. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  116395. /**
  116396. * Sets the mesh indices,
  116397. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  116398. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  116399. * @param totalVertices Defines the total number of vertices
  116400. * @returns the current mesh
  116401. */
  116402. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  116403. /**
  116404. * Gets a boolean indicating if specific vertex data is present
  116405. * @param kind defines the vertex data kind to use
  116406. * @returns true is data kind is present
  116407. */
  116408. isVerticesDataPresent(kind: string): boolean;
  116409. /**
  116410. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  116411. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  116412. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  116413. * @returns a BoundingInfo
  116414. */
  116415. getBoundingInfo(): BoundingInfo;
  116416. /**
  116417. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  116418. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  116419. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  116420. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  116421. * @returns the current mesh
  116422. */
  116423. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  116424. /**
  116425. * Overwrite the current bounding info
  116426. * @param boundingInfo defines the new bounding info
  116427. * @returns the current mesh
  116428. */
  116429. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  116430. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  116431. get useBones(): boolean;
  116432. /** @hidden */
  116433. _preActivate(): void;
  116434. /** @hidden */
  116435. _preActivateForIntermediateRendering(renderId: number): void;
  116436. /** @hidden */
  116437. _activate(renderId: number, intermediateRendering: boolean): boolean;
  116438. /** @hidden */
  116439. _postActivate(): void;
  116440. /** @hidden */
  116441. _freeze(): void;
  116442. /** @hidden */
  116443. _unFreeze(): void;
  116444. /**
  116445. * Gets the current world matrix
  116446. * @returns a Matrix
  116447. */
  116448. getWorldMatrix(): Matrix;
  116449. /** @hidden */
  116450. _getWorldMatrixDeterminant(): number;
  116451. /**
  116452. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  116453. */
  116454. get isAnInstance(): boolean;
  116455. /**
  116456. * Gets a boolean indicating if this mesh has instances
  116457. */
  116458. get hasInstances(): boolean;
  116459. /**
  116460. * Gets a boolean indicating if this mesh has thin instances
  116461. */
  116462. get hasThinInstances(): boolean;
  116463. /**
  116464. * Perform relative position change from the point of view of behind the front of the mesh.
  116465. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116466. * Supports definition of mesh facing forward or backward
  116467. * @param amountRight defines the distance on the right axis
  116468. * @param amountUp defines the distance on the up axis
  116469. * @param amountForward defines the distance on the forward axis
  116470. * @returns the current mesh
  116471. */
  116472. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  116473. /**
  116474. * Calculate relative position change from the point of view of behind the front of the mesh.
  116475. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116476. * Supports definition of mesh facing forward or backward
  116477. * @param amountRight defines the distance on the right axis
  116478. * @param amountUp defines the distance on the up axis
  116479. * @param amountForward defines the distance on the forward axis
  116480. * @returns the new displacement vector
  116481. */
  116482. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  116483. /**
  116484. * Perform relative rotation change from the point of view of behind the front of the mesh.
  116485. * Supports definition of mesh facing forward or backward
  116486. * @param flipBack defines the flip
  116487. * @param twirlClockwise defines the twirl
  116488. * @param tiltRight defines the tilt
  116489. * @returns the current mesh
  116490. */
  116491. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  116492. /**
  116493. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  116494. * Supports definition of mesh facing forward or backward.
  116495. * @param flipBack defines the flip
  116496. * @param twirlClockwise defines the twirl
  116497. * @param tiltRight defines the tilt
  116498. * @returns the new rotation vector
  116499. */
  116500. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  116501. /**
  116502. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  116503. * This means the mesh underlying bounding box and sphere are recomputed.
  116504. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  116505. * @returns the current mesh
  116506. */
  116507. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  116508. /** @hidden */
  116509. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  116510. /** @hidden */
  116511. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  116512. /** @hidden */
  116513. _updateBoundingInfo(): AbstractMesh;
  116514. /** @hidden */
  116515. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  116516. /** @hidden */
  116517. protected _afterComputeWorldMatrix(): void;
  116518. /** @hidden */
  116519. get _effectiveMesh(): AbstractMesh;
  116520. /**
  116521. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  116522. * A mesh is in the frustum if its bounding box intersects the frustum
  116523. * @param frustumPlanes defines the frustum to test
  116524. * @returns true if the mesh is in the frustum planes
  116525. */
  116526. isInFrustum(frustumPlanes: Plane[]): boolean;
  116527. /**
  116528. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  116529. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  116530. * @param frustumPlanes defines the frustum to test
  116531. * @returns true if the mesh is completely in the frustum planes
  116532. */
  116533. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  116534. /**
  116535. * True if the mesh intersects another mesh or a SolidParticle object
  116536. * @param mesh defines a target mesh or SolidParticle to test
  116537. * @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)
  116538. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  116539. * @returns true if there is an intersection
  116540. */
  116541. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  116542. /**
  116543. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  116544. * @param point defines the point to test
  116545. * @returns true if there is an intersection
  116546. */
  116547. intersectsPoint(point: Vector3): boolean;
  116548. /**
  116549. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  116550. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116551. */
  116552. get checkCollisions(): boolean;
  116553. set checkCollisions(collisionEnabled: boolean);
  116554. /**
  116555. * Gets Collider object used to compute collisions (not physics)
  116556. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116557. */
  116558. get collider(): Nullable<Collider>;
  116559. /**
  116560. * Move the mesh using collision engine
  116561. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116562. * @param displacement defines the requested displacement vector
  116563. * @returns the current mesh
  116564. */
  116565. moveWithCollisions(displacement: Vector3): AbstractMesh;
  116566. private _onCollisionPositionChange;
  116567. /** @hidden */
  116568. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  116569. /** @hidden */
  116570. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  116571. /** @hidden */
  116572. _checkCollision(collider: Collider): AbstractMesh;
  116573. /** @hidden */
  116574. _generatePointsArray(): boolean;
  116575. /**
  116576. * Checks if the passed Ray intersects with the mesh
  116577. * @param ray defines the ray to use
  116578. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  116579. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116580. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  116581. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  116582. * @returns the picking info
  116583. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  116584. */
  116585. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  116586. /**
  116587. * Clones the current mesh
  116588. * @param name defines the mesh name
  116589. * @param newParent defines the new mesh parent
  116590. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  116591. * @returns the new mesh
  116592. */
  116593. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  116594. /**
  116595. * Disposes all the submeshes of the current meshnp
  116596. * @returns the current mesh
  116597. */
  116598. releaseSubMeshes(): AbstractMesh;
  116599. /**
  116600. * Releases resources associated with this abstract mesh.
  116601. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116602. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116603. */
  116604. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116605. /**
  116606. * Adds the passed mesh as a child to the current mesh
  116607. * @param mesh defines the child mesh
  116608. * @returns the current mesh
  116609. */
  116610. addChild(mesh: AbstractMesh): AbstractMesh;
  116611. /**
  116612. * Removes the passed mesh from the current mesh children list
  116613. * @param mesh defines the child mesh
  116614. * @returns the current mesh
  116615. */
  116616. removeChild(mesh: AbstractMesh): AbstractMesh;
  116617. /** @hidden */
  116618. private _initFacetData;
  116619. /**
  116620. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  116621. * This method can be called within the render loop.
  116622. * 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
  116623. * @returns the current mesh
  116624. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116625. */
  116626. updateFacetData(): AbstractMesh;
  116627. /**
  116628. * Returns the facetLocalNormals array.
  116629. * The normals are expressed in the mesh local spac
  116630. * @returns an array of Vector3
  116631. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116632. */
  116633. getFacetLocalNormals(): Vector3[];
  116634. /**
  116635. * Returns the facetLocalPositions array.
  116636. * The facet positions are expressed in the mesh local space
  116637. * @returns an array of Vector3
  116638. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116639. */
  116640. getFacetLocalPositions(): Vector3[];
  116641. /**
  116642. * Returns the facetLocalPartioning array
  116643. * @returns an array of array of numbers
  116644. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116645. */
  116646. getFacetLocalPartitioning(): number[][];
  116647. /**
  116648. * Returns the i-th facet position in the world system.
  116649. * This method allocates a new Vector3 per call
  116650. * @param i defines the facet index
  116651. * @returns a new Vector3
  116652. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116653. */
  116654. getFacetPosition(i: number): Vector3;
  116655. /**
  116656. * Sets the reference Vector3 with the i-th facet position in the world system
  116657. * @param i defines the facet index
  116658. * @param ref defines the target vector
  116659. * @returns the current mesh
  116660. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116661. */
  116662. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  116663. /**
  116664. * Returns the i-th facet normal in the world system.
  116665. * This method allocates a new Vector3 per call
  116666. * @param i defines the facet index
  116667. * @returns a new Vector3
  116668. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116669. */
  116670. getFacetNormal(i: number): Vector3;
  116671. /**
  116672. * Sets the reference Vector3 with the i-th facet normal in the world system
  116673. * @param i defines the facet index
  116674. * @param ref defines the target vector
  116675. * @returns the current mesh
  116676. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116677. */
  116678. getFacetNormalToRef(i: number, ref: Vector3): this;
  116679. /**
  116680. * 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)
  116681. * @param x defines x coordinate
  116682. * @param y defines y coordinate
  116683. * @param z defines z coordinate
  116684. * @returns the array of facet indexes
  116685. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116686. */
  116687. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  116688. /**
  116689. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  116690. * @param projected sets as the (x,y,z) world projection on the facet
  116691. * @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
  116692. * @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
  116693. * @param x defines x coordinate
  116694. * @param y defines y coordinate
  116695. * @param z defines z coordinate
  116696. * @returns the face index if found (or null instead)
  116697. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116698. */
  116699. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116700. /**
  116701. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  116702. * @param projected sets as the (x,y,z) local projection on the facet
  116703. * @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
  116704. * @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
  116705. * @param x defines x coordinate
  116706. * @param y defines y coordinate
  116707. * @param z defines z coordinate
  116708. * @returns the face index if found (or null instead)
  116709. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116710. */
  116711. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116712. /**
  116713. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  116714. * @returns the parameters
  116715. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116716. */
  116717. getFacetDataParameters(): any;
  116718. /**
  116719. * Disables the feature FacetData and frees the related memory
  116720. * @returns the current mesh
  116721. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116722. */
  116723. disableFacetData(): AbstractMesh;
  116724. /**
  116725. * Updates the AbstractMesh indices array
  116726. * @param indices defines the data source
  116727. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  116728. * @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)
  116729. * @returns the current mesh
  116730. */
  116731. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  116732. /**
  116733. * Creates new normals data for the mesh
  116734. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  116735. * @returns the current mesh
  116736. */
  116737. createNormals(updatable: boolean): AbstractMesh;
  116738. /**
  116739. * Align the mesh with a normal
  116740. * @param normal defines the normal to use
  116741. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  116742. * @returns the current mesh
  116743. */
  116744. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  116745. /** @hidden */
  116746. _checkOcclusionQuery(): boolean;
  116747. /**
  116748. * Disables the mesh edge rendering mode
  116749. * @returns the currentAbstractMesh
  116750. */
  116751. disableEdgesRendering(): AbstractMesh;
  116752. /**
  116753. * Enables the edge rendering mode on the mesh.
  116754. * This mode makes the mesh edges visible
  116755. * @param epsilon defines the maximal distance between two angles to detect a face
  116756. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  116757. * @returns the currentAbstractMesh
  116758. * @see https://www.babylonjs-playground.com/#19O9TU#0
  116759. */
  116760. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  116761. /**
  116762. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  116763. * @returns an array of particle systems in the scene that use the mesh as an emitter
  116764. */
  116765. getConnectedParticleSystems(): IParticleSystem[];
  116766. }
  116767. }
  116768. declare module BABYLON {
  116769. /**
  116770. * Interface used to define ActionEvent
  116771. */
  116772. export interface IActionEvent {
  116773. /** The mesh or sprite that triggered the action */
  116774. source: any;
  116775. /** The X mouse cursor position at the time of the event */
  116776. pointerX: number;
  116777. /** The Y mouse cursor position at the time of the event */
  116778. pointerY: number;
  116779. /** The mesh that is currently pointed at (can be null) */
  116780. meshUnderPointer: Nullable<AbstractMesh>;
  116781. /** the original (browser) event that triggered the ActionEvent */
  116782. sourceEvent?: any;
  116783. /** additional data for the event */
  116784. additionalData?: any;
  116785. }
  116786. /**
  116787. * ActionEvent is the event being sent when an action is triggered.
  116788. */
  116789. export class ActionEvent implements IActionEvent {
  116790. /** The mesh or sprite that triggered the action */
  116791. source: any;
  116792. /** The X mouse cursor position at the time of the event */
  116793. pointerX: number;
  116794. /** The Y mouse cursor position at the time of the event */
  116795. pointerY: number;
  116796. /** The mesh that is currently pointed at (can be null) */
  116797. meshUnderPointer: Nullable<AbstractMesh>;
  116798. /** the original (browser) event that triggered the ActionEvent */
  116799. sourceEvent?: any;
  116800. /** additional data for the event */
  116801. additionalData?: any;
  116802. /**
  116803. * Creates a new ActionEvent
  116804. * @param source The mesh or sprite that triggered the action
  116805. * @param pointerX The X mouse cursor position at the time of the event
  116806. * @param pointerY The Y mouse cursor position at the time of the event
  116807. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  116808. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  116809. * @param additionalData additional data for the event
  116810. */
  116811. constructor(
  116812. /** The mesh or sprite that triggered the action */
  116813. source: any,
  116814. /** The X mouse cursor position at the time of the event */
  116815. pointerX: number,
  116816. /** The Y mouse cursor position at the time of the event */
  116817. pointerY: number,
  116818. /** The mesh that is currently pointed at (can be null) */
  116819. meshUnderPointer: Nullable<AbstractMesh>,
  116820. /** the original (browser) event that triggered the ActionEvent */
  116821. sourceEvent?: any,
  116822. /** additional data for the event */
  116823. additionalData?: any);
  116824. /**
  116825. * Helper function to auto-create an ActionEvent from a source mesh.
  116826. * @param source The source mesh that triggered the event
  116827. * @param evt The original (browser) event
  116828. * @param additionalData additional data for the event
  116829. * @returns the new ActionEvent
  116830. */
  116831. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  116832. /**
  116833. * Helper function to auto-create an ActionEvent from a source sprite
  116834. * @param source The source sprite that triggered the event
  116835. * @param scene Scene associated with the sprite
  116836. * @param evt The original (browser) event
  116837. * @param additionalData additional data for the event
  116838. * @returns the new ActionEvent
  116839. */
  116840. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  116841. /**
  116842. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  116843. * @param scene the scene where the event occurred
  116844. * @param evt The original (browser) event
  116845. * @returns the new ActionEvent
  116846. */
  116847. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  116848. /**
  116849. * Helper function to auto-create an ActionEvent from a primitive
  116850. * @param prim defines the target primitive
  116851. * @param pointerPos defines the pointer position
  116852. * @param evt The original (browser) event
  116853. * @param additionalData additional data for the event
  116854. * @returns the new ActionEvent
  116855. */
  116856. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  116857. }
  116858. }
  116859. declare module BABYLON {
  116860. /**
  116861. * Abstract class used to decouple action Manager from scene and meshes.
  116862. * Do not instantiate.
  116863. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116864. */
  116865. export abstract class AbstractActionManager implements IDisposable {
  116866. /** Gets the list of active triggers */
  116867. static Triggers: {
  116868. [key: string]: number;
  116869. };
  116870. /** Gets the cursor to use when hovering items */
  116871. hoverCursor: string;
  116872. /** Gets the list of actions */
  116873. actions: IAction[];
  116874. /**
  116875. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  116876. */
  116877. isRecursive: boolean;
  116878. /**
  116879. * Releases all associated resources
  116880. */
  116881. abstract dispose(): void;
  116882. /**
  116883. * Does this action manager has pointer triggers
  116884. */
  116885. abstract get hasPointerTriggers(): boolean;
  116886. /**
  116887. * Does this action manager has pick triggers
  116888. */
  116889. abstract get hasPickTriggers(): boolean;
  116890. /**
  116891. * Process a specific trigger
  116892. * @param trigger defines the trigger to process
  116893. * @param evt defines the event details to be processed
  116894. */
  116895. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  116896. /**
  116897. * Does this action manager handles actions of any of the given triggers
  116898. * @param triggers defines the triggers to be tested
  116899. * @return a boolean indicating whether one (or more) of the triggers is handled
  116900. */
  116901. abstract hasSpecificTriggers(triggers: number[]): boolean;
  116902. /**
  116903. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  116904. * speed.
  116905. * @param triggerA defines the trigger to be tested
  116906. * @param triggerB defines the trigger to be tested
  116907. * @return a boolean indicating whether one (or more) of the triggers is handled
  116908. */
  116909. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  116910. /**
  116911. * Does this action manager handles actions of a given trigger
  116912. * @param trigger defines the trigger to be tested
  116913. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  116914. * @return whether the trigger is handled
  116915. */
  116916. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  116917. /**
  116918. * Serialize this manager to a JSON object
  116919. * @param name defines the property name to store this manager
  116920. * @returns a JSON representation of this manager
  116921. */
  116922. abstract serialize(name: string): any;
  116923. /**
  116924. * Registers an action to this action manager
  116925. * @param action defines the action to be registered
  116926. * @return the action amended (prepared) after registration
  116927. */
  116928. abstract registerAction(action: IAction): Nullable<IAction>;
  116929. /**
  116930. * Unregisters an action to this action manager
  116931. * @param action defines the action to be unregistered
  116932. * @return a boolean indicating whether the action has been unregistered
  116933. */
  116934. abstract unregisterAction(action: IAction): Boolean;
  116935. /**
  116936. * Does exist one action manager with at least one trigger
  116937. **/
  116938. static get HasTriggers(): boolean;
  116939. /**
  116940. * Does exist one action manager with at least one pick trigger
  116941. **/
  116942. static get HasPickTriggers(): boolean;
  116943. /**
  116944. * Does exist one action manager that handles actions of a given trigger
  116945. * @param trigger defines the trigger to be tested
  116946. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  116947. **/
  116948. static HasSpecificTrigger(trigger: number): boolean;
  116949. }
  116950. }
  116951. declare module BABYLON {
  116952. /**
  116953. * Defines how a node can be built from a string name.
  116954. */
  116955. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  116956. /**
  116957. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  116958. */
  116959. export class Node implements IBehaviorAware<Node> {
  116960. /** @hidden */
  116961. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  116962. private static _NodeConstructors;
  116963. /**
  116964. * Add a new node constructor
  116965. * @param type defines the type name of the node to construct
  116966. * @param constructorFunc defines the constructor function
  116967. */
  116968. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  116969. /**
  116970. * Returns a node constructor based on type name
  116971. * @param type defines the type name
  116972. * @param name defines the new node name
  116973. * @param scene defines the hosting scene
  116974. * @param options defines optional options to transmit to constructors
  116975. * @returns the new constructor or null
  116976. */
  116977. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  116978. /**
  116979. * Gets or sets the name of the node
  116980. */
  116981. name: string;
  116982. /**
  116983. * Gets or sets the id of the node
  116984. */
  116985. id: string;
  116986. /**
  116987. * Gets or sets the unique id of the node
  116988. */
  116989. uniqueId: number;
  116990. /**
  116991. * Gets or sets a string used to store user defined state for the node
  116992. */
  116993. state: string;
  116994. /**
  116995. * Gets or sets an object used to store user defined information for the node
  116996. */
  116997. metadata: any;
  116998. /**
  116999. * For internal use only. Please do not use.
  117000. */
  117001. reservedDataStore: any;
  117002. /**
  117003. * List of inspectable custom properties (used by the Inspector)
  117004. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117005. */
  117006. inspectableCustomProperties: IInspectable[];
  117007. private _doNotSerialize;
  117008. /**
  117009. * Gets or sets a boolean used to define if the node must be serialized
  117010. */
  117011. get doNotSerialize(): boolean;
  117012. set doNotSerialize(value: boolean);
  117013. /** @hidden */
  117014. _isDisposed: boolean;
  117015. /**
  117016. * Gets a list of Animations associated with the node
  117017. */
  117018. animations: Animation[];
  117019. protected _ranges: {
  117020. [name: string]: Nullable<AnimationRange>;
  117021. };
  117022. /**
  117023. * Callback raised when the node is ready to be used
  117024. */
  117025. onReady: Nullable<(node: Node) => void>;
  117026. private _isEnabled;
  117027. private _isParentEnabled;
  117028. private _isReady;
  117029. /** @hidden */
  117030. _currentRenderId: number;
  117031. private _parentUpdateId;
  117032. /** @hidden */
  117033. _childUpdateId: number;
  117034. /** @hidden */
  117035. _waitingParentId: Nullable<string>;
  117036. /** @hidden */
  117037. _scene: Scene;
  117038. /** @hidden */
  117039. _cache: any;
  117040. private _parentNode;
  117041. private _children;
  117042. /** @hidden */
  117043. _worldMatrix: Matrix;
  117044. /** @hidden */
  117045. _worldMatrixDeterminant: number;
  117046. /** @hidden */
  117047. _worldMatrixDeterminantIsDirty: boolean;
  117048. /** @hidden */
  117049. private _sceneRootNodesIndex;
  117050. /**
  117051. * Gets a boolean indicating if the node has been disposed
  117052. * @returns true if the node was disposed
  117053. */
  117054. isDisposed(): boolean;
  117055. /**
  117056. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117057. * @see https://doc.babylonjs.com/how_to/parenting
  117058. */
  117059. set parent(parent: Nullable<Node>);
  117060. get parent(): Nullable<Node>;
  117061. /** @hidden */
  117062. _addToSceneRootNodes(): void;
  117063. /** @hidden */
  117064. _removeFromSceneRootNodes(): void;
  117065. private _animationPropertiesOverride;
  117066. /**
  117067. * Gets or sets the animation properties override
  117068. */
  117069. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117070. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117071. /**
  117072. * Gets a string identifying the name of the class
  117073. * @returns "Node" string
  117074. */
  117075. getClassName(): string;
  117076. /** @hidden */
  117077. readonly _isNode: boolean;
  117078. /**
  117079. * An event triggered when the mesh is disposed
  117080. */
  117081. onDisposeObservable: Observable<Node>;
  117082. private _onDisposeObserver;
  117083. /**
  117084. * Sets a callback that will be raised when the node will be disposed
  117085. */
  117086. set onDispose(callback: () => void);
  117087. /**
  117088. * Creates a new Node
  117089. * @param name the name and id to be given to this node
  117090. * @param scene the scene this node will be added to
  117091. */
  117092. constructor(name: string, scene?: Nullable<Scene>);
  117093. /**
  117094. * Gets the scene of the node
  117095. * @returns a scene
  117096. */
  117097. getScene(): Scene;
  117098. /**
  117099. * Gets the engine of the node
  117100. * @returns a Engine
  117101. */
  117102. getEngine(): Engine;
  117103. private _behaviors;
  117104. /**
  117105. * Attach a behavior to the node
  117106. * @see https://doc.babylonjs.com/features/behaviour
  117107. * @param behavior defines the behavior to attach
  117108. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117109. * @returns the current Node
  117110. */
  117111. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117112. /**
  117113. * Remove an attached behavior
  117114. * @see https://doc.babylonjs.com/features/behaviour
  117115. * @param behavior defines the behavior to attach
  117116. * @returns the current Node
  117117. */
  117118. removeBehavior(behavior: Behavior<Node>): Node;
  117119. /**
  117120. * Gets the list of attached behaviors
  117121. * @see https://doc.babylonjs.com/features/behaviour
  117122. */
  117123. get behaviors(): Behavior<Node>[];
  117124. /**
  117125. * Gets an attached behavior by name
  117126. * @param name defines the name of the behavior to look for
  117127. * @see https://doc.babylonjs.com/features/behaviour
  117128. * @returns null if behavior was not found else the requested behavior
  117129. */
  117130. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117131. /**
  117132. * Returns the latest update of the World matrix
  117133. * @returns a Matrix
  117134. */
  117135. getWorldMatrix(): Matrix;
  117136. /** @hidden */
  117137. _getWorldMatrixDeterminant(): number;
  117138. /**
  117139. * Returns directly the latest state of the mesh World matrix.
  117140. * A Matrix is returned.
  117141. */
  117142. get worldMatrixFromCache(): Matrix;
  117143. /** @hidden */
  117144. _initCache(): void;
  117145. /** @hidden */
  117146. updateCache(force?: boolean): void;
  117147. /** @hidden */
  117148. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117149. /** @hidden */
  117150. _updateCache(ignoreParentClass?: boolean): void;
  117151. /** @hidden */
  117152. _isSynchronized(): boolean;
  117153. /** @hidden */
  117154. _markSyncedWithParent(): void;
  117155. /** @hidden */
  117156. isSynchronizedWithParent(): boolean;
  117157. /** @hidden */
  117158. isSynchronized(): boolean;
  117159. /**
  117160. * Is this node ready to be used/rendered
  117161. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117162. * @return true if the node is ready
  117163. */
  117164. isReady(completeCheck?: boolean): boolean;
  117165. /**
  117166. * Is this node enabled?
  117167. * 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
  117168. * @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
  117169. * @return whether this node (and its parent) is enabled
  117170. */
  117171. isEnabled(checkAncestors?: boolean): boolean;
  117172. /** @hidden */
  117173. protected _syncParentEnabledState(): void;
  117174. /**
  117175. * Set the enabled state of this node
  117176. * @param value defines the new enabled state
  117177. */
  117178. setEnabled(value: boolean): void;
  117179. /**
  117180. * Is this node a descendant of the given node?
  117181. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117182. * @param ancestor defines the parent node to inspect
  117183. * @returns a boolean indicating if this node is a descendant of the given node
  117184. */
  117185. isDescendantOf(ancestor: Node): boolean;
  117186. /** @hidden */
  117187. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117188. /**
  117189. * Will return all nodes that have this node as ascendant
  117190. * @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
  117191. * @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
  117192. * @return all children nodes of all types
  117193. */
  117194. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117195. /**
  117196. * Get all child-meshes of this node
  117197. * @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)
  117198. * @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
  117199. * @returns an array of AbstractMesh
  117200. */
  117201. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117202. /**
  117203. * Get all direct children of this node
  117204. * @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
  117205. * @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)
  117206. * @returns an array of Node
  117207. */
  117208. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117209. /** @hidden */
  117210. _setReady(state: boolean): void;
  117211. /**
  117212. * Get an animation by name
  117213. * @param name defines the name of the animation to look for
  117214. * @returns null if not found else the requested animation
  117215. */
  117216. getAnimationByName(name: string): Nullable<Animation>;
  117217. /**
  117218. * Creates an animation range for this node
  117219. * @param name defines the name of the range
  117220. * @param from defines the starting key
  117221. * @param to defines the end key
  117222. */
  117223. createAnimationRange(name: string, from: number, to: number): void;
  117224. /**
  117225. * Delete a specific animation range
  117226. * @param name defines the name of the range to delete
  117227. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117228. */
  117229. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117230. /**
  117231. * Get an animation range by name
  117232. * @param name defines the name of the animation range to look for
  117233. * @returns null if not found else the requested animation range
  117234. */
  117235. getAnimationRange(name: string): Nullable<AnimationRange>;
  117236. /**
  117237. * Gets the list of all animation ranges defined on this node
  117238. * @returns an array
  117239. */
  117240. getAnimationRanges(): Nullable<AnimationRange>[];
  117241. /**
  117242. * Will start the animation sequence
  117243. * @param name defines the range frames for animation sequence
  117244. * @param loop defines if the animation should loop (false by default)
  117245. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117246. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117247. * @returns the object created for this animation. If range does not exist, it will return null
  117248. */
  117249. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117250. /**
  117251. * Serialize animation ranges into a JSON compatible object
  117252. * @returns serialization object
  117253. */
  117254. serializeAnimationRanges(): any;
  117255. /**
  117256. * Computes the world matrix of the node
  117257. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117258. * @returns the world matrix
  117259. */
  117260. computeWorldMatrix(force?: boolean): Matrix;
  117261. /**
  117262. * Releases resources associated with this node.
  117263. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117264. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117265. */
  117266. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117267. /**
  117268. * Parse animation range data from a serialization object and store them into a given node
  117269. * @param node defines where to store the animation ranges
  117270. * @param parsedNode defines the serialization object to read data from
  117271. * @param scene defines the hosting scene
  117272. */
  117273. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117274. /**
  117275. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117276. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117277. * @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
  117278. * @returns the new bounding vectors
  117279. */
  117280. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117281. min: Vector3;
  117282. max: Vector3;
  117283. };
  117284. }
  117285. }
  117286. declare module BABYLON {
  117287. /**
  117288. * @hidden
  117289. */
  117290. export class _IAnimationState {
  117291. key: number;
  117292. repeatCount: number;
  117293. workValue?: any;
  117294. loopMode?: number;
  117295. offsetValue?: any;
  117296. highLimitValue?: any;
  117297. }
  117298. /**
  117299. * Class used to store any kind of animation
  117300. */
  117301. export class Animation {
  117302. /**Name of the animation */
  117303. name: string;
  117304. /**Property to animate */
  117305. targetProperty: string;
  117306. /**The frames per second of the animation */
  117307. framePerSecond: number;
  117308. /**The data type of the animation */
  117309. dataType: number;
  117310. /**The loop mode of the animation */
  117311. loopMode?: number | undefined;
  117312. /**Specifies if blending should be enabled */
  117313. enableBlending?: boolean | undefined;
  117314. /**
  117315. * Use matrix interpolation instead of using direct key value when animating matrices
  117316. */
  117317. static AllowMatricesInterpolation: boolean;
  117318. /**
  117319. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117320. */
  117321. static AllowMatrixDecomposeForInterpolation: boolean;
  117322. /** Define the Url to load snippets */
  117323. static SnippetUrl: string;
  117324. /** Snippet ID if the animation was created from the snippet server */
  117325. snippetId: string;
  117326. /**
  117327. * Stores the key frames of the animation
  117328. */
  117329. private _keys;
  117330. /**
  117331. * Stores the easing function of the animation
  117332. */
  117333. private _easingFunction;
  117334. /**
  117335. * @hidden Internal use only
  117336. */
  117337. _runtimeAnimations: RuntimeAnimation[];
  117338. /**
  117339. * The set of event that will be linked to this animation
  117340. */
  117341. private _events;
  117342. /**
  117343. * Stores an array of target property paths
  117344. */
  117345. targetPropertyPath: string[];
  117346. /**
  117347. * Stores the blending speed of the animation
  117348. */
  117349. blendingSpeed: number;
  117350. /**
  117351. * Stores the animation ranges for the animation
  117352. */
  117353. private _ranges;
  117354. /**
  117355. * @hidden Internal use
  117356. */
  117357. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117358. /**
  117359. * Sets up an animation
  117360. * @param property The property to animate
  117361. * @param animationType The animation type to apply
  117362. * @param framePerSecond The frames per second of the animation
  117363. * @param easingFunction The easing function used in the animation
  117364. * @returns The created animation
  117365. */
  117366. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117367. /**
  117368. * Create and start an animation on a node
  117369. * @param name defines the name of the global animation that will be run on all nodes
  117370. * @param node defines the root node where the animation will take place
  117371. * @param targetProperty defines property to animate
  117372. * @param framePerSecond defines the number of frame per second yo use
  117373. * @param totalFrame defines the number of frames in total
  117374. * @param from defines the initial value
  117375. * @param to defines the final value
  117376. * @param loopMode defines which loop mode you want to use (off by default)
  117377. * @param easingFunction defines the easing function to use (linear by default)
  117378. * @param onAnimationEnd defines the callback to call when animation end
  117379. * @returns the animatable created for this animation
  117380. */
  117381. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117382. /**
  117383. * Create and start an animation on a node and its descendants
  117384. * @param name defines the name of the global animation that will be run on all nodes
  117385. * @param node defines the root node where the animation will take place
  117386. * @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
  117387. * @param targetProperty defines property to animate
  117388. * @param framePerSecond defines the number of frame per second to use
  117389. * @param totalFrame defines the number of frames in total
  117390. * @param from defines the initial value
  117391. * @param to defines the final value
  117392. * @param loopMode defines which loop mode you want to use (off by default)
  117393. * @param easingFunction defines the easing function to use (linear by default)
  117394. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  117395. * @returns the list of animatables created for all nodes
  117396. * @example https://www.babylonjs-playground.com/#MH0VLI
  117397. */
  117398. 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[]>;
  117399. /**
  117400. * Creates a new animation, merges it with the existing animations and starts it
  117401. * @param name Name of the animation
  117402. * @param node Node which contains the scene that begins the animations
  117403. * @param targetProperty Specifies which property to animate
  117404. * @param framePerSecond The frames per second of the animation
  117405. * @param totalFrame The total number of frames
  117406. * @param from The frame at the beginning of the animation
  117407. * @param to The frame at the end of the animation
  117408. * @param loopMode Specifies the loop mode of the animation
  117409. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  117410. * @param onAnimationEnd Callback to run once the animation is complete
  117411. * @returns Nullable animation
  117412. */
  117413. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117414. /**
  117415. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117416. * @param sourceAnimation defines the Animation containing keyframes to convert
  117417. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117418. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  117419. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  117420. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  117421. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  117422. */
  117423. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  117424. /**
  117425. * Transition property of an host to the target Value
  117426. * @param property The property to transition
  117427. * @param targetValue The target Value of the property
  117428. * @param host The object where the property to animate belongs
  117429. * @param scene Scene used to run the animation
  117430. * @param frameRate Framerate (in frame/s) to use
  117431. * @param transition The transition type we want to use
  117432. * @param duration The duration of the animation, in milliseconds
  117433. * @param onAnimationEnd Callback trigger at the end of the animation
  117434. * @returns Nullable animation
  117435. */
  117436. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  117437. /**
  117438. * Return the array of runtime animations currently using this animation
  117439. */
  117440. get runtimeAnimations(): RuntimeAnimation[];
  117441. /**
  117442. * Specifies if any of the runtime animations are currently running
  117443. */
  117444. get hasRunningRuntimeAnimations(): boolean;
  117445. /**
  117446. * Initializes the animation
  117447. * @param name Name of the animation
  117448. * @param targetProperty Property to animate
  117449. * @param framePerSecond The frames per second of the animation
  117450. * @param dataType The data type of the animation
  117451. * @param loopMode The loop mode of the animation
  117452. * @param enableBlending Specifies if blending should be enabled
  117453. */
  117454. constructor(
  117455. /**Name of the animation */
  117456. name: string,
  117457. /**Property to animate */
  117458. targetProperty: string,
  117459. /**The frames per second of the animation */
  117460. framePerSecond: number,
  117461. /**The data type of the animation */
  117462. dataType: number,
  117463. /**The loop mode of the animation */
  117464. loopMode?: number | undefined,
  117465. /**Specifies if blending should be enabled */
  117466. enableBlending?: boolean | undefined);
  117467. /**
  117468. * Converts the animation to a string
  117469. * @param fullDetails support for multiple levels of logging within scene loading
  117470. * @returns String form of the animation
  117471. */
  117472. toString(fullDetails?: boolean): string;
  117473. /**
  117474. * Add an event to this animation
  117475. * @param event Event to add
  117476. */
  117477. addEvent(event: AnimationEvent): void;
  117478. /**
  117479. * Remove all events found at the given frame
  117480. * @param frame The frame to remove events from
  117481. */
  117482. removeEvents(frame: number): void;
  117483. /**
  117484. * Retrieves all the events from the animation
  117485. * @returns Events from the animation
  117486. */
  117487. getEvents(): AnimationEvent[];
  117488. /**
  117489. * Creates an animation range
  117490. * @param name Name of the animation range
  117491. * @param from Starting frame of the animation range
  117492. * @param to Ending frame of the animation
  117493. */
  117494. createRange(name: string, from: number, to: number): void;
  117495. /**
  117496. * Deletes an animation range by name
  117497. * @param name Name of the animation range to delete
  117498. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  117499. */
  117500. deleteRange(name: string, deleteFrames?: boolean): void;
  117501. /**
  117502. * Gets the animation range by name, or null if not defined
  117503. * @param name Name of the animation range
  117504. * @returns Nullable animation range
  117505. */
  117506. getRange(name: string): Nullable<AnimationRange>;
  117507. /**
  117508. * Gets the key frames from the animation
  117509. * @returns The key frames of the animation
  117510. */
  117511. getKeys(): Array<IAnimationKey>;
  117512. /**
  117513. * Gets the highest frame rate of the animation
  117514. * @returns Highest frame rate of the animation
  117515. */
  117516. getHighestFrame(): number;
  117517. /**
  117518. * Gets the easing function of the animation
  117519. * @returns Easing function of the animation
  117520. */
  117521. getEasingFunction(): IEasingFunction;
  117522. /**
  117523. * Sets the easing function of the animation
  117524. * @param easingFunction A custom mathematical formula for animation
  117525. */
  117526. setEasingFunction(easingFunction: EasingFunction): void;
  117527. /**
  117528. * Interpolates a scalar linearly
  117529. * @param startValue Start value of the animation curve
  117530. * @param endValue End value of the animation curve
  117531. * @param gradient Scalar amount to interpolate
  117532. * @returns Interpolated scalar value
  117533. */
  117534. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  117535. /**
  117536. * Interpolates a scalar cubically
  117537. * @param startValue Start value of the animation curve
  117538. * @param outTangent End tangent of the animation
  117539. * @param endValue End value of the animation curve
  117540. * @param inTangent Start tangent of the animation curve
  117541. * @param gradient Scalar amount to interpolate
  117542. * @returns Interpolated scalar value
  117543. */
  117544. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  117545. /**
  117546. * Interpolates a quaternion using a spherical linear interpolation
  117547. * @param startValue Start value of the animation curve
  117548. * @param endValue End value of the animation curve
  117549. * @param gradient Scalar amount to interpolate
  117550. * @returns Interpolated quaternion value
  117551. */
  117552. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  117553. /**
  117554. * Interpolates a quaternion cubically
  117555. * @param startValue Start value of the animation curve
  117556. * @param outTangent End tangent of the animation curve
  117557. * @param endValue End value of the animation curve
  117558. * @param inTangent Start tangent of the animation curve
  117559. * @param gradient Scalar amount to interpolate
  117560. * @returns Interpolated quaternion value
  117561. */
  117562. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  117563. /**
  117564. * Interpolates a Vector3 linearl
  117565. * @param startValue Start value of the animation curve
  117566. * @param endValue End value of the animation curve
  117567. * @param gradient Scalar amount to interpolate
  117568. * @returns Interpolated scalar value
  117569. */
  117570. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  117571. /**
  117572. * Interpolates a Vector3 cubically
  117573. * @param startValue Start value of the animation curve
  117574. * @param outTangent End tangent of the animation
  117575. * @param endValue End value of the animation curve
  117576. * @param inTangent Start tangent of the animation curve
  117577. * @param gradient Scalar amount to interpolate
  117578. * @returns InterpolatedVector3 value
  117579. */
  117580. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  117581. /**
  117582. * Interpolates a Vector2 linearly
  117583. * @param startValue Start value of the animation curve
  117584. * @param endValue End value of the animation curve
  117585. * @param gradient Scalar amount to interpolate
  117586. * @returns Interpolated Vector2 value
  117587. */
  117588. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  117589. /**
  117590. * Interpolates a Vector2 cubically
  117591. * @param startValue Start value of the animation curve
  117592. * @param outTangent End tangent of the animation
  117593. * @param endValue End value of the animation curve
  117594. * @param inTangent Start tangent of the animation curve
  117595. * @param gradient Scalar amount to interpolate
  117596. * @returns Interpolated Vector2 value
  117597. */
  117598. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  117599. /**
  117600. * Interpolates a size linearly
  117601. * @param startValue Start value of the animation curve
  117602. * @param endValue End value of the animation curve
  117603. * @param gradient Scalar amount to interpolate
  117604. * @returns Interpolated Size value
  117605. */
  117606. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  117607. /**
  117608. * Interpolates a Color3 linearly
  117609. * @param startValue Start value of the animation curve
  117610. * @param endValue End value of the animation curve
  117611. * @param gradient Scalar amount to interpolate
  117612. * @returns Interpolated Color3 value
  117613. */
  117614. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  117615. /**
  117616. * Interpolates a Color4 linearly
  117617. * @param startValue Start value of the animation curve
  117618. * @param endValue End value of the animation curve
  117619. * @param gradient Scalar amount to interpolate
  117620. * @returns Interpolated Color3 value
  117621. */
  117622. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  117623. /**
  117624. * @hidden Internal use only
  117625. */
  117626. _getKeyValue(value: any): any;
  117627. /**
  117628. * @hidden Internal use only
  117629. */
  117630. _interpolate(currentFrame: number, state: _IAnimationState): any;
  117631. /**
  117632. * Defines the function to use to interpolate matrices
  117633. * @param startValue defines the start matrix
  117634. * @param endValue defines the end matrix
  117635. * @param gradient defines the gradient between both matrices
  117636. * @param result defines an optional target matrix where to store the interpolation
  117637. * @returns the interpolated matrix
  117638. */
  117639. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  117640. /**
  117641. * Makes a copy of the animation
  117642. * @returns Cloned animation
  117643. */
  117644. clone(): Animation;
  117645. /**
  117646. * Sets the key frames of the animation
  117647. * @param values The animation key frames to set
  117648. */
  117649. setKeys(values: Array<IAnimationKey>): void;
  117650. /**
  117651. * Serializes the animation to an object
  117652. * @returns Serialized object
  117653. */
  117654. serialize(): any;
  117655. /**
  117656. * Float animation type
  117657. */
  117658. static readonly ANIMATIONTYPE_FLOAT: number;
  117659. /**
  117660. * Vector3 animation type
  117661. */
  117662. static readonly ANIMATIONTYPE_VECTOR3: number;
  117663. /**
  117664. * Quaternion animation type
  117665. */
  117666. static readonly ANIMATIONTYPE_QUATERNION: number;
  117667. /**
  117668. * Matrix animation type
  117669. */
  117670. static readonly ANIMATIONTYPE_MATRIX: number;
  117671. /**
  117672. * Color3 animation type
  117673. */
  117674. static readonly ANIMATIONTYPE_COLOR3: number;
  117675. /**
  117676. * Color3 animation type
  117677. */
  117678. static readonly ANIMATIONTYPE_COLOR4: number;
  117679. /**
  117680. * Vector2 animation type
  117681. */
  117682. static readonly ANIMATIONTYPE_VECTOR2: number;
  117683. /**
  117684. * Size animation type
  117685. */
  117686. static readonly ANIMATIONTYPE_SIZE: number;
  117687. /**
  117688. * Relative Loop Mode
  117689. */
  117690. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  117691. /**
  117692. * Cycle Loop Mode
  117693. */
  117694. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  117695. /**
  117696. * Constant Loop Mode
  117697. */
  117698. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  117699. /** @hidden */
  117700. static _UniversalLerp(left: any, right: any, amount: number): any;
  117701. /**
  117702. * Parses an animation object and creates an animation
  117703. * @param parsedAnimation Parsed animation object
  117704. * @returns Animation object
  117705. */
  117706. static Parse(parsedAnimation: any): Animation;
  117707. /**
  117708. * Appends the serialized animations from the source animations
  117709. * @param source Source containing the animations
  117710. * @param destination Target to store the animations
  117711. */
  117712. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117713. /**
  117714. * Creates a new animation or an array of animations from a snippet saved in a remote file
  117715. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  117716. * @param url defines the url to load from
  117717. * @returns a promise that will resolve to the new animation or an array of animations
  117718. */
  117719. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  117720. /**
  117721. * Creates an animation or an array of animations from a snippet saved by the Inspector
  117722. * @param snippetId defines the snippet to load
  117723. * @returns a promise that will resolve to the new animation or a new array of animations
  117724. */
  117725. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  117726. }
  117727. }
  117728. declare module BABYLON {
  117729. /**
  117730. * Interface containing an array of animations
  117731. */
  117732. export interface IAnimatable {
  117733. /**
  117734. * Array of animations
  117735. */
  117736. animations: Nullable<Array<Animation>>;
  117737. }
  117738. }
  117739. declare module BABYLON {
  117740. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  117741. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117742. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117743. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117744. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117745. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117746. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117747. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117748. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117749. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117750. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117751. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117752. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117753. /**
  117754. * Decorator used to define property that can be serialized as reference to a camera
  117755. * @param sourceName defines the name of the property to decorate
  117756. */
  117757. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117758. /**
  117759. * Class used to help serialization objects
  117760. */
  117761. export class SerializationHelper {
  117762. /** @hidden */
  117763. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  117764. /** @hidden */
  117765. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  117766. /** @hidden */
  117767. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  117768. /** @hidden */
  117769. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  117770. /**
  117771. * Appends the serialized animations from the source animations
  117772. * @param source Source containing the animations
  117773. * @param destination Target to store the animations
  117774. */
  117775. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117776. /**
  117777. * Static function used to serialized a specific entity
  117778. * @param entity defines the entity to serialize
  117779. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  117780. * @returns a JSON compatible object representing the serialization of the entity
  117781. */
  117782. static Serialize<T>(entity: T, serializationObject?: any): any;
  117783. /**
  117784. * Creates a new entity from a serialization data object
  117785. * @param creationFunction defines a function used to instanciated the new entity
  117786. * @param source defines the source serialization data
  117787. * @param scene defines the hosting scene
  117788. * @param rootUrl defines the root url for resources
  117789. * @returns a new entity
  117790. */
  117791. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  117792. /**
  117793. * Clones an object
  117794. * @param creationFunction defines the function used to instanciate the new object
  117795. * @param source defines the source object
  117796. * @returns the cloned object
  117797. */
  117798. static Clone<T>(creationFunction: () => T, source: T): T;
  117799. /**
  117800. * Instanciates a new object based on a source one (some data will be shared between both object)
  117801. * @param creationFunction defines the function used to instanciate the new object
  117802. * @param source defines the source object
  117803. * @returns the new object
  117804. */
  117805. static Instanciate<T>(creationFunction: () => T, source: T): T;
  117806. }
  117807. }
  117808. declare module BABYLON {
  117809. /**
  117810. * Base class of all the textures in babylon.
  117811. * It groups all the common properties the materials, post process, lights... might need
  117812. * in order to make a correct use of the texture.
  117813. */
  117814. export class BaseTexture implements IAnimatable {
  117815. /**
  117816. * Default anisotropic filtering level for the application.
  117817. * It is set to 4 as a good tradeoff between perf and quality.
  117818. */
  117819. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  117820. /**
  117821. * Gets or sets the unique id of the texture
  117822. */
  117823. uniqueId: number;
  117824. /**
  117825. * Define the name of the texture.
  117826. */
  117827. name: string;
  117828. /**
  117829. * Gets or sets an object used to store user defined information.
  117830. */
  117831. metadata: any;
  117832. /**
  117833. * For internal use only. Please do not use.
  117834. */
  117835. reservedDataStore: any;
  117836. private _hasAlpha;
  117837. /**
  117838. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  117839. */
  117840. set hasAlpha(value: boolean);
  117841. get hasAlpha(): boolean;
  117842. /**
  117843. * Defines if the alpha value should be determined via the rgb values.
  117844. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  117845. */
  117846. getAlphaFromRGB: boolean;
  117847. /**
  117848. * Intensity or strength of the texture.
  117849. * It is commonly used by materials to fine tune the intensity of the texture
  117850. */
  117851. level: number;
  117852. /**
  117853. * Define the UV chanel to use starting from 0 and defaulting to 0.
  117854. * This is part of the texture as textures usually maps to one uv set.
  117855. */
  117856. coordinatesIndex: number;
  117857. protected _coordinatesMode: number;
  117858. /**
  117859. * How a texture is mapped.
  117860. *
  117861. * | Value | Type | Description |
  117862. * | ----- | ----------------------------------- | ----------- |
  117863. * | 0 | EXPLICIT_MODE | |
  117864. * | 1 | SPHERICAL_MODE | |
  117865. * | 2 | PLANAR_MODE | |
  117866. * | 3 | CUBIC_MODE | |
  117867. * | 4 | PROJECTION_MODE | |
  117868. * | 5 | SKYBOX_MODE | |
  117869. * | 6 | INVCUBIC_MODE | |
  117870. * | 7 | EQUIRECTANGULAR_MODE | |
  117871. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  117872. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  117873. */
  117874. set coordinatesMode(value: number);
  117875. get coordinatesMode(): number;
  117876. private _wrapU;
  117877. /**
  117878. * | Value | Type | Description |
  117879. * | ----- | ------------------ | ----------- |
  117880. * | 0 | CLAMP_ADDRESSMODE | |
  117881. * | 1 | WRAP_ADDRESSMODE | |
  117882. * | 2 | MIRROR_ADDRESSMODE | |
  117883. */
  117884. get wrapU(): number;
  117885. set wrapU(value: number);
  117886. private _wrapV;
  117887. /**
  117888. * | Value | Type | Description |
  117889. * | ----- | ------------------ | ----------- |
  117890. * | 0 | CLAMP_ADDRESSMODE | |
  117891. * | 1 | WRAP_ADDRESSMODE | |
  117892. * | 2 | MIRROR_ADDRESSMODE | |
  117893. */
  117894. get wrapV(): number;
  117895. set wrapV(value: number);
  117896. /**
  117897. * | Value | Type | Description |
  117898. * | ----- | ------------------ | ----------- |
  117899. * | 0 | CLAMP_ADDRESSMODE | |
  117900. * | 1 | WRAP_ADDRESSMODE | |
  117901. * | 2 | MIRROR_ADDRESSMODE | |
  117902. */
  117903. wrapR: number;
  117904. /**
  117905. * With compliant hardware and browser (supporting anisotropic filtering)
  117906. * this defines the level of anisotropic filtering in the texture.
  117907. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  117908. */
  117909. anisotropicFilteringLevel: number;
  117910. /**
  117911. * Define if the texture is a cube texture or if false a 2d texture.
  117912. */
  117913. get isCube(): boolean;
  117914. set isCube(value: boolean);
  117915. /**
  117916. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  117917. */
  117918. get is3D(): boolean;
  117919. set is3D(value: boolean);
  117920. /**
  117921. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  117922. */
  117923. get is2DArray(): boolean;
  117924. set is2DArray(value: boolean);
  117925. private _gammaSpace;
  117926. /**
  117927. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  117928. * HDR texture are usually stored in linear space.
  117929. * This only impacts the PBR and Background materials
  117930. */
  117931. get gammaSpace(): boolean;
  117932. set gammaSpace(gamma: boolean);
  117933. /**
  117934. * Gets or sets whether or not the texture contains RGBD data.
  117935. */
  117936. get isRGBD(): boolean;
  117937. set isRGBD(value: boolean);
  117938. /**
  117939. * Is Z inverted in the texture (useful in a cube texture).
  117940. */
  117941. invertZ: boolean;
  117942. /**
  117943. * Are mip maps generated for this texture or not.
  117944. */
  117945. get noMipmap(): boolean;
  117946. /**
  117947. * @hidden
  117948. */
  117949. lodLevelInAlpha: boolean;
  117950. /**
  117951. * With prefiltered texture, defined the offset used during the prefiltering steps.
  117952. */
  117953. get lodGenerationOffset(): number;
  117954. set lodGenerationOffset(value: number);
  117955. /**
  117956. * With prefiltered texture, defined the scale used during the prefiltering steps.
  117957. */
  117958. get lodGenerationScale(): number;
  117959. set lodGenerationScale(value: number);
  117960. /**
  117961. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  117962. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  117963. * average roughness values.
  117964. */
  117965. get linearSpecularLOD(): boolean;
  117966. set linearSpecularLOD(value: boolean);
  117967. /**
  117968. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  117969. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  117970. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  117971. */
  117972. get irradianceTexture(): Nullable<BaseTexture>;
  117973. set irradianceTexture(value: Nullable<BaseTexture>);
  117974. /**
  117975. * Define if the texture is a render target.
  117976. */
  117977. isRenderTarget: boolean;
  117978. /**
  117979. * Define the unique id of the texture in the scene.
  117980. */
  117981. get uid(): string;
  117982. /** @hidden */
  117983. _prefiltered: boolean;
  117984. /**
  117985. * Return a string representation of the texture.
  117986. * @returns the texture as a string
  117987. */
  117988. toString(): string;
  117989. /**
  117990. * Get the class name of the texture.
  117991. * @returns "BaseTexture"
  117992. */
  117993. getClassName(): string;
  117994. /**
  117995. * Define the list of animation attached to the texture.
  117996. */
  117997. animations: Animation[];
  117998. /**
  117999. * An event triggered when the texture is disposed.
  118000. */
  118001. onDisposeObservable: Observable<BaseTexture>;
  118002. private _onDisposeObserver;
  118003. /**
  118004. * Callback triggered when the texture has been disposed.
  118005. * Kept for back compatibility, you can use the onDisposeObservable instead.
  118006. */
  118007. set onDispose(callback: () => void);
  118008. /**
  118009. * Define the current state of the loading sequence when in delayed load mode.
  118010. */
  118011. delayLoadState: number;
  118012. protected _scene: Nullable<Scene>;
  118013. protected _engine: Nullable<ThinEngine>;
  118014. /** @hidden */
  118015. _texture: Nullable<InternalTexture>;
  118016. private _uid;
  118017. /**
  118018. * Define if the texture is preventinga material to render or not.
  118019. * If not and the texture is not ready, the engine will use a default black texture instead.
  118020. */
  118021. get isBlocking(): boolean;
  118022. /**
  118023. * Instantiates a new BaseTexture.
  118024. * Base class of all the textures in babylon.
  118025. * It groups all the common properties the materials, post process, lights... might need
  118026. * in order to make a correct use of the texture.
  118027. * @param sceneOrEngine Define the scene or engine the texture blongs to
  118028. */
  118029. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  118030. /**
  118031. * Get the scene the texture belongs to.
  118032. * @returns the scene or null if undefined
  118033. */
  118034. getScene(): Nullable<Scene>;
  118035. /** @hidden */
  118036. protected _getEngine(): Nullable<ThinEngine>;
  118037. /**
  118038. * Checks if the texture has the same transform matrix than another texture
  118039. * @param texture texture to check against
  118040. * @returns true if the transforms are the same, else false
  118041. */
  118042. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  118043. /**
  118044. * Get the texture transform matrix used to offset tile the texture for istance.
  118045. * @returns the transformation matrix
  118046. */
  118047. getTextureMatrix(): Matrix;
  118048. /**
  118049. * Get the texture reflection matrix used to rotate/transform the reflection.
  118050. * @returns the reflection matrix
  118051. */
  118052. getReflectionTextureMatrix(): Matrix;
  118053. /**
  118054. * Get the underlying lower level texture from Babylon.
  118055. * @returns the insternal texture
  118056. */
  118057. getInternalTexture(): Nullable<InternalTexture>;
  118058. /**
  118059. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  118060. * @returns true if ready or not blocking
  118061. */
  118062. isReadyOrNotBlocking(): boolean;
  118063. /**
  118064. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  118065. * @returns true if fully ready
  118066. */
  118067. isReady(): boolean;
  118068. private _cachedSize;
  118069. /**
  118070. * Get the size of the texture.
  118071. * @returns the texture size.
  118072. */
  118073. getSize(): ISize;
  118074. /**
  118075. * Get the base size of the texture.
  118076. * It can be different from the size if the texture has been resized for POT for instance
  118077. * @returns the base size
  118078. */
  118079. getBaseSize(): ISize;
  118080. /**
  118081. * Update the sampling mode of the texture.
  118082. * Default is Trilinear mode.
  118083. *
  118084. * | Value | Type | Description |
  118085. * | ----- | ------------------ | ----------- |
  118086. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  118087. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  118088. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  118089. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  118090. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  118091. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  118092. * | 7 | NEAREST_LINEAR | |
  118093. * | 8 | NEAREST_NEAREST | |
  118094. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  118095. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  118096. * | 11 | LINEAR_LINEAR | |
  118097. * | 12 | LINEAR_NEAREST | |
  118098. *
  118099. * > _mag_: magnification filter (close to the viewer)
  118100. * > _min_: minification filter (far from the viewer)
  118101. * > _mip_: filter used between mip map levels
  118102. *@param samplingMode Define the new sampling mode of the texture
  118103. */
  118104. updateSamplingMode(samplingMode: number): void;
  118105. /**
  118106. * Scales the texture if is `canRescale()`
  118107. * @param ratio the resize factor we want to use to rescale
  118108. */
  118109. scale(ratio: number): void;
  118110. /**
  118111. * Get if the texture can rescale.
  118112. */
  118113. get canRescale(): boolean;
  118114. /** @hidden */
  118115. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  118116. /** @hidden */
  118117. _rebuild(): void;
  118118. /**
  118119. * Triggers the load sequence in delayed load mode.
  118120. */
  118121. delayLoad(): void;
  118122. /**
  118123. * Clones the texture.
  118124. * @returns the cloned texture
  118125. */
  118126. clone(): Nullable<BaseTexture>;
  118127. /**
  118128. * Get the texture underlying type (INT, FLOAT...)
  118129. */
  118130. get textureType(): number;
  118131. /**
  118132. * Get the texture underlying format (RGB, RGBA...)
  118133. */
  118134. get textureFormat(): number;
  118135. /**
  118136. * Indicates that textures need to be re-calculated for all materials
  118137. */
  118138. protected _markAllSubMeshesAsTexturesDirty(): void;
  118139. /**
  118140. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  118141. * This will returns an RGBA array buffer containing either in values (0-255) or
  118142. * float values (0-1) depending of the underlying buffer type.
  118143. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  118144. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  118145. * @param buffer defines a user defined buffer to fill with data (can be null)
  118146. * @returns The Array buffer containing the pixels data.
  118147. */
  118148. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  118149. /**
  118150. * Release and destroy the underlying lower level texture aka internalTexture.
  118151. */
  118152. releaseInternalTexture(): void;
  118153. /** @hidden */
  118154. get _lodTextureHigh(): Nullable<BaseTexture>;
  118155. /** @hidden */
  118156. get _lodTextureMid(): Nullable<BaseTexture>;
  118157. /** @hidden */
  118158. get _lodTextureLow(): Nullable<BaseTexture>;
  118159. /**
  118160. * Dispose the texture and release its associated resources.
  118161. */
  118162. dispose(): void;
  118163. /**
  118164. * Serialize the texture into a JSON representation that can be parsed later on.
  118165. * @returns the JSON representation of the texture
  118166. */
  118167. serialize(): any;
  118168. /**
  118169. * Helper function to be called back once a list of texture contains only ready textures.
  118170. * @param textures Define the list of textures to wait for
  118171. * @param callback Define the callback triggered once the entire list will be ready
  118172. */
  118173. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  118174. private static _isScene;
  118175. }
  118176. }
  118177. declare module BABYLON {
  118178. /**
  118179. * Options to be used when creating an effect.
  118180. */
  118181. export interface IEffectCreationOptions {
  118182. /**
  118183. * Atrributes that will be used in the shader.
  118184. */
  118185. attributes: string[];
  118186. /**
  118187. * Uniform varible names that will be set in the shader.
  118188. */
  118189. uniformsNames: string[];
  118190. /**
  118191. * Uniform buffer variable names that will be set in the shader.
  118192. */
  118193. uniformBuffersNames: string[];
  118194. /**
  118195. * Sampler texture variable names that will be set in the shader.
  118196. */
  118197. samplers: string[];
  118198. /**
  118199. * Define statements that will be set in the shader.
  118200. */
  118201. defines: any;
  118202. /**
  118203. * Possible fallbacks for this effect to improve performance when needed.
  118204. */
  118205. fallbacks: Nullable<IEffectFallbacks>;
  118206. /**
  118207. * Callback that will be called when the shader is compiled.
  118208. */
  118209. onCompiled: Nullable<(effect: Effect) => void>;
  118210. /**
  118211. * Callback that will be called if an error occurs during shader compilation.
  118212. */
  118213. onError: Nullable<(effect: Effect, errors: string) => void>;
  118214. /**
  118215. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118216. */
  118217. indexParameters?: any;
  118218. /**
  118219. * Max number of lights that can be used in the shader.
  118220. */
  118221. maxSimultaneousLights?: number;
  118222. /**
  118223. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  118224. */
  118225. transformFeedbackVaryings?: Nullable<string[]>;
  118226. /**
  118227. * 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
  118228. */
  118229. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  118230. /**
  118231. * Is this effect rendering to several color attachments ?
  118232. */
  118233. multiTarget?: boolean;
  118234. }
  118235. /**
  118236. * Effect containing vertex and fragment shader that can be executed on an object.
  118237. */
  118238. export class Effect implements IDisposable {
  118239. /**
  118240. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  118241. */
  118242. static ShadersRepository: string;
  118243. /**
  118244. * Enable logging of the shader code when a compilation error occurs
  118245. */
  118246. static LogShaderCodeOnCompilationError: boolean;
  118247. /**
  118248. * Name of the effect.
  118249. */
  118250. name: any;
  118251. /**
  118252. * String container all the define statements that should be set on the shader.
  118253. */
  118254. defines: string;
  118255. /**
  118256. * Callback that will be called when the shader is compiled.
  118257. */
  118258. onCompiled: Nullable<(effect: Effect) => void>;
  118259. /**
  118260. * Callback that will be called if an error occurs during shader compilation.
  118261. */
  118262. onError: Nullable<(effect: Effect, errors: string) => void>;
  118263. /**
  118264. * Callback that will be called when effect is bound.
  118265. */
  118266. onBind: Nullable<(effect: Effect) => void>;
  118267. /**
  118268. * Unique ID of the effect.
  118269. */
  118270. uniqueId: number;
  118271. /**
  118272. * Observable that will be called when the shader is compiled.
  118273. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118274. */
  118275. onCompileObservable: Observable<Effect>;
  118276. /**
  118277. * Observable that will be called if an error occurs during shader compilation.
  118278. */
  118279. onErrorObservable: Observable<Effect>;
  118280. /** @hidden */
  118281. _onBindObservable: Nullable<Observable<Effect>>;
  118282. /**
  118283. * @hidden
  118284. * Specifies if the effect was previously ready
  118285. */
  118286. _wasPreviouslyReady: boolean;
  118287. /**
  118288. * Observable that will be called when effect is bound.
  118289. */
  118290. get onBindObservable(): Observable<Effect>;
  118291. /** @hidden */
  118292. _bonesComputationForcedToCPU: boolean;
  118293. /** @hidden */
  118294. _multiTarget: boolean;
  118295. private static _uniqueIdSeed;
  118296. private _engine;
  118297. private _uniformBuffersNames;
  118298. private _uniformBuffersNamesList;
  118299. private _uniformsNames;
  118300. private _samplerList;
  118301. private _samplers;
  118302. private _isReady;
  118303. private _compilationError;
  118304. private _allFallbacksProcessed;
  118305. private _attributesNames;
  118306. private _attributes;
  118307. private _attributeLocationByName;
  118308. private _uniforms;
  118309. /**
  118310. * Key for the effect.
  118311. * @hidden
  118312. */
  118313. _key: string;
  118314. private _indexParameters;
  118315. private _fallbacks;
  118316. private _vertexSourceCode;
  118317. private _fragmentSourceCode;
  118318. private _vertexSourceCodeOverride;
  118319. private _fragmentSourceCodeOverride;
  118320. private _transformFeedbackVaryings;
  118321. /**
  118322. * Compiled shader to webGL program.
  118323. * @hidden
  118324. */
  118325. _pipelineContext: Nullable<IPipelineContext>;
  118326. private _valueCache;
  118327. private static _baseCache;
  118328. /**
  118329. * Instantiates an effect.
  118330. * An effect can be used to create/manage/execute vertex and fragment shaders.
  118331. * @param baseName Name of the effect.
  118332. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  118333. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  118334. * @param samplers List of sampler variables that will be passed to the shader.
  118335. * @param engine Engine to be used to render the effect
  118336. * @param defines Define statements to be added to the shader.
  118337. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  118338. * @param onCompiled Callback that will be called when the shader is compiled.
  118339. * @param onError Callback that will be called if an error occurs during shader compilation.
  118340. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118341. */
  118342. 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);
  118343. private _useFinalCode;
  118344. /**
  118345. * Unique key for this effect
  118346. */
  118347. get key(): string;
  118348. /**
  118349. * If the effect has been compiled and prepared.
  118350. * @returns if the effect is compiled and prepared.
  118351. */
  118352. isReady(): boolean;
  118353. private _isReadyInternal;
  118354. /**
  118355. * The engine the effect was initialized with.
  118356. * @returns the engine.
  118357. */
  118358. getEngine(): Engine;
  118359. /**
  118360. * The pipeline context for this effect
  118361. * @returns the associated pipeline context
  118362. */
  118363. getPipelineContext(): Nullable<IPipelineContext>;
  118364. /**
  118365. * The set of names of attribute variables for the shader.
  118366. * @returns An array of attribute names.
  118367. */
  118368. getAttributesNames(): string[];
  118369. /**
  118370. * Returns the attribute at the given index.
  118371. * @param index The index of the attribute.
  118372. * @returns The location of the attribute.
  118373. */
  118374. getAttributeLocation(index: number): number;
  118375. /**
  118376. * Returns the attribute based on the name of the variable.
  118377. * @param name of the attribute to look up.
  118378. * @returns the attribute location.
  118379. */
  118380. getAttributeLocationByName(name: string): number;
  118381. /**
  118382. * The number of attributes.
  118383. * @returns the numnber of attributes.
  118384. */
  118385. getAttributesCount(): number;
  118386. /**
  118387. * Gets the index of a uniform variable.
  118388. * @param uniformName of the uniform to look up.
  118389. * @returns the index.
  118390. */
  118391. getUniformIndex(uniformName: string): number;
  118392. /**
  118393. * Returns the attribute based on the name of the variable.
  118394. * @param uniformName of the uniform to look up.
  118395. * @returns the location of the uniform.
  118396. */
  118397. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  118398. /**
  118399. * Returns an array of sampler variable names
  118400. * @returns The array of sampler variable names.
  118401. */
  118402. getSamplers(): string[];
  118403. /**
  118404. * Returns an array of uniform variable names
  118405. * @returns The array of uniform variable names.
  118406. */
  118407. getUniformNames(): string[];
  118408. /**
  118409. * Returns an array of uniform buffer variable names
  118410. * @returns The array of uniform buffer variable names.
  118411. */
  118412. getUniformBuffersNames(): string[];
  118413. /**
  118414. * Returns the index parameters used to create the effect
  118415. * @returns The index parameters object
  118416. */
  118417. getIndexParameters(): any;
  118418. /**
  118419. * The error from the last compilation.
  118420. * @returns the error string.
  118421. */
  118422. getCompilationError(): string;
  118423. /**
  118424. * Gets a boolean indicating that all fallbacks were used during compilation
  118425. * @returns true if all fallbacks were used
  118426. */
  118427. allFallbacksProcessed(): boolean;
  118428. /**
  118429. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  118430. * @param func The callback to be used.
  118431. */
  118432. executeWhenCompiled(func: (effect: Effect) => void): void;
  118433. private _checkIsReady;
  118434. private _loadShader;
  118435. /**
  118436. * Gets the vertex shader source code of this effect
  118437. */
  118438. get vertexSourceCode(): string;
  118439. /**
  118440. * Gets the fragment shader source code of this effect
  118441. */
  118442. get fragmentSourceCode(): string;
  118443. /**
  118444. * Recompiles the webGL program
  118445. * @param vertexSourceCode The source code for the vertex shader.
  118446. * @param fragmentSourceCode The source code for the fragment shader.
  118447. * @param onCompiled Callback called when completed.
  118448. * @param onError Callback called on error.
  118449. * @hidden
  118450. */
  118451. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  118452. /**
  118453. * Prepares the effect
  118454. * @hidden
  118455. */
  118456. _prepareEffect(): void;
  118457. private _getShaderCodeAndErrorLine;
  118458. private _processCompilationErrors;
  118459. /**
  118460. * Checks if the effect is supported. (Must be called after compilation)
  118461. */
  118462. get isSupported(): boolean;
  118463. /**
  118464. * Binds a texture to the engine to be used as output of the shader.
  118465. * @param channel Name of the output variable.
  118466. * @param texture Texture to bind.
  118467. * @hidden
  118468. */
  118469. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  118470. /**
  118471. * Sets a texture on the engine to be used in the shader.
  118472. * @param channel Name of the sampler variable.
  118473. * @param texture Texture to set.
  118474. */
  118475. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  118476. /**
  118477. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  118478. * @param channel Name of the sampler variable.
  118479. * @param texture Texture to set.
  118480. */
  118481. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  118482. /**
  118483. * Sets an array of textures on the engine to be used in the shader.
  118484. * @param channel Name of the variable.
  118485. * @param textures Textures to set.
  118486. */
  118487. setTextureArray(channel: string, textures: BaseTexture[]): void;
  118488. /**
  118489. * 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)
  118490. * @param channel Name of the sampler variable.
  118491. * @param postProcess Post process to get the input texture from.
  118492. */
  118493. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  118494. /**
  118495. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  118496. * 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)
  118497. * @param channel Name of the sampler variable.
  118498. * @param postProcess Post process to get the output texture from.
  118499. */
  118500. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  118501. /** @hidden */
  118502. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  118503. /** @hidden */
  118504. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  118505. /** @hidden */
  118506. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  118507. /** @hidden */
  118508. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  118509. /**
  118510. * Binds a buffer to a uniform.
  118511. * @param buffer Buffer to bind.
  118512. * @param name Name of the uniform variable to bind to.
  118513. */
  118514. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  118515. /**
  118516. * Binds block to a uniform.
  118517. * @param blockName Name of the block to bind.
  118518. * @param index Index to bind.
  118519. */
  118520. bindUniformBlock(blockName: string, index: number): void;
  118521. /**
  118522. * Sets an interger value on a uniform variable.
  118523. * @param uniformName Name of the variable.
  118524. * @param value Value to be set.
  118525. * @returns this effect.
  118526. */
  118527. setInt(uniformName: string, value: number): Effect;
  118528. /**
  118529. * Sets an int array on a uniform variable.
  118530. * @param uniformName Name of the variable.
  118531. * @param array array to be set.
  118532. * @returns this effect.
  118533. */
  118534. setIntArray(uniformName: string, array: Int32Array): Effect;
  118535. /**
  118536. * 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)
  118537. * @param uniformName Name of the variable.
  118538. * @param array array to be set.
  118539. * @returns this effect.
  118540. */
  118541. setIntArray2(uniformName: string, array: Int32Array): Effect;
  118542. /**
  118543. * 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)
  118544. * @param uniformName Name of the variable.
  118545. * @param array array to be set.
  118546. * @returns this effect.
  118547. */
  118548. setIntArray3(uniformName: string, array: Int32Array): Effect;
  118549. /**
  118550. * 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)
  118551. * @param uniformName Name of the variable.
  118552. * @param array array to be set.
  118553. * @returns this effect.
  118554. */
  118555. setIntArray4(uniformName: string, array: Int32Array): Effect;
  118556. /**
  118557. * Sets an float array on a uniform variable.
  118558. * @param uniformName Name of the variable.
  118559. * @param array array to be set.
  118560. * @returns this effect.
  118561. */
  118562. setFloatArray(uniformName: string, array: Float32Array): Effect;
  118563. /**
  118564. * 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)
  118565. * @param uniformName Name of the variable.
  118566. * @param array array to be set.
  118567. * @returns this effect.
  118568. */
  118569. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  118570. /**
  118571. * 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)
  118572. * @param uniformName Name of the variable.
  118573. * @param array array to be set.
  118574. * @returns this effect.
  118575. */
  118576. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  118577. /**
  118578. * 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)
  118579. * @param uniformName Name of the variable.
  118580. * @param array array to be set.
  118581. * @returns this effect.
  118582. */
  118583. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  118584. /**
  118585. * Sets an array on a uniform variable.
  118586. * @param uniformName Name of the variable.
  118587. * @param array array to be set.
  118588. * @returns this effect.
  118589. */
  118590. setArray(uniformName: string, array: number[]): Effect;
  118591. /**
  118592. * 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)
  118593. * @param uniformName Name of the variable.
  118594. * @param array array to be set.
  118595. * @returns this effect.
  118596. */
  118597. setArray2(uniformName: string, array: number[]): Effect;
  118598. /**
  118599. * 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)
  118600. * @param uniformName Name of the variable.
  118601. * @param array array to be set.
  118602. * @returns this effect.
  118603. */
  118604. setArray3(uniformName: string, array: number[]): Effect;
  118605. /**
  118606. * 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)
  118607. * @param uniformName Name of the variable.
  118608. * @param array array to be set.
  118609. * @returns this effect.
  118610. */
  118611. setArray4(uniformName: string, array: number[]): Effect;
  118612. /**
  118613. * Sets matrices on a uniform variable.
  118614. * @param uniformName Name of the variable.
  118615. * @param matrices matrices to be set.
  118616. * @returns this effect.
  118617. */
  118618. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  118619. /**
  118620. * Sets matrix on a uniform variable.
  118621. * @param uniformName Name of the variable.
  118622. * @param matrix matrix to be set.
  118623. * @returns this effect.
  118624. */
  118625. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  118626. /**
  118627. * 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)
  118628. * @param uniformName Name of the variable.
  118629. * @param matrix matrix to be set.
  118630. * @returns this effect.
  118631. */
  118632. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118633. /**
  118634. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  118635. * @param uniformName Name of the variable.
  118636. * @param matrix matrix to be set.
  118637. * @returns this effect.
  118638. */
  118639. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118640. /**
  118641. * Sets a float on a uniform variable.
  118642. * @param uniformName Name of the variable.
  118643. * @param value value to be set.
  118644. * @returns this effect.
  118645. */
  118646. setFloat(uniformName: string, value: number): Effect;
  118647. /**
  118648. * Sets a boolean on a uniform variable.
  118649. * @param uniformName Name of the variable.
  118650. * @param bool value to be set.
  118651. * @returns this effect.
  118652. */
  118653. setBool(uniformName: string, bool: boolean): Effect;
  118654. /**
  118655. * Sets a Vector2 on a uniform variable.
  118656. * @param uniformName Name of the variable.
  118657. * @param vector2 vector2 to be set.
  118658. * @returns this effect.
  118659. */
  118660. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  118661. /**
  118662. * Sets a float2 on a uniform variable.
  118663. * @param uniformName Name of the variable.
  118664. * @param x First float in float2.
  118665. * @param y Second float in float2.
  118666. * @returns this effect.
  118667. */
  118668. setFloat2(uniformName: string, x: number, y: number): Effect;
  118669. /**
  118670. * Sets a Vector3 on a uniform variable.
  118671. * @param uniformName Name of the variable.
  118672. * @param vector3 Value to be set.
  118673. * @returns this effect.
  118674. */
  118675. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  118676. /**
  118677. * Sets a float3 on a uniform variable.
  118678. * @param uniformName Name of the variable.
  118679. * @param x First float in float3.
  118680. * @param y Second float in float3.
  118681. * @param z Third float in float3.
  118682. * @returns this effect.
  118683. */
  118684. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  118685. /**
  118686. * Sets a Vector4 on a uniform variable.
  118687. * @param uniformName Name of the variable.
  118688. * @param vector4 Value to be set.
  118689. * @returns this effect.
  118690. */
  118691. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  118692. /**
  118693. * Sets a float4 on a uniform variable.
  118694. * @param uniformName Name of the variable.
  118695. * @param x First float in float4.
  118696. * @param y Second float in float4.
  118697. * @param z Third float in float4.
  118698. * @param w Fourth float in float4.
  118699. * @returns this effect.
  118700. */
  118701. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  118702. /**
  118703. * Sets a Color3 on a uniform variable.
  118704. * @param uniformName Name of the variable.
  118705. * @param color3 Value to be set.
  118706. * @returns this effect.
  118707. */
  118708. setColor3(uniformName: string, color3: IColor3Like): Effect;
  118709. /**
  118710. * Sets a Color4 on a uniform variable.
  118711. * @param uniformName Name of the variable.
  118712. * @param color3 Value to be set.
  118713. * @param alpha Alpha value to be set.
  118714. * @returns this effect.
  118715. */
  118716. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  118717. /**
  118718. * Sets a Color4 on a uniform variable
  118719. * @param uniformName defines the name of the variable
  118720. * @param color4 defines the value to be set
  118721. * @returns this effect.
  118722. */
  118723. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  118724. /** Release all associated resources */
  118725. dispose(): void;
  118726. /**
  118727. * This function will add a new shader to the shader store
  118728. * @param name the name of the shader
  118729. * @param pixelShader optional pixel shader content
  118730. * @param vertexShader optional vertex shader content
  118731. */
  118732. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  118733. /**
  118734. * Store of each shader (The can be looked up using effect.key)
  118735. */
  118736. static ShadersStore: {
  118737. [key: string]: string;
  118738. };
  118739. /**
  118740. * Store of each included file for a shader (The can be looked up using effect.key)
  118741. */
  118742. static IncludesShadersStore: {
  118743. [key: string]: string;
  118744. };
  118745. /**
  118746. * Resets the cache of effects.
  118747. */
  118748. static ResetCache(): void;
  118749. }
  118750. }
  118751. declare module BABYLON {
  118752. /**
  118753. * Interface used to describe the capabilities of the engine relatively to the current browser
  118754. */
  118755. export interface EngineCapabilities {
  118756. /** Maximum textures units per fragment shader */
  118757. maxTexturesImageUnits: number;
  118758. /** Maximum texture units per vertex shader */
  118759. maxVertexTextureImageUnits: number;
  118760. /** Maximum textures units in the entire pipeline */
  118761. maxCombinedTexturesImageUnits: number;
  118762. /** Maximum texture size */
  118763. maxTextureSize: number;
  118764. /** Maximum texture samples */
  118765. maxSamples?: number;
  118766. /** Maximum cube texture size */
  118767. maxCubemapTextureSize: number;
  118768. /** Maximum render texture size */
  118769. maxRenderTextureSize: number;
  118770. /** Maximum number of vertex attributes */
  118771. maxVertexAttribs: number;
  118772. /** Maximum number of varyings */
  118773. maxVaryingVectors: number;
  118774. /** Maximum number of uniforms per vertex shader */
  118775. maxVertexUniformVectors: number;
  118776. /** Maximum number of uniforms per fragment shader */
  118777. maxFragmentUniformVectors: number;
  118778. /** Defines if standard derivates (dx/dy) are supported */
  118779. standardDerivatives: boolean;
  118780. /** Defines if s3tc texture compression is supported */
  118781. s3tc?: WEBGL_compressed_texture_s3tc;
  118782. /** Defines if pvrtc texture compression is supported */
  118783. pvrtc: any;
  118784. /** Defines if etc1 texture compression is supported */
  118785. etc1: any;
  118786. /** Defines if etc2 texture compression is supported */
  118787. etc2: any;
  118788. /** Defines if astc texture compression is supported */
  118789. astc: any;
  118790. /** Defines if bptc texture compression is supported */
  118791. bptc: any;
  118792. /** Defines if float textures are supported */
  118793. textureFloat: boolean;
  118794. /** Defines if vertex array objects are supported */
  118795. vertexArrayObject: boolean;
  118796. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  118797. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  118798. /** Gets the maximum level of anisotropy supported */
  118799. maxAnisotropy: number;
  118800. /** Defines if instancing is supported */
  118801. instancedArrays: boolean;
  118802. /** Defines if 32 bits indices are supported */
  118803. uintIndices: boolean;
  118804. /** Defines if high precision shaders are supported */
  118805. highPrecisionShaderSupported: boolean;
  118806. /** Defines if depth reading in the fragment shader is supported */
  118807. fragmentDepthSupported: boolean;
  118808. /** Defines if float texture linear filtering is supported*/
  118809. textureFloatLinearFiltering: boolean;
  118810. /** Defines if rendering to float textures is supported */
  118811. textureFloatRender: boolean;
  118812. /** Defines if half float textures are supported*/
  118813. textureHalfFloat: boolean;
  118814. /** Defines if half float texture linear filtering is supported*/
  118815. textureHalfFloatLinearFiltering: boolean;
  118816. /** Defines if rendering to half float textures is supported */
  118817. textureHalfFloatRender: boolean;
  118818. /** Defines if textureLOD shader command is supported */
  118819. textureLOD: boolean;
  118820. /** Defines if draw buffers extension is supported */
  118821. drawBuffersExtension: boolean;
  118822. /** Defines if depth textures are supported */
  118823. depthTextureExtension: boolean;
  118824. /** Defines if float color buffer are supported */
  118825. colorBufferFloat: boolean;
  118826. /** Gets disjoint timer query extension (null if not supported) */
  118827. timerQuery?: EXT_disjoint_timer_query;
  118828. /** Defines if timestamp can be used with timer query */
  118829. canUseTimestampForTimerQuery: boolean;
  118830. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  118831. multiview?: any;
  118832. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  118833. oculusMultiview?: any;
  118834. /** Function used to let the system compiles shaders in background */
  118835. parallelShaderCompile?: {
  118836. COMPLETION_STATUS_KHR: number;
  118837. };
  118838. /** Max number of texture samples for MSAA */
  118839. maxMSAASamples: number;
  118840. /** Defines if the blend min max extension is supported */
  118841. blendMinMax: boolean;
  118842. }
  118843. }
  118844. declare module BABYLON {
  118845. /**
  118846. * @hidden
  118847. **/
  118848. export class DepthCullingState {
  118849. private _isDepthTestDirty;
  118850. private _isDepthMaskDirty;
  118851. private _isDepthFuncDirty;
  118852. private _isCullFaceDirty;
  118853. private _isCullDirty;
  118854. private _isZOffsetDirty;
  118855. private _isFrontFaceDirty;
  118856. private _depthTest;
  118857. private _depthMask;
  118858. private _depthFunc;
  118859. private _cull;
  118860. private _cullFace;
  118861. private _zOffset;
  118862. private _frontFace;
  118863. /**
  118864. * Initializes the state.
  118865. */
  118866. constructor();
  118867. get isDirty(): boolean;
  118868. get zOffset(): number;
  118869. set zOffset(value: number);
  118870. get cullFace(): Nullable<number>;
  118871. set cullFace(value: Nullable<number>);
  118872. get cull(): Nullable<boolean>;
  118873. set cull(value: Nullable<boolean>);
  118874. get depthFunc(): Nullable<number>;
  118875. set depthFunc(value: Nullable<number>);
  118876. get depthMask(): boolean;
  118877. set depthMask(value: boolean);
  118878. get depthTest(): boolean;
  118879. set depthTest(value: boolean);
  118880. get frontFace(): Nullable<number>;
  118881. set frontFace(value: Nullable<number>);
  118882. reset(): void;
  118883. apply(gl: WebGLRenderingContext): void;
  118884. }
  118885. }
  118886. declare module BABYLON {
  118887. /**
  118888. * @hidden
  118889. **/
  118890. export class StencilState {
  118891. /** 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 */
  118892. static readonly ALWAYS: number;
  118893. /** Passed to stencilOperation to specify that stencil value must be kept */
  118894. static readonly KEEP: number;
  118895. /** Passed to stencilOperation to specify that stencil value must be replaced */
  118896. static readonly REPLACE: number;
  118897. private _isStencilTestDirty;
  118898. private _isStencilMaskDirty;
  118899. private _isStencilFuncDirty;
  118900. private _isStencilOpDirty;
  118901. private _stencilTest;
  118902. private _stencilMask;
  118903. private _stencilFunc;
  118904. private _stencilFuncRef;
  118905. private _stencilFuncMask;
  118906. private _stencilOpStencilFail;
  118907. private _stencilOpDepthFail;
  118908. private _stencilOpStencilDepthPass;
  118909. get isDirty(): boolean;
  118910. get stencilFunc(): number;
  118911. set stencilFunc(value: number);
  118912. get stencilFuncRef(): number;
  118913. set stencilFuncRef(value: number);
  118914. get stencilFuncMask(): number;
  118915. set stencilFuncMask(value: number);
  118916. get stencilOpStencilFail(): number;
  118917. set stencilOpStencilFail(value: number);
  118918. get stencilOpDepthFail(): number;
  118919. set stencilOpDepthFail(value: number);
  118920. get stencilOpStencilDepthPass(): number;
  118921. set stencilOpStencilDepthPass(value: number);
  118922. get stencilMask(): number;
  118923. set stencilMask(value: number);
  118924. get stencilTest(): boolean;
  118925. set stencilTest(value: boolean);
  118926. constructor();
  118927. reset(): void;
  118928. apply(gl: WebGLRenderingContext): void;
  118929. }
  118930. }
  118931. declare module BABYLON {
  118932. /**
  118933. * @hidden
  118934. **/
  118935. export class AlphaState {
  118936. private _isAlphaBlendDirty;
  118937. private _isBlendFunctionParametersDirty;
  118938. private _isBlendEquationParametersDirty;
  118939. private _isBlendConstantsDirty;
  118940. private _alphaBlend;
  118941. private _blendFunctionParameters;
  118942. private _blendEquationParameters;
  118943. private _blendConstants;
  118944. /**
  118945. * Initializes the state.
  118946. */
  118947. constructor();
  118948. get isDirty(): boolean;
  118949. get alphaBlend(): boolean;
  118950. set alphaBlend(value: boolean);
  118951. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  118952. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  118953. setAlphaEquationParameters(rgb: number, alpha: number): void;
  118954. reset(): void;
  118955. apply(gl: WebGLRenderingContext): void;
  118956. }
  118957. }
  118958. declare module BABYLON {
  118959. /** @hidden */
  118960. export class WebGL2ShaderProcessor implements IShaderProcessor {
  118961. attributeProcessor(attribute: string): string;
  118962. varyingProcessor(varying: string, isFragment: boolean): string;
  118963. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  118964. }
  118965. }
  118966. declare module BABYLON {
  118967. /**
  118968. * Interface for attribute information associated with buffer instanciation
  118969. */
  118970. export interface InstancingAttributeInfo {
  118971. /**
  118972. * Name of the GLSL attribute
  118973. * if attribute index is not specified, this is used to retrieve the index from the effect
  118974. */
  118975. attributeName: string;
  118976. /**
  118977. * Index/offset of the attribute in the vertex shader
  118978. * if not specified, this will be computes from the name.
  118979. */
  118980. index?: number;
  118981. /**
  118982. * size of the attribute, 1, 2, 3 or 4
  118983. */
  118984. attributeSize: number;
  118985. /**
  118986. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  118987. */
  118988. offset: number;
  118989. /**
  118990. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  118991. * default to 1
  118992. */
  118993. divisor?: number;
  118994. /**
  118995. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  118996. * default is FLOAT
  118997. */
  118998. attributeType?: number;
  118999. /**
  119000. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  119001. */
  119002. normalized?: boolean;
  119003. }
  119004. }
  119005. declare module BABYLON {
  119006. interface ThinEngine {
  119007. /**
  119008. * Update a video texture
  119009. * @param texture defines the texture to update
  119010. * @param video defines the video element to use
  119011. * @param invertY defines if data must be stored with Y axis inverted
  119012. */
  119013. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  119014. }
  119015. }
  119016. declare module BABYLON {
  119017. interface ThinEngine {
  119018. /**
  119019. * Creates a dynamic texture
  119020. * @param width defines the width of the texture
  119021. * @param height defines the height of the texture
  119022. * @param generateMipMaps defines if the engine should generate the mip levels
  119023. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  119024. * @returns the dynamic texture inside an InternalTexture
  119025. */
  119026. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  119027. /**
  119028. * Update the content of a dynamic texture
  119029. * @param texture defines the texture to update
  119030. * @param canvas defines the canvas containing the source
  119031. * @param invertY defines if data must be stored with Y axis inverted
  119032. * @param premulAlpha defines if alpha is stored as premultiplied
  119033. * @param format defines the format of the data
  119034. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119035. */
  119036. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  119037. }
  119038. }
  119039. declare module BABYLON {
  119040. /**
  119041. * Settings for finer control over video usage
  119042. */
  119043. export interface VideoTextureSettings {
  119044. /**
  119045. * Applies `autoplay` to video, if specified
  119046. */
  119047. autoPlay?: boolean;
  119048. /**
  119049. * Applies `muted` to video, if specified
  119050. */
  119051. muted?: boolean;
  119052. /**
  119053. * Applies `loop` to video, if specified
  119054. */
  119055. loop?: boolean;
  119056. /**
  119057. * Automatically updates internal texture from video at every frame in the render loop
  119058. */
  119059. autoUpdateTexture: boolean;
  119060. /**
  119061. * Image src displayed during the video loading or until the user interacts with the video.
  119062. */
  119063. poster?: string;
  119064. }
  119065. /**
  119066. * If you want to display a video in your scene, this is the special texture for that.
  119067. * This special texture works similar to other textures, with the exception of a few parameters.
  119068. * @see https://doc.babylonjs.com/how_to/video_texture
  119069. */
  119070. export class VideoTexture extends Texture {
  119071. /**
  119072. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  119073. */
  119074. readonly autoUpdateTexture: boolean;
  119075. /**
  119076. * The video instance used by the texture internally
  119077. */
  119078. readonly video: HTMLVideoElement;
  119079. private _onUserActionRequestedObservable;
  119080. /**
  119081. * Event triggerd when a dom action is required by the user to play the video.
  119082. * This happens due to recent changes in browser policies preventing video to auto start.
  119083. */
  119084. get onUserActionRequestedObservable(): Observable<Texture>;
  119085. private _generateMipMaps;
  119086. private _stillImageCaptured;
  119087. private _displayingPosterTexture;
  119088. private _settings;
  119089. private _createInternalTextureOnEvent;
  119090. private _frameId;
  119091. private _currentSrc;
  119092. /**
  119093. * Creates a video texture.
  119094. * If you want to display a video in your scene, this is the special texture for that.
  119095. * This special texture works similar to other textures, with the exception of a few parameters.
  119096. * @see https://doc.babylonjs.com/how_to/video_texture
  119097. * @param name optional name, will detect from video source, if not defined
  119098. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  119099. * @param scene is obviously the current scene.
  119100. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  119101. * @param invertY is false by default but can be used to invert video on Y axis
  119102. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  119103. * @param settings allows finer control over video usage
  119104. */
  119105. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  119106. private _getName;
  119107. private _getVideo;
  119108. private _createInternalTexture;
  119109. private reset;
  119110. /**
  119111. * @hidden Internal method to initiate `update`.
  119112. */
  119113. _rebuild(): void;
  119114. /**
  119115. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  119116. */
  119117. update(): void;
  119118. /**
  119119. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  119120. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  119121. */
  119122. updateTexture(isVisible: boolean): void;
  119123. protected _updateInternalTexture: () => void;
  119124. /**
  119125. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  119126. * @param url New url.
  119127. */
  119128. updateURL(url: string): void;
  119129. /**
  119130. * Clones the texture.
  119131. * @returns the cloned texture
  119132. */
  119133. clone(): VideoTexture;
  119134. /**
  119135. * Dispose the texture and release its associated resources.
  119136. */
  119137. dispose(): void;
  119138. /**
  119139. * Creates a video texture straight from a stream.
  119140. * @param scene Define the scene the texture should be created in
  119141. * @param stream Define the stream the texture should be created from
  119142. * @returns The created video texture as a promise
  119143. */
  119144. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  119145. /**
  119146. * Creates a video texture straight from your WebCam video feed.
  119147. * @param scene Define the scene the texture should be created in
  119148. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119149. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119150. * @returns The created video texture as a promise
  119151. */
  119152. static CreateFromWebCamAsync(scene: Scene, constraints: {
  119153. minWidth: number;
  119154. maxWidth: number;
  119155. minHeight: number;
  119156. maxHeight: number;
  119157. deviceId: string;
  119158. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  119159. /**
  119160. * Creates a video texture straight from your WebCam video feed.
  119161. * @param scene Define the scene the texture should be created in
  119162. * @param onReady Define a callback to triggered once the texture will be ready
  119163. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119164. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119165. */
  119166. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  119167. minWidth: number;
  119168. maxWidth: number;
  119169. minHeight: number;
  119170. maxHeight: number;
  119171. deviceId: string;
  119172. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  119173. }
  119174. }
  119175. declare module BABYLON {
  119176. /**
  119177. * Defines the interface used by objects working like Scene
  119178. * @hidden
  119179. */
  119180. export interface ISceneLike {
  119181. _addPendingData(data: any): void;
  119182. _removePendingData(data: any): void;
  119183. offlineProvider: IOfflineProvider;
  119184. }
  119185. /**
  119186. * Information about the current host
  119187. */
  119188. export interface HostInformation {
  119189. /**
  119190. * Defines if the current host is a mobile
  119191. */
  119192. isMobile: boolean;
  119193. }
  119194. /** Interface defining initialization parameters for Engine class */
  119195. export interface EngineOptions extends WebGLContextAttributes {
  119196. /**
  119197. * Defines if the engine should no exceed a specified device ratio
  119198. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  119199. */
  119200. limitDeviceRatio?: number;
  119201. /**
  119202. * Defines if webvr should be enabled automatically
  119203. * @see https://doc.babylonjs.com/how_to/webvr_camera
  119204. */
  119205. autoEnableWebVR?: boolean;
  119206. /**
  119207. * Defines if webgl2 should be turned off even if supported
  119208. * @see https://doc.babylonjs.com/features/webgl2
  119209. */
  119210. disableWebGL2Support?: boolean;
  119211. /**
  119212. * Defines if webaudio should be initialized as well
  119213. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119214. */
  119215. audioEngine?: boolean;
  119216. /**
  119217. * Defines if animations should run using a deterministic lock step
  119218. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119219. */
  119220. deterministicLockstep?: boolean;
  119221. /** Defines the maximum steps to use with deterministic lock step mode */
  119222. lockstepMaxSteps?: number;
  119223. /** Defines the seconds between each deterministic lock step */
  119224. timeStep?: number;
  119225. /**
  119226. * Defines that engine should ignore context lost events
  119227. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  119228. */
  119229. doNotHandleContextLost?: boolean;
  119230. /**
  119231. * Defines that engine should ignore modifying touch action attribute and style
  119232. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  119233. */
  119234. doNotHandleTouchAction?: boolean;
  119235. /**
  119236. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  119237. */
  119238. useHighPrecisionFloats?: boolean;
  119239. /**
  119240. * Make the canvas XR Compatible for XR sessions
  119241. */
  119242. xrCompatible?: boolean;
  119243. /**
  119244. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  119245. */
  119246. useHighPrecisionMatrix?: boolean;
  119247. /**
  119248. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  119249. */
  119250. failIfMajorPerformanceCaveat?: boolean;
  119251. }
  119252. /**
  119253. * The base engine class (root of all engines)
  119254. */
  119255. export class ThinEngine {
  119256. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  119257. static ExceptionList: ({
  119258. key: string;
  119259. capture: string;
  119260. captureConstraint: number;
  119261. targets: string[];
  119262. } | {
  119263. key: string;
  119264. capture: null;
  119265. captureConstraint: null;
  119266. targets: string[];
  119267. })[];
  119268. /** @hidden */
  119269. static _TextureLoaders: IInternalTextureLoader[];
  119270. /**
  119271. * Returns the current npm package of the sdk
  119272. */
  119273. static get NpmPackage(): string;
  119274. /**
  119275. * Returns the current version of the framework
  119276. */
  119277. static get Version(): string;
  119278. /**
  119279. * Returns a string describing the current engine
  119280. */
  119281. get description(): string;
  119282. /**
  119283. * Gets or sets the epsilon value used by collision engine
  119284. */
  119285. static CollisionsEpsilon: number;
  119286. /**
  119287. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119288. */
  119289. static get ShadersRepository(): string;
  119290. static set ShadersRepository(value: string);
  119291. /** @hidden */
  119292. _shaderProcessor: IShaderProcessor;
  119293. /**
  119294. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  119295. */
  119296. forcePOTTextures: boolean;
  119297. /**
  119298. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  119299. */
  119300. isFullscreen: boolean;
  119301. /**
  119302. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  119303. */
  119304. cullBackFaces: boolean;
  119305. /**
  119306. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  119307. */
  119308. renderEvenInBackground: boolean;
  119309. /**
  119310. * Gets or sets a boolean indicating that cache can be kept between frames
  119311. */
  119312. preventCacheWipeBetweenFrames: boolean;
  119313. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  119314. validateShaderPrograms: boolean;
  119315. /**
  119316. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  119317. * This can provide greater z depth for distant objects.
  119318. */
  119319. useReverseDepthBuffer: boolean;
  119320. /**
  119321. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  119322. */
  119323. disableUniformBuffers: boolean;
  119324. /** @hidden */
  119325. _uniformBuffers: UniformBuffer[];
  119326. /**
  119327. * Gets a boolean indicating that the engine supports uniform buffers
  119328. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  119329. */
  119330. get supportsUniformBuffers(): boolean;
  119331. /** @hidden */
  119332. _gl: WebGLRenderingContext;
  119333. /** @hidden */
  119334. _webGLVersion: number;
  119335. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  119336. protected _windowIsBackground: boolean;
  119337. protected _creationOptions: EngineOptions;
  119338. protected _highPrecisionShadersAllowed: boolean;
  119339. /** @hidden */
  119340. get _shouldUseHighPrecisionShader(): boolean;
  119341. /**
  119342. * Gets a boolean indicating that only power of 2 textures are supported
  119343. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  119344. */
  119345. get needPOTTextures(): boolean;
  119346. /** @hidden */
  119347. _badOS: boolean;
  119348. /** @hidden */
  119349. _badDesktopOS: boolean;
  119350. private _hardwareScalingLevel;
  119351. /** @hidden */
  119352. _caps: EngineCapabilities;
  119353. private _isStencilEnable;
  119354. private _glVersion;
  119355. private _glRenderer;
  119356. private _glVendor;
  119357. /** @hidden */
  119358. _videoTextureSupported: boolean;
  119359. protected _renderingQueueLaunched: boolean;
  119360. protected _activeRenderLoops: (() => void)[];
  119361. /**
  119362. * Observable signaled when a context lost event is raised
  119363. */
  119364. onContextLostObservable: Observable<ThinEngine>;
  119365. /**
  119366. * Observable signaled when a context restored event is raised
  119367. */
  119368. onContextRestoredObservable: Observable<ThinEngine>;
  119369. private _onContextLost;
  119370. private _onContextRestored;
  119371. protected _contextWasLost: boolean;
  119372. /** @hidden */
  119373. _doNotHandleContextLost: boolean;
  119374. /**
  119375. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  119376. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  119377. */
  119378. get doNotHandleContextLost(): boolean;
  119379. set doNotHandleContextLost(value: boolean);
  119380. /**
  119381. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  119382. */
  119383. disableVertexArrayObjects: boolean;
  119384. /** @hidden */
  119385. protected _colorWrite: boolean;
  119386. /** @hidden */
  119387. protected _colorWriteChanged: boolean;
  119388. /** @hidden */
  119389. protected _depthCullingState: DepthCullingState;
  119390. /** @hidden */
  119391. protected _stencilState: StencilState;
  119392. /** @hidden */
  119393. _alphaState: AlphaState;
  119394. /** @hidden */
  119395. _alphaMode: number;
  119396. /** @hidden */
  119397. _alphaEquation: number;
  119398. /** @hidden */
  119399. _internalTexturesCache: InternalTexture[];
  119400. /** @hidden */
  119401. protected _activeChannel: number;
  119402. private _currentTextureChannel;
  119403. /** @hidden */
  119404. protected _boundTexturesCache: {
  119405. [key: string]: Nullable<InternalTexture>;
  119406. };
  119407. /** @hidden */
  119408. protected _currentEffect: Nullable<Effect>;
  119409. /** @hidden */
  119410. protected _currentProgram: Nullable<WebGLProgram>;
  119411. private _compiledEffects;
  119412. private _vertexAttribArraysEnabled;
  119413. /** @hidden */
  119414. protected _cachedViewport: Nullable<IViewportLike>;
  119415. private _cachedVertexArrayObject;
  119416. /** @hidden */
  119417. protected _cachedVertexBuffers: any;
  119418. /** @hidden */
  119419. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  119420. /** @hidden */
  119421. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  119422. /** @hidden */
  119423. _currentRenderTarget: Nullable<InternalTexture>;
  119424. private _uintIndicesCurrentlySet;
  119425. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  119426. /** @hidden */
  119427. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  119428. /** @hidden */
  119429. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  119430. private _currentBufferPointers;
  119431. private _currentInstanceLocations;
  119432. private _currentInstanceBuffers;
  119433. private _textureUnits;
  119434. /** @hidden */
  119435. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  119436. /** @hidden */
  119437. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  119438. /** @hidden */
  119439. _boundRenderFunction: any;
  119440. private _vaoRecordInProgress;
  119441. private _mustWipeVertexAttributes;
  119442. private _emptyTexture;
  119443. private _emptyCubeTexture;
  119444. private _emptyTexture3D;
  119445. private _emptyTexture2DArray;
  119446. /** @hidden */
  119447. _frameHandler: number;
  119448. private _nextFreeTextureSlots;
  119449. private _maxSimultaneousTextures;
  119450. private _activeRequests;
  119451. /** @hidden */
  119452. _transformTextureUrl: Nullable<(url: string) => string>;
  119453. /**
  119454. * Gets information about the current host
  119455. */
  119456. hostInformation: HostInformation;
  119457. protected get _supportsHardwareTextureRescaling(): boolean;
  119458. private _framebufferDimensionsObject;
  119459. /**
  119460. * sets the object from which width and height will be taken from when getting render width and height
  119461. * Will fallback to the gl object
  119462. * @param dimensions the framebuffer width and height that will be used.
  119463. */
  119464. set framebufferDimensionsObject(dimensions: Nullable<{
  119465. framebufferWidth: number;
  119466. framebufferHeight: number;
  119467. }>);
  119468. /**
  119469. * Gets the current viewport
  119470. */
  119471. get currentViewport(): Nullable<IViewportLike>;
  119472. /**
  119473. * Gets the default empty texture
  119474. */
  119475. get emptyTexture(): InternalTexture;
  119476. /**
  119477. * Gets the default empty 3D texture
  119478. */
  119479. get emptyTexture3D(): InternalTexture;
  119480. /**
  119481. * Gets the default empty 2D array texture
  119482. */
  119483. get emptyTexture2DArray(): InternalTexture;
  119484. /**
  119485. * Gets the default empty cube texture
  119486. */
  119487. get emptyCubeTexture(): InternalTexture;
  119488. /**
  119489. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  119490. */
  119491. readonly premultipliedAlpha: boolean;
  119492. /**
  119493. * Observable event triggered before each texture is initialized
  119494. */
  119495. onBeforeTextureInitObservable: Observable<Texture>;
  119496. /**
  119497. * Creates a new engine
  119498. * @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
  119499. * @param antialias defines enable antialiasing (default: false)
  119500. * @param options defines further options to be sent to the getContext() function
  119501. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  119502. */
  119503. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  119504. private _rebuildInternalTextures;
  119505. private _rebuildEffects;
  119506. /**
  119507. * Gets a boolean indicating if all created effects are ready
  119508. * @returns true if all effects are ready
  119509. */
  119510. areAllEffectsReady(): boolean;
  119511. protected _rebuildBuffers(): void;
  119512. protected _initGLContext(): void;
  119513. /**
  119514. * Gets version of the current webGL context
  119515. */
  119516. get webGLVersion(): number;
  119517. /**
  119518. * Gets a string identifying the name of the class
  119519. * @returns "Engine" string
  119520. */
  119521. getClassName(): string;
  119522. /**
  119523. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  119524. */
  119525. get isStencilEnable(): boolean;
  119526. /** @hidden */
  119527. _prepareWorkingCanvas(): void;
  119528. /**
  119529. * Reset the texture cache to empty state
  119530. */
  119531. resetTextureCache(): void;
  119532. /**
  119533. * Gets an object containing information about the current webGL context
  119534. * @returns an object containing the vender, the renderer and the version of the current webGL context
  119535. */
  119536. getGlInfo(): {
  119537. vendor: string;
  119538. renderer: string;
  119539. version: string;
  119540. };
  119541. /**
  119542. * Defines the hardware scaling level.
  119543. * By default the hardware scaling level is computed from the window device ratio.
  119544. * 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.
  119545. * @param level defines the level to use
  119546. */
  119547. setHardwareScalingLevel(level: number): void;
  119548. /**
  119549. * Gets the current hardware scaling level.
  119550. * By default the hardware scaling level is computed from the window device ratio.
  119551. * 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.
  119552. * @returns a number indicating the current hardware scaling level
  119553. */
  119554. getHardwareScalingLevel(): number;
  119555. /**
  119556. * Gets the list of loaded textures
  119557. * @returns an array containing all loaded textures
  119558. */
  119559. getLoadedTexturesCache(): InternalTexture[];
  119560. /**
  119561. * Gets the object containing all engine capabilities
  119562. * @returns the EngineCapabilities object
  119563. */
  119564. getCaps(): EngineCapabilities;
  119565. /**
  119566. * stop executing a render loop function and remove it from the execution array
  119567. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  119568. */
  119569. stopRenderLoop(renderFunction?: () => void): void;
  119570. /** @hidden */
  119571. _renderLoop(): void;
  119572. /**
  119573. * Gets the HTML canvas attached with the current webGL context
  119574. * @returns a HTML canvas
  119575. */
  119576. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  119577. /**
  119578. * Gets host window
  119579. * @returns the host window object
  119580. */
  119581. getHostWindow(): Nullable<Window>;
  119582. /**
  119583. * Gets the current render width
  119584. * @param useScreen defines if screen size must be used (or the current render target if any)
  119585. * @returns a number defining the current render width
  119586. */
  119587. getRenderWidth(useScreen?: boolean): number;
  119588. /**
  119589. * Gets the current render height
  119590. * @param useScreen defines if screen size must be used (or the current render target if any)
  119591. * @returns a number defining the current render height
  119592. */
  119593. getRenderHeight(useScreen?: boolean): number;
  119594. /**
  119595. * Can be used to override the current requestAnimationFrame requester.
  119596. * @hidden
  119597. */
  119598. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  119599. /**
  119600. * Register and execute a render loop. The engine can have more than one render function
  119601. * @param renderFunction defines the function to continuously execute
  119602. */
  119603. runRenderLoop(renderFunction: () => void): void;
  119604. /**
  119605. * Clear the current render buffer or the current render target (if any is set up)
  119606. * @param color defines the color to use
  119607. * @param backBuffer defines if the back buffer must be cleared
  119608. * @param depth defines if the depth buffer must be cleared
  119609. * @param stencil defines if the stencil buffer must be cleared
  119610. */
  119611. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119612. private _viewportCached;
  119613. /** @hidden */
  119614. _viewport(x: number, y: number, width: number, height: number): void;
  119615. /**
  119616. * Set the WebGL's viewport
  119617. * @param viewport defines the viewport element to be used
  119618. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119619. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119620. */
  119621. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119622. /**
  119623. * Begin a new frame
  119624. */
  119625. beginFrame(): void;
  119626. /**
  119627. * Enf the current frame
  119628. */
  119629. endFrame(): void;
  119630. /**
  119631. * Resize the view according to the canvas' size
  119632. */
  119633. resize(): void;
  119634. /**
  119635. * Force a specific size of the canvas
  119636. * @param width defines the new canvas' width
  119637. * @param height defines the new canvas' height
  119638. * @returns true if the size was changed
  119639. */
  119640. setSize(width: number, height: number): boolean;
  119641. /**
  119642. * Binds the frame buffer to the specified texture.
  119643. * @param texture The texture to render to or null for the default canvas
  119644. * @param faceIndex The face of the texture to render to in case of cube texture
  119645. * @param requiredWidth The width of the target to render to
  119646. * @param requiredHeight The height of the target to render to
  119647. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119648. * @param lodLevel defines the lod level to bind to the frame buffer
  119649. * @param layer defines the 2d array index to bind to frame buffer to
  119650. */
  119651. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  119652. /** @hidden */
  119653. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  119654. /**
  119655. * Unbind the current render target texture from the webGL context
  119656. * @param texture defines the render target texture to unbind
  119657. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119658. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119659. */
  119660. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119661. /**
  119662. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  119663. */
  119664. flushFramebuffer(): void;
  119665. /**
  119666. * Unbind the current render target and bind the default framebuffer
  119667. */
  119668. restoreDefaultFramebuffer(): void;
  119669. /** @hidden */
  119670. protected _resetVertexBufferBinding(): void;
  119671. /**
  119672. * Creates a vertex buffer
  119673. * @param data the data for the vertex buffer
  119674. * @returns the new WebGL static buffer
  119675. */
  119676. createVertexBuffer(data: DataArray): DataBuffer;
  119677. private _createVertexBuffer;
  119678. /**
  119679. * Creates a dynamic vertex buffer
  119680. * @param data the data for the dynamic vertex buffer
  119681. * @returns the new WebGL dynamic buffer
  119682. */
  119683. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  119684. protected _resetIndexBufferBinding(): void;
  119685. /**
  119686. * Creates a new index buffer
  119687. * @param indices defines the content of the index buffer
  119688. * @param updatable defines if the index buffer must be updatable
  119689. * @returns a new webGL buffer
  119690. */
  119691. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  119692. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  119693. /**
  119694. * Bind a webGL buffer to the webGL context
  119695. * @param buffer defines the buffer to bind
  119696. */
  119697. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  119698. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  119699. private bindBuffer;
  119700. /**
  119701. * update the bound buffer with the given data
  119702. * @param data defines the data to update
  119703. */
  119704. updateArrayBuffer(data: Float32Array): void;
  119705. private _vertexAttribPointer;
  119706. /** @hidden */
  119707. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  119708. private _bindVertexBuffersAttributes;
  119709. /**
  119710. * Records a vertex array object
  119711. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119712. * @param vertexBuffers defines the list of vertex buffers to store
  119713. * @param indexBuffer defines the index buffer to store
  119714. * @param effect defines the effect to store
  119715. * @returns the new vertex array object
  119716. */
  119717. recordVertexArrayObject(vertexBuffers: {
  119718. [key: string]: VertexBuffer;
  119719. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  119720. /**
  119721. * Bind a specific vertex array object
  119722. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119723. * @param vertexArrayObject defines the vertex array object to bind
  119724. * @param indexBuffer defines the index buffer to bind
  119725. */
  119726. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  119727. /**
  119728. * Bind webGl buffers directly to the webGL context
  119729. * @param vertexBuffer defines the vertex buffer to bind
  119730. * @param indexBuffer defines the index buffer to bind
  119731. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119732. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119733. * @param effect defines the effect associated with the vertex buffer
  119734. */
  119735. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  119736. private _unbindVertexArrayObject;
  119737. /**
  119738. * Bind a list of vertex buffers to the webGL context
  119739. * @param vertexBuffers defines the list of vertex buffers to bind
  119740. * @param indexBuffer defines the index buffer to bind
  119741. * @param effect defines the effect associated with the vertex buffers
  119742. */
  119743. bindBuffers(vertexBuffers: {
  119744. [key: string]: Nullable<VertexBuffer>;
  119745. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  119746. /**
  119747. * Unbind all instance attributes
  119748. */
  119749. unbindInstanceAttributes(): void;
  119750. /**
  119751. * Release and free the memory of a vertex array object
  119752. * @param vao defines the vertex array object to delete
  119753. */
  119754. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  119755. /** @hidden */
  119756. _releaseBuffer(buffer: DataBuffer): boolean;
  119757. protected _deleteBuffer(buffer: DataBuffer): void;
  119758. /**
  119759. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  119760. * @param instancesBuffer defines the webGL buffer to update and bind
  119761. * @param data defines the data to store in the buffer
  119762. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  119763. */
  119764. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  119765. /**
  119766. * Bind the content of a webGL buffer used with instantiation
  119767. * @param instancesBuffer defines the webGL buffer to bind
  119768. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  119769. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  119770. */
  119771. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  119772. /**
  119773. * Disable the instance attribute corresponding to the name in parameter
  119774. * @param name defines the name of the attribute to disable
  119775. */
  119776. disableInstanceAttributeByName(name: string): void;
  119777. /**
  119778. * Disable the instance attribute corresponding to the location in parameter
  119779. * @param attributeLocation defines the attribute location of the attribute to disable
  119780. */
  119781. disableInstanceAttribute(attributeLocation: number): void;
  119782. /**
  119783. * Disable the attribute corresponding to the location in parameter
  119784. * @param attributeLocation defines the attribute location of the attribute to disable
  119785. */
  119786. disableAttributeByIndex(attributeLocation: number): void;
  119787. /**
  119788. * Send a draw order
  119789. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119790. * @param indexStart defines the starting index
  119791. * @param indexCount defines the number of index to draw
  119792. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119793. */
  119794. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119795. /**
  119796. * Draw a list of points
  119797. * @param verticesStart defines the index of first vertex to draw
  119798. * @param verticesCount defines the count of vertices to draw
  119799. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119800. */
  119801. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119802. /**
  119803. * Draw a list of unindexed primitives
  119804. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119805. * @param verticesStart defines the index of first vertex to draw
  119806. * @param verticesCount defines the count of vertices to draw
  119807. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119808. */
  119809. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119810. /**
  119811. * Draw a list of indexed primitives
  119812. * @param fillMode defines the primitive to use
  119813. * @param indexStart defines the starting index
  119814. * @param indexCount defines the number of index to draw
  119815. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119816. */
  119817. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119818. /**
  119819. * Draw a list of unindexed primitives
  119820. * @param fillMode defines the primitive to use
  119821. * @param verticesStart defines the index of first vertex to draw
  119822. * @param verticesCount defines the count of vertices to draw
  119823. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119824. */
  119825. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119826. private _drawMode;
  119827. /** @hidden */
  119828. protected _reportDrawCall(): void;
  119829. /** @hidden */
  119830. _releaseEffect(effect: Effect): void;
  119831. /** @hidden */
  119832. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  119833. /**
  119834. * Create a new effect (used to store vertex/fragment shaders)
  119835. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  119836. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  119837. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  119838. * @param samplers defines an array of string used to represent textures
  119839. * @param defines defines the string containing the defines to use to compile the shaders
  119840. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119841. * @param onCompiled defines a function to call when the effect creation is successful
  119842. * @param onError defines a function to call when the effect creation has failed
  119843. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  119844. * @returns the new Effect
  119845. */
  119846. 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;
  119847. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  119848. private _compileShader;
  119849. private _compileRawShader;
  119850. /** @hidden */
  119851. _getShaderSource(shader: WebGLShader): Nullable<string>;
  119852. /**
  119853. * Directly creates a webGL program
  119854. * @param pipelineContext defines the pipeline context to attach to
  119855. * @param vertexCode defines the vertex shader code to use
  119856. * @param fragmentCode defines the fragment shader code to use
  119857. * @param context defines the webGL context to use (if not set, the current one will be used)
  119858. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119859. * @returns the new webGL program
  119860. */
  119861. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119862. /**
  119863. * Creates a webGL program
  119864. * @param pipelineContext defines the pipeline context to attach to
  119865. * @param vertexCode defines the vertex shader code to use
  119866. * @param fragmentCode defines the fragment shader code to use
  119867. * @param defines defines the string containing the defines to use to compile the shaders
  119868. * @param context defines the webGL context to use (if not set, the current one will be used)
  119869. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119870. * @returns the new webGL program
  119871. */
  119872. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119873. /**
  119874. * Creates a new pipeline context
  119875. * @returns the new pipeline
  119876. */
  119877. createPipelineContext(): IPipelineContext;
  119878. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119879. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  119880. /** @hidden */
  119881. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  119882. /** @hidden */
  119883. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  119884. /** @hidden */
  119885. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  119886. /**
  119887. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119888. * @param pipelineContext defines the pipeline context to use
  119889. * @param uniformsNames defines the list of uniform names
  119890. * @returns an array of webGL uniform locations
  119891. */
  119892. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119893. /**
  119894. * Gets the lsit of active attributes for a given webGL program
  119895. * @param pipelineContext defines the pipeline context to use
  119896. * @param attributesNames defines the list of attribute names to get
  119897. * @returns an array of indices indicating the offset of each attribute
  119898. */
  119899. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119900. /**
  119901. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119902. * @param effect defines the effect to activate
  119903. */
  119904. enableEffect(effect: Nullable<Effect>): void;
  119905. /**
  119906. * Set the value of an uniform to a number (int)
  119907. * @param uniform defines the webGL uniform location where to store the value
  119908. * @param value defines the int number to store
  119909. * @returns true if the value was set
  119910. */
  119911. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119912. /**
  119913. * Set the value of an uniform to an array of int32
  119914. * @param uniform defines the webGL uniform location where to store the value
  119915. * @param array defines the array of int32 to store
  119916. * @returns true if the value was set
  119917. */
  119918. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119919. /**
  119920. * Set the value of an uniform to an array of int32 (stored as vec2)
  119921. * @param uniform defines the webGL uniform location where to store the value
  119922. * @param array defines the array of int32 to store
  119923. * @returns true if the value was set
  119924. */
  119925. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119926. /**
  119927. * Set the value of an uniform to an array of int32 (stored as vec3)
  119928. * @param uniform defines the webGL uniform location where to store the value
  119929. * @param array defines the array of int32 to store
  119930. * @returns true if the value was set
  119931. */
  119932. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119933. /**
  119934. * Set the value of an uniform to an array of int32 (stored as vec4)
  119935. * @param uniform defines the webGL uniform location where to store the value
  119936. * @param array defines the array of int32 to store
  119937. * @returns true if the value was set
  119938. */
  119939. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119940. /**
  119941. * Set the value of an uniform to an array of number
  119942. * @param uniform defines the webGL uniform location where to store the value
  119943. * @param array defines the array of number to store
  119944. * @returns true if the value was set
  119945. */
  119946. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119947. /**
  119948. * Set the value of an uniform to an array of number (stored as vec2)
  119949. * @param uniform defines the webGL uniform location where to store the value
  119950. * @param array defines the array of number to store
  119951. * @returns true if the value was set
  119952. */
  119953. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119954. /**
  119955. * Set the value of an uniform to an array of number (stored as vec3)
  119956. * @param uniform defines the webGL uniform location where to store the value
  119957. * @param array defines the array of number to store
  119958. * @returns true if the value was set
  119959. */
  119960. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119961. /**
  119962. * Set the value of an uniform to an array of number (stored as vec4)
  119963. * @param uniform defines the webGL uniform location where to store the value
  119964. * @param array defines the array of number to store
  119965. * @returns true if the value was set
  119966. */
  119967. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119968. /**
  119969. * Set the value of an uniform to an array of float32 (stored as matrices)
  119970. * @param uniform defines the webGL uniform location where to store the value
  119971. * @param matrices defines the array of float32 to store
  119972. * @returns true if the value was set
  119973. */
  119974. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  119975. /**
  119976. * Set the value of an uniform to a matrix (3x3)
  119977. * @param uniform defines the webGL uniform location where to store the value
  119978. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119979. * @returns true if the value was set
  119980. */
  119981. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119982. /**
  119983. * Set the value of an uniform to a matrix (2x2)
  119984. * @param uniform defines the webGL uniform location where to store the value
  119985. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119986. * @returns true if the value was set
  119987. */
  119988. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119989. /**
  119990. * Set the value of an uniform to a number (float)
  119991. * @param uniform defines the webGL uniform location where to store the value
  119992. * @param value defines the float number to store
  119993. * @returns true if the value was transfered
  119994. */
  119995. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119996. /**
  119997. * Set the value of an uniform to a vec2
  119998. * @param uniform defines the webGL uniform location where to store the value
  119999. * @param x defines the 1st component of the value
  120000. * @param y defines the 2nd component of the value
  120001. * @returns true if the value was set
  120002. */
  120003. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  120004. /**
  120005. * Set the value of an uniform to a vec3
  120006. * @param uniform defines the webGL uniform location where to store the value
  120007. * @param x defines the 1st component of the value
  120008. * @param y defines the 2nd component of the value
  120009. * @param z defines the 3rd component of the value
  120010. * @returns true if the value was set
  120011. */
  120012. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  120013. /**
  120014. * Set the value of an uniform to a vec4
  120015. * @param uniform defines the webGL uniform location where to store the value
  120016. * @param x defines the 1st component of the value
  120017. * @param y defines the 2nd component of the value
  120018. * @param z defines the 3rd component of the value
  120019. * @param w defines the 4th component of the value
  120020. * @returns true if the value was set
  120021. */
  120022. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  120023. /**
  120024. * Apply all cached states (depth, culling, stencil and alpha)
  120025. */
  120026. applyStates(): void;
  120027. /**
  120028. * Enable or disable color writing
  120029. * @param enable defines the state to set
  120030. */
  120031. setColorWrite(enable: boolean): void;
  120032. /**
  120033. * Gets a boolean indicating if color writing is enabled
  120034. * @returns the current color writing state
  120035. */
  120036. getColorWrite(): boolean;
  120037. /**
  120038. * Gets the depth culling state manager
  120039. */
  120040. get depthCullingState(): DepthCullingState;
  120041. /**
  120042. * Gets the alpha state manager
  120043. */
  120044. get alphaState(): AlphaState;
  120045. /**
  120046. * Gets the stencil state manager
  120047. */
  120048. get stencilState(): StencilState;
  120049. /**
  120050. * Clears the list of texture accessible through engine.
  120051. * This can help preventing texture load conflict due to name collision.
  120052. */
  120053. clearInternalTexturesCache(): void;
  120054. /**
  120055. * Force the entire cache to be cleared
  120056. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120057. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120058. */
  120059. wipeCaches(bruteForce?: boolean): void;
  120060. /** @hidden */
  120061. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  120062. min: number;
  120063. mag: number;
  120064. };
  120065. /** @hidden */
  120066. _createTexture(): WebGLTexture;
  120067. /**
  120068. * Usually called from Texture.ts.
  120069. * Passed information to create a WebGLTexture
  120070. * @param url defines a value which contains one of the following:
  120071. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120072. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120073. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120074. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120075. * @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)
  120076. * @param scene needed for loading to the correct scene
  120077. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120078. * @param onLoad optional callback to be called upon successful completion
  120079. * @param onError optional callback to be called upon failure
  120080. * @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
  120081. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120082. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120083. * @param forcedExtension defines the extension to use to pick the right loader
  120084. * @param mimeType defines an optional mime type
  120085. * @param loaderOptions options to be passed to the loader
  120086. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120087. */
  120088. 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, loaderOptions?: any): InternalTexture;
  120089. /**
  120090. * Loads an image as an HTMLImageElement.
  120091. * @param input url string, ArrayBuffer, or Blob to load
  120092. * @param onLoad callback called when the image successfully loads
  120093. * @param onError callback called when the image fails to load
  120094. * @param offlineProvider offline provider for caching
  120095. * @param mimeType optional mime type
  120096. * @returns the HTMLImageElement of the loaded image
  120097. * @hidden
  120098. */
  120099. 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>;
  120100. /**
  120101. * @hidden
  120102. */
  120103. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  120104. private _unpackFlipYCached;
  120105. /**
  120106. * In case you are sharing the context with other applications, it might
  120107. * be interested to not cache the unpack flip y state to ensure a consistent
  120108. * value would be set.
  120109. */
  120110. enableUnpackFlipYCached: boolean;
  120111. /** @hidden */
  120112. _unpackFlipY(value: boolean): void;
  120113. /** @hidden */
  120114. _getUnpackAlignement(): number;
  120115. private _getTextureTarget;
  120116. /**
  120117. * Update the sampling mode of a given texture
  120118. * @param samplingMode defines the required sampling mode
  120119. * @param texture defines the texture to update
  120120. * @param generateMipMaps defines whether to generate mipmaps for the texture
  120121. */
  120122. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  120123. /**
  120124. * Update the sampling mode of a given texture
  120125. * @param texture defines the texture to update
  120126. * @param wrapU defines the texture wrap mode of the u coordinates
  120127. * @param wrapV defines the texture wrap mode of the v coordinates
  120128. * @param wrapR defines the texture wrap mode of the r coordinates
  120129. */
  120130. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  120131. /** @hidden */
  120132. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  120133. width: number;
  120134. height: number;
  120135. layers?: number;
  120136. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  120137. /** @hidden */
  120138. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120139. /** @hidden */
  120140. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  120141. /**
  120142. * Update a portion of an internal texture
  120143. * @param texture defines the texture to update
  120144. * @param imageData defines the data to store into the texture
  120145. * @param xOffset defines the x coordinates of the update rectangle
  120146. * @param yOffset defines the y coordinates of the update rectangle
  120147. * @param width defines the width of the update rectangle
  120148. * @param height defines the height of the update rectangle
  120149. * @param faceIndex defines the face index if texture is a cube (0 by default)
  120150. * @param lod defines the lod level to update (0 by default)
  120151. */
  120152. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  120153. /** @hidden */
  120154. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120155. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  120156. private _prepareWebGLTexture;
  120157. /** @hidden */
  120158. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  120159. private _getDepthStencilBuffer;
  120160. /** @hidden */
  120161. _releaseFramebufferObjects(texture: InternalTexture): void;
  120162. /** @hidden */
  120163. _releaseTexture(texture: InternalTexture): void;
  120164. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120165. protected _setProgram(program: WebGLProgram): void;
  120166. protected _boundUniforms: {
  120167. [key: number]: WebGLUniformLocation;
  120168. };
  120169. /**
  120170. * Binds an effect to the webGL context
  120171. * @param effect defines the effect to bind
  120172. */
  120173. bindSamplers(effect: Effect): void;
  120174. private _activateCurrentTexture;
  120175. /** @hidden */
  120176. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  120177. /** @hidden */
  120178. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  120179. /**
  120180. * Unbind all textures from the webGL context
  120181. */
  120182. unbindAllTextures(): void;
  120183. /**
  120184. * Sets a texture to the according uniform.
  120185. * @param channel The texture channel
  120186. * @param uniform The uniform to set
  120187. * @param texture The texture to apply
  120188. */
  120189. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  120190. private _bindSamplerUniformToChannel;
  120191. private _getTextureWrapMode;
  120192. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120193. /**
  120194. * Sets an array of texture to the webGL context
  120195. * @param channel defines the channel where the texture array must be set
  120196. * @param uniform defines the associated uniform location
  120197. * @param textures defines the array of textures to bind
  120198. */
  120199. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  120200. /** @hidden */
  120201. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  120202. private _setTextureParameterFloat;
  120203. private _setTextureParameterInteger;
  120204. /**
  120205. * Unbind all vertex attributes from the webGL context
  120206. */
  120207. unbindAllAttributes(): void;
  120208. /**
  120209. * 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
  120210. */
  120211. releaseEffects(): void;
  120212. /**
  120213. * Dispose and release all associated resources
  120214. */
  120215. dispose(): void;
  120216. /**
  120217. * Attach a new callback raised when context lost event is fired
  120218. * @param callback defines the callback to call
  120219. */
  120220. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120221. /**
  120222. * Attach a new callback raised when context restored event is fired
  120223. * @param callback defines the callback to call
  120224. */
  120225. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120226. /**
  120227. * Get the current error code of the webGL context
  120228. * @returns the error code
  120229. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120230. */
  120231. getError(): number;
  120232. private _canRenderToFloatFramebuffer;
  120233. private _canRenderToHalfFloatFramebuffer;
  120234. private _canRenderToFramebuffer;
  120235. /** @hidden */
  120236. _getWebGLTextureType(type: number): number;
  120237. /** @hidden */
  120238. _getInternalFormat(format: number): number;
  120239. /** @hidden */
  120240. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  120241. /** @hidden */
  120242. _getRGBAMultiSampleBufferFormat(type: number): number;
  120243. /** @hidden */
  120244. _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;
  120245. /**
  120246. * Loads a file from a url
  120247. * @param url url to load
  120248. * @param onSuccess callback called when the file successfully loads
  120249. * @param onProgress callback called while file is loading (if the server supports this mode)
  120250. * @param offlineProvider defines the offline provider for caching
  120251. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  120252. * @param onError callback called when the file fails to load
  120253. * @returns a file request object
  120254. * @hidden
  120255. */
  120256. 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;
  120257. /**
  120258. * Reads pixels from the current frame buffer. Please note that this function can be slow
  120259. * @param x defines the x coordinate of the rectangle where pixels must be read
  120260. * @param y defines the y coordinate of the rectangle where pixels must be read
  120261. * @param width defines the width of the rectangle where pixels must be read
  120262. * @param height defines the height of the rectangle where pixels must be read
  120263. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  120264. * @returns a Uint8Array containing RGBA colors
  120265. */
  120266. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  120267. private static _IsSupported;
  120268. private static _HasMajorPerformanceCaveat;
  120269. /**
  120270. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120271. */
  120272. static get IsSupported(): boolean;
  120273. /**
  120274. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120275. * @returns true if the engine can be created
  120276. * @ignorenaming
  120277. */
  120278. static isSupported(): boolean;
  120279. /**
  120280. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  120281. */
  120282. static get HasMajorPerformanceCaveat(): boolean;
  120283. /**
  120284. * Find the next highest power of two.
  120285. * @param x Number to start search from.
  120286. * @return Next highest power of two.
  120287. */
  120288. static CeilingPOT(x: number): number;
  120289. /**
  120290. * Find the next lowest power of two.
  120291. * @param x Number to start search from.
  120292. * @return Next lowest power of two.
  120293. */
  120294. static FloorPOT(x: number): number;
  120295. /**
  120296. * Find the nearest power of two.
  120297. * @param x Number to start search from.
  120298. * @return Next nearest power of two.
  120299. */
  120300. static NearestPOT(x: number): number;
  120301. /**
  120302. * Get the closest exponent of two
  120303. * @param value defines the value to approximate
  120304. * @param max defines the maximum value to return
  120305. * @param mode defines how to define the closest value
  120306. * @returns closest exponent of two of the given value
  120307. */
  120308. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  120309. /**
  120310. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  120311. * @param func - the function to be called
  120312. * @param requester - the object that will request the next frame. Falls back to window.
  120313. * @returns frame number
  120314. */
  120315. static QueueNewFrame(func: () => void, requester?: any): number;
  120316. /**
  120317. * Gets host document
  120318. * @returns the host document object
  120319. */
  120320. getHostDocument(): Nullable<Document>;
  120321. }
  120322. }
  120323. declare module BABYLON {
  120324. /**
  120325. * Defines the source of the internal texture
  120326. */
  120327. export enum InternalTextureSource {
  120328. /**
  120329. * The source of the texture data is unknown
  120330. */
  120331. Unknown = 0,
  120332. /**
  120333. * Texture data comes from an URL
  120334. */
  120335. Url = 1,
  120336. /**
  120337. * Texture data is only used for temporary storage
  120338. */
  120339. Temp = 2,
  120340. /**
  120341. * Texture data comes from raw data (ArrayBuffer)
  120342. */
  120343. Raw = 3,
  120344. /**
  120345. * Texture content is dynamic (video or dynamic texture)
  120346. */
  120347. Dynamic = 4,
  120348. /**
  120349. * Texture content is generated by rendering to it
  120350. */
  120351. RenderTarget = 5,
  120352. /**
  120353. * Texture content is part of a multi render target process
  120354. */
  120355. MultiRenderTarget = 6,
  120356. /**
  120357. * Texture data comes from a cube data file
  120358. */
  120359. Cube = 7,
  120360. /**
  120361. * Texture data comes from a raw cube data
  120362. */
  120363. CubeRaw = 8,
  120364. /**
  120365. * Texture data come from a prefiltered cube data file
  120366. */
  120367. CubePrefiltered = 9,
  120368. /**
  120369. * Texture content is raw 3D data
  120370. */
  120371. Raw3D = 10,
  120372. /**
  120373. * Texture content is raw 2D array data
  120374. */
  120375. Raw2DArray = 11,
  120376. /**
  120377. * Texture content is a depth texture
  120378. */
  120379. Depth = 12,
  120380. /**
  120381. * Texture data comes from a raw cube data encoded with RGBD
  120382. */
  120383. CubeRawRGBD = 13
  120384. }
  120385. /**
  120386. * Class used to store data associated with WebGL texture data for the engine
  120387. * This class should not be used directly
  120388. */
  120389. export class InternalTexture {
  120390. /** @hidden */
  120391. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  120392. /**
  120393. * Defines if the texture is ready
  120394. */
  120395. isReady: boolean;
  120396. /**
  120397. * Defines if the texture is a cube texture
  120398. */
  120399. isCube: boolean;
  120400. /**
  120401. * Defines if the texture contains 3D data
  120402. */
  120403. is3D: boolean;
  120404. /**
  120405. * Defines if the texture contains 2D array data
  120406. */
  120407. is2DArray: boolean;
  120408. /**
  120409. * Defines if the texture contains multiview data
  120410. */
  120411. isMultiview: boolean;
  120412. /**
  120413. * Gets the URL used to load this texture
  120414. */
  120415. url: string;
  120416. /**
  120417. * Gets the sampling mode of the texture
  120418. */
  120419. samplingMode: number;
  120420. /**
  120421. * Gets a boolean indicating if the texture needs mipmaps generation
  120422. */
  120423. generateMipMaps: boolean;
  120424. /**
  120425. * Gets the number of samples used by the texture (WebGL2+ only)
  120426. */
  120427. samples: number;
  120428. /**
  120429. * Gets the type of the texture (int, float...)
  120430. */
  120431. type: number;
  120432. /**
  120433. * Gets the format of the texture (RGB, RGBA...)
  120434. */
  120435. format: number;
  120436. /**
  120437. * Observable called when the texture is loaded
  120438. */
  120439. onLoadedObservable: Observable<InternalTexture>;
  120440. /**
  120441. * Gets the width of the texture
  120442. */
  120443. width: number;
  120444. /**
  120445. * Gets the height of the texture
  120446. */
  120447. height: number;
  120448. /**
  120449. * Gets the depth of the texture
  120450. */
  120451. depth: number;
  120452. /**
  120453. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  120454. */
  120455. baseWidth: number;
  120456. /**
  120457. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  120458. */
  120459. baseHeight: number;
  120460. /**
  120461. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  120462. */
  120463. baseDepth: number;
  120464. /**
  120465. * Gets a boolean indicating if the texture is inverted on Y axis
  120466. */
  120467. invertY: boolean;
  120468. /** @hidden */
  120469. _invertVScale: boolean;
  120470. /** @hidden */
  120471. _associatedChannel: number;
  120472. /** @hidden */
  120473. _source: InternalTextureSource;
  120474. /** @hidden */
  120475. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  120476. /** @hidden */
  120477. _bufferView: Nullable<ArrayBufferView>;
  120478. /** @hidden */
  120479. _bufferViewArray: Nullable<ArrayBufferView[]>;
  120480. /** @hidden */
  120481. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  120482. /** @hidden */
  120483. _size: number;
  120484. /** @hidden */
  120485. _extension: string;
  120486. /** @hidden */
  120487. _files: Nullable<string[]>;
  120488. /** @hidden */
  120489. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120490. /** @hidden */
  120491. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120492. /** @hidden */
  120493. _framebuffer: Nullable<WebGLFramebuffer>;
  120494. /** @hidden */
  120495. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  120496. /** @hidden */
  120497. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  120498. /** @hidden */
  120499. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  120500. /** @hidden */
  120501. _attachments: Nullable<number[]>;
  120502. /** @hidden */
  120503. _textureArray: Nullable<InternalTexture[]>;
  120504. /** @hidden */
  120505. _cachedCoordinatesMode: Nullable<number>;
  120506. /** @hidden */
  120507. _cachedWrapU: Nullable<number>;
  120508. /** @hidden */
  120509. _cachedWrapV: Nullable<number>;
  120510. /** @hidden */
  120511. _cachedWrapR: Nullable<number>;
  120512. /** @hidden */
  120513. _cachedAnisotropicFilteringLevel: Nullable<number>;
  120514. /** @hidden */
  120515. _isDisabled: boolean;
  120516. /** @hidden */
  120517. _compression: Nullable<string>;
  120518. /** @hidden */
  120519. _generateStencilBuffer: boolean;
  120520. /** @hidden */
  120521. _generateDepthBuffer: boolean;
  120522. /** @hidden */
  120523. _comparisonFunction: number;
  120524. /** @hidden */
  120525. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  120526. /** @hidden */
  120527. _lodGenerationScale: number;
  120528. /** @hidden */
  120529. _lodGenerationOffset: number;
  120530. /** @hidden */
  120531. _depthStencilTexture: Nullable<InternalTexture>;
  120532. /** @hidden */
  120533. _colorTextureArray: Nullable<WebGLTexture>;
  120534. /** @hidden */
  120535. _depthStencilTextureArray: Nullable<WebGLTexture>;
  120536. /** @hidden */
  120537. _lodTextureHigh: Nullable<BaseTexture>;
  120538. /** @hidden */
  120539. _lodTextureMid: Nullable<BaseTexture>;
  120540. /** @hidden */
  120541. _lodTextureLow: Nullable<BaseTexture>;
  120542. /** @hidden */
  120543. _isRGBD: boolean;
  120544. /** @hidden */
  120545. _linearSpecularLOD: boolean;
  120546. /** @hidden */
  120547. _irradianceTexture: Nullable<BaseTexture>;
  120548. /** @hidden */
  120549. _webGLTexture: Nullable<WebGLTexture>;
  120550. /** @hidden */
  120551. _references: number;
  120552. /** @hidden */
  120553. _gammaSpace: Nullable<boolean>;
  120554. private _engine;
  120555. /**
  120556. * Gets the Engine the texture belongs to.
  120557. * @returns The babylon engine
  120558. */
  120559. getEngine(): ThinEngine;
  120560. /**
  120561. * Gets the data source type of the texture
  120562. */
  120563. get source(): InternalTextureSource;
  120564. /**
  120565. * Creates a new InternalTexture
  120566. * @param engine defines the engine to use
  120567. * @param source defines the type of data that will be used
  120568. * @param delayAllocation if the texture allocation should be delayed (default: false)
  120569. */
  120570. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  120571. /**
  120572. * Increments the number of references (ie. the number of Texture that point to it)
  120573. */
  120574. incrementReferences(): void;
  120575. /**
  120576. * Change the size of the texture (not the size of the content)
  120577. * @param width defines the new width
  120578. * @param height defines the new height
  120579. * @param depth defines the new depth (1 by default)
  120580. */
  120581. updateSize(width: int, height: int, depth?: int): void;
  120582. /** @hidden */
  120583. _rebuild(): void;
  120584. /** @hidden */
  120585. _swapAndDie(target: InternalTexture): void;
  120586. /**
  120587. * Dispose the current allocated resources
  120588. */
  120589. dispose(): void;
  120590. }
  120591. }
  120592. declare module BABYLON {
  120593. /**
  120594. * Class used to work with sound analyzer using fast fourier transform (FFT)
  120595. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120596. */
  120597. export class Analyser {
  120598. /**
  120599. * Gets or sets the smoothing
  120600. * @ignorenaming
  120601. */
  120602. SMOOTHING: number;
  120603. /**
  120604. * Gets or sets the FFT table size
  120605. * @ignorenaming
  120606. */
  120607. FFT_SIZE: number;
  120608. /**
  120609. * Gets or sets the bar graph amplitude
  120610. * @ignorenaming
  120611. */
  120612. BARGRAPHAMPLITUDE: number;
  120613. /**
  120614. * Gets or sets the position of the debug canvas
  120615. * @ignorenaming
  120616. */
  120617. DEBUGCANVASPOS: {
  120618. x: number;
  120619. y: number;
  120620. };
  120621. /**
  120622. * Gets or sets the debug canvas size
  120623. * @ignorenaming
  120624. */
  120625. DEBUGCANVASSIZE: {
  120626. width: number;
  120627. height: number;
  120628. };
  120629. private _byteFreqs;
  120630. private _byteTime;
  120631. private _floatFreqs;
  120632. private _webAudioAnalyser;
  120633. private _debugCanvas;
  120634. private _debugCanvasContext;
  120635. private _scene;
  120636. private _registerFunc;
  120637. private _audioEngine;
  120638. /**
  120639. * Creates a new analyser
  120640. * @param scene defines hosting scene
  120641. */
  120642. constructor(scene: Scene);
  120643. /**
  120644. * Get the number of data values you will have to play with for the visualization
  120645. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  120646. * @returns a number
  120647. */
  120648. getFrequencyBinCount(): number;
  120649. /**
  120650. * Gets the current frequency data as a byte array
  120651. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120652. * @returns a Uint8Array
  120653. */
  120654. getByteFrequencyData(): Uint8Array;
  120655. /**
  120656. * Gets the current waveform as a byte array
  120657. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  120658. * @returns a Uint8Array
  120659. */
  120660. getByteTimeDomainData(): Uint8Array;
  120661. /**
  120662. * Gets the current frequency data as a float array
  120663. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120664. * @returns a Float32Array
  120665. */
  120666. getFloatFrequencyData(): Float32Array;
  120667. /**
  120668. * Renders the debug canvas
  120669. */
  120670. drawDebugCanvas(): void;
  120671. /**
  120672. * Stops rendering the debug canvas and removes it
  120673. */
  120674. stopDebugCanvas(): void;
  120675. /**
  120676. * Connects two audio nodes
  120677. * @param inputAudioNode defines first node to connect
  120678. * @param outputAudioNode defines second node to connect
  120679. */
  120680. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  120681. /**
  120682. * Releases all associated resources
  120683. */
  120684. dispose(): void;
  120685. }
  120686. }
  120687. declare module BABYLON {
  120688. /**
  120689. * This represents an audio engine and it is responsible
  120690. * to play, synchronize and analyse sounds throughout the application.
  120691. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120692. */
  120693. export interface IAudioEngine extends IDisposable {
  120694. /**
  120695. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120696. */
  120697. readonly canUseWebAudio: boolean;
  120698. /**
  120699. * Gets the current AudioContext if available.
  120700. */
  120701. readonly audioContext: Nullable<AudioContext>;
  120702. /**
  120703. * The master gain node defines the global audio volume of your audio engine.
  120704. */
  120705. readonly masterGain: GainNode;
  120706. /**
  120707. * Gets whether or not mp3 are supported by your browser.
  120708. */
  120709. readonly isMP3supported: boolean;
  120710. /**
  120711. * Gets whether or not ogg are supported by your browser.
  120712. */
  120713. readonly isOGGsupported: boolean;
  120714. /**
  120715. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120716. * @ignoreNaming
  120717. */
  120718. WarnedWebAudioUnsupported: boolean;
  120719. /**
  120720. * Defines if the audio engine relies on a custom unlocked button.
  120721. * In this case, the embedded button will not be displayed.
  120722. */
  120723. useCustomUnlockedButton: boolean;
  120724. /**
  120725. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  120726. */
  120727. readonly unlocked: boolean;
  120728. /**
  120729. * Event raised when audio has been unlocked on the browser.
  120730. */
  120731. onAudioUnlockedObservable: Observable<AudioEngine>;
  120732. /**
  120733. * Event raised when audio has been locked on the browser.
  120734. */
  120735. onAudioLockedObservable: Observable<AudioEngine>;
  120736. /**
  120737. * Flags the audio engine in Locked state.
  120738. * This happens due to new browser policies preventing audio to autoplay.
  120739. */
  120740. lock(): void;
  120741. /**
  120742. * Unlocks the audio engine once a user action has been done on the dom.
  120743. * This is helpful to resume play once browser policies have been satisfied.
  120744. */
  120745. unlock(): void;
  120746. /**
  120747. * Gets the global volume sets on the master gain.
  120748. * @returns the global volume if set or -1 otherwise
  120749. */
  120750. getGlobalVolume(): number;
  120751. /**
  120752. * Sets the global volume of your experience (sets on the master gain).
  120753. * @param newVolume Defines the new global volume of the application
  120754. */
  120755. setGlobalVolume(newVolume: number): void;
  120756. /**
  120757. * Connect the audio engine to an audio analyser allowing some amazing
  120758. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120759. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120760. * @param analyser The analyser to connect to the engine
  120761. */
  120762. connectToAnalyser(analyser: Analyser): void;
  120763. }
  120764. /**
  120765. * This represents the default audio engine used in babylon.
  120766. * It is responsible to play, synchronize and analyse sounds throughout the application.
  120767. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120768. */
  120769. export class AudioEngine implements IAudioEngine {
  120770. private _audioContext;
  120771. private _audioContextInitialized;
  120772. private _muteButton;
  120773. private _hostElement;
  120774. /**
  120775. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120776. */
  120777. canUseWebAudio: boolean;
  120778. /**
  120779. * The master gain node defines the global audio volume of your audio engine.
  120780. */
  120781. masterGain: GainNode;
  120782. /**
  120783. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120784. * @ignoreNaming
  120785. */
  120786. WarnedWebAudioUnsupported: boolean;
  120787. /**
  120788. * Gets whether or not mp3 are supported by your browser.
  120789. */
  120790. isMP3supported: boolean;
  120791. /**
  120792. * Gets whether or not ogg are supported by your browser.
  120793. */
  120794. isOGGsupported: boolean;
  120795. /**
  120796. * Gets whether audio has been unlocked on the device.
  120797. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  120798. * a user interaction has happened.
  120799. */
  120800. unlocked: boolean;
  120801. /**
  120802. * Defines if the audio engine relies on a custom unlocked button.
  120803. * In this case, the embedded button will not be displayed.
  120804. */
  120805. useCustomUnlockedButton: boolean;
  120806. /**
  120807. * Event raised when audio has been unlocked on the browser.
  120808. */
  120809. onAudioUnlockedObservable: Observable<AudioEngine>;
  120810. /**
  120811. * Event raised when audio has been locked on the browser.
  120812. */
  120813. onAudioLockedObservable: Observable<AudioEngine>;
  120814. /**
  120815. * Gets the current AudioContext if available.
  120816. */
  120817. get audioContext(): Nullable<AudioContext>;
  120818. private _connectedAnalyser;
  120819. /**
  120820. * Instantiates a new audio engine.
  120821. *
  120822. * There should be only one per page as some browsers restrict the number
  120823. * of audio contexts you can create.
  120824. * @param hostElement defines the host element where to display the mute icon if necessary
  120825. */
  120826. constructor(hostElement?: Nullable<HTMLElement>);
  120827. /**
  120828. * Flags the audio engine in Locked state.
  120829. * This happens due to new browser policies preventing audio to autoplay.
  120830. */
  120831. lock(): void;
  120832. /**
  120833. * Unlocks the audio engine once a user action has been done on the dom.
  120834. * This is helpful to resume play once browser policies have been satisfied.
  120835. */
  120836. unlock(): void;
  120837. private _resumeAudioContext;
  120838. private _initializeAudioContext;
  120839. private _tryToRun;
  120840. private _triggerRunningState;
  120841. private _triggerSuspendedState;
  120842. private _displayMuteButton;
  120843. private _moveButtonToTopLeft;
  120844. private _onResize;
  120845. private _hideMuteButton;
  120846. /**
  120847. * Destroy and release the resources associated with the audio ccontext.
  120848. */
  120849. dispose(): void;
  120850. /**
  120851. * Gets the global volume sets on the master gain.
  120852. * @returns the global volume if set or -1 otherwise
  120853. */
  120854. getGlobalVolume(): number;
  120855. /**
  120856. * Sets the global volume of your experience (sets on the master gain).
  120857. * @param newVolume Defines the new global volume of the application
  120858. */
  120859. setGlobalVolume(newVolume: number): void;
  120860. /**
  120861. * Connect the audio engine to an audio analyser allowing some amazing
  120862. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120863. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120864. * @param analyser The analyser to connect to the engine
  120865. */
  120866. connectToAnalyser(analyser: Analyser): void;
  120867. }
  120868. }
  120869. declare module BABYLON {
  120870. /**
  120871. * Interface used to present a loading screen while loading a scene
  120872. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120873. */
  120874. export interface ILoadingScreen {
  120875. /**
  120876. * Function called to display the loading screen
  120877. */
  120878. displayLoadingUI: () => void;
  120879. /**
  120880. * Function called to hide the loading screen
  120881. */
  120882. hideLoadingUI: () => void;
  120883. /**
  120884. * Gets or sets the color to use for the background
  120885. */
  120886. loadingUIBackgroundColor: string;
  120887. /**
  120888. * Gets or sets the text to display while loading
  120889. */
  120890. loadingUIText: string;
  120891. }
  120892. /**
  120893. * Class used for the default loading screen
  120894. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120895. */
  120896. export class DefaultLoadingScreen implements ILoadingScreen {
  120897. private _renderingCanvas;
  120898. private _loadingText;
  120899. private _loadingDivBackgroundColor;
  120900. private _loadingDiv;
  120901. private _loadingTextDiv;
  120902. /** Gets or sets the logo url to use for the default loading screen */
  120903. static DefaultLogoUrl: string;
  120904. /** Gets or sets the spinner url to use for the default loading screen */
  120905. static DefaultSpinnerUrl: string;
  120906. /**
  120907. * Creates a new default loading screen
  120908. * @param _renderingCanvas defines the canvas used to render the scene
  120909. * @param _loadingText defines the default text to display
  120910. * @param _loadingDivBackgroundColor defines the default background color
  120911. */
  120912. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  120913. /**
  120914. * Function called to display the loading screen
  120915. */
  120916. displayLoadingUI(): void;
  120917. /**
  120918. * Function called to hide the loading screen
  120919. */
  120920. hideLoadingUI(): void;
  120921. /**
  120922. * Gets or sets the text to display while loading
  120923. */
  120924. set loadingUIText(text: string);
  120925. get loadingUIText(): string;
  120926. /**
  120927. * Gets or sets the color to use for the background
  120928. */
  120929. get loadingUIBackgroundColor(): string;
  120930. set loadingUIBackgroundColor(color: string);
  120931. private _resizeLoadingUI;
  120932. }
  120933. }
  120934. declare module BABYLON {
  120935. /**
  120936. * Interface for any object that can request an animation frame
  120937. */
  120938. export interface ICustomAnimationFrameRequester {
  120939. /**
  120940. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  120941. */
  120942. renderFunction?: Function;
  120943. /**
  120944. * Called to request the next frame to render to
  120945. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  120946. */
  120947. requestAnimationFrame: Function;
  120948. /**
  120949. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  120950. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  120951. */
  120952. requestID?: number;
  120953. }
  120954. }
  120955. declare module BABYLON {
  120956. /**
  120957. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  120958. */
  120959. export class PerformanceMonitor {
  120960. private _enabled;
  120961. private _rollingFrameTime;
  120962. private _lastFrameTimeMs;
  120963. /**
  120964. * constructor
  120965. * @param frameSampleSize The number of samples required to saturate the sliding window
  120966. */
  120967. constructor(frameSampleSize?: number);
  120968. /**
  120969. * Samples current frame
  120970. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  120971. */
  120972. sampleFrame(timeMs?: number): void;
  120973. /**
  120974. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120975. */
  120976. get averageFrameTime(): number;
  120977. /**
  120978. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120979. */
  120980. get averageFrameTimeVariance(): number;
  120981. /**
  120982. * Returns the frame time of the most recent frame
  120983. */
  120984. get instantaneousFrameTime(): number;
  120985. /**
  120986. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  120987. */
  120988. get averageFPS(): number;
  120989. /**
  120990. * Returns the average framerate in frames per second using the most recent frame time
  120991. */
  120992. get instantaneousFPS(): number;
  120993. /**
  120994. * Returns true if enough samples have been taken to completely fill the sliding window
  120995. */
  120996. get isSaturated(): boolean;
  120997. /**
  120998. * Enables contributions to the sliding window sample set
  120999. */
  121000. enable(): void;
  121001. /**
  121002. * Disables contributions to the sliding window sample set
  121003. * Samples will not be interpolated over the disabled period
  121004. */
  121005. disable(): void;
  121006. /**
  121007. * Returns true if sampling is enabled
  121008. */
  121009. get isEnabled(): boolean;
  121010. /**
  121011. * Resets performance monitor
  121012. */
  121013. reset(): void;
  121014. }
  121015. /**
  121016. * RollingAverage
  121017. *
  121018. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  121019. */
  121020. export class RollingAverage {
  121021. /**
  121022. * Current average
  121023. */
  121024. average: number;
  121025. /**
  121026. * Current variance
  121027. */
  121028. variance: number;
  121029. protected _samples: Array<number>;
  121030. protected _sampleCount: number;
  121031. protected _pos: number;
  121032. protected _m2: number;
  121033. /**
  121034. * constructor
  121035. * @param length The number of samples required to saturate the sliding window
  121036. */
  121037. constructor(length: number);
  121038. /**
  121039. * Adds a sample to the sample set
  121040. * @param v The sample value
  121041. */
  121042. add(v: number): void;
  121043. /**
  121044. * Returns previously added values or null if outside of history or outside the sliding window domain
  121045. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  121046. * @return Value previously recorded with add() or null if outside of range
  121047. */
  121048. history(i: number): number;
  121049. /**
  121050. * Returns true if enough samples have been taken to completely fill the sliding window
  121051. * @return true if sample-set saturated
  121052. */
  121053. isSaturated(): boolean;
  121054. /**
  121055. * Resets the rolling average (equivalent to 0 samples taken so far)
  121056. */
  121057. reset(): void;
  121058. /**
  121059. * Wraps a value around the sample range boundaries
  121060. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  121061. * @return Wrapped position in sample range
  121062. */
  121063. protected _wrapPosition(i: number): number;
  121064. }
  121065. }
  121066. declare module BABYLON {
  121067. /**
  121068. * This class is used to track a performance counter which is number based.
  121069. * The user has access to many properties which give statistics of different nature.
  121070. *
  121071. * The implementer can track two kinds of Performance Counter: time and count.
  121072. * 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.
  121073. * 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.
  121074. */
  121075. export class PerfCounter {
  121076. /**
  121077. * Gets or sets a global boolean to turn on and off all the counters
  121078. */
  121079. static Enabled: boolean;
  121080. /**
  121081. * Returns the smallest value ever
  121082. */
  121083. get min(): number;
  121084. /**
  121085. * Returns the biggest value ever
  121086. */
  121087. get max(): number;
  121088. /**
  121089. * Returns the average value since the performance counter is running
  121090. */
  121091. get average(): number;
  121092. /**
  121093. * Returns the average value of the last second the counter was monitored
  121094. */
  121095. get lastSecAverage(): number;
  121096. /**
  121097. * Returns the current value
  121098. */
  121099. get current(): number;
  121100. /**
  121101. * Gets the accumulated total
  121102. */
  121103. get total(): number;
  121104. /**
  121105. * Gets the total value count
  121106. */
  121107. get count(): number;
  121108. /**
  121109. * Creates a new counter
  121110. */
  121111. constructor();
  121112. /**
  121113. * Call this method to start monitoring a new frame.
  121114. * 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.
  121115. */
  121116. fetchNewFrame(): void;
  121117. /**
  121118. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  121119. * @param newCount the count value to add to the monitored count
  121120. * @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.
  121121. */
  121122. addCount(newCount: number, fetchResult: boolean): void;
  121123. /**
  121124. * Start monitoring this performance counter
  121125. */
  121126. beginMonitoring(): void;
  121127. /**
  121128. * Compute the time lapsed since the previous beginMonitoring() call.
  121129. * @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
  121130. */
  121131. endMonitoring(newFrame?: boolean): void;
  121132. private _fetchResult;
  121133. private _startMonitoringTime;
  121134. private _min;
  121135. private _max;
  121136. private _average;
  121137. private _current;
  121138. private _totalValueCount;
  121139. private _totalAccumulated;
  121140. private _lastSecAverage;
  121141. private _lastSecAccumulated;
  121142. private _lastSecTime;
  121143. private _lastSecValueCount;
  121144. }
  121145. }
  121146. declare module BABYLON {
  121147. interface ThinEngine {
  121148. /** @hidden */
  121149. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  121150. }
  121151. }
  121152. declare module BABYLON {
  121153. /**
  121154. * Defines the interface used by display changed events
  121155. */
  121156. export interface IDisplayChangedEventArgs {
  121157. /** Gets the vrDisplay object (if any) */
  121158. vrDisplay: Nullable<any>;
  121159. /** Gets a boolean indicating if webVR is supported */
  121160. vrSupported: boolean;
  121161. }
  121162. /**
  121163. * Defines the interface used by objects containing a viewport (like a camera)
  121164. */
  121165. interface IViewportOwnerLike {
  121166. /**
  121167. * Gets or sets the viewport
  121168. */
  121169. viewport: IViewportLike;
  121170. }
  121171. /**
  121172. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  121173. */
  121174. export class Engine extends ThinEngine {
  121175. /** Defines that alpha blending is disabled */
  121176. static readonly ALPHA_DISABLE: number;
  121177. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  121178. static readonly ALPHA_ADD: number;
  121179. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  121180. static readonly ALPHA_COMBINE: number;
  121181. /** Defines that alpha blending to DEST - SRC * DEST */
  121182. static readonly ALPHA_SUBTRACT: number;
  121183. /** Defines that alpha blending to SRC * DEST */
  121184. static readonly ALPHA_MULTIPLY: number;
  121185. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  121186. static readonly ALPHA_MAXIMIZED: number;
  121187. /** Defines that alpha blending to SRC + DEST */
  121188. static readonly ALPHA_ONEONE: number;
  121189. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  121190. static readonly ALPHA_PREMULTIPLIED: number;
  121191. /**
  121192. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  121193. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  121194. */
  121195. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  121196. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  121197. static readonly ALPHA_INTERPOLATE: number;
  121198. /**
  121199. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  121200. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  121201. */
  121202. static readonly ALPHA_SCREENMODE: number;
  121203. /** Defines that the ressource is not delayed*/
  121204. static readonly DELAYLOADSTATE_NONE: number;
  121205. /** Defines that the ressource was successfully delay loaded */
  121206. static readonly DELAYLOADSTATE_LOADED: number;
  121207. /** Defines that the ressource is currently delay loading */
  121208. static readonly DELAYLOADSTATE_LOADING: number;
  121209. /** Defines that the ressource is delayed and has not started loading */
  121210. static readonly DELAYLOADSTATE_NOTLOADED: number;
  121211. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  121212. static readonly NEVER: number;
  121213. /** 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 */
  121214. static readonly ALWAYS: number;
  121215. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  121216. static readonly LESS: number;
  121217. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  121218. static readonly EQUAL: number;
  121219. /** 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 */
  121220. static readonly LEQUAL: number;
  121221. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  121222. static readonly GREATER: number;
  121223. /** 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 */
  121224. static readonly GEQUAL: number;
  121225. /** 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 */
  121226. static readonly NOTEQUAL: number;
  121227. /** Passed to stencilOperation to specify that stencil value must be kept */
  121228. static readonly KEEP: number;
  121229. /** Passed to stencilOperation to specify that stencil value must be replaced */
  121230. static readonly REPLACE: number;
  121231. /** Passed to stencilOperation to specify that stencil value must be incremented */
  121232. static readonly INCR: number;
  121233. /** Passed to stencilOperation to specify that stencil value must be decremented */
  121234. static readonly DECR: number;
  121235. /** Passed to stencilOperation to specify that stencil value must be inverted */
  121236. static readonly INVERT: number;
  121237. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  121238. static readonly INCR_WRAP: number;
  121239. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  121240. static readonly DECR_WRAP: number;
  121241. /** Texture is not repeating outside of 0..1 UVs */
  121242. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  121243. /** Texture is repeating outside of 0..1 UVs */
  121244. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  121245. /** Texture is repeating and mirrored */
  121246. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  121247. /** ALPHA */
  121248. static readonly TEXTUREFORMAT_ALPHA: number;
  121249. /** LUMINANCE */
  121250. static readonly TEXTUREFORMAT_LUMINANCE: number;
  121251. /** LUMINANCE_ALPHA */
  121252. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  121253. /** RGB */
  121254. static readonly TEXTUREFORMAT_RGB: number;
  121255. /** RGBA */
  121256. static readonly TEXTUREFORMAT_RGBA: number;
  121257. /** RED */
  121258. static readonly TEXTUREFORMAT_RED: number;
  121259. /** RED (2nd reference) */
  121260. static readonly TEXTUREFORMAT_R: number;
  121261. /** RG */
  121262. static readonly TEXTUREFORMAT_RG: number;
  121263. /** RED_INTEGER */
  121264. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121265. /** RED_INTEGER (2nd reference) */
  121266. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121267. /** RG_INTEGER */
  121268. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121269. /** RGB_INTEGER */
  121270. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121271. /** RGBA_INTEGER */
  121272. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121273. /** UNSIGNED_BYTE */
  121274. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121275. /** UNSIGNED_BYTE (2nd reference) */
  121276. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121277. /** FLOAT */
  121278. static readonly TEXTURETYPE_FLOAT: number;
  121279. /** HALF_FLOAT */
  121280. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121281. /** BYTE */
  121282. static readonly TEXTURETYPE_BYTE: number;
  121283. /** SHORT */
  121284. static readonly TEXTURETYPE_SHORT: number;
  121285. /** UNSIGNED_SHORT */
  121286. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121287. /** INT */
  121288. static readonly TEXTURETYPE_INT: number;
  121289. /** UNSIGNED_INT */
  121290. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121291. /** UNSIGNED_SHORT_4_4_4_4 */
  121292. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121293. /** UNSIGNED_SHORT_5_5_5_1 */
  121294. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121295. /** UNSIGNED_SHORT_5_6_5 */
  121296. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121297. /** UNSIGNED_INT_2_10_10_10_REV */
  121298. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121299. /** UNSIGNED_INT_24_8 */
  121300. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121301. /** UNSIGNED_INT_10F_11F_11F_REV */
  121302. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121303. /** UNSIGNED_INT_5_9_9_9_REV */
  121304. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121305. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121306. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121307. /** nearest is mag = nearest and min = nearest and mip = linear */
  121308. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121309. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121310. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121311. /** Trilinear is mag = linear and min = linear and mip = linear */
  121312. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121313. /** nearest is mag = nearest and min = nearest and mip = linear */
  121314. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121315. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121316. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121317. /** Trilinear is mag = linear and min = linear and mip = linear */
  121318. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121319. /** mag = nearest and min = nearest and mip = nearest */
  121320. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121321. /** mag = nearest and min = linear and mip = nearest */
  121322. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121323. /** mag = nearest and min = linear and mip = linear */
  121324. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121325. /** mag = nearest and min = linear and mip = none */
  121326. static readonly TEXTURE_NEAREST_LINEAR: number;
  121327. /** mag = nearest and min = nearest and mip = none */
  121328. static readonly TEXTURE_NEAREST_NEAREST: number;
  121329. /** mag = linear and min = nearest and mip = nearest */
  121330. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121331. /** mag = linear and min = nearest and mip = linear */
  121332. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121333. /** mag = linear and min = linear and mip = none */
  121334. static readonly TEXTURE_LINEAR_LINEAR: number;
  121335. /** mag = linear and min = nearest and mip = none */
  121336. static readonly TEXTURE_LINEAR_NEAREST: number;
  121337. /** Explicit coordinates mode */
  121338. static readonly TEXTURE_EXPLICIT_MODE: number;
  121339. /** Spherical coordinates mode */
  121340. static readonly TEXTURE_SPHERICAL_MODE: number;
  121341. /** Planar coordinates mode */
  121342. static readonly TEXTURE_PLANAR_MODE: number;
  121343. /** Cubic coordinates mode */
  121344. static readonly TEXTURE_CUBIC_MODE: number;
  121345. /** Projection coordinates mode */
  121346. static readonly TEXTURE_PROJECTION_MODE: number;
  121347. /** Skybox coordinates mode */
  121348. static readonly TEXTURE_SKYBOX_MODE: number;
  121349. /** Inverse Cubic coordinates mode */
  121350. static readonly TEXTURE_INVCUBIC_MODE: number;
  121351. /** Equirectangular coordinates mode */
  121352. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121353. /** Equirectangular Fixed coordinates mode */
  121354. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121355. /** Equirectangular Fixed Mirrored coordinates mode */
  121356. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121357. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121358. static readonly SCALEMODE_FLOOR: number;
  121359. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121360. static readonly SCALEMODE_NEAREST: number;
  121361. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121362. static readonly SCALEMODE_CEILING: number;
  121363. /**
  121364. * Returns the current npm package of the sdk
  121365. */
  121366. static get NpmPackage(): string;
  121367. /**
  121368. * Returns the current version of the framework
  121369. */
  121370. static get Version(): string;
  121371. /** Gets the list of created engines */
  121372. static get Instances(): Engine[];
  121373. /**
  121374. * Gets the latest created engine
  121375. */
  121376. static get LastCreatedEngine(): Nullable<Engine>;
  121377. /**
  121378. * Gets the latest created scene
  121379. */
  121380. static get LastCreatedScene(): Nullable<Scene>;
  121381. /**
  121382. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  121383. * @param flag defines which part of the materials must be marked as dirty
  121384. * @param predicate defines a predicate used to filter which materials should be affected
  121385. */
  121386. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121387. /**
  121388. * Method called to create the default loading screen.
  121389. * This can be overriden in your own app.
  121390. * @param canvas The rendering canvas element
  121391. * @returns The loading screen
  121392. */
  121393. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  121394. /**
  121395. * Method called to create the default rescale post process on each engine.
  121396. */
  121397. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  121398. /**
  121399. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  121400. **/
  121401. enableOfflineSupport: boolean;
  121402. /**
  121403. * 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)
  121404. **/
  121405. disableManifestCheck: boolean;
  121406. /**
  121407. * Gets the list of created scenes
  121408. */
  121409. scenes: Scene[];
  121410. /**
  121411. * Event raised when a new scene is created
  121412. */
  121413. onNewSceneAddedObservable: Observable<Scene>;
  121414. /**
  121415. * Gets the list of created postprocesses
  121416. */
  121417. postProcesses: PostProcess[];
  121418. /**
  121419. * Gets a boolean indicating if the pointer is currently locked
  121420. */
  121421. isPointerLock: boolean;
  121422. /**
  121423. * Observable event triggered each time the rendering canvas is resized
  121424. */
  121425. onResizeObservable: Observable<Engine>;
  121426. /**
  121427. * Observable event triggered each time the canvas loses focus
  121428. */
  121429. onCanvasBlurObservable: Observable<Engine>;
  121430. /**
  121431. * Observable event triggered each time the canvas gains focus
  121432. */
  121433. onCanvasFocusObservable: Observable<Engine>;
  121434. /**
  121435. * Observable event triggered each time the canvas receives pointerout event
  121436. */
  121437. onCanvasPointerOutObservable: Observable<PointerEvent>;
  121438. /**
  121439. * Observable raised when the engine begins a new frame
  121440. */
  121441. onBeginFrameObservable: Observable<Engine>;
  121442. /**
  121443. * If set, will be used to request the next animation frame for the render loop
  121444. */
  121445. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  121446. /**
  121447. * Observable raised when the engine ends the current frame
  121448. */
  121449. onEndFrameObservable: Observable<Engine>;
  121450. /**
  121451. * Observable raised when the engine is about to compile a shader
  121452. */
  121453. onBeforeShaderCompilationObservable: Observable<Engine>;
  121454. /**
  121455. * Observable raised when the engine has jsut compiled a shader
  121456. */
  121457. onAfterShaderCompilationObservable: Observable<Engine>;
  121458. /**
  121459. * Gets the audio engine
  121460. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121461. * @ignorenaming
  121462. */
  121463. static audioEngine: IAudioEngine;
  121464. /**
  121465. * Default AudioEngine factory responsible of creating the Audio Engine.
  121466. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  121467. */
  121468. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  121469. /**
  121470. * Default offline support factory responsible of creating a tool used to store data locally.
  121471. * By default, this will create a Database object if the workload has been embedded.
  121472. */
  121473. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  121474. private _loadingScreen;
  121475. private _pointerLockRequested;
  121476. private _rescalePostProcess;
  121477. private _deterministicLockstep;
  121478. private _lockstepMaxSteps;
  121479. private _timeStep;
  121480. protected get _supportsHardwareTextureRescaling(): boolean;
  121481. private _fps;
  121482. private _deltaTime;
  121483. /** @hidden */
  121484. _drawCalls: PerfCounter;
  121485. /** 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 */
  121486. canvasTabIndex: number;
  121487. /**
  121488. * Turn this value on if you want to pause FPS computation when in background
  121489. */
  121490. disablePerformanceMonitorInBackground: boolean;
  121491. private _performanceMonitor;
  121492. /**
  121493. * Gets the performance monitor attached to this engine
  121494. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121495. */
  121496. get performanceMonitor(): PerformanceMonitor;
  121497. private _onFocus;
  121498. private _onBlur;
  121499. private _onCanvasPointerOut;
  121500. private _onCanvasBlur;
  121501. private _onCanvasFocus;
  121502. private _onFullscreenChange;
  121503. private _onPointerLockChange;
  121504. /**
  121505. * Gets the HTML element used to attach event listeners
  121506. * @returns a HTML element
  121507. */
  121508. getInputElement(): Nullable<HTMLElement>;
  121509. /**
  121510. * Creates a new engine
  121511. * @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
  121512. * @param antialias defines enable antialiasing (default: false)
  121513. * @param options defines further options to be sent to the getContext() function
  121514. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  121515. */
  121516. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  121517. /**
  121518. * Gets current aspect ratio
  121519. * @param viewportOwner defines the camera to use to get the aspect ratio
  121520. * @param useScreen defines if screen size must be used (or the current render target if any)
  121521. * @returns a number defining the aspect ratio
  121522. */
  121523. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  121524. /**
  121525. * Gets current screen aspect ratio
  121526. * @returns a number defining the aspect ratio
  121527. */
  121528. getScreenAspectRatio(): number;
  121529. /**
  121530. * Gets the client rect of the HTML canvas attached with the current webGL context
  121531. * @returns a client rectanglee
  121532. */
  121533. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  121534. /**
  121535. * Gets the client rect of the HTML element used for events
  121536. * @returns a client rectanglee
  121537. */
  121538. getInputElementClientRect(): Nullable<ClientRect>;
  121539. /**
  121540. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121541. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121542. * @returns true if engine is in deterministic lock step mode
  121543. */
  121544. isDeterministicLockStep(): boolean;
  121545. /**
  121546. * Gets the max steps when engine is running in deterministic lock step
  121547. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121548. * @returns the max steps
  121549. */
  121550. getLockstepMaxSteps(): number;
  121551. /**
  121552. * Returns the time in ms between steps when using deterministic lock step.
  121553. * @returns time step in (ms)
  121554. */
  121555. getTimeStep(): number;
  121556. /**
  121557. * Force the mipmap generation for the given render target texture
  121558. * @param texture defines the render target texture to use
  121559. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  121560. */
  121561. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  121562. /** States */
  121563. /**
  121564. * Set various states to the webGL context
  121565. * @param culling defines backface culling state
  121566. * @param zOffset defines the value to apply to zOffset (0 by default)
  121567. * @param force defines if states must be applied even if cache is up to date
  121568. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121569. */
  121570. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121571. /**
  121572. * Set the z offset to apply to current rendering
  121573. * @param value defines the offset to apply
  121574. */
  121575. setZOffset(value: number): void;
  121576. /**
  121577. * Gets the current value of the zOffset
  121578. * @returns the current zOffset state
  121579. */
  121580. getZOffset(): number;
  121581. /**
  121582. * Enable or disable depth buffering
  121583. * @param enable defines the state to set
  121584. */
  121585. setDepthBuffer(enable: boolean): void;
  121586. /**
  121587. * Gets a boolean indicating if depth writing is enabled
  121588. * @returns the current depth writing state
  121589. */
  121590. getDepthWrite(): boolean;
  121591. /**
  121592. * Enable or disable depth writing
  121593. * @param enable defines the state to set
  121594. */
  121595. setDepthWrite(enable: boolean): void;
  121596. /**
  121597. * Gets a boolean indicating if stencil buffer is enabled
  121598. * @returns the current stencil buffer state
  121599. */
  121600. getStencilBuffer(): boolean;
  121601. /**
  121602. * Enable or disable the stencil buffer
  121603. * @param enable defines if the stencil buffer must be enabled or disabled
  121604. */
  121605. setStencilBuffer(enable: boolean): void;
  121606. /**
  121607. * Gets the current stencil mask
  121608. * @returns a number defining the new stencil mask to use
  121609. */
  121610. getStencilMask(): number;
  121611. /**
  121612. * Sets the current stencil mask
  121613. * @param mask defines the new stencil mask to use
  121614. */
  121615. setStencilMask(mask: number): void;
  121616. /**
  121617. * Gets the current stencil function
  121618. * @returns a number defining the stencil function to use
  121619. */
  121620. getStencilFunction(): number;
  121621. /**
  121622. * Gets the current stencil reference value
  121623. * @returns a number defining the stencil reference value to use
  121624. */
  121625. getStencilFunctionReference(): number;
  121626. /**
  121627. * Gets the current stencil mask
  121628. * @returns a number defining the stencil mask to use
  121629. */
  121630. getStencilFunctionMask(): number;
  121631. /**
  121632. * Sets the current stencil function
  121633. * @param stencilFunc defines the new stencil function to use
  121634. */
  121635. setStencilFunction(stencilFunc: number): void;
  121636. /**
  121637. * Sets the current stencil reference
  121638. * @param reference defines the new stencil reference to use
  121639. */
  121640. setStencilFunctionReference(reference: number): void;
  121641. /**
  121642. * Sets the current stencil mask
  121643. * @param mask defines the new stencil mask to use
  121644. */
  121645. setStencilFunctionMask(mask: number): void;
  121646. /**
  121647. * Gets the current stencil operation when stencil fails
  121648. * @returns a number defining stencil operation to use when stencil fails
  121649. */
  121650. getStencilOperationFail(): number;
  121651. /**
  121652. * Gets the current stencil operation when depth fails
  121653. * @returns a number defining stencil operation to use when depth fails
  121654. */
  121655. getStencilOperationDepthFail(): number;
  121656. /**
  121657. * Gets the current stencil operation when stencil passes
  121658. * @returns a number defining stencil operation to use when stencil passes
  121659. */
  121660. getStencilOperationPass(): number;
  121661. /**
  121662. * Sets the stencil operation to use when stencil fails
  121663. * @param operation defines the stencil operation to use when stencil fails
  121664. */
  121665. setStencilOperationFail(operation: number): void;
  121666. /**
  121667. * Sets the stencil operation to use when depth fails
  121668. * @param operation defines the stencil operation to use when depth fails
  121669. */
  121670. setStencilOperationDepthFail(operation: number): void;
  121671. /**
  121672. * Sets the stencil operation to use when stencil passes
  121673. * @param operation defines the stencil operation to use when stencil passes
  121674. */
  121675. setStencilOperationPass(operation: number): void;
  121676. /**
  121677. * Sets a boolean indicating if the dithering state is enabled or disabled
  121678. * @param value defines the dithering state
  121679. */
  121680. setDitheringState(value: boolean): void;
  121681. /**
  121682. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  121683. * @param value defines the rasterizer state
  121684. */
  121685. setRasterizerState(value: boolean): void;
  121686. /**
  121687. * Gets the current depth function
  121688. * @returns a number defining the depth function
  121689. */
  121690. getDepthFunction(): Nullable<number>;
  121691. /**
  121692. * Sets the current depth function
  121693. * @param depthFunc defines the function to use
  121694. */
  121695. setDepthFunction(depthFunc: number): void;
  121696. /**
  121697. * Sets the current depth function to GREATER
  121698. */
  121699. setDepthFunctionToGreater(): void;
  121700. /**
  121701. * Sets the current depth function to GEQUAL
  121702. */
  121703. setDepthFunctionToGreaterOrEqual(): void;
  121704. /**
  121705. * Sets the current depth function to LESS
  121706. */
  121707. setDepthFunctionToLess(): void;
  121708. /**
  121709. * Sets the current depth function to LEQUAL
  121710. */
  121711. setDepthFunctionToLessOrEqual(): void;
  121712. private _cachedStencilBuffer;
  121713. private _cachedStencilFunction;
  121714. private _cachedStencilMask;
  121715. private _cachedStencilOperationPass;
  121716. private _cachedStencilOperationFail;
  121717. private _cachedStencilOperationDepthFail;
  121718. private _cachedStencilReference;
  121719. /**
  121720. * Caches the the state of the stencil buffer
  121721. */
  121722. cacheStencilState(): void;
  121723. /**
  121724. * Restores the state of the stencil buffer
  121725. */
  121726. restoreStencilState(): void;
  121727. /**
  121728. * Directly set the WebGL Viewport
  121729. * @param x defines the x coordinate of the viewport (in screen space)
  121730. * @param y defines the y coordinate of the viewport (in screen space)
  121731. * @param width defines the width of the viewport (in screen space)
  121732. * @param height defines the height of the viewport (in screen space)
  121733. * @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
  121734. */
  121735. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  121736. /**
  121737. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  121738. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121739. * @param y defines the y-coordinate of the corner of the clear rectangle
  121740. * @param width defines the width of the clear rectangle
  121741. * @param height defines the height of the clear rectangle
  121742. * @param clearColor defines the clear color
  121743. */
  121744. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  121745. /**
  121746. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  121747. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121748. * @param y defines the y-coordinate of the corner of the clear rectangle
  121749. * @param width defines the width of the clear rectangle
  121750. * @param height defines the height of the clear rectangle
  121751. */
  121752. enableScissor(x: number, y: number, width: number, height: number): void;
  121753. /**
  121754. * Disable previously set scissor test rectangle
  121755. */
  121756. disableScissor(): void;
  121757. protected _reportDrawCall(): void;
  121758. /**
  121759. * Initializes a webVR display and starts listening to display change events
  121760. * The onVRDisplayChangedObservable will be notified upon these changes
  121761. * @returns The onVRDisplayChangedObservable
  121762. */
  121763. initWebVR(): Observable<IDisplayChangedEventArgs>;
  121764. /** @hidden */
  121765. _prepareVRComponent(): void;
  121766. /** @hidden */
  121767. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  121768. /** @hidden */
  121769. _submitVRFrame(): void;
  121770. /**
  121771. * Call this function to leave webVR mode
  121772. * Will do nothing if webVR is not supported or if there is no webVR device
  121773. * @see https://doc.babylonjs.com/how_to/webvr_camera
  121774. */
  121775. disableVR(): void;
  121776. /**
  121777. * Gets a boolean indicating that the system is in VR mode and is presenting
  121778. * @returns true if VR mode is engaged
  121779. */
  121780. isVRPresenting(): boolean;
  121781. /** @hidden */
  121782. _requestVRFrame(): void;
  121783. /** @hidden */
  121784. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121785. /**
  121786. * Gets the source code of the vertex shader associated with a specific webGL program
  121787. * @param program defines the program to use
  121788. * @returns a string containing the source code of the vertex shader associated with the program
  121789. */
  121790. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  121791. /**
  121792. * Gets the source code of the fragment shader associated with a specific webGL program
  121793. * @param program defines the program to use
  121794. * @returns a string containing the source code of the fragment shader associated with the program
  121795. */
  121796. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  121797. /**
  121798. * Sets a depth stencil texture from a render target to the according uniform.
  121799. * @param channel The texture channel
  121800. * @param uniform The uniform to set
  121801. * @param texture The render target texture containing the depth stencil texture to apply
  121802. */
  121803. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  121804. /**
  121805. * Sets a texture to the webGL context from a postprocess
  121806. * @param channel defines the channel to use
  121807. * @param postProcess defines the source postprocess
  121808. */
  121809. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  121810. /**
  121811. * Binds the output of the passed in post process to the texture channel specified
  121812. * @param channel The channel the texture should be bound to
  121813. * @param postProcess The post process which's output should be bound
  121814. */
  121815. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  121816. protected _rebuildBuffers(): void;
  121817. /** @hidden */
  121818. _renderFrame(): void;
  121819. _renderLoop(): void;
  121820. /** @hidden */
  121821. _renderViews(): boolean;
  121822. /**
  121823. * Toggle full screen mode
  121824. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121825. */
  121826. switchFullscreen(requestPointerLock: boolean): void;
  121827. /**
  121828. * Enters full screen mode
  121829. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121830. */
  121831. enterFullscreen(requestPointerLock: boolean): void;
  121832. /**
  121833. * Exits full screen mode
  121834. */
  121835. exitFullscreen(): void;
  121836. /**
  121837. * Enters Pointerlock mode
  121838. */
  121839. enterPointerlock(): void;
  121840. /**
  121841. * Exits Pointerlock mode
  121842. */
  121843. exitPointerlock(): void;
  121844. /**
  121845. * Begin a new frame
  121846. */
  121847. beginFrame(): void;
  121848. /**
  121849. * Enf the current frame
  121850. */
  121851. endFrame(): void;
  121852. resize(): void;
  121853. /**
  121854. * Force a specific size of the canvas
  121855. * @param width defines the new canvas' width
  121856. * @param height defines the new canvas' height
  121857. * @returns true if the size was changed
  121858. */
  121859. setSize(width: number, height: number): boolean;
  121860. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121861. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121862. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121863. _releaseTexture(texture: InternalTexture): void;
  121864. /**
  121865. * @hidden
  121866. * Rescales a texture
  121867. * @param source input texutre
  121868. * @param destination destination texture
  121869. * @param scene scene to use to render the resize
  121870. * @param internalFormat format to use when resizing
  121871. * @param onComplete callback to be called when resize has completed
  121872. */
  121873. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121874. /**
  121875. * Gets the current framerate
  121876. * @returns a number representing the framerate
  121877. */
  121878. getFps(): number;
  121879. /**
  121880. * Gets the time spent between current and previous frame
  121881. * @returns a number representing the delta time in ms
  121882. */
  121883. getDeltaTime(): number;
  121884. private _measureFps;
  121885. /** @hidden */
  121886. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  121887. /**
  121888. * Updates the sample count of a render target texture
  121889. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121890. * @param texture defines the texture to update
  121891. * @param samples defines the sample count to set
  121892. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121893. */
  121894. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  121895. /**
  121896. * Updates a depth texture Comparison Mode and Function.
  121897. * If the comparison Function is equal to 0, the mode will be set to none.
  121898. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  121899. * @param texture The texture to set the comparison function for
  121900. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  121901. */
  121902. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  121903. /**
  121904. * Creates a webGL buffer to use with instanciation
  121905. * @param capacity defines the size of the buffer
  121906. * @returns the webGL buffer
  121907. */
  121908. createInstancesBuffer(capacity: number): DataBuffer;
  121909. /**
  121910. * Delete a webGL buffer used with instanciation
  121911. * @param buffer defines the webGL buffer to delete
  121912. */
  121913. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  121914. private _clientWaitAsync;
  121915. /** @hidden */
  121916. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  121917. dispose(): void;
  121918. private _disableTouchAction;
  121919. /**
  121920. * Display the loading screen
  121921. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121922. */
  121923. displayLoadingUI(): void;
  121924. /**
  121925. * Hide the loading screen
  121926. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121927. */
  121928. hideLoadingUI(): void;
  121929. /**
  121930. * Gets the current loading screen object
  121931. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121932. */
  121933. get loadingScreen(): ILoadingScreen;
  121934. /**
  121935. * Sets the current loading screen object
  121936. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121937. */
  121938. set loadingScreen(loadingScreen: ILoadingScreen);
  121939. /**
  121940. * Sets the current loading screen text
  121941. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121942. */
  121943. set loadingUIText(text: string);
  121944. /**
  121945. * Sets the current loading screen background color
  121946. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121947. */
  121948. set loadingUIBackgroundColor(color: string);
  121949. /** Pointerlock and fullscreen */
  121950. /**
  121951. * Ask the browser to promote the current element to pointerlock mode
  121952. * @param element defines the DOM element to promote
  121953. */
  121954. static _RequestPointerlock(element: HTMLElement): void;
  121955. /**
  121956. * Asks the browser to exit pointerlock mode
  121957. */
  121958. static _ExitPointerlock(): void;
  121959. /**
  121960. * Ask the browser to promote the current element to fullscreen rendering mode
  121961. * @param element defines the DOM element to promote
  121962. */
  121963. static _RequestFullscreen(element: HTMLElement): void;
  121964. /**
  121965. * Asks the browser to exit fullscreen mode
  121966. */
  121967. static _ExitFullscreen(): void;
  121968. }
  121969. }
  121970. declare module BABYLON {
  121971. /**
  121972. * The engine store class is responsible to hold all the instances of Engine and Scene created
  121973. * during the life time of the application.
  121974. */
  121975. export class EngineStore {
  121976. /** Gets the list of created engines */
  121977. static Instances: Engine[];
  121978. /** @hidden */
  121979. static _LastCreatedScene: Nullable<Scene>;
  121980. /**
  121981. * Gets the latest created engine
  121982. */
  121983. static get LastCreatedEngine(): Nullable<Engine>;
  121984. /**
  121985. * Gets the latest created scene
  121986. */
  121987. static get LastCreatedScene(): Nullable<Scene>;
  121988. /**
  121989. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  121990. * @ignorenaming
  121991. */
  121992. static UseFallbackTexture: boolean;
  121993. /**
  121994. * Texture content used if a texture cannot loaded
  121995. * @ignorenaming
  121996. */
  121997. static FallbackTexture: string;
  121998. }
  121999. }
  122000. declare module BABYLON {
  122001. /**
  122002. * Helper class that provides a small promise polyfill
  122003. */
  122004. export class PromisePolyfill {
  122005. /**
  122006. * Static function used to check if the polyfill is required
  122007. * If this is the case then the function will inject the polyfill to window.Promise
  122008. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  122009. */
  122010. static Apply(force?: boolean): void;
  122011. }
  122012. }
  122013. declare module BABYLON {
  122014. /**
  122015. * Interface for screenshot methods with describe argument called `size` as object with options
  122016. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  122017. */
  122018. export interface IScreenshotSize {
  122019. /**
  122020. * number in pixels for canvas height
  122021. */
  122022. height?: number;
  122023. /**
  122024. * multiplier allowing render at a higher or lower resolution
  122025. * If value is defined then height and width will be ignored and taken from camera
  122026. */
  122027. precision?: number;
  122028. /**
  122029. * number in pixels for canvas width
  122030. */
  122031. width?: number;
  122032. }
  122033. }
  122034. declare module BABYLON {
  122035. interface IColor4Like {
  122036. r: float;
  122037. g: float;
  122038. b: float;
  122039. a: float;
  122040. }
  122041. /**
  122042. * Class containing a set of static utilities functions
  122043. */
  122044. export class Tools {
  122045. /**
  122046. * Gets or sets the base URL to use to load assets
  122047. */
  122048. static get BaseUrl(): string;
  122049. static set BaseUrl(value: string);
  122050. /**
  122051. * Enable/Disable Custom HTTP Request Headers globally.
  122052. * default = false
  122053. * @see CustomRequestHeaders
  122054. */
  122055. static UseCustomRequestHeaders: boolean;
  122056. /**
  122057. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  122058. * i.e. when loading files, where the server/service expects an Authorization header
  122059. */
  122060. static CustomRequestHeaders: {
  122061. [key: string]: string;
  122062. };
  122063. /**
  122064. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  122065. */
  122066. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  122067. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  122068. /**
  122069. * Default behaviour for cors in the application.
  122070. * It can be a string if the expected behavior is identical in the entire app.
  122071. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  122072. */
  122073. static get CorsBehavior(): string | ((url: string | string[]) => string);
  122074. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  122075. /**
  122076. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122077. * @ignorenaming
  122078. */
  122079. static get UseFallbackTexture(): boolean;
  122080. static set UseFallbackTexture(value: boolean);
  122081. /**
  122082. * Use this object to register external classes like custom textures or material
  122083. * to allow the laoders to instantiate them
  122084. */
  122085. static get RegisteredExternalClasses(): {
  122086. [key: string]: Object;
  122087. };
  122088. static set RegisteredExternalClasses(classes: {
  122089. [key: string]: Object;
  122090. });
  122091. /**
  122092. * Texture content used if a texture cannot loaded
  122093. * @ignorenaming
  122094. */
  122095. static get fallbackTexture(): string;
  122096. static set fallbackTexture(value: string);
  122097. /**
  122098. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  122099. * @param u defines the coordinate on X axis
  122100. * @param v defines the coordinate on Y axis
  122101. * @param width defines the width of the source data
  122102. * @param height defines the height of the source data
  122103. * @param pixels defines the source byte array
  122104. * @param color defines the output color
  122105. */
  122106. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  122107. /**
  122108. * Interpolates between a and b via alpha
  122109. * @param a The lower value (returned when alpha = 0)
  122110. * @param b The upper value (returned when alpha = 1)
  122111. * @param alpha The interpolation-factor
  122112. * @return The mixed value
  122113. */
  122114. static Mix(a: number, b: number, alpha: number): number;
  122115. /**
  122116. * Tries to instantiate a new object from a given class name
  122117. * @param className defines the class name to instantiate
  122118. * @returns the new object or null if the system was not able to do the instantiation
  122119. */
  122120. static Instantiate(className: string): any;
  122121. /**
  122122. * Provides a slice function that will work even on IE
  122123. * @param data defines the array to slice
  122124. * @param start defines the start of the data (optional)
  122125. * @param end defines the end of the data (optional)
  122126. * @returns the new sliced array
  122127. */
  122128. static Slice<T>(data: T, start?: number, end?: number): T;
  122129. /**
  122130. * Polyfill for setImmediate
  122131. * @param action defines the action to execute after the current execution block
  122132. */
  122133. static SetImmediate(action: () => void): void;
  122134. /**
  122135. * Function indicating if a number is an exponent of 2
  122136. * @param value defines the value to test
  122137. * @returns true if the value is an exponent of 2
  122138. */
  122139. static IsExponentOfTwo(value: number): boolean;
  122140. private static _tmpFloatArray;
  122141. /**
  122142. * Returns the nearest 32-bit single precision float representation of a Number
  122143. * @param value A Number. If the parameter is of a different type, it will get converted
  122144. * to a number or to NaN if it cannot be converted
  122145. * @returns number
  122146. */
  122147. static FloatRound(value: number): number;
  122148. /**
  122149. * Extracts the filename from a path
  122150. * @param path defines the path to use
  122151. * @returns the filename
  122152. */
  122153. static GetFilename(path: string): string;
  122154. /**
  122155. * Extracts the "folder" part of a path (everything before the filename).
  122156. * @param uri The URI to extract the info from
  122157. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  122158. * @returns The "folder" part of the path
  122159. */
  122160. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  122161. /**
  122162. * Extracts text content from a DOM element hierarchy
  122163. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  122164. */
  122165. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  122166. /**
  122167. * Convert an angle in radians to degrees
  122168. * @param angle defines the angle to convert
  122169. * @returns the angle in degrees
  122170. */
  122171. static ToDegrees(angle: number): number;
  122172. /**
  122173. * Convert an angle in degrees to radians
  122174. * @param angle defines the angle to convert
  122175. * @returns the angle in radians
  122176. */
  122177. static ToRadians(angle: number): number;
  122178. /**
  122179. * Returns an array if obj is not an array
  122180. * @param obj defines the object to evaluate as an array
  122181. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  122182. * @returns either obj directly if obj is an array or a new array containing obj
  122183. */
  122184. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  122185. /**
  122186. * Gets the pointer prefix to use
  122187. * @param engine defines the engine we are finding the prefix for
  122188. * @returns "pointer" if touch is enabled. Else returns "mouse"
  122189. */
  122190. static GetPointerPrefix(engine: Engine): string;
  122191. /**
  122192. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  122193. * @param url define the url we are trying
  122194. * @param element define the dom element where to configure the cors policy
  122195. */
  122196. static SetCorsBehavior(url: string | string[], element: {
  122197. crossOrigin: string | null;
  122198. }): void;
  122199. /**
  122200. * Removes unwanted characters from an url
  122201. * @param url defines the url to clean
  122202. * @returns the cleaned url
  122203. */
  122204. static CleanUrl(url: string): string;
  122205. /**
  122206. * Gets or sets a function used to pre-process url before using them to load assets
  122207. */
  122208. static get PreprocessUrl(): (url: string) => string;
  122209. static set PreprocessUrl(processor: (url: string) => string);
  122210. /**
  122211. * Loads an image as an HTMLImageElement.
  122212. * @param input url string, ArrayBuffer, or Blob to load
  122213. * @param onLoad callback called when the image successfully loads
  122214. * @param onError callback called when the image fails to load
  122215. * @param offlineProvider offline provider for caching
  122216. * @param mimeType optional mime type
  122217. * @returns the HTMLImageElement of the loaded image
  122218. */
  122219. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  122220. /**
  122221. * Loads a file from a url
  122222. * @param url url string, ArrayBuffer, or Blob to load
  122223. * @param onSuccess callback called when the file successfully loads
  122224. * @param onProgress callback called while file is loading (if the server supports this mode)
  122225. * @param offlineProvider defines the offline provider for caching
  122226. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122227. * @param onError callback called when the file fails to load
  122228. * @returns a file request object
  122229. */
  122230. 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;
  122231. /**
  122232. * Loads a file from a url
  122233. * @param url the file url to load
  122234. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122235. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  122236. */
  122237. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  122238. /**
  122239. * Load a script (identified by an url). When the url returns, the
  122240. * content of this file is added into a new script element, attached to the DOM (body element)
  122241. * @param scriptUrl defines the url of the script to laod
  122242. * @param onSuccess defines the callback called when the script is loaded
  122243. * @param onError defines the callback to call if an error occurs
  122244. * @param scriptId defines the id of the script element
  122245. */
  122246. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  122247. /**
  122248. * Load an asynchronous script (identified by an url). When the url returns, the
  122249. * content of this file is added into a new script element, attached to the DOM (body element)
  122250. * @param scriptUrl defines the url of the script to laod
  122251. * @param scriptId defines the id of the script element
  122252. * @returns a promise request object
  122253. */
  122254. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  122255. /**
  122256. * Loads a file from a blob
  122257. * @param fileToLoad defines the blob to use
  122258. * @param callback defines the callback to call when data is loaded
  122259. * @param progressCallback defines the callback to call during loading process
  122260. * @returns a file request object
  122261. */
  122262. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122263. /**
  122264. * Reads a file from a File object
  122265. * @param file defines the file to load
  122266. * @param onSuccess defines the callback to call when data is loaded
  122267. * @param onProgress defines the callback to call during loading process
  122268. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122269. * @param onError defines the callback to call when an error occurs
  122270. * @returns a file request object
  122271. */
  122272. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122273. /**
  122274. * Creates a data url from a given string content
  122275. * @param content defines the content to convert
  122276. * @returns the new data url link
  122277. */
  122278. static FileAsURL(content: string): string;
  122279. /**
  122280. * Format the given number to a specific decimal format
  122281. * @param value defines the number to format
  122282. * @param decimals defines the number of decimals to use
  122283. * @returns the formatted string
  122284. */
  122285. static Format(value: number, decimals?: number): string;
  122286. /**
  122287. * Tries to copy an object by duplicating every property
  122288. * @param source defines the source object
  122289. * @param destination defines the target object
  122290. * @param doNotCopyList defines a list of properties to avoid
  122291. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122292. */
  122293. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122294. /**
  122295. * Gets a boolean indicating if the given object has no own property
  122296. * @param obj defines the object to test
  122297. * @returns true if object has no own property
  122298. */
  122299. static IsEmpty(obj: any): boolean;
  122300. /**
  122301. * Function used to register events at window level
  122302. * @param windowElement defines the Window object to use
  122303. * @param events defines the events to register
  122304. */
  122305. static RegisterTopRootEvents(windowElement: Window, events: {
  122306. name: string;
  122307. handler: Nullable<(e: FocusEvent) => any>;
  122308. }[]): void;
  122309. /**
  122310. * Function used to unregister events from window level
  122311. * @param windowElement defines the Window object to use
  122312. * @param events defines the events to unregister
  122313. */
  122314. static UnregisterTopRootEvents(windowElement: Window, events: {
  122315. name: string;
  122316. handler: Nullable<(e: FocusEvent) => any>;
  122317. }[]): void;
  122318. /**
  122319. * @ignore
  122320. */
  122321. static _ScreenshotCanvas: HTMLCanvasElement;
  122322. /**
  122323. * Dumps the current bound framebuffer
  122324. * @param width defines the rendering width
  122325. * @param height defines the rendering height
  122326. * @param engine defines the hosting engine
  122327. * @param successCallback defines the callback triggered once the data are available
  122328. * @param mimeType defines the mime type of the result
  122329. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122330. */
  122331. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122332. /**
  122333. * Converts the canvas data to blob.
  122334. * This acts as a polyfill for browsers not supporting the to blob function.
  122335. * @param canvas Defines the canvas to extract the data from
  122336. * @param successCallback Defines the callback triggered once the data are available
  122337. * @param mimeType Defines the mime type of the result
  122338. */
  122339. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122340. /**
  122341. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122342. * @param successCallback defines the callback triggered once the data are available
  122343. * @param mimeType defines the mime type of the result
  122344. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122345. */
  122346. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122347. /**
  122348. * Downloads a blob in the browser
  122349. * @param blob defines the blob to download
  122350. * @param fileName defines the name of the downloaded file
  122351. */
  122352. static Download(blob: Blob, fileName: string): void;
  122353. /**
  122354. * Captures a screenshot of the current rendering
  122355. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122356. * @param engine defines the rendering engine
  122357. * @param camera defines the source camera
  122358. * @param size This parameter can be set to a single number or to an object with the
  122359. * following (optional) properties: precision, width, height. If a single number is passed,
  122360. * it will be used for both width and height. If an object is passed, the screenshot size
  122361. * will be derived from the parameters. The precision property is a multiplier allowing
  122362. * rendering at a higher or lower resolution
  122363. * @param successCallback defines the callback receives a single parameter which contains the
  122364. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122365. * src parameter of an <img> to display it
  122366. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122367. * Check your browser for supported MIME types
  122368. */
  122369. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  122370. /**
  122371. * Captures a screenshot of the current rendering
  122372. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122373. * @param engine defines the rendering engine
  122374. * @param camera defines the source camera
  122375. * @param size This parameter can be set to a single number or to an object with the
  122376. * following (optional) properties: precision, width, height. If a single number is passed,
  122377. * it will be used for both width and height. If an object is passed, the screenshot size
  122378. * will be derived from the parameters. The precision property is a multiplier allowing
  122379. * rendering at a higher or lower resolution
  122380. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122381. * Check your browser for supported MIME types
  122382. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122383. * to the src parameter of an <img> to display it
  122384. */
  122385. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  122386. /**
  122387. * Generates an image screenshot from the specified camera.
  122388. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122389. * @param engine The engine to use for rendering
  122390. * @param camera The camera to use for rendering
  122391. * @param size This parameter can be set to a single number or to an object with the
  122392. * following (optional) properties: precision, width, height. If a single number is passed,
  122393. * it will be used for both width and height. If an object is passed, the screenshot size
  122394. * will be derived from the parameters. The precision property is a multiplier allowing
  122395. * rendering at a higher or lower resolution
  122396. * @param successCallback The callback receives a single parameter which contains the
  122397. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122398. * src parameter of an <img> to display it
  122399. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122400. * Check your browser for supported MIME types
  122401. * @param samples Texture samples (default: 1)
  122402. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122403. * @param fileName A name for for the downloaded file.
  122404. */
  122405. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122406. /**
  122407. * Generates an image screenshot from the specified camera.
  122408. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122409. * @param engine The engine to use for rendering
  122410. * @param camera The camera to use for rendering
  122411. * @param size This parameter can be set to a single number or to an object with the
  122412. * following (optional) properties: precision, width, height. If a single number is passed,
  122413. * it will be used for both width and height. If an object is passed, the screenshot size
  122414. * will be derived from the parameters. The precision property is a multiplier allowing
  122415. * rendering at a higher or lower resolution
  122416. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122417. * Check your browser for supported MIME types
  122418. * @param samples Texture samples (default: 1)
  122419. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122420. * @param fileName A name for for the downloaded file.
  122421. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122422. * to the src parameter of an <img> to display it
  122423. */
  122424. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  122425. /**
  122426. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  122427. * Be aware Math.random() could cause collisions, but:
  122428. * "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"
  122429. * @returns a pseudo random id
  122430. */
  122431. static RandomId(): string;
  122432. /**
  122433. * Test if the given uri is a base64 string
  122434. * @param uri The uri to test
  122435. * @return True if the uri is a base64 string or false otherwise
  122436. */
  122437. static IsBase64(uri: string): boolean;
  122438. /**
  122439. * Decode the given base64 uri.
  122440. * @param uri The uri to decode
  122441. * @return The decoded base64 data.
  122442. */
  122443. static DecodeBase64(uri: string): ArrayBuffer;
  122444. /**
  122445. * Gets the absolute url.
  122446. * @param url the input url
  122447. * @return the absolute url
  122448. */
  122449. static GetAbsoluteUrl(url: string): string;
  122450. /**
  122451. * No log
  122452. */
  122453. static readonly NoneLogLevel: number;
  122454. /**
  122455. * Only message logs
  122456. */
  122457. static readonly MessageLogLevel: number;
  122458. /**
  122459. * Only warning logs
  122460. */
  122461. static readonly WarningLogLevel: number;
  122462. /**
  122463. * Only error logs
  122464. */
  122465. static readonly ErrorLogLevel: number;
  122466. /**
  122467. * All logs
  122468. */
  122469. static readonly AllLogLevel: number;
  122470. /**
  122471. * Gets a value indicating the number of loading errors
  122472. * @ignorenaming
  122473. */
  122474. static get errorsCount(): number;
  122475. /**
  122476. * Callback called when a new log is added
  122477. */
  122478. static OnNewCacheEntry: (entry: string) => void;
  122479. /**
  122480. * Log a message to the console
  122481. * @param message defines the message to log
  122482. */
  122483. static Log(message: string): void;
  122484. /**
  122485. * Write a warning message to the console
  122486. * @param message defines the message to log
  122487. */
  122488. static Warn(message: string): void;
  122489. /**
  122490. * Write an error message to the console
  122491. * @param message defines the message to log
  122492. */
  122493. static Error(message: string): void;
  122494. /**
  122495. * Gets current log cache (list of logs)
  122496. */
  122497. static get LogCache(): string;
  122498. /**
  122499. * Clears the log cache
  122500. */
  122501. static ClearLogCache(): void;
  122502. /**
  122503. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  122504. */
  122505. static set LogLevels(level: number);
  122506. /**
  122507. * Checks if the window object exists
  122508. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  122509. */
  122510. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  122511. /**
  122512. * No performance log
  122513. */
  122514. static readonly PerformanceNoneLogLevel: number;
  122515. /**
  122516. * Use user marks to log performance
  122517. */
  122518. static readonly PerformanceUserMarkLogLevel: number;
  122519. /**
  122520. * Log performance to the console
  122521. */
  122522. static readonly PerformanceConsoleLogLevel: number;
  122523. private static _performance;
  122524. /**
  122525. * Sets the current performance log level
  122526. */
  122527. static set PerformanceLogLevel(level: number);
  122528. private static _StartPerformanceCounterDisabled;
  122529. private static _EndPerformanceCounterDisabled;
  122530. private static _StartUserMark;
  122531. private static _EndUserMark;
  122532. private static _StartPerformanceConsole;
  122533. private static _EndPerformanceConsole;
  122534. /**
  122535. * Starts a performance counter
  122536. */
  122537. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122538. /**
  122539. * Ends a specific performance coutner
  122540. */
  122541. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122542. /**
  122543. * Gets either window.performance.now() if supported or Date.now() else
  122544. */
  122545. static get Now(): number;
  122546. /**
  122547. * This method will return the name of the class used to create the instance of the given object.
  122548. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  122549. * @param object the object to get the class name from
  122550. * @param isType defines if the object is actually a type
  122551. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  122552. */
  122553. static GetClassName(object: any, isType?: boolean): string;
  122554. /**
  122555. * Gets the first element of an array satisfying a given predicate
  122556. * @param array defines the array to browse
  122557. * @param predicate defines the predicate to use
  122558. * @returns null if not found or the element
  122559. */
  122560. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  122561. /**
  122562. * This method will return the name of the full name of the class, including its owning module (if any).
  122563. * 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).
  122564. * @param object the object to get the class name from
  122565. * @param isType defines if the object is actually a type
  122566. * @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.
  122567. * @ignorenaming
  122568. */
  122569. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  122570. /**
  122571. * Returns a promise that resolves after the given amount of time.
  122572. * @param delay Number of milliseconds to delay
  122573. * @returns Promise that resolves after the given amount of time
  122574. */
  122575. static DelayAsync(delay: number): Promise<void>;
  122576. /**
  122577. * Utility function to detect if the current user agent is Safari
  122578. * @returns whether or not the current user agent is safari
  122579. */
  122580. static IsSafari(): boolean;
  122581. }
  122582. /**
  122583. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  122584. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  122585. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  122586. * @param name The name of the class, case should be preserved
  122587. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  122588. */
  122589. export function className(name: string, module?: string): (target: Object) => void;
  122590. /**
  122591. * An implementation of a loop for asynchronous functions.
  122592. */
  122593. export class AsyncLoop {
  122594. /**
  122595. * Defines the number of iterations for the loop
  122596. */
  122597. iterations: number;
  122598. /**
  122599. * Defines the current index of the loop.
  122600. */
  122601. index: number;
  122602. private _done;
  122603. private _fn;
  122604. private _successCallback;
  122605. /**
  122606. * Constructor.
  122607. * @param iterations the number of iterations.
  122608. * @param func the function to run each iteration
  122609. * @param successCallback the callback that will be called upon succesful execution
  122610. * @param offset starting offset.
  122611. */
  122612. constructor(
  122613. /**
  122614. * Defines the number of iterations for the loop
  122615. */
  122616. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  122617. /**
  122618. * Execute the next iteration. Must be called after the last iteration was finished.
  122619. */
  122620. executeNext(): void;
  122621. /**
  122622. * Break the loop and run the success callback.
  122623. */
  122624. breakLoop(): void;
  122625. /**
  122626. * Create and run an async loop.
  122627. * @param iterations the number of iterations.
  122628. * @param fn the function to run each iteration
  122629. * @param successCallback the callback that will be called upon succesful execution
  122630. * @param offset starting offset.
  122631. * @returns the created async loop object
  122632. */
  122633. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  122634. /**
  122635. * A for-loop that will run a given number of iterations synchronous and the rest async.
  122636. * @param iterations total number of iterations
  122637. * @param syncedIterations number of synchronous iterations in each async iteration.
  122638. * @param fn the function to call each iteration.
  122639. * @param callback a success call back that will be called when iterating stops.
  122640. * @param breakFunction a break condition (optional)
  122641. * @param timeout timeout settings for the setTimeout function. default - 0.
  122642. * @returns the created async loop object
  122643. */
  122644. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  122645. }
  122646. }
  122647. declare module BABYLON {
  122648. /**
  122649. * This class implement a typical dictionary using a string as key and the generic type T as value.
  122650. * The underlying implementation relies on an associative array to ensure the best performances.
  122651. * The value can be anything including 'null' but except 'undefined'
  122652. */
  122653. export class StringDictionary<T> {
  122654. /**
  122655. * This will clear this dictionary and copy the content from the 'source' one.
  122656. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  122657. * @param source the dictionary to take the content from and copy to this dictionary
  122658. */
  122659. copyFrom(source: StringDictionary<T>): void;
  122660. /**
  122661. * Get a value based from its key
  122662. * @param key the given key to get the matching value from
  122663. * @return the value if found, otherwise undefined is returned
  122664. */
  122665. get(key: string): T | undefined;
  122666. /**
  122667. * Get a value from its key or add it if it doesn't exist.
  122668. * This method will ensure you that a given key/data will be present in the dictionary.
  122669. * @param key the given key to get the matching value from
  122670. * @param factory the factory that will create the value if the key is not present in the dictionary.
  122671. * The factory will only be invoked if there's no data for the given key.
  122672. * @return the value corresponding to the key.
  122673. */
  122674. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  122675. /**
  122676. * Get a value from its key if present in the dictionary otherwise add it
  122677. * @param key the key to get the value from
  122678. * @param val if there's no such key/value pair in the dictionary add it with this value
  122679. * @return the value corresponding to the key
  122680. */
  122681. getOrAdd(key: string, val: T): T;
  122682. /**
  122683. * Check if there's a given key in the dictionary
  122684. * @param key the key to check for
  122685. * @return true if the key is present, false otherwise
  122686. */
  122687. contains(key: string): boolean;
  122688. /**
  122689. * Add a new key and its corresponding value
  122690. * @param key the key to add
  122691. * @param value the value corresponding to the key
  122692. * @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
  122693. */
  122694. add(key: string, value: T): boolean;
  122695. /**
  122696. * Update a specific value associated to a key
  122697. * @param key defines the key to use
  122698. * @param value defines the value to store
  122699. * @returns true if the value was updated (or false if the key was not found)
  122700. */
  122701. set(key: string, value: T): boolean;
  122702. /**
  122703. * Get the element of the given key and remove it from the dictionary
  122704. * @param key defines the key to search
  122705. * @returns the value associated with the key or null if not found
  122706. */
  122707. getAndRemove(key: string): Nullable<T>;
  122708. /**
  122709. * Remove a key/value from the dictionary.
  122710. * @param key the key to remove
  122711. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  122712. */
  122713. remove(key: string): boolean;
  122714. /**
  122715. * Clear the whole content of the dictionary
  122716. */
  122717. clear(): void;
  122718. /**
  122719. * Gets the current count
  122720. */
  122721. get count(): number;
  122722. /**
  122723. * Execute a callback on each key/val of the dictionary.
  122724. * Note that you can remove any element in this dictionary in the callback implementation
  122725. * @param callback the callback to execute on a given key/value pair
  122726. */
  122727. forEach(callback: (key: string, val: T) => void): void;
  122728. /**
  122729. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  122730. * If the callback returns null or undefined the method will iterate to the next key/value pair
  122731. * Note that you can remove any element in this dictionary in the callback implementation
  122732. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  122733. * @returns the first item
  122734. */
  122735. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  122736. private _count;
  122737. private _data;
  122738. }
  122739. }
  122740. declare module BABYLON {
  122741. /** @hidden */
  122742. export interface ICollisionCoordinator {
  122743. createCollider(): Collider;
  122744. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122745. init(scene: Scene): void;
  122746. }
  122747. /** @hidden */
  122748. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  122749. private _scene;
  122750. private _scaledPosition;
  122751. private _scaledVelocity;
  122752. private _finalPosition;
  122753. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122754. createCollider(): Collider;
  122755. init(scene: Scene): void;
  122756. private _collideWithWorld;
  122757. }
  122758. }
  122759. declare module BABYLON {
  122760. /**
  122761. * Class used to manage all inputs for the scene.
  122762. */
  122763. export class InputManager {
  122764. /** The distance in pixel that you have to move to prevent some events */
  122765. static DragMovementThreshold: number;
  122766. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  122767. static LongPressDelay: number;
  122768. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  122769. static DoubleClickDelay: number;
  122770. /** If you need to check double click without raising a single click at first click, enable this flag */
  122771. static ExclusiveDoubleClickMode: boolean;
  122772. /** 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. */
  122773. private _alreadyAttached;
  122774. private _alreadyAttachedTo;
  122775. private _wheelEventName;
  122776. private _onPointerMove;
  122777. private _onPointerDown;
  122778. private _onPointerUp;
  122779. private _initClickEvent;
  122780. private _initActionManager;
  122781. private _delayedSimpleClick;
  122782. private _delayedSimpleClickTimeout;
  122783. private _previousDelayedSimpleClickTimeout;
  122784. private _meshPickProceed;
  122785. private _previousButtonPressed;
  122786. private _currentPickResult;
  122787. private _previousPickResult;
  122788. private _totalPointersPressed;
  122789. private _doubleClickOccured;
  122790. private _pointerOverMesh;
  122791. private _pickedDownMesh;
  122792. private _pickedUpMesh;
  122793. private _pointerX;
  122794. private _pointerY;
  122795. private _unTranslatedPointerX;
  122796. private _unTranslatedPointerY;
  122797. private _startingPointerPosition;
  122798. private _previousStartingPointerPosition;
  122799. private _startingPointerTime;
  122800. private _previousStartingPointerTime;
  122801. private _pointerCaptures;
  122802. private _meshUnderPointerId;
  122803. private _onKeyDown;
  122804. private _onKeyUp;
  122805. private _keyboardIsAttached;
  122806. private _onCanvasFocusObserver;
  122807. private _onCanvasBlurObserver;
  122808. private _scene;
  122809. /**
  122810. * Creates a new InputManager
  122811. * @param scene defines the hosting scene
  122812. */
  122813. constructor(scene: Scene);
  122814. /**
  122815. * Gets the mesh that is currently under the pointer
  122816. */
  122817. get meshUnderPointer(): Nullable<AbstractMesh>;
  122818. /**
  122819. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  122820. * @param pointerId the pointer id to use
  122821. * @returns The mesh under this pointer id or null if not found
  122822. */
  122823. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  122824. /**
  122825. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  122826. */
  122827. get unTranslatedPointer(): Vector2;
  122828. /**
  122829. * Gets or sets the current on-screen X position of the pointer
  122830. */
  122831. get pointerX(): number;
  122832. set pointerX(value: number);
  122833. /**
  122834. * Gets or sets the current on-screen Y position of the pointer
  122835. */
  122836. get pointerY(): number;
  122837. set pointerY(value: number);
  122838. private _updatePointerPosition;
  122839. private _processPointerMove;
  122840. private _setRayOnPointerInfo;
  122841. private _checkPrePointerObservable;
  122842. /**
  122843. * Use this method to simulate a pointer move on a mesh
  122844. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122845. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122846. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122847. */
  122848. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122849. /**
  122850. * Use this method to simulate a pointer down on a mesh
  122851. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122852. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122853. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122854. */
  122855. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122856. private _processPointerDown;
  122857. /** @hidden */
  122858. _isPointerSwiping(): boolean;
  122859. /**
  122860. * Use this method to simulate a pointer up on a mesh
  122861. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122862. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122863. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122864. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  122865. */
  122866. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  122867. private _processPointerUp;
  122868. /**
  122869. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  122870. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  122871. * @returns true if the pointer was captured
  122872. */
  122873. isPointerCaptured(pointerId?: number): boolean;
  122874. /**
  122875. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  122876. * @param attachUp defines if you want to attach events to pointerup
  122877. * @param attachDown defines if you want to attach events to pointerdown
  122878. * @param attachMove defines if you want to attach events to pointermove
  122879. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  122880. */
  122881. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  122882. /**
  122883. * Detaches all event handlers
  122884. */
  122885. detachControl(): void;
  122886. /**
  122887. * Force the value of meshUnderPointer
  122888. * @param mesh defines the mesh to use
  122889. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  122890. */
  122891. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  122892. /**
  122893. * Gets the mesh under the pointer
  122894. * @returns a Mesh or null if no mesh is under the pointer
  122895. */
  122896. getPointerOverMesh(): Nullable<AbstractMesh>;
  122897. }
  122898. }
  122899. declare module BABYLON {
  122900. /**
  122901. * This class defines the direct association between an animation and a target
  122902. */
  122903. export class TargetedAnimation {
  122904. /**
  122905. * Animation to perform
  122906. */
  122907. animation: Animation;
  122908. /**
  122909. * Target to animate
  122910. */
  122911. target: any;
  122912. /**
  122913. * Returns the string "TargetedAnimation"
  122914. * @returns "TargetedAnimation"
  122915. */
  122916. getClassName(): string;
  122917. /**
  122918. * Serialize the object
  122919. * @returns the JSON object representing the current entity
  122920. */
  122921. serialize(): any;
  122922. }
  122923. /**
  122924. * Use this class to create coordinated animations on multiple targets
  122925. */
  122926. export class AnimationGroup implements IDisposable {
  122927. /** The name of the animation group */
  122928. name: string;
  122929. private _scene;
  122930. private _targetedAnimations;
  122931. private _animatables;
  122932. private _from;
  122933. private _to;
  122934. private _isStarted;
  122935. private _isPaused;
  122936. private _speedRatio;
  122937. private _loopAnimation;
  122938. private _isAdditive;
  122939. /**
  122940. * Gets or sets the unique id of the node
  122941. */
  122942. uniqueId: number;
  122943. /**
  122944. * This observable will notify when one animation have ended
  122945. */
  122946. onAnimationEndObservable: Observable<TargetedAnimation>;
  122947. /**
  122948. * Observer raised when one animation loops
  122949. */
  122950. onAnimationLoopObservable: Observable<TargetedAnimation>;
  122951. /**
  122952. * Observer raised when all animations have looped
  122953. */
  122954. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  122955. /**
  122956. * This observable will notify when all animations have ended.
  122957. */
  122958. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  122959. /**
  122960. * This observable will notify when all animations have paused.
  122961. */
  122962. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  122963. /**
  122964. * This observable will notify when all animations are playing.
  122965. */
  122966. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  122967. /**
  122968. * Gets the first frame
  122969. */
  122970. get from(): number;
  122971. /**
  122972. * Gets the last frame
  122973. */
  122974. get to(): number;
  122975. /**
  122976. * Define if the animations are started
  122977. */
  122978. get isStarted(): boolean;
  122979. /**
  122980. * Gets a value indicating that the current group is playing
  122981. */
  122982. get isPlaying(): boolean;
  122983. /**
  122984. * Gets or sets the speed ratio to use for all animations
  122985. */
  122986. get speedRatio(): number;
  122987. /**
  122988. * Gets or sets the speed ratio to use for all animations
  122989. */
  122990. set speedRatio(value: number);
  122991. /**
  122992. * Gets or sets if all animations should loop or not
  122993. */
  122994. get loopAnimation(): boolean;
  122995. set loopAnimation(value: boolean);
  122996. /**
  122997. * Gets or sets if all animations should be evaluated additively
  122998. */
  122999. get isAdditive(): boolean;
  123000. set isAdditive(value: boolean);
  123001. /**
  123002. * Gets the targeted animations for this animation group
  123003. */
  123004. get targetedAnimations(): Array<TargetedAnimation>;
  123005. /**
  123006. * returning the list of animatables controlled by this animation group.
  123007. */
  123008. get animatables(): Array<Animatable>;
  123009. /**
  123010. * Gets the list of target animations
  123011. */
  123012. get children(): TargetedAnimation[];
  123013. /**
  123014. * Instantiates a new Animation Group.
  123015. * This helps managing several animations at once.
  123016. * @see https://doc.babylonjs.com/how_to/group
  123017. * @param name Defines the name of the group
  123018. * @param scene Defines the scene the group belongs to
  123019. */
  123020. constructor(
  123021. /** The name of the animation group */
  123022. name: string, scene?: Nullable<Scene>);
  123023. /**
  123024. * Add an animation (with its target) in the group
  123025. * @param animation defines the animation we want to add
  123026. * @param target defines the target of the animation
  123027. * @returns the TargetedAnimation object
  123028. */
  123029. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  123030. /**
  123031. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  123032. * It can add constant keys at begin or end
  123033. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  123034. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  123035. * @returns the animation group
  123036. */
  123037. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  123038. private _animationLoopCount;
  123039. private _animationLoopFlags;
  123040. private _processLoop;
  123041. /**
  123042. * Start all animations on given targets
  123043. * @param loop defines if animations must loop
  123044. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  123045. * @param from defines the from key (optional)
  123046. * @param to defines the to key (optional)
  123047. * @param isAdditive defines the additive state for the resulting animatables (optional)
  123048. * @returns the current animation group
  123049. */
  123050. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  123051. /**
  123052. * Pause all animations
  123053. * @returns the animation group
  123054. */
  123055. pause(): AnimationGroup;
  123056. /**
  123057. * Play all animations to initial state
  123058. * This function will start() the animations if they were not started or will restart() them if they were paused
  123059. * @param loop defines if animations must loop
  123060. * @returns the animation group
  123061. */
  123062. play(loop?: boolean): AnimationGroup;
  123063. /**
  123064. * Reset all animations to initial state
  123065. * @returns the animation group
  123066. */
  123067. reset(): AnimationGroup;
  123068. /**
  123069. * Restart animations from key 0
  123070. * @returns the animation group
  123071. */
  123072. restart(): AnimationGroup;
  123073. /**
  123074. * Stop all animations
  123075. * @returns the animation group
  123076. */
  123077. stop(): AnimationGroup;
  123078. /**
  123079. * Set animation weight for all animatables
  123080. * @param weight defines the weight to use
  123081. * @return the animationGroup
  123082. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123083. */
  123084. setWeightForAllAnimatables(weight: number): AnimationGroup;
  123085. /**
  123086. * Synchronize and normalize all animatables with a source animatable
  123087. * @param root defines the root animatable to synchronize with
  123088. * @return the animationGroup
  123089. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123090. */
  123091. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  123092. /**
  123093. * Goes to a specific frame in this animation group
  123094. * @param frame the frame number to go to
  123095. * @return the animationGroup
  123096. */
  123097. goToFrame(frame: number): AnimationGroup;
  123098. /**
  123099. * Dispose all associated resources
  123100. */
  123101. dispose(): void;
  123102. private _checkAnimationGroupEnded;
  123103. /**
  123104. * Clone the current animation group and returns a copy
  123105. * @param newName defines the name of the new group
  123106. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  123107. * @returns the new aniamtion group
  123108. */
  123109. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  123110. /**
  123111. * Serializes the animationGroup to an object
  123112. * @returns Serialized object
  123113. */
  123114. serialize(): any;
  123115. /**
  123116. * Returns a new AnimationGroup object parsed from the source provided.
  123117. * @param parsedAnimationGroup defines the source
  123118. * @param scene defines the scene that will receive the animationGroup
  123119. * @returns a new AnimationGroup
  123120. */
  123121. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  123122. /**
  123123. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  123124. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  123125. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  123126. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  123127. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  123128. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  123129. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  123130. */
  123131. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  123132. /**
  123133. * Returns the string "AnimationGroup"
  123134. * @returns "AnimationGroup"
  123135. */
  123136. getClassName(): string;
  123137. /**
  123138. * Creates a detailled string about the object
  123139. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  123140. * @returns a string representing the object
  123141. */
  123142. toString(fullDetails?: boolean): string;
  123143. }
  123144. }
  123145. declare module BABYLON {
  123146. /**
  123147. * Define an interface for all classes that will hold resources
  123148. */
  123149. export interface IDisposable {
  123150. /**
  123151. * Releases all held resources
  123152. */
  123153. dispose(): void;
  123154. }
  123155. /** Interface defining initialization parameters for Scene class */
  123156. export interface SceneOptions {
  123157. /**
  123158. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  123159. * It will improve performance when the number of geometries becomes important.
  123160. */
  123161. useGeometryUniqueIdsMap?: boolean;
  123162. /**
  123163. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  123164. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123165. */
  123166. useMaterialMeshMap?: boolean;
  123167. /**
  123168. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  123169. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123170. */
  123171. useClonedMeshMap?: boolean;
  123172. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  123173. virtual?: boolean;
  123174. }
  123175. /**
  123176. * Represents a scene to be rendered by the engine.
  123177. * @see https://doc.babylonjs.com/features/scene
  123178. */
  123179. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  123180. /** The fog is deactivated */
  123181. static readonly FOGMODE_NONE: number;
  123182. /** The fog density is following an exponential function */
  123183. static readonly FOGMODE_EXP: number;
  123184. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  123185. static readonly FOGMODE_EXP2: number;
  123186. /** The fog density is following a linear function. */
  123187. static readonly FOGMODE_LINEAR: number;
  123188. /**
  123189. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  123190. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123191. */
  123192. static MinDeltaTime: number;
  123193. /**
  123194. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  123195. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123196. */
  123197. static MaxDeltaTime: number;
  123198. /**
  123199. * Factory used to create the default material.
  123200. * @param name The name of the material to create
  123201. * @param scene The scene to create the material for
  123202. * @returns The default material
  123203. */
  123204. static DefaultMaterialFactory(scene: Scene): Material;
  123205. /**
  123206. * Factory used to create the a collision coordinator.
  123207. * @returns The collision coordinator
  123208. */
  123209. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  123210. /** @hidden */
  123211. _inputManager: InputManager;
  123212. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  123213. cameraToUseForPointers: Nullable<Camera>;
  123214. /** @hidden */
  123215. readonly _isScene: boolean;
  123216. /** @hidden */
  123217. _blockEntityCollection: boolean;
  123218. /**
  123219. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  123220. */
  123221. autoClear: boolean;
  123222. /**
  123223. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  123224. */
  123225. autoClearDepthAndStencil: boolean;
  123226. /**
  123227. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  123228. */
  123229. clearColor: Color4;
  123230. /**
  123231. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  123232. */
  123233. ambientColor: Color3;
  123234. /**
  123235. * This is use to store the default BRDF lookup for PBR materials in your scene.
  123236. * It should only be one of the following (if not the default embedded one):
  123237. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  123238. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  123239. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  123240. * The material properties need to be setup according to the type of texture in use.
  123241. */
  123242. environmentBRDFTexture: BaseTexture;
  123243. /**
  123244. * Texture used in all pbr material as the reflection texture.
  123245. * As in the majority of the scene they are the same (exception for multi room and so on),
  123246. * this is easier to reference from here than from all the materials.
  123247. */
  123248. get environmentTexture(): Nullable<BaseTexture>;
  123249. /**
  123250. * Texture used in all pbr material as the reflection texture.
  123251. * As in the majority of the scene they are the same (exception for multi room and so on),
  123252. * this is easier to set here than in all the materials.
  123253. */
  123254. set environmentTexture(value: Nullable<BaseTexture>);
  123255. /** @hidden */
  123256. protected _environmentIntensity: number;
  123257. /**
  123258. * Intensity of the environment in all pbr material.
  123259. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123260. * As in the majority of the scene they are the same (exception for multi room and so on),
  123261. * this is easier to reference from here than from all the materials.
  123262. */
  123263. get environmentIntensity(): number;
  123264. /**
  123265. * Intensity of the environment in all pbr material.
  123266. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123267. * As in the majority of the scene they are the same (exception for multi room and so on),
  123268. * this is easier to set here than in all the materials.
  123269. */
  123270. set environmentIntensity(value: number);
  123271. /** @hidden */
  123272. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123273. /**
  123274. * Default image processing configuration used either in the rendering
  123275. * Forward main pass or through the imageProcessingPostProcess if present.
  123276. * As in the majority of the scene they are the same (exception for multi camera),
  123277. * this is easier to reference from here than from all the materials and post process.
  123278. *
  123279. * No setter as we it is a shared configuration, you can set the values instead.
  123280. */
  123281. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123282. private _forceWireframe;
  123283. /**
  123284. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123285. */
  123286. set forceWireframe(value: boolean);
  123287. get forceWireframe(): boolean;
  123288. private _skipFrustumClipping;
  123289. /**
  123290. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123291. */
  123292. set skipFrustumClipping(value: boolean);
  123293. get skipFrustumClipping(): boolean;
  123294. private _forcePointsCloud;
  123295. /**
  123296. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123297. */
  123298. set forcePointsCloud(value: boolean);
  123299. get forcePointsCloud(): boolean;
  123300. /**
  123301. * Gets or sets the active clipplane 1
  123302. */
  123303. clipPlane: Nullable<Plane>;
  123304. /**
  123305. * Gets or sets the active clipplane 2
  123306. */
  123307. clipPlane2: Nullable<Plane>;
  123308. /**
  123309. * Gets or sets the active clipplane 3
  123310. */
  123311. clipPlane3: Nullable<Plane>;
  123312. /**
  123313. * Gets or sets the active clipplane 4
  123314. */
  123315. clipPlane4: Nullable<Plane>;
  123316. /**
  123317. * Gets or sets the active clipplane 5
  123318. */
  123319. clipPlane5: Nullable<Plane>;
  123320. /**
  123321. * Gets or sets the active clipplane 6
  123322. */
  123323. clipPlane6: Nullable<Plane>;
  123324. /**
  123325. * Gets or sets a boolean indicating if animations are enabled
  123326. */
  123327. animationsEnabled: boolean;
  123328. private _animationPropertiesOverride;
  123329. /**
  123330. * Gets or sets the animation properties override
  123331. */
  123332. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123333. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123334. /**
  123335. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123336. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123337. */
  123338. useConstantAnimationDeltaTime: boolean;
  123339. /**
  123340. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123341. * Please note that it requires to run a ray cast through the scene on every frame
  123342. */
  123343. constantlyUpdateMeshUnderPointer: boolean;
  123344. /**
  123345. * Defines the HTML cursor to use when hovering over interactive elements
  123346. */
  123347. hoverCursor: string;
  123348. /**
  123349. * Defines the HTML default cursor to use (empty by default)
  123350. */
  123351. defaultCursor: string;
  123352. /**
  123353. * Defines whether cursors are handled by the scene.
  123354. */
  123355. doNotHandleCursors: boolean;
  123356. /**
  123357. * This is used to call preventDefault() on pointer down
  123358. * in order to block unwanted artifacts like system double clicks
  123359. */
  123360. preventDefaultOnPointerDown: boolean;
  123361. /**
  123362. * This is used to call preventDefault() on pointer up
  123363. * in order to block unwanted artifacts like system double clicks
  123364. */
  123365. preventDefaultOnPointerUp: boolean;
  123366. /**
  123367. * Gets or sets user defined metadata
  123368. */
  123369. metadata: any;
  123370. /**
  123371. * For internal use only. Please do not use.
  123372. */
  123373. reservedDataStore: any;
  123374. /**
  123375. * Gets the name of the plugin used to load this scene (null by default)
  123376. */
  123377. loadingPluginName: string;
  123378. /**
  123379. * Use this array to add regular expressions used to disable offline support for specific urls
  123380. */
  123381. disableOfflineSupportExceptionRules: RegExp[];
  123382. /**
  123383. * An event triggered when the scene is disposed.
  123384. */
  123385. onDisposeObservable: Observable<Scene>;
  123386. private _onDisposeObserver;
  123387. /** Sets a function to be executed when this scene is disposed. */
  123388. set onDispose(callback: () => void);
  123389. /**
  123390. * An event triggered before rendering the scene (right after animations and physics)
  123391. */
  123392. onBeforeRenderObservable: Observable<Scene>;
  123393. private _onBeforeRenderObserver;
  123394. /** Sets a function to be executed before rendering this scene */
  123395. set beforeRender(callback: Nullable<() => void>);
  123396. /**
  123397. * An event triggered after rendering the scene
  123398. */
  123399. onAfterRenderObservable: Observable<Scene>;
  123400. /**
  123401. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  123402. */
  123403. onAfterRenderCameraObservable: Observable<Camera>;
  123404. private _onAfterRenderObserver;
  123405. /** Sets a function to be executed after rendering this scene */
  123406. set afterRender(callback: Nullable<() => void>);
  123407. /**
  123408. * An event triggered before animating the scene
  123409. */
  123410. onBeforeAnimationsObservable: Observable<Scene>;
  123411. /**
  123412. * An event triggered after animations processing
  123413. */
  123414. onAfterAnimationsObservable: Observable<Scene>;
  123415. /**
  123416. * An event triggered before draw calls are ready to be sent
  123417. */
  123418. onBeforeDrawPhaseObservable: Observable<Scene>;
  123419. /**
  123420. * An event triggered after draw calls have been sent
  123421. */
  123422. onAfterDrawPhaseObservable: Observable<Scene>;
  123423. /**
  123424. * An event triggered when the scene is ready
  123425. */
  123426. onReadyObservable: Observable<Scene>;
  123427. /**
  123428. * An event triggered before rendering a camera
  123429. */
  123430. onBeforeCameraRenderObservable: Observable<Camera>;
  123431. private _onBeforeCameraRenderObserver;
  123432. /** Sets a function to be executed before rendering a camera*/
  123433. set beforeCameraRender(callback: () => void);
  123434. /**
  123435. * An event triggered after rendering a camera
  123436. */
  123437. onAfterCameraRenderObservable: Observable<Camera>;
  123438. private _onAfterCameraRenderObserver;
  123439. /** Sets a function to be executed after rendering a camera*/
  123440. set afterCameraRender(callback: () => void);
  123441. /**
  123442. * An event triggered when active meshes evaluation is about to start
  123443. */
  123444. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  123445. /**
  123446. * An event triggered when active meshes evaluation is done
  123447. */
  123448. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  123449. /**
  123450. * An event triggered when particles rendering is about to start
  123451. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123452. */
  123453. onBeforeParticlesRenderingObservable: Observable<Scene>;
  123454. /**
  123455. * An event triggered when particles rendering is done
  123456. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123457. */
  123458. onAfterParticlesRenderingObservable: Observable<Scene>;
  123459. /**
  123460. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  123461. */
  123462. onDataLoadedObservable: Observable<Scene>;
  123463. /**
  123464. * An event triggered when a camera is created
  123465. */
  123466. onNewCameraAddedObservable: Observable<Camera>;
  123467. /**
  123468. * An event triggered when a camera is removed
  123469. */
  123470. onCameraRemovedObservable: Observable<Camera>;
  123471. /**
  123472. * An event triggered when a light is created
  123473. */
  123474. onNewLightAddedObservable: Observable<Light>;
  123475. /**
  123476. * An event triggered when a light is removed
  123477. */
  123478. onLightRemovedObservable: Observable<Light>;
  123479. /**
  123480. * An event triggered when a geometry is created
  123481. */
  123482. onNewGeometryAddedObservable: Observable<Geometry>;
  123483. /**
  123484. * An event triggered when a geometry is removed
  123485. */
  123486. onGeometryRemovedObservable: Observable<Geometry>;
  123487. /**
  123488. * An event triggered when a transform node is created
  123489. */
  123490. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  123491. /**
  123492. * An event triggered when a transform node is removed
  123493. */
  123494. onTransformNodeRemovedObservable: Observable<TransformNode>;
  123495. /**
  123496. * An event triggered when a mesh is created
  123497. */
  123498. onNewMeshAddedObservable: Observable<AbstractMesh>;
  123499. /**
  123500. * An event triggered when a mesh is removed
  123501. */
  123502. onMeshRemovedObservable: Observable<AbstractMesh>;
  123503. /**
  123504. * An event triggered when a skeleton is created
  123505. */
  123506. onNewSkeletonAddedObservable: Observable<Skeleton>;
  123507. /**
  123508. * An event triggered when a skeleton is removed
  123509. */
  123510. onSkeletonRemovedObservable: Observable<Skeleton>;
  123511. /**
  123512. * An event triggered when a material is created
  123513. */
  123514. onNewMaterialAddedObservable: Observable<Material>;
  123515. /**
  123516. * An event triggered when a material is removed
  123517. */
  123518. onMaterialRemovedObservable: Observable<Material>;
  123519. /**
  123520. * An event triggered when a texture is created
  123521. */
  123522. onNewTextureAddedObservable: Observable<BaseTexture>;
  123523. /**
  123524. * An event triggered when a texture is removed
  123525. */
  123526. onTextureRemovedObservable: Observable<BaseTexture>;
  123527. /**
  123528. * An event triggered when render targets are about to be rendered
  123529. * Can happen multiple times per frame.
  123530. */
  123531. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  123532. /**
  123533. * An event triggered when render targets were rendered.
  123534. * Can happen multiple times per frame.
  123535. */
  123536. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  123537. /**
  123538. * An event triggered before calculating deterministic simulation step
  123539. */
  123540. onBeforeStepObservable: Observable<Scene>;
  123541. /**
  123542. * An event triggered after calculating deterministic simulation step
  123543. */
  123544. onAfterStepObservable: Observable<Scene>;
  123545. /**
  123546. * An event triggered when the activeCamera property is updated
  123547. */
  123548. onActiveCameraChanged: Observable<Scene>;
  123549. /**
  123550. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  123551. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123552. * 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)
  123553. */
  123554. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123555. /**
  123556. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  123557. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123558. * 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)
  123559. */
  123560. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123561. /**
  123562. * This Observable will when a mesh has been imported into the scene.
  123563. */
  123564. onMeshImportedObservable: Observable<AbstractMesh>;
  123565. /**
  123566. * This Observable will when an animation file has been imported into the scene.
  123567. */
  123568. onAnimationFileImportedObservable: Observable<Scene>;
  123569. /**
  123570. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  123571. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  123572. */
  123573. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  123574. /** @hidden */
  123575. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  123576. /**
  123577. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  123578. */
  123579. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  123580. /**
  123581. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  123582. */
  123583. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  123584. /**
  123585. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  123586. */
  123587. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  123588. /** Callback called when a pointer move is detected */
  123589. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123590. /** Callback called when a pointer down is detected */
  123591. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123592. /** Callback called when a pointer up is detected */
  123593. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  123594. /** Callback called when a pointer pick is detected */
  123595. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  123596. /**
  123597. * 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).
  123598. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  123599. */
  123600. onPrePointerObservable: Observable<PointerInfoPre>;
  123601. /**
  123602. * Observable event triggered each time an input event is received from the rendering canvas
  123603. */
  123604. onPointerObservable: Observable<PointerInfo>;
  123605. /**
  123606. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  123607. */
  123608. get unTranslatedPointer(): Vector2;
  123609. /**
  123610. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  123611. */
  123612. static get DragMovementThreshold(): number;
  123613. static set DragMovementThreshold(value: number);
  123614. /**
  123615. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  123616. */
  123617. static get LongPressDelay(): number;
  123618. static set LongPressDelay(value: number);
  123619. /**
  123620. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  123621. */
  123622. static get DoubleClickDelay(): number;
  123623. static set DoubleClickDelay(value: number);
  123624. /** If you need to check double click without raising a single click at first click, enable this flag */
  123625. static get ExclusiveDoubleClickMode(): boolean;
  123626. static set ExclusiveDoubleClickMode(value: boolean);
  123627. /** @hidden */
  123628. _mirroredCameraPosition: Nullable<Vector3>;
  123629. /**
  123630. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  123631. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  123632. */
  123633. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  123634. /**
  123635. * Observable event triggered each time an keyboard event is received from the hosting window
  123636. */
  123637. onKeyboardObservable: Observable<KeyboardInfo>;
  123638. private _useRightHandedSystem;
  123639. /**
  123640. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  123641. */
  123642. set useRightHandedSystem(value: boolean);
  123643. get useRightHandedSystem(): boolean;
  123644. private _timeAccumulator;
  123645. private _currentStepId;
  123646. private _currentInternalStep;
  123647. /**
  123648. * Sets the step Id used by deterministic lock step
  123649. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123650. * @param newStepId defines the step Id
  123651. */
  123652. setStepId(newStepId: number): void;
  123653. /**
  123654. * Gets the step Id used by deterministic lock step
  123655. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123656. * @returns the step Id
  123657. */
  123658. getStepId(): number;
  123659. /**
  123660. * Gets the internal step used by deterministic lock step
  123661. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123662. * @returns the internal step
  123663. */
  123664. getInternalStep(): number;
  123665. private _fogEnabled;
  123666. /**
  123667. * Gets or sets a boolean indicating if fog is enabled on this scene
  123668. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123669. * (Default is true)
  123670. */
  123671. set fogEnabled(value: boolean);
  123672. get fogEnabled(): boolean;
  123673. private _fogMode;
  123674. /**
  123675. * Gets or sets the fog mode to use
  123676. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123677. * | mode | value |
  123678. * | --- | --- |
  123679. * | FOGMODE_NONE | 0 |
  123680. * | FOGMODE_EXP | 1 |
  123681. * | FOGMODE_EXP2 | 2 |
  123682. * | FOGMODE_LINEAR | 3 |
  123683. */
  123684. set fogMode(value: number);
  123685. get fogMode(): number;
  123686. /**
  123687. * Gets or sets the fog color to use
  123688. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123689. * (Default is Color3(0.2, 0.2, 0.3))
  123690. */
  123691. fogColor: Color3;
  123692. /**
  123693. * Gets or sets the fog density to use
  123694. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123695. * (Default is 0.1)
  123696. */
  123697. fogDensity: number;
  123698. /**
  123699. * Gets or sets the fog start distance to use
  123700. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123701. * (Default is 0)
  123702. */
  123703. fogStart: number;
  123704. /**
  123705. * Gets or sets the fog end distance to use
  123706. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123707. * (Default is 1000)
  123708. */
  123709. fogEnd: number;
  123710. /**
  123711. * Flag indicating that the frame buffer binding is handled by another component
  123712. */
  123713. prePass: boolean;
  123714. private _shadowsEnabled;
  123715. /**
  123716. * Gets or sets a boolean indicating if shadows are enabled on this scene
  123717. */
  123718. set shadowsEnabled(value: boolean);
  123719. get shadowsEnabled(): boolean;
  123720. private _lightsEnabled;
  123721. /**
  123722. * Gets or sets a boolean indicating if lights are enabled on this scene
  123723. */
  123724. set lightsEnabled(value: boolean);
  123725. get lightsEnabled(): boolean;
  123726. /** All of the active cameras added to this scene. */
  123727. activeCameras: Camera[];
  123728. /** @hidden */
  123729. _activeCamera: Nullable<Camera>;
  123730. /** Gets or sets the current active camera */
  123731. get activeCamera(): Nullable<Camera>;
  123732. set activeCamera(value: Nullable<Camera>);
  123733. private _defaultMaterial;
  123734. /** The default material used on meshes when no material is affected */
  123735. get defaultMaterial(): Material;
  123736. /** The default material used on meshes when no material is affected */
  123737. set defaultMaterial(value: Material);
  123738. private _texturesEnabled;
  123739. /**
  123740. * Gets or sets a boolean indicating if textures are enabled on this scene
  123741. */
  123742. set texturesEnabled(value: boolean);
  123743. get texturesEnabled(): boolean;
  123744. /**
  123745. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  123746. */
  123747. physicsEnabled: boolean;
  123748. /**
  123749. * Gets or sets a boolean indicating if particles are enabled on this scene
  123750. */
  123751. particlesEnabled: boolean;
  123752. /**
  123753. * Gets or sets a boolean indicating if sprites are enabled on this scene
  123754. */
  123755. spritesEnabled: boolean;
  123756. private _skeletonsEnabled;
  123757. /**
  123758. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  123759. */
  123760. set skeletonsEnabled(value: boolean);
  123761. get skeletonsEnabled(): boolean;
  123762. /**
  123763. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  123764. */
  123765. lensFlaresEnabled: boolean;
  123766. /**
  123767. * Gets or sets a boolean indicating if collisions are enabled on this scene
  123768. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123769. */
  123770. collisionsEnabled: boolean;
  123771. private _collisionCoordinator;
  123772. /** @hidden */
  123773. get collisionCoordinator(): ICollisionCoordinator;
  123774. /**
  123775. * Defines the gravity applied to this scene (used only for collisions)
  123776. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123777. */
  123778. gravity: Vector3;
  123779. /**
  123780. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  123781. */
  123782. postProcessesEnabled: boolean;
  123783. /**
  123784. * Gets the current postprocess manager
  123785. */
  123786. postProcessManager: PostProcessManager;
  123787. /**
  123788. * Gets or sets a boolean indicating if render targets are enabled on this scene
  123789. */
  123790. renderTargetsEnabled: boolean;
  123791. /**
  123792. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  123793. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  123794. */
  123795. dumpNextRenderTargets: boolean;
  123796. /**
  123797. * The list of user defined render targets added to the scene
  123798. */
  123799. customRenderTargets: RenderTargetTexture[];
  123800. /**
  123801. * Defines if texture loading must be delayed
  123802. * If true, textures will only be loaded when they need to be rendered
  123803. */
  123804. useDelayedTextureLoading: boolean;
  123805. /**
  123806. * Gets the list of meshes imported to the scene through SceneLoader
  123807. */
  123808. importedMeshesFiles: String[];
  123809. /**
  123810. * Gets or sets a boolean indicating if probes are enabled on this scene
  123811. */
  123812. probesEnabled: boolean;
  123813. /**
  123814. * Gets or sets the current offline provider to use to store scene data
  123815. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  123816. */
  123817. offlineProvider: IOfflineProvider;
  123818. /**
  123819. * Gets or sets the action manager associated with the scene
  123820. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  123821. */
  123822. actionManager: AbstractActionManager;
  123823. private _meshesForIntersections;
  123824. /**
  123825. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  123826. */
  123827. proceduralTexturesEnabled: boolean;
  123828. private _engine;
  123829. private _totalVertices;
  123830. /** @hidden */
  123831. _activeIndices: PerfCounter;
  123832. /** @hidden */
  123833. _activeParticles: PerfCounter;
  123834. /** @hidden */
  123835. _activeBones: PerfCounter;
  123836. private _animationRatio;
  123837. /** @hidden */
  123838. _animationTimeLast: number;
  123839. /** @hidden */
  123840. _animationTime: number;
  123841. /**
  123842. * Gets or sets a general scale for animation speed
  123843. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  123844. */
  123845. animationTimeScale: number;
  123846. /** @hidden */
  123847. _cachedMaterial: Nullable<Material>;
  123848. /** @hidden */
  123849. _cachedEffect: Nullable<Effect>;
  123850. /** @hidden */
  123851. _cachedVisibility: Nullable<number>;
  123852. private _renderId;
  123853. private _frameId;
  123854. private _executeWhenReadyTimeoutId;
  123855. private _intermediateRendering;
  123856. private _viewUpdateFlag;
  123857. private _projectionUpdateFlag;
  123858. /** @hidden */
  123859. _toBeDisposed: Nullable<IDisposable>[];
  123860. private _activeRequests;
  123861. /** @hidden */
  123862. _pendingData: any[];
  123863. private _isDisposed;
  123864. /**
  123865. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  123866. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  123867. */
  123868. dispatchAllSubMeshesOfActiveMeshes: boolean;
  123869. private _activeMeshes;
  123870. private _processedMaterials;
  123871. private _renderTargets;
  123872. /** @hidden */
  123873. _activeParticleSystems: SmartArray<IParticleSystem>;
  123874. private _activeSkeletons;
  123875. private _softwareSkinnedMeshes;
  123876. private _renderingManager;
  123877. /** @hidden */
  123878. _activeAnimatables: Animatable[];
  123879. private _transformMatrix;
  123880. private _sceneUbo;
  123881. /** @hidden */
  123882. _viewMatrix: Matrix;
  123883. private _projectionMatrix;
  123884. /** @hidden */
  123885. _forcedViewPosition: Nullable<Vector3>;
  123886. /** @hidden */
  123887. _frustumPlanes: Plane[];
  123888. /**
  123889. * Gets the list of frustum planes (built from the active camera)
  123890. */
  123891. get frustumPlanes(): Plane[];
  123892. /**
  123893. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  123894. * This is useful if there are more lights that the maximum simulteanous authorized
  123895. */
  123896. requireLightSorting: boolean;
  123897. /** @hidden */
  123898. readonly useMaterialMeshMap: boolean;
  123899. /** @hidden */
  123900. readonly useClonedMeshMap: boolean;
  123901. private _externalData;
  123902. private _uid;
  123903. /**
  123904. * @hidden
  123905. * Backing store of defined scene components.
  123906. */
  123907. _components: ISceneComponent[];
  123908. /**
  123909. * @hidden
  123910. * Backing store of defined scene components.
  123911. */
  123912. _serializableComponents: ISceneSerializableComponent[];
  123913. /**
  123914. * List of components to register on the next registration step.
  123915. */
  123916. private _transientComponents;
  123917. /**
  123918. * Registers the transient components if needed.
  123919. */
  123920. private _registerTransientComponents;
  123921. /**
  123922. * @hidden
  123923. * Add a component to the scene.
  123924. * Note that the ccomponent could be registered on th next frame if this is called after
  123925. * the register component stage.
  123926. * @param component Defines the component to add to the scene
  123927. */
  123928. _addComponent(component: ISceneComponent): void;
  123929. /**
  123930. * @hidden
  123931. * Gets a component from the scene.
  123932. * @param name defines the name of the component to retrieve
  123933. * @returns the component or null if not present
  123934. */
  123935. _getComponent(name: string): Nullable<ISceneComponent>;
  123936. /**
  123937. * @hidden
  123938. * Defines the actions happening before camera updates.
  123939. */
  123940. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  123941. /**
  123942. * @hidden
  123943. * Defines the actions happening before clear the canvas.
  123944. */
  123945. _beforeClearStage: Stage<SimpleStageAction>;
  123946. /**
  123947. * @hidden
  123948. * Defines the actions when collecting render targets for the frame.
  123949. */
  123950. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123951. /**
  123952. * @hidden
  123953. * Defines the actions happening for one camera in the frame.
  123954. */
  123955. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123956. /**
  123957. * @hidden
  123958. * Defines the actions happening during the per mesh ready checks.
  123959. */
  123960. _isReadyForMeshStage: Stage<MeshStageAction>;
  123961. /**
  123962. * @hidden
  123963. * Defines the actions happening before evaluate active mesh checks.
  123964. */
  123965. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  123966. /**
  123967. * @hidden
  123968. * Defines the actions happening during the evaluate sub mesh checks.
  123969. */
  123970. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  123971. /**
  123972. * @hidden
  123973. * Defines the actions happening during the active mesh stage.
  123974. */
  123975. _activeMeshStage: Stage<ActiveMeshStageAction>;
  123976. /**
  123977. * @hidden
  123978. * Defines the actions happening during the per camera render target step.
  123979. */
  123980. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  123981. /**
  123982. * @hidden
  123983. * Defines the actions happening just before the active camera is drawing.
  123984. */
  123985. _beforeCameraDrawStage: Stage<CameraStageAction>;
  123986. /**
  123987. * @hidden
  123988. * Defines the actions happening just before a render target is drawing.
  123989. */
  123990. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123991. /**
  123992. * @hidden
  123993. * Defines the actions happening just before a rendering group is drawing.
  123994. */
  123995. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123996. /**
  123997. * @hidden
  123998. * Defines the actions happening just before a mesh is drawing.
  123999. */
  124000. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124001. /**
  124002. * @hidden
  124003. * Defines the actions happening just after a mesh has been drawn.
  124004. */
  124005. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124006. /**
  124007. * @hidden
  124008. * Defines the actions happening just after a rendering group has been drawn.
  124009. */
  124010. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124011. /**
  124012. * @hidden
  124013. * Defines the actions happening just after the active camera has been drawn.
  124014. */
  124015. _afterCameraDrawStage: Stage<CameraStageAction>;
  124016. /**
  124017. * @hidden
  124018. * Defines the actions happening just after a render target has been drawn.
  124019. */
  124020. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124021. /**
  124022. * @hidden
  124023. * Defines the actions happening just after rendering all cameras and computing intersections.
  124024. */
  124025. _afterRenderStage: Stage<SimpleStageAction>;
  124026. /**
  124027. * @hidden
  124028. * Defines the actions happening when a pointer move event happens.
  124029. */
  124030. _pointerMoveStage: Stage<PointerMoveStageAction>;
  124031. /**
  124032. * @hidden
  124033. * Defines the actions happening when a pointer down event happens.
  124034. */
  124035. _pointerDownStage: Stage<PointerUpDownStageAction>;
  124036. /**
  124037. * @hidden
  124038. * Defines the actions happening when a pointer up event happens.
  124039. */
  124040. _pointerUpStage: Stage<PointerUpDownStageAction>;
  124041. /**
  124042. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  124043. */
  124044. private geometriesByUniqueId;
  124045. /**
  124046. * Creates a new Scene
  124047. * @param engine defines the engine to use to render this scene
  124048. * @param options defines the scene options
  124049. */
  124050. constructor(engine: Engine, options?: SceneOptions);
  124051. /**
  124052. * Gets a string identifying the name of the class
  124053. * @returns "Scene" string
  124054. */
  124055. getClassName(): string;
  124056. private _defaultMeshCandidates;
  124057. /**
  124058. * @hidden
  124059. */
  124060. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  124061. private _defaultSubMeshCandidates;
  124062. /**
  124063. * @hidden
  124064. */
  124065. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  124066. /**
  124067. * Sets the default candidate providers for the scene.
  124068. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  124069. * and getCollidingSubMeshCandidates to their default function
  124070. */
  124071. setDefaultCandidateProviders(): void;
  124072. /**
  124073. * Gets the mesh that is currently under the pointer
  124074. */
  124075. get meshUnderPointer(): Nullable<AbstractMesh>;
  124076. /**
  124077. * Gets or sets the current on-screen X position of the pointer
  124078. */
  124079. get pointerX(): number;
  124080. set pointerX(value: number);
  124081. /**
  124082. * Gets or sets the current on-screen Y position of the pointer
  124083. */
  124084. get pointerY(): number;
  124085. set pointerY(value: number);
  124086. /**
  124087. * Gets the cached material (ie. the latest rendered one)
  124088. * @returns the cached material
  124089. */
  124090. getCachedMaterial(): Nullable<Material>;
  124091. /**
  124092. * Gets the cached effect (ie. the latest rendered one)
  124093. * @returns the cached effect
  124094. */
  124095. getCachedEffect(): Nullable<Effect>;
  124096. /**
  124097. * Gets the cached visibility state (ie. the latest rendered one)
  124098. * @returns the cached visibility state
  124099. */
  124100. getCachedVisibility(): Nullable<number>;
  124101. /**
  124102. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  124103. * @param material defines the current material
  124104. * @param effect defines the current effect
  124105. * @param visibility defines the current visibility state
  124106. * @returns true if one parameter is not cached
  124107. */
  124108. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  124109. /**
  124110. * Gets the engine associated with the scene
  124111. * @returns an Engine
  124112. */
  124113. getEngine(): Engine;
  124114. /**
  124115. * Gets the total number of vertices rendered per frame
  124116. * @returns the total number of vertices rendered per frame
  124117. */
  124118. getTotalVertices(): number;
  124119. /**
  124120. * Gets the performance counter for total vertices
  124121. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124122. */
  124123. get totalVerticesPerfCounter(): PerfCounter;
  124124. /**
  124125. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  124126. * @returns the total number of active indices rendered per frame
  124127. */
  124128. getActiveIndices(): number;
  124129. /**
  124130. * Gets the performance counter for active indices
  124131. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124132. */
  124133. get totalActiveIndicesPerfCounter(): PerfCounter;
  124134. /**
  124135. * Gets the total number of active particles rendered per frame
  124136. * @returns the total number of active particles rendered per frame
  124137. */
  124138. getActiveParticles(): number;
  124139. /**
  124140. * Gets the performance counter for active particles
  124141. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124142. */
  124143. get activeParticlesPerfCounter(): PerfCounter;
  124144. /**
  124145. * Gets the total number of active bones rendered per frame
  124146. * @returns the total number of active bones rendered per frame
  124147. */
  124148. getActiveBones(): number;
  124149. /**
  124150. * Gets the performance counter for active bones
  124151. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124152. */
  124153. get activeBonesPerfCounter(): PerfCounter;
  124154. /**
  124155. * Gets the array of active meshes
  124156. * @returns an array of AbstractMesh
  124157. */
  124158. getActiveMeshes(): SmartArray<AbstractMesh>;
  124159. /**
  124160. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  124161. * @returns a number
  124162. */
  124163. getAnimationRatio(): number;
  124164. /**
  124165. * Gets an unique Id for the current render phase
  124166. * @returns a number
  124167. */
  124168. getRenderId(): number;
  124169. /**
  124170. * Gets an unique Id for the current frame
  124171. * @returns a number
  124172. */
  124173. getFrameId(): number;
  124174. /** Call this function if you want to manually increment the render Id*/
  124175. incrementRenderId(): void;
  124176. private _createUbo;
  124177. /**
  124178. * Use this method to simulate a pointer move on a mesh
  124179. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124180. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124181. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124182. * @returns the current scene
  124183. */
  124184. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124185. /**
  124186. * Use this method to simulate a pointer down on a mesh
  124187. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124188. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124189. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124190. * @returns the current scene
  124191. */
  124192. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124193. /**
  124194. * Use this method to simulate a pointer up on a mesh
  124195. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124196. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124197. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124198. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124199. * @returns the current scene
  124200. */
  124201. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  124202. /**
  124203. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124204. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124205. * @returns true if the pointer was captured
  124206. */
  124207. isPointerCaptured(pointerId?: number): boolean;
  124208. /**
  124209. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124210. * @param attachUp defines if you want to attach events to pointerup
  124211. * @param attachDown defines if you want to attach events to pointerdown
  124212. * @param attachMove defines if you want to attach events to pointermove
  124213. */
  124214. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  124215. /** Detaches all event handlers*/
  124216. detachControl(): void;
  124217. /**
  124218. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  124219. * Delay loaded resources are not taking in account
  124220. * @return true if all required resources are ready
  124221. */
  124222. isReady(): boolean;
  124223. /** Resets all cached information relative to material (including effect and visibility) */
  124224. resetCachedMaterial(): void;
  124225. /**
  124226. * Registers a function to be called before every frame render
  124227. * @param func defines the function to register
  124228. */
  124229. registerBeforeRender(func: () => void): void;
  124230. /**
  124231. * Unregisters a function called before every frame render
  124232. * @param func defines the function to unregister
  124233. */
  124234. unregisterBeforeRender(func: () => void): void;
  124235. /**
  124236. * Registers a function to be called after every frame render
  124237. * @param func defines the function to register
  124238. */
  124239. registerAfterRender(func: () => void): void;
  124240. /**
  124241. * Unregisters a function called after every frame render
  124242. * @param func defines the function to unregister
  124243. */
  124244. unregisterAfterRender(func: () => void): void;
  124245. private _executeOnceBeforeRender;
  124246. /**
  124247. * The provided function will run before render once and will be disposed afterwards.
  124248. * A timeout delay can be provided so that the function will be executed in N ms.
  124249. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  124250. * @param func The function to be executed.
  124251. * @param timeout optional delay in ms
  124252. */
  124253. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  124254. /** @hidden */
  124255. _addPendingData(data: any): void;
  124256. /** @hidden */
  124257. _removePendingData(data: any): void;
  124258. /**
  124259. * Returns the number of items waiting to be loaded
  124260. * @returns the number of items waiting to be loaded
  124261. */
  124262. getWaitingItemsCount(): number;
  124263. /**
  124264. * Returns a boolean indicating if the scene is still loading data
  124265. */
  124266. get isLoading(): boolean;
  124267. /**
  124268. * Registers a function to be executed when the scene is ready
  124269. * @param {Function} func - the function to be executed
  124270. */
  124271. executeWhenReady(func: () => void): void;
  124272. /**
  124273. * Returns a promise that resolves when the scene is ready
  124274. * @returns A promise that resolves when the scene is ready
  124275. */
  124276. whenReadyAsync(): Promise<void>;
  124277. /** @hidden */
  124278. _checkIsReady(): void;
  124279. /**
  124280. * Gets all animatable attached to the scene
  124281. */
  124282. get animatables(): Animatable[];
  124283. /**
  124284. * Resets the last animation time frame.
  124285. * Useful to override when animations start running when loading a scene for the first time.
  124286. */
  124287. resetLastAnimationTimeFrame(): void;
  124288. /**
  124289. * Gets the current view matrix
  124290. * @returns a Matrix
  124291. */
  124292. getViewMatrix(): Matrix;
  124293. /**
  124294. * Gets the current projection matrix
  124295. * @returns a Matrix
  124296. */
  124297. getProjectionMatrix(): Matrix;
  124298. /**
  124299. * Gets the current transform matrix
  124300. * @returns a Matrix made of View * Projection
  124301. */
  124302. getTransformMatrix(): Matrix;
  124303. /**
  124304. * Sets the current transform matrix
  124305. * @param viewL defines the View matrix to use
  124306. * @param projectionL defines the Projection matrix to use
  124307. * @param viewR defines the right View matrix to use (if provided)
  124308. * @param projectionR defines the right Projection matrix to use (if provided)
  124309. */
  124310. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124311. /**
  124312. * Gets the uniform buffer used to store scene data
  124313. * @returns a UniformBuffer
  124314. */
  124315. getSceneUniformBuffer(): UniformBuffer;
  124316. /**
  124317. * Gets an unique (relatively to the current scene) Id
  124318. * @returns an unique number for the scene
  124319. */
  124320. getUniqueId(): number;
  124321. /**
  124322. * Add a mesh to the list of scene's meshes
  124323. * @param newMesh defines the mesh to add
  124324. * @param recursive if all child meshes should also be added to the scene
  124325. */
  124326. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124327. /**
  124328. * Remove a mesh for the list of scene's meshes
  124329. * @param toRemove defines the mesh to remove
  124330. * @param recursive if all child meshes should also be removed from the scene
  124331. * @returns the index where the mesh was in the mesh list
  124332. */
  124333. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124334. /**
  124335. * Add a transform node to the list of scene's transform nodes
  124336. * @param newTransformNode defines the transform node to add
  124337. */
  124338. addTransformNode(newTransformNode: TransformNode): void;
  124339. /**
  124340. * Remove a transform node for the list of scene's transform nodes
  124341. * @param toRemove defines the transform node to remove
  124342. * @returns the index where the transform node was in the transform node list
  124343. */
  124344. removeTransformNode(toRemove: TransformNode): number;
  124345. /**
  124346. * Remove a skeleton for the list of scene's skeletons
  124347. * @param toRemove defines the skeleton to remove
  124348. * @returns the index where the skeleton was in the skeleton list
  124349. */
  124350. removeSkeleton(toRemove: Skeleton): number;
  124351. /**
  124352. * Remove a morph target for the list of scene's morph targets
  124353. * @param toRemove defines the morph target to remove
  124354. * @returns the index where the morph target was in the morph target list
  124355. */
  124356. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  124357. /**
  124358. * Remove a light for the list of scene's lights
  124359. * @param toRemove defines the light to remove
  124360. * @returns the index where the light was in the light list
  124361. */
  124362. removeLight(toRemove: Light): number;
  124363. /**
  124364. * Remove a camera for the list of scene's cameras
  124365. * @param toRemove defines the camera to remove
  124366. * @returns the index where the camera was in the camera list
  124367. */
  124368. removeCamera(toRemove: Camera): number;
  124369. /**
  124370. * Remove a particle system for the list of scene's particle systems
  124371. * @param toRemove defines the particle system to remove
  124372. * @returns the index where the particle system was in the particle system list
  124373. */
  124374. removeParticleSystem(toRemove: IParticleSystem): number;
  124375. /**
  124376. * Remove a animation for the list of scene's animations
  124377. * @param toRemove defines the animation to remove
  124378. * @returns the index where the animation was in the animation list
  124379. */
  124380. removeAnimation(toRemove: Animation): number;
  124381. /**
  124382. * Will stop the animation of the given target
  124383. * @param target - the target
  124384. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  124385. * @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)
  124386. */
  124387. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  124388. /**
  124389. * Removes the given animation group from this scene.
  124390. * @param toRemove The animation group to remove
  124391. * @returns The index of the removed animation group
  124392. */
  124393. removeAnimationGroup(toRemove: AnimationGroup): number;
  124394. /**
  124395. * Removes the given multi-material from this scene.
  124396. * @param toRemove The multi-material to remove
  124397. * @returns The index of the removed multi-material
  124398. */
  124399. removeMultiMaterial(toRemove: MultiMaterial): number;
  124400. /**
  124401. * Removes the given material from this scene.
  124402. * @param toRemove The material to remove
  124403. * @returns The index of the removed material
  124404. */
  124405. removeMaterial(toRemove: Material): number;
  124406. /**
  124407. * Removes the given action manager from this scene.
  124408. * @param toRemove The action manager to remove
  124409. * @returns The index of the removed action manager
  124410. */
  124411. removeActionManager(toRemove: AbstractActionManager): number;
  124412. /**
  124413. * Removes the given texture from this scene.
  124414. * @param toRemove The texture to remove
  124415. * @returns The index of the removed texture
  124416. */
  124417. removeTexture(toRemove: BaseTexture): number;
  124418. /**
  124419. * Adds the given light to this scene
  124420. * @param newLight The light to add
  124421. */
  124422. addLight(newLight: Light): void;
  124423. /**
  124424. * Sorts the list list based on light priorities
  124425. */
  124426. sortLightsByPriority(): void;
  124427. /**
  124428. * Adds the given camera to this scene
  124429. * @param newCamera The camera to add
  124430. */
  124431. addCamera(newCamera: Camera): void;
  124432. /**
  124433. * Adds the given skeleton to this scene
  124434. * @param newSkeleton The skeleton to add
  124435. */
  124436. addSkeleton(newSkeleton: Skeleton): void;
  124437. /**
  124438. * Adds the given particle system to this scene
  124439. * @param newParticleSystem The particle system to add
  124440. */
  124441. addParticleSystem(newParticleSystem: IParticleSystem): void;
  124442. /**
  124443. * Adds the given animation to this scene
  124444. * @param newAnimation The animation to add
  124445. */
  124446. addAnimation(newAnimation: Animation): void;
  124447. /**
  124448. * Adds the given animation group to this scene.
  124449. * @param newAnimationGroup The animation group to add
  124450. */
  124451. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  124452. /**
  124453. * Adds the given multi-material to this scene
  124454. * @param newMultiMaterial The multi-material to add
  124455. */
  124456. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  124457. /**
  124458. * Adds the given material to this scene
  124459. * @param newMaterial The material to add
  124460. */
  124461. addMaterial(newMaterial: Material): void;
  124462. /**
  124463. * Adds the given morph target to this scene
  124464. * @param newMorphTargetManager The morph target to add
  124465. */
  124466. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  124467. /**
  124468. * Adds the given geometry to this scene
  124469. * @param newGeometry The geometry to add
  124470. */
  124471. addGeometry(newGeometry: Geometry): void;
  124472. /**
  124473. * Adds the given action manager to this scene
  124474. * @param newActionManager The action manager to add
  124475. */
  124476. addActionManager(newActionManager: AbstractActionManager): void;
  124477. /**
  124478. * Adds the given texture to this scene.
  124479. * @param newTexture The texture to add
  124480. */
  124481. addTexture(newTexture: BaseTexture): void;
  124482. /**
  124483. * Switch active camera
  124484. * @param newCamera defines the new active camera
  124485. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  124486. */
  124487. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  124488. /**
  124489. * sets the active camera of the scene using its ID
  124490. * @param id defines the camera's ID
  124491. * @return the new active camera or null if none found.
  124492. */
  124493. setActiveCameraByID(id: string): Nullable<Camera>;
  124494. /**
  124495. * sets the active camera of the scene using its name
  124496. * @param name defines the camera's name
  124497. * @returns the new active camera or null if none found.
  124498. */
  124499. setActiveCameraByName(name: string): Nullable<Camera>;
  124500. /**
  124501. * get an animation group using its name
  124502. * @param name defines the material's name
  124503. * @return the animation group or null if none found.
  124504. */
  124505. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  124506. /**
  124507. * Get a material using its unique id
  124508. * @param uniqueId defines the material's unique id
  124509. * @return the material or null if none found.
  124510. */
  124511. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  124512. /**
  124513. * get a material using its id
  124514. * @param id defines the material's ID
  124515. * @return the material or null if none found.
  124516. */
  124517. getMaterialByID(id: string): Nullable<Material>;
  124518. /**
  124519. * Gets a the last added material using a given id
  124520. * @param id defines the material's ID
  124521. * @return the last material with the given id or null if none found.
  124522. */
  124523. getLastMaterialByID(id: string): Nullable<Material>;
  124524. /**
  124525. * Gets a material using its name
  124526. * @param name defines the material's name
  124527. * @return the material or null if none found.
  124528. */
  124529. getMaterialByName(name: string): Nullable<Material>;
  124530. /**
  124531. * Get a texture using its unique id
  124532. * @param uniqueId defines the texture's unique id
  124533. * @return the texture or null if none found.
  124534. */
  124535. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  124536. /**
  124537. * Gets a camera using its id
  124538. * @param id defines the id to look for
  124539. * @returns the camera or null if not found
  124540. */
  124541. getCameraByID(id: string): Nullable<Camera>;
  124542. /**
  124543. * Gets a camera using its unique id
  124544. * @param uniqueId defines the unique id to look for
  124545. * @returns the camera or null if not found
  124546. */
  124547. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  124548. /**
  124549. * Gets a camera using its name
  124550. * @param name defines the camera's name
  124551. * @return the camera or null if none found.
  124552. */
  124553. getCameraByName(name: string): Nullable<Camera>;
  124554. /**
  124555. * Gets a bone using its id
  124556. * @param id defines the bone's id
  124557. * @return the bone or null if not found
  124558. */
  124559. getBoneByID(id: string): Nullable<Bone>;
  124560. /**
  124561. * Gets a bone using its id
  124562. * @param name defines the bone's name
  124563. * @return the bone or null if not found
  124564. */
  124565. getBoneByName(name: string): Nullable<Bone>;
  124566. /**
  124567. * Gets a light node using its name
  124568. * @param name defines the the light's name
  124569. * @return the light or null if none found.
  124570. */
  124571. getLightByName(name: string): Nullable<Light>;
  124572. /**
  124573. * Gets a light node using its id
  124574. * @param id defines the light's id
  124575. * @return the light or null if none found.
  124576. */
  124577. getLightByID(id: string): Nullable<Light>;
  124578. /**
  124579. * Gets a light node using its scene-generated unique ID
  124580. * @param uniqueId defines the light's unique id
  124581. * @return the light or null if none found.
  124582. */
  124583. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  124584. /**
  124585. * Gets a particle system by id
  124586. * @param id defines the particle system id
  124587. * @return the corresponding system or null if none found
  124588. */
  124589. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  124590. /**
  124591. * Gets a geometry using its ID
  124592. * @param id defines the geometry's id
  124593. * @return the geometry or null if none found.
  124594. */
  124595. getGeometryByID(id: string): Nullable<Geometry>;
  124596. private _getGeometryByUniqueID;
  124597. /**
  124598. * Add a new geometry to this scene
  124599. * @param geometry defines the geometry to be added to the scene.
  124600. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  124601. * @return a boolean defining if the geometry was added or not
  124602. */
  124603. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  124604. /**
  124605. * Removes an existing geometry
  124606. * @param geometry defines the geometry to be removed from the scene
  124607. * @return a boolean defining if the geometry was removed or not
  124608. */
  124609. removeGeometry(geometry: Geometry): boolean;
  124610. /**
  124611. * Gets the list of geometries attached to the scene
  124612. * @returns an array of Geometry
  124613. */
  124614. getGeometries(): Geometry[];
  124615. /**
  124616. * Gets the first added mesh found of a given ID
  124617. * @param id defines the id to search for
  124618. * @return the mesh found or null if not found at all
  124619. */
  124620. getMeshByID(id: string): Nullable<AbstractMesh>;
  124621. /**
  124622. * Gets a list of meshes using their id
  124623. * @param id defines the id to search for
  124624. * @returns a list of meshes
  124625. */
  124626. getMeshesByID(id: string): Array<AbstractMesh>;
  124627. /**
  124628. * Gets the first added transform node found of a given ID
  124629. * @param id defines the id to search for
  124630. * @return the found transform node or null if not found at all.
  124631. */
  124632. getTransformNodeByID(id: string): Nullable<TransformNode>;
  124633. /**
  124634. * Gets a transform node with its auto-generated unique id
  124635. * @param uniqueId efines the unique id to search for
  124636. * @return the found transform node or null if not found at all.
  124637. */
  124638. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  124639. /**
  124640. * Gets a list of transform nodes using their id
  124641. * @param id defines the id to search for
  124642. * @returns a list of transform nodes
  124643. */
  124644. getTransformNodesByID(id: string): Array<TransformNode>;
  124645. /**
  124646. * Gets a mesh with its auto-generated unique id
  124647. * @param uniqueId defines the unique id to search for
  124648. * @return the found mesh or null if not found at all.
  124649. */
  124650. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  124651. /**
  124652. * Gets a the last added mesh using a given id
  124653. * @param id defines the id to search for
  124654. * @return the found mesh or null if not found at all.
  124655. */
  124656. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  124657. /**
  124658. * Gets a the last added node (Mesh, Camera, Light) using a given id
  124659. * @param id defines the id to search for
  124660. * @return the found node or null if not found at all
  124661. */
  124662. getLastEntryByID(id: string): Nullable<Node>;
  124663. /**
  124664. * Gets a node (Mesh, Camera, Light) using a given id
  124665. * @param id defines the id to search for
  124666. * @return the found node or null if not found at all
  124667. */
  124668. getNodeByID(id: string): Nullable<Node>;
  124669. /**
  124670. * Gets a node (Mesh, Camera, Light) using a given name
  124671. * @param name defines the name to search for
  124672. * @return the found node or null if not found at all.
  124673. */
  124674. getNodeByName(name: string): Nullable<Node>;
  124675. /**
  124676. * Gets a mesh using a given name
  124677. * @param name defines the name to search for
  124678. * @return the found mesh or null if not found at all.
  124679. */
  124680. getMeshByName(name: string): Nullable<AbstractMesh>;
  124681. /**
  124682. * Gets a transform node using a given name
  124683. * @param name defines the name to search for
  124684. * @return the found transform node or null if not found at all.
  124685. */
  124686. getTransformNodeByName(name: string): Nullable<TransformNode>;
  124687. /**
  124688. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  124689. * @param id defines the id to search for
  124690. * @return the found skeleton or null if not found at all.
  124691. */
  124692. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  124693. /**
  124694. * Gets a skeleton using a given auto generated unique id
  124695. * @param uniqueId defines the unique id to search for
  124696. * @return the found skeleton or null if not found at all.
  124697. */
  124698. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  124699. /**
  124700. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  124701. * @param id defines the id to search for
  124702. * @return the found skeleton or null if not found at all.
  124703. */
  124704. getSkeletonById(id: string): Nullable<Skeleton>;
  124705. /**
  124706. * Gets a skeleton using a given name
  124707. * @param name defines the name to search for
  124708. * @return the found skeleton or null if not found at all.
  124709. */
  124710. getSkeletonByName(name: string): Nullable<Skeleton>;
  124711. /**
  124712. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  124713. * @param id defines the id to search for
  124714. * @return the found morph target manager or null if not found at all.
  124715. */
  124716. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  124717. /**
  124718. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  124719. * @param id defines the id to search for
  124720. * @return the found morph target or null if not found at all.
  124721. */
  124722. getMorphTargetById(id: string): Nullable<MorphTarget>;
  124723. /**
  124724. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  124725. * @param name defines the name to search for
  124726. * @return the found morph target or null if not found at all.
  124727. */
  124728. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  124729. /**
  124730. * Gets a post process using a given name (if many are found, this function will pick the first one)
  124731. * @param name defines the name to search for
  124732. * @return the found post process or null if not found at all.
  124733. */
  124734. getPostProcessByName(name: string): Nullable<PostProcess>;
  124735. /**
  124736. * Gets a boolean indicating if the given mesh is active
  124737. * @param mesh defines the mesh to look for
  124738. * @returns true if the mesh is in the active list
  124739. */
  124740. isActiveMesh(mesh: AbstractMesh): boolean;
  124741. /**
  124742. * Return a unique id as a string which can serve as an identifier for the scene
  124743. */
  124744. get uid(): string;
  124745. /**
  124746. * Add an externaly attached data from its key.
  124747. * This method call will fail and return false, if such key already exists.
  124748. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  124749. * @param key the unique key that identifies the data
  124750. * @param data the data object to associate to the key for this Engine instance
  124751. * @return true if no such key were already present and the data was added successfully, false otherwise
  124752. */
  124753. addExternalData<T>(key: string, data: T): boolean;
  124754. /**
  124755. * Get an externaly attached data from its key
  124756. * @param key the unique key that identifies the data
  124757. * @return the associated data, if present (can be null), or undefined if not present
  124758. */
  124759. getExternalData<T>(key: string): Nullable<T>;
  124760. /**
  124761. * Get an externaly attached data from its key, create it using a factory if it's not already present
  124762. * @param key the unique key that identifies the data
  124763. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  124764. * @return the associated data, can be null if the factory returned null.
  124765. */
  124766. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  124767. /**
  124768. * Remove an externaly attached data from the Engine instance
  124769. * @param key the unique key that identifies the data
  124770. * @return true if the data was successfully removed, false if it doesn't exist
  124771. */
  124772. removeExternalData(key: string): boolean;
  124773. private _evaluateSubMesh;
  124774. /**
  124775. * Clear the processed materials smart array preventing retention point in material dispose.
  124776. */
  124777. freeProcessedMaterials(): void;
  124778. private _preventFreeActiveMeshesAndRenderingGroups;
  124779. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  124780. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  124781. * when disposing several meshes in a row or a hierarchy of meshes.
  124782. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  124783. */
  124784. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  124785. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  124786. /**
  124787. * Clear the active meshes smart array preventing retention point in mesh dispose.
  124788. */
  124789. freeActiveMeshes(): void;
  124790. /**
  124791. * Clear the info related to rendering groups preventing retention points during dispose.
  124792. */
  124793. freeRenderingGroups(): void;
  124794. /** @hidden */
  124795. _isInIntermediateRendering(): boolean;
  124796. /**
  124797. * Lambda returning the list of potentially active meshes.
  124798. */
  124799. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  124800. /**
  124801. * Lambda returning the list of potentially active sub meshes.
  124802. */
  124803. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  124804. /**
  124805. * Lambda returning the list of potentially intersecting sub meshes.
  124806. */
  124807. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  124808. /**
  124809. * Lambda returning the list of potentially colliding sub meshes.
  124810. */
  124811. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  124812. private _activeMeshesFrozen;
  124813. private _skipEvaluateActiveMeshesCompletely;
  124814. /**
  124815. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  124816. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  124817. * @param onSuccess optional success callback
  124818. * @param onError optional error callback
  124819. * @returns the current scene
  124820. */
  124821. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  124822. /**
  124823. * Use this function to restart evaluating active meshes on every frame
  124824. * @returns the current scene
  124825. */
  124826. unfreezeActiveMeshes(): Scene;
  124827. private _evaluateActiveMeshes;
  124828. private _activeMesh;
  124829. /**
  124830. * Update the transform matrix to update from the current active camera
  124831. * @param force defines a boolean used to force the update even if cache is up to date
  124832. */
  124833. updateTransformMatrix(force?: boolean): void;
  124834. private _bindFrameBuffer;
  124835. /** @hidden */
  124836. _allowPostProcessClearColor: boolean;
  124837. /** @hidden */
  124838. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  124839. private _processSubCameras;
  124840. private _checkIntersections;
  124841. /** @hidden */
  124842. _advancePhysicsEngineStep(step: number): void;
  124843. /**
  124844. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  124845. */
  124846. getDeterministicFrameTime: () => number;
  124847. /** @hidden */
  124848. _animate(): void;
  124849. /** Execute all animations (for a frame) */
  124850. animate(): void;
  124851. /**
  124852. * Render the scene
  124853. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  124854. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  124855. */
  124856. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  124857. /**
  124858. * Freeze all materials
  124859. * A frozen material will not be updatable but should be faster to render
  124860. */
  124861. freezeMaterials(): void;
  124862. /**
  124863. * Unfreeze all materials
  124864. * A frozen material will not be updatable but should be faster to render
  124865. */
  124866. unfreezeMaterials(): void;
  124867. /**
  124868. * Releases all held ressources
  124869. */
  124870. dispose(): void;
  124871. /**
  124872. * Gets if the scene is already disposed
  124873. */
  124874. get isDisposed(): boolean;
  124875. /**
  124876. * Call this function to reduce memory footprint of the scene.
  124877. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  124878. */
  124879. clearCachedVertexData(): void;
  124880. /**
  124881. * This function will remove the local cached buffer data from texture.
  124882. * It will save memory but will prevent the texture from being rebuilt
  124883. */
  124884. cleanCachedTextureBuffer(): void;
  124885. /**
  124886. * Get the world extend vectors with an optional filter
  124887. *
  124888. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  124889. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  124890. */
  124891. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  124892. min: Vector3;
  124893. max: Vector3;
  124894. };
  124895. /**
  124896. * Creates a ray that can be used to pick in the scene
  124897. * @param x defines the x coordinate of the origin (on-screen)
  124898. * @param y defines the y coordinate of the origin (on-screen)
  124899. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124900. * @param camera defines the camera to use for the picking
  124901. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124902. * @returns a Ray
  124903. */
  124904. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  124905. /**
  124906. * Creates a ray that can be used to pick in the scene
  124907. * @param x defines the x coordinate of the origin (on-screen)
  124908. * @param y defines the y coordinate of the origin (on-screen)
  124909. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124910. * @param result defines the ray where to store the picking ray
  124911. * @param camera defines the camera to use for the picking
  124912. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124913. * @returns the current scene
  124914. */
  124915. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  124916. /**
  124917. * Creates a ray that can be used to pick in the scene
  124918. * @param x defines the x coordinate of the origin (on-screen)
  124919. * @param y defines the y coordinate of the origin (on-screen)
  124920. * @param camera defines the camera to use for the picking
  124921. * @returns a Ray
  124922. */
  124923. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  124924. /**
  124925. * Creates a ray that can be used to pick in the scene
  124926. * @param x defines the x coordinate of the origin (on-screen)
  124927. * @param y defines the y coordinate of the origin (on-screen)
  124928. * @param result defines the ray where to store the picking ray
  124929. * @param camera defines the camera to use for the picking
  124930. * @returns the current scene
  124931. */
  124932. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  124933. /** Launch a ray to try to pick a mesh in the scene
  124934. * @param x position on screen
  124935. * @param y position on screen
  124936. * @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
  124937. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124938. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124939. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124940. * @returns a PickingInfo
  124941. */
  124942. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124943. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  124944. * @param x position on screen
  124945. * @param y position on screen
  124946. * @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
  124947. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124948. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124949. * @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)
  124950. */
  124951. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  124952. /** Use the given ray to pick a mesh in the scene
  124953. * @param ray The ray to use to pick meshes
  124954. * @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
  124955. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124956. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124957. * @returns a PickingInfo
  124958. */
  124959. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124960. /**
  124961. * Launch a ray to try to pick a mesh in the scene
  124962. * @param x X position on screen
  124963. * @param y Y position on screen
  124964. * @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
  124965. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124966. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124967. * @returns an array of PickingInfo
  124968. */
  124969. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124970. /**
  124971. * Launch a ray to try to pick a mesh in the scene
  124972. * @param ray Ray to use
  124973. * @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
  124974. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124975. * @returns an array of PickingInfo
  124976. */
  124977. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124978. /**
  124979. * Force the value of meshUnderPointer
  124980. * @param mesh defines the mesh to use
  124981. * @param pointerId optional pointer id when using more than one pointer
  124982. */
  124983. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  124984. /**
  124985. * Gets the mesh under the pointer
  124986. * @returns a Mesh or null if no mesh is under the pointer
  124987. */
  124988. getPointerOverMesh(): Nullable<AbstractMesh>;
  124989. /** @hidden */
  124990. _rebuildGeometries(): void;
  124991. /** @hidden */
  124992. _rebuildTextures(): void;
  124993. private _getByTags;
  124994. /**
  124995. * Get a list of meshes by tags
  124996. * @param tagsQuery defines the tags query to use
  124997. * @param forEach defines a predicate used to filter results
  124998. * @returns an array of Mesh
  124999. */
  125000. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  125001. /**
  125002. * Get a list of cameras by tags
  125003. * @param tagsQuery defines the tags query to use
  125004. * @param forEach defines a predicate used to filter results
  125005. * @returns an array of Camera
  125006. */
  125007. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  125008. /**
  125009. * Get a list of lights by tags
  125010. * @param tagsQuery defines the tags query to use
  125011. * @param forEach defines a predicate used to filter results
  125012. * @returns an array of Light
  125013. */
  125014. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  125015. /**
  125016. * Get a list of materials by tags
  125017. * @param tagsQuery defines the tags query to use
  125018. * @param forEach defines a predicate used to filter results
  125019. * @returns an array of Material
  125020. */
  125021. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  125022. /**
  125023. * Get a list of transform nodes by tags
  125024. * @param tagsQuery defines the tags query to use
  125025. * @param forEach defines a predicate used to filter results
  125026. * @returns an array of TransformNode
  125027. */
  125028. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  125029. /**
  125030. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  125031. * This allowed control for front to back rendering or reversly depending of the special needs.
  125032. *
  125033. * @param renderingGroupId The rendering group id corresponding to its index
  125034. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  125035. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  125036. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  125037. */
  125038. 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;
  125039. /**
  125040. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  125041. *
  125042. * @param renderingGroupId The rendering group id corresponding to its index
  125043. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  125044. * @param depth Automatically clears depth between groups if true and autoClear is true.
  125045. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  125046. */
  125047. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  125048. /**
  125049. * Gets the current auto clear configuration for one rendering group of the rendering
  125050. * manager.
  125051. * @param index the rendering group index to get the information for
  125052. * @returns The auto clear setup for the requested rendering group
  125053. */
  125054. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  125055. private _blockMaterialDirtyMechanism;
  125056. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  125057. get blockMaterialDirtyMechanism(): boolean;
  125058. set blockMaterialDirtyMechanism(value: boolean);
  125059. /**
  125060. * Will flag all materials as dirty to trigger new shader compilation
  125061. * @param flag defines the flag used to specify which material part must be marked as dirty
  125062. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  125063. */
  125064. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  125065. /** @hidden */
  125066. _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;
  125067. /** @hidden */
  125068. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125069. /** @hidden */
  125070. _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;
  125071. /** @hidden */
  125072. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  125073. /** @hidden */
  125074. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  125075. /** @hidden */
  125076. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125077. }
  125078. }
  125079. declare module BABYLON {
  125080. /**
  125081. * Set of assets to keep when moving a scene into an asset container.
  125082. */
  125083. export class KeepAssets extends AbstractScene {
  125084. }
  125085. /**
  125086. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  125087. */
  125088. export class InstantiatedEntries {
  125089. /**
  125090. * List of new root nodes (eg. nodes with no parent)
  125091. */
  125092. rootNodes: TransformNode[];
  125093. /**
  125094. * List of new skeletons
  125095. */
  125096. skeletons: Skeleton[];
  125097. /**
  125098. * List of new animation groups
  125099. */
  125100. animationGroups: AnimationGroup[];
  125101. }
  125102. /**
  125103. * Container with a set of assets that can be added or removed from a scene.
  125104. */
  125105. export class AssetContainer extends AbstractScene {
  125106. private _wasAddedToScene;
  125107. /**
  125108. * The scene the AssetContainer belongs to.
  125109. */
  125110. scene: Scene;
  125111. /**
  125112. * Instantiates an AssetContainer.
  125113. * @param scene The scene the AssetContainer belongs to.
  125114. */
  125115. constructor(scene: Scene);
  125116. /**
  125117. * Instantiate or clone all meshes and add the new ones to the scene.
  125118. * Skeletons and animation groups will all be cloned
  125119. * @param nameFunction defines an optional function used to get new names for clones
  125120. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  125121. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  125122. */
  125123. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  125124. /**
  125125. * Adds all the assets from the container to the scene.
  125126. */
  125127. addAllToScene(): void;
  125128. /**
  125129. * Removes all the assets in the container from the scene
  125130. */
  125131. removeAllFromScene(): void;
  125132. /**
  125133. * Disposes all the assets in the container
  125134. */
  125135. dispose(): void;
  125136. private _moveAssets;
  125137. /**
  125138. * Removes all the assets contained in the scene and adds them to the container.
  125139. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125140. */
  125141. moveAllFromScene(keepAssets?: KeepAssets): void;
  125142. /**
  125143. * 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.
  125144. * @returns the root mesh
  125145. */
  125146. createRootMesh(): Mesh;
  125147. /**
  125148. * Merge animations (direct and animation groups) from this asset container into a scene
  125149. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125150. * @param animatables set of animatables to retarget to a node from the scene
  125151. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  125152. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  125153. */
  125154. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  125155. }
  125156. }
  125157. declare module BABYLON {
  125158. /**
  125159. * Defines how the parser contract is defined.
  125160. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  125161. */
  125162. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  125163. /**
  125164. * Defines how the individual parser contract is defined.
  125165. * These parser can parse an individual asset
  125166. */
  125167. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  125168. /**
  125169. * Base class of the scene acting as a container for the different elements composing a scene.
  125170. * This class is dynamically extended by the different components of the scene increasing
  125171. * flexibility and reducing coupling
  125172. */
  125173. export abstract class AbstractScene {
  125174. /**
  125175. * Stores the list of available parsers in the application.
  125176. */
  125177. private static _BabylonFileParsers;
  125178. /**
  125179. * Stores the list of available individual parsers in the application.
  125180. */
  125181. private static _IndividualBabylonFileParsers;
  125182. /**
  125183. * Adds a parser in the list of available ones
  125184. * @param name Defines the name of the parser
  125185. * @param parser Defines the parser to add
  125186. */
  125187. static AddParser(name: string, parser: BabylonFileParser): void;
  125188. /**
  125189. * Gets a general parser from the list of avaialble ones
  125190. * @param name Defines the name of the parser
  125191. * @returns the requested parser or null
  125192. */
  125193. static GetParser(name: string): Nullable<BabylonFileParser>;
  125194. /**
  125195. * Adds n individual parser in the list of available ones
  125196. * @param name Defines the name of the parser
  125197. * @param parser Defines the parser to add
  125198. */
  125199. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  125200. /**
  125201. * Gets an individual parser from the list of avaialble ones
  125202. * @param name Defines the name of the parser
  125203. * @returns the requested parser or null
  125204. */
  125205. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  125206. /**
  125207. * Parser json data and populate both a scene and its associated container object
  125208. * @param jsonData Defines the data to parse
  125209. * @param scene Defines the scene to parse the data for
  125210. * @param container Defines the container attached to the parsing sequence
  125211. * @param rootUrl Defines the root url of the data
  125212. */
  125213. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  125214. /**
  125215. * Gets the list of root nodes (ie. nodes with no parent)
  125216. */
  125217. rootNodes: Node[];
  125218. /** All of the cameras added to this scene
  125219. * @see https://doc.babylonjs.com/babylon101/cameras
  125220. */
  125221. cameras: Camera[];
  125222. /**
  125223. * All of the lights added to this scene
  125224. * @see https://doc.babylonjs.com/babylon101/lights
  125225. */
  125226. lights: Light[];
  125227. /**
  125228. * All of the (abstract) meshes added to this scene
  125229. */
  125230. meshes: AbstractMesh[];
  125231. /**
  125232. * The list of skeletons added to the scene
  125233. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125234. */
  125235. skeletons: Skeleton[];
  125236. /**
  125237. * All of the particle systems added to this scene
  125238. * @see https://doc.babylonjs.com/babylon101/particles
  125239. */
  125240. particleSystems: IParticleSystem[];
  125241. /**
  125242. * Gets a list of Animations associated with the scene
  125243. */
  125244. animations: Animation[];
  125245. /**
  125246. * All of the animation groups added to this scene
  125247. * @see https://doc.babylonjs.com/how_to/group
  125248. */
  125249. animationGroups: AnimationGroup[];
  125250. /**
  125251. * All of the multi-materials added to this scene
  125252. * @see https://doc.babylonjs.com/how_to/multi_materials
  125253. */
  125254. multiMaterials: MultiMaterial[];
  125255. /**
  125256. * All of the materials added to this scene
  125257. * In the context of a Scene, it is not supposed to be modified manually.
  125258. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  125259. * Note also that the order of the Material within the array is not significant and might change.
  125260. * @see https://doc.babylonjs.com/babylon101/materials
  125261. */
  125262. materials: Material[];
  125263. /**
  125264. * The list of morph target managers added to the scene
  125265. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125266. */
  125267. morphTargetManagers: MorphTargetManager[];
  125268. /**
  125269. * The list of geometries used in the scene.
  125270. */
  125271. geometries: Geometry[];
  125272. /**
  125273. * All of the tranform nodes added to this scene
  125274. * In the context of a Scene, it is not supposed to be modified manually.
  125275. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125276. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125277. * @see https://doc.babylonjs.com/how_to/transformnode
  125278. */
  125279. transformNodes: TransformNode[];
  125280. /**
  125281. * ActionManagers available on the scene.
  125282. */
  125283. actionManagers: AbstractActionManager[];
  125284. /**
  125285. * Textures to keep.
  125286. */
  125287. textures: BaseTexture[];
  125288. /** @hidden */
  125289. protected _environmentTexture: Nullable<BaseTexture>;
  125290. /**
  125291. * Texture used in all pbr material as the reflection texture.
  125292. * As in the majority of the scene they are the same (exception for multi room and so on),
  125293. * this is easier to reference from here than from all the materials.
  125294. */
  125295. get environmentTexture(): Nullable<BaseTexture>;
  125296. set environmentTexture(value: Nullable<BaseTexture>);
  125297. /**
  125298. * The list of postprocesses added to the scene
  125299. */
  125300. postProcesses: PostProcess[];
  125301. /**
  125302. * @returns all meshes, lights, cameras, transformNodes and bones
  125303. */
  125304. getNodes(): Array<Node>;
  125305. }
  125306. }
  125307. declare module BABYLON {
  125308. /**
  125309. * Interface used to define options for Sound class
  125310. */
  125311. export interface ISoundOptions {
  125312. /**
  125313. * Does the sound autoplay once loaded.
  125314. */
  125315. autoplay?: boolean;
  125316. /**
  125317. * Does the sound loop after it finishes playing once.
  125318. */
  125319. loop?: boolean;
  125320. /**
  125321. * Sound's volume
  125322. */
  125323. volume?: number;
  125324. /**
  125325. * Is it a spatial sound?
  125326. */
  125327. spatialSound?: boolean;
  125328. /**
  125329. * Maximum distance to hear that sound
  125330. */
  125331. maxDistance?: number;
  125332. /**
  125333. * Uses user defined attenuation function
  125334. */
  125335. useCustomAttenuation?: boolean;
  125336. /**
  125337. * Define the roll off factor of spatial sounds.
  125338. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125339. */
  125340. rolloffFactor?: number;
  125341. /**
  125342. * Define the reference distance the sound should be heard perfectly.
  125343. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125344. */
  125345. refDistance?: number;
  125346. /**
  125347. * Define the distance attenuation model the sound will follow.
  125348. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125349. */
  125350. distanceModel?: string;
  125351. /**
  125352. * Defines the playback speed (1 by default)
  125353. */
  125354. playbackRate?: number;
  125355. /**
  125356. * Defines if the sound is from a streaming source
  125357. */
  125358. streaming?: boolean;
  125359. /**
  125360. * Defines an optional length (in seconds) inside the sound file
  125361. */
  125362. length?: number;
  125363. /**
  125364. * Defines an optional offset (in seconds) inside the sound file
  125365. */
  125366. offset?: number;
  125367. /**
  125368. * If true, URLs will not be required to state the audio file codec to use.
  125369. */
  125370. skipCodecCheck?: boolean;
  125371. }
  125372. /**
  125373. * Defines a sound that can be played in the application.
  125374. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  125375. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125376. */
  125377. export class Sound {
  125378. /**
  125379. * The name of the sound in the scene.
  125380. */
  125381. name: string;
  125382. /**
  125383. * Does the sound autoplay once loaded.
  125384. */
  125385. autoplay: boolean;
  125386. /**
  125387. * Does the sound loop after it finishes playing once.
  125388. */
  125389. loop: boolean;
  125390. /**
  125391. * Does the sound use a custom attenuation curve to simulate the falloff
  125392. * happening when the source gets further away from the camera.
  125393. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125394. */
  125395. useCustomAttenuation: boolean;
  125396. /**
  125397. * The sound track id this sound belongs to.
  125398. */
  125399. soundTrackId: number;
  125400. /**
  125401. * Is this sound currently played.
  125402. */
  125403. isPlaying: boolean;
  125404. /**
  125405. * Is this sound currently paused.
  125406. */
  125407. isPaused: boolean;
  125408. /**
  125409. * Does this sound enables spatial sound.
  125410. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125411. */
  125412. spatialSound: boolean;
  125413. /**
  125414. * Define the reference distance the sound should be heard perfectly.
  125415. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125416. */
  125417. refDistance: number;
  125418. /**
  125419. * Define the roll off factor of spatial sounds.
  125420. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125421. */
  125422. rolloffFactor: number;
  125423. /**
  125424. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  125425. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125426. */
  125427. maxDistance: number;
  125428. /**
  125429. * Define the distance attenuation model the sound will follow.
  125430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125431. */
  125432. distanceModel: string;
  125433. /**
  125434. * @hidden
  125435. * Back Compat
  125436. **/
  125437. onended: () => any;
  125438. /**
  125439. * Gets or sets an object used to store user defined information for the sound.
  125440. */
  125441. metadata: any;
  125442. /**
  125443. * Observable event when the current playing sound finishes.
  125444. */
  125445. onEndedObservable: Observable<Sound>;
  125446. private _panningModel;
  125447. private _playbackRate;
  125448. private _streaming;
  125449. private _startTime;
  125450. private _startOffset;
  125451. private _position;
  125452. /** @hidden */
  125453. _positionInEmitterSpace: boolean;
  125454. private _localDirection;
  125455. private _volume;
  125456. private _isReadyToPlay;
  125457. private _isDirectional;
  125458. private _readyToPlayCallback;
  125459. private _audioBuffer;
  125460. private _soundSource;
  125461. private _streamingSource;
  125462. private _soundPanner;
  125463. private _soundGain;
  125464. private _inputAudioNode;
  125465. private _outputAudioNode;
  125466. private _coneInnerAngle;
  125467. private _coneOuterAngle;
  125468. private _coneOuterGain;
  125469. private _scene;
  125470. private _connectedTransformNode;
  125471. private _customAttenuationFunction;
  125472. private _registerFunc;
  125473. private _isOutputConnected;
  125474. private _htmlAudioElement;
  125475. private _urlType;
  125476. private _length?;
  125477. private _offset?;
  125478. /** @hidden */
  125479. static _SceneComponentInitialization: (scene: Scene) => void;
  125480. /**
  125481. * Create a sound and attach it to a scene
  125482. * @param name Name of your sound
  125483. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  125484. * @param scene defines the scene the sound belongs to
  125485. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  125486. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  125487. */
  125488. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  125489. /**
  125490. * Release the sound and its associated resources
  125491. */
  125492. dispose(): void;
  125493. /**
  125494. * Gets if the sounds is ready to be played or not.
  125495. * @returns true if ready, otherwise false
  125496. */
  125497. isReady(): boolean;
  125498. private _soundLoaded;
  125499. /**
  125500. * Sets the data of the sound from an audiobuffer
  125501. * @param audioBuffer The audioBuffer containing the data
  125502. */
  125503. setAudioBuffer(audioBuffer: AudioBuffer): void;
  125504. /**
  125505. * Updates the current sounds options such as maxdistance, loop...
  125506. * @param options A JSON object containing values named as the object properties
  125507. */
  125508. updateOptions(options: ISoundOptions): void;
  125509. private _createSpatialParameters;
  125510. private _updateSpatialParameters;
  125511. /**
  125512. * Switch the panning model to HRTF:
  125513. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125514. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125515. */
  125516. switchPanningModelToHRTF(): void;
  125517. /**
  125518. * Switch the panning model to Equal Power:
  125519. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125520. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125521. */
  125522. switchPanningModelToEqualPower(): void;
  125523. private _switchPanningModel;
  125524. /**
  125525. * Connect this sound to a sound track audio node like gain...
  125526. * @param soundTrackAudioNode the sound track audio node to connect to
  125527. */
  125528. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  125529. /**
  125530. * Transform this sound into a directional source
  125531. * @param coneInnerAngle Size of the inner cone in degree
  125532. * @param coneOuterAngle Size of the outer cone in degree
  125533. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  125534. */
  125535. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  125536. /**
  125537. * Gets or sets the inner angle for the directional cone.
  125538. */
  125539. get directionalConeInnerAngle(): number;
  125540. /**
  125541. * Gets or sets the inner angle for the directional cone.
  125542. */
  125543. set directionalConeInnerAngle(value: number);
  125544. /**
  125545. * Gets or sets the outer angle for the directional cone.
  125546. */
  125547. get directionalConeOuterAngle(): number;
  125548. /**
  125549. * Gets or sets the outer angle for the directional cone.
  125550. */
  125551. set directionalConeOuterAngle(value: number);
  125552. /**
  125553. * Sets the position of the emitter if spatial sound is enabled
  125554. * @param newPosition Defines the new posisiton
  125555. */
  125556. setPosition(newPosition: Vector3): void;
  125557. /**
  125558. * Sets the local direction of the emitter if spatial sound is enabled
  125559. * @param newLocalDirection Defines the new local direction
  125560. */
  125561. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  125562. private _updateDirection;
  125563. /** @hidden */
  125564. updateDistanceFromListener(): void;
  125565. /**
  125566. * Sets a new custom attenuation function for the sound.
  125567. * @param callback Defines the function used for the attenuation
  125568. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125569. */
  125570. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  125571. /**
  125572. * Play the sound
  125573. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  125574. * @param offset (optional) Start the sound at a specific time in seconds
  125575. * @param length (optional) Sound duration (in seconds)
  125576. */
  125577. play(time?: number, offset?: number, length?: number): void;
  125578. private _onended;
  125579. /**
  125580. * Stop the sound
  125581. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  125582. */
  125583. stop(time?: number): void;
  125584. /**
  125585. * Put the sound in pause
  125586. */
  125587. pause(): void;
  125588. /**
  125589. * Sets a dedicated volume for this sounds
  125590. * @param newVolume Define the new volume of the sound
  125591. * @param time Define time for gradual change to new volume
  125592. */
  125593. setVolume(newVolume: number, time?: number): void;
  125594. /**
  125595. * Set the sound play back rate
  125596. * @param newPlaybackRate Define the playback rate the sound should be played at
  125597. */
  125598. setPlaybackRate(newPlaybackRate: number): void;
  125599. /**
  125600. * Gets the volume of the sound.
  125601. * @returns the volume of the sound
  125602. */
  125603. getVolume(): number;
  125604. /**
  125605. * Attach the sound to a dedicated mesh
  125606. * @param transformNode The transform node to connect the sound with
  125607. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125608. */
  125609. attachToMesh(transformNode: TransformNode): void;
  125610. /**
  125611. * Detach the sound from the previously attached mesh
  125612. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125613. */
  125614. detachFromMesh(): void;
  125615. private _onRegisterAfterWorldMatrixUpdate;
  125616. /**
  125617. * Clone the current sound in the scene.
  125618. * @returns the new sound clone
  125619. */
  125620. clone(): Nullable<Sound>;
  125621. /**
  125622. * Gets the current underlying audio buffer containing the data
  125623. * @returns the audio buffer
  125624. */
  125625. getAudioBuffer(): Nullable<AudioBuffer>;
  125626. /**
  125627. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  125628. * @returns the source node
  125629. */
  125630. getSoundSource(): Nullable<AudioBufferSourceNode>;
  125631. /**
  125632. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  125633. * @returns the gain node
  125634. */
  125635. getSoundGain(): Nullable<GainNode>;
  125636. /**
  125637. * Serializes the Sound in a JSON representation
  125638. * @returns the JSON representation of the sound
  125639. */
  125640. serialize(): any;
  125641. /**
  125642. * Parse a JSON representation of a sound to innstantiate in a given scene
  125643. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  125644. * @param scene Define the scene the new parsed sound should be created in
  125645. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  125646. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  125647. * @returns the newly parsed sound
  125648. */
  125649. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  125650. }
  125651. }
  125652. declare module BABYLON {
  125653. /**
  125654. * This defines an action helpful to play a defined sound on a triggered action.
  125655. */
  125656. export class PlaySoundAction extends Action {
  125657. private _sound;
  125658. /**
  125659. * Instantiate the action
  125660. * @param triggerOptions defines the trigger options
  125661. * @param sound defines the sound to play
  125662. * @param condition defines the trigger related conditions
  125663. */
  125664. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125665. /** @hidden */
  125666. _prepare(): void;
  125667. /**
  125668. * Execute the action and play the sound.
  125669. */
  125670. execute(): void;
  125671. /**
  125672. * Serializes the actions and its related information.
  125673. * @param parent defines the object to serialize in
  125674. * @returns the serialized object
  125675. */
  125676. serialize(parent: any): any;
  125677. }
  125678. /**
  125679. * This defines an action helpful to stop a defined sound on a triggered action.
  125680. */
  125681. export class StopSoundAction extends Action {
  125682. private _sound;
  125683. /**
  125684. * Instantiate the action
  125685. * @param triggerOptions defines the trigger options
  125686. * @param sound defines the sound to stop
  125687. * @param condition defines the trigger related conditions
  125688. */
  125689. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125690. /** @hidden */
  125691. _prepare(): void;
  125692. /**
  125693. * Execute the action and stop the sound.
  125694. */
  125695. execute(): void;
  125696. /**
  125697. * Serializes the actions and its related information.
  125698. * @param parent defines the object to serialize in
  125699. * @returns the serialized object
  125700. */
  125701. serialize(parent: any): any;
  125702. }
  125703. }
  125704. declare module BABYLON {
  125705. /**
  125706. * This defines an action responsible to change the value of a property
  125707. * by interpolating between its current value and the newly set one once triggered.
  125708. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125709. */
  125710. export class InterpolateValueAction extends Action {
  125711. /**
  125712. * Defines the path of the property where the value should be interpolated
  125713. */
  125714. propertyPath: string;
  125715. /**
  125716. * Defines the target value at the end of the interpolation.
  125717. */
  125718. value: any;
  125719. /**
  125720. * Defines the time it will take for the property to interpolate to the value.
  125721. */
  125722. duration: number;
  125723. /**
  125724. * Defines if the other scene animations should be stopped when the action has been triggered
  125725. */
  125726. stopOtherAnimations?: boolean;
  125727. /**
  125728. * Defines a callback raised once the interpolation animation has been done.
  125729. */
  125730. onInterpolationDone?: () => void;
  125731. /**
  125732. * Observable triggered once the interpolation animation has been done.
  125733. */
  125734. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  125735. private _target;
  125736. private _effectiveTarget;
  125737. private _property;
  125738. /**
  125739. * Instantiate the action
  125740. * @param triggerOptions defines the trigger options
  125741. * @param target defines the object containing the value to interpolate
  125742. * @param propertyPath defines the path to the property in the target object
  125743. * @param value defines the target value at the end of the interpolation
  125744. * @param duration deines the time it will take for the property to interpolate to the value.
  125745. * @param condition defines the trigger related conditions
  125746. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  125747. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  125748. */
  125749. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  125750. /** @hidden */
  125751. _prepare(): void;
  125752. /**
  125753. * Execute the action starts the value interpolation.
  125754. */
  125755. execute(): void;
  125756. /**
  125757. * Serializes the actions and its related information.
  125758. * @param parent defines the object to serialize in
  125759. * @returns the serialized object
  125760. */
  125761. serialize(parent: any): any;
  125762. }
  125763. }
  125764. declare module BABYLON {
  125765. /**
  125766. * Options allowed during the creation of a sound track.
  125767. */
  125768. export interface ISoundTrackOptions {
  125769. /**
  125770. * The volume the sound track should take during creation
  125771. */
  125772. volume?: number;
  125773. /**
  125774. * Define if the sound track is the main sound track of the scene
  125775. */
  125776. mainTrack?: boolean;
  125777. }
  125778. /**
  125779. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  125780. * It will be also used in a future release to apply effects on a specific track.
  125781. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125782. */
  125783. export class SoundTrack {
  125784. /**
  125785. * The unique identifier of the sound track in the scene.
  125786. */
  125787. id: number;
  125788. /**
  125789. * The list of sounds included in the sound track.
  125790. */
  125791. soundCollection: Array<Sound>;
  125792. private _outputAudioNode;
  125793. private _scene;
  125794. private _connectedAnalyser;
  125795. private _options;
  125796. private _isInitialized;
  125797. /**
  125798. * Creates a new sound track.
  125799. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125800. * @param scene Define the scene the sound track belongs to
  125801. * @param options
  125802. */
  125803. constructor(scene: Scene, options?: ISoundTrackOptions);
  125804. private _initializeSoundTrackAudioGraph;
  125805. /**
  125806. * Release the sound track and its associated resources
  125807. */
  125808. dispose(): void;
  125809. /**
  125810. * Adds a sound to this sound track
  125811. * @param sound define the cound to add
  125812. * @ignoreNaming
  125813. */
  125814. AddSound(sound: Sound): void;
  125815. /**
  125816. * Removes a sound to this sound track
  125817. * @param sound define the cound to remove
  125818. * @ignoreNaming
  125819. */
  125820. RemoveSound(sound: Sound): void;
  125821. /**
  125822. * Set a global volume for the full sound track.
  125823. * @param newVolume Define the new volume of the sound track
  125824. */
  125825. setVolume(newVolume: number): void;
  125826. /**
  125827. * Switch the panning model to HRTF:
  125828. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125829. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125830. */
  125831. switchPanningModelToHRTF(): void;
  125832. /**
  125833. * Switch the panning model to Equal Power:
  125834. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125835. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125836. */
  125837. switchPanningModelToEqualPower(): void;
  125838. /**
  125839. * Connect the sound track to an audio analyser allowing some amazing
  125840. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  125841. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  125842. * @param analyser The analyser to connect to the engine
  125843. */
  125844. connectToAnalyser(analyser: Analyser): void;
  125845. }
  125846. }
  125847. declare module BABYLON {
  125848. interface AbstractScene {
  125849. /**
  125850. * The list of sounds used in the scene.
  125851. */
  125852. sounds: Nullable<Array<Sound>>;
  125853. }
  125854. interface Scene {
  125855. /**
  125856. * @hidden
  125857. * Backing field
  125858. */
  125859. _mainSoundTrack: SoundTrack;
  125860. /**
  125861. * The main sound track played by the scene.
  125862. * It cotains your primary collection of sounds.
  125863. */
  125864. mainSoundTrack: SoundTrack;
  125865. /**
  125866. * The list of sound tracks added to the scene
  125867. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125868. */
  125869. soundTracks: Nullable<Array<SoundTrack>>;
  125870. /**
  125871. * Gets a sound using a given name
  125872. * @param name defines the name to search for
  125873. * @return the found sound or null if not found at all.
  125874. */
  125875. getSoundByName(name: string): Nullable<Sound>;
  125876. /**
  125877. * Gets or sets if audio support is enabled
  125878. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125879. */
  125880. audioEnabled: boolean;
  125881. /**
  125882. * Gets or sets if audio will be output to headphones
  125883. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125884. */
  125885. headphone: boolean;
  125886. /**
  125887. * Gets or sets custom audio listener position provider
  125888. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125889. */
  125890. audioListenerPositionProvider: Nullable<() => Vector3>;
  125891. /**
  125892. * Gets or sets a refresh rate when using 3D audio positioning
  125893. */
  125894. audioPositioningRefreshRate: number;
  125895. }
  125896. /**
  125897. * Defines the sound scene component responsible to manage any sounds
  125898. * in a given scene.
  125899. */
  125900. export class AudioSceneComponent implements ISceneSerializableComponent {
  125901. private static _CameraDirectionLH;
  125902. private static _CameraDirectionRH;
  125903. /**
  125904. * The component name helpfull to identify the component in the list of scene components.
  125905. */
  125906. readonly name: string;
  125907. /**
  125908. * The scene the component belongs to.
  125909. */
  125910. scene: Scene;
  125911. private _audioEnabled;
  125912. /**
  125913. * Gets whether audio is enabled or not.
  125914. * Please use related enable/disable method to switch state.
  125915. */
  125916. get audioEnabled(): boolean;
  125917. private _headphone;
  125918. /**
  125919. * Gets whether audio is outputing to headphone or not.
  125920. * Please use the according Switch methods to change output.
  125921. */
  125922. get headphone(): boolean;
  125923. /**
  125924. * Gets or sets a refresh rate when using 3D audio positioning
  125925. */
  125926. audioPositioningRefreshRate: number;
  125927. private _audioListenerPositionProvider;
  125928. /**
  125929. * Gets the current audio listener position provider
  125930. */
  125931. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  125932. /**
  125933. * Sets a custom listener position for all sounds in the scene
  125934. * By default, this is the position of the first active camera
  125935. */
  125936. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  125937. /**
  125938. * Creates a new instance of the component for the given scene
  125939. * @param scene Defines the scene to register the component in
  125940. */
  125941. constructor(scene: Scene);
  125942. /**
  125943. * Registers the component in a given scene
  125944. */
  125945. register(): void;
  125946. /**
  125947. * Rebuilds the elements related to this component in case of
  125948. * context lost for instance.
  125949. */
  125950. rebuild(): void;
  125951. /**
  125952. * Serializes the component data to the specified json object
  125953. * @param serializationObject The object to serialize to
  125954. */
  125955. serialize(serializationObject: any): void;
  125956. /**
  125957. * Adds all the elements from the container to the scene
  125958. * @param container the container holding the elements
  125959. */
  125960. addFromContainer(container: AbstractScene): void;
  125961. /**
  125962. * Removes all the elements in the container from the scene
  125963. * @param container contains the elements to remove
  125964. * @param dispose if the removed element should be disposed (default: false)
  125965. */
  125966. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125967. /**
  125968. * Disposes the component and the associated ressources.
  125969. */
  125970. dispose(): void;
  125971. /**
  125972. * Disables audio in the associated scene.
  125973. */
  125974. disableAudio(): void;
  125975. /**
  125976. * Enables audio in the associated scene.
  125977. */
  125978. enableAudio(): void;
  125979. /**
  125980. * Switch audio to headphone output.
  125981. */
  125982. switchAudioModeForHeadphones(): void;
  125983. /**
  125984. * Switch audio to normal speakers.
  125985. */
  125986. switchAudioModeForNormalSpeakers(): void;
  125987. private _cachedCameraDirection;
  125988. private _cachedCameraPosition;
  125989. private _lastCheck;
  125990. private _afterRender;
  125991. }
  125992. }
  125993. declare module BABYLON {
  125994. /**
  125995. * Wraps one or more Sound objects and selects one with random weight for playback.
  125996. */
  125997. export class WeightedSound {
  125998. /** When true a Sound will be selected and played when the current playing Sound completes. */
  125999. loop: boolean;
  126000. private _coneInnerAngle;
  126001. private _coneOuterAngle;
  126002. private _volume;
  126003. /** A Sound is currently playing. */
  126004. isPlaying: boolean;
  126005. /** A Sound is currently paused. */
  126006. isPaused: boolean;
  126007. private _sounds;
  126008. private _weights;
  126009. private _currentIndex?;
  126010. /**
  126011. * Creates a new WeightedSound from the list of sounds given.
  126012. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  126013. * @param sounds Array of Sounds that will be selected from.
  126014. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  126015. */
  126016. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  126017. /**
  126018. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  126019. */
  126020. get directionalConeInnerAngle(): number;
  126021. /**
  126022. * The size of cone in degress for a directional sound in which there will be no attenuation.
  126023. */
  126024. set directionalConeInnerAngle(value: number);
  126025. /**
  126026. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126027. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126028. */
  126029. get directionalConeOuterAngle(): number;
  126030. /**
  126031. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126032. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126033. */
  126034. set directionalConeOuterAngle(value: number);
  126035. /**
  126036. * Playback volume.
  126037. */
  126038. get volume(): number;
  126039. /**
  126040. * Playback volume.
  126041. */
  126042. set volume(value: number);
  126043. private _onended;
  126044. /**
  126045. * Suspend playback
  126046. */
  126047. pause(): void;
  126048. /**
  126049. * Stop playback
  126050. */
  126051. stop(): void;
  126052. /**
  126053. * Start playback.
  126054. * @param startOffset Position the clip head at a specific time in seconds.
  126055. */
  126056. play(startOffset?: number): void;
  126057. }
  126058. }
  126059. declare module BABYLON {
  126060. /**
  126061. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  126062. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126063. */
  126064. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  126065. /**
  126066. * Gets the name of the behavior.
  126067. */
  126068. get name(): string;
  126069. /**
  126070. * The easing function used by animations
  126071. */
  126072. static EasingFunction: BackEase;
  126073. /**
  126074. * The easing mode used by animations
  126075. */
  126076. static EasingMode: number;
  126077. /**
  126078. * The duration of the animation, in milliseconds
  126079. */
  126080. transitionDuration: number;
  126081. /**
  126082. * Length of the distance animated by the transition when lower radius is reached
  126083. */
  126084. lowerRadiusTransitionRange: number;
  126085. /**
  126086. * Length of the distance animated by the transition when upper radius is reached
  126087. */
  126088. upperRadiusTransitionRange: number;
  126089. private _autoTransitionRange;
  126090. /**
  126091. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126092. */
  126093. get autoTransitionRange(): boolean;
  126094. /**
  126095. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126096. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  126097. */
  126098. set autoTransitionRange(value: boolean);
  126099. private _attachedCamera;
  126100. private _onAfterCheckInputsObserver;
  126101. private _onMeshTargetChangedObserver;
  126102. /**
  126103. * Initializes the behavior.
  126104. */
  126105. init(): void;
  126106. /**
  126107. * Attaches the behavior to its arc rotate camera.
  126108. * @param camera Defines the camera to attach the behavior to
  126109. */
  126110. attach(camera: ArcRotateCamera): void;
  126111. /**
  126112. * Detaches the behavior from its current arc rotate camera.
  126113. */
  126114. detach(): void;
  126115. private _radiusIsAnimating;
  126116. private _radiusBounceTransition;
  126117. private _animatables;
  126118. private _cachedWheelPrecision;
  126119. /**
  126120. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  126121. * @param radiusLimit The limit to check against.
  126122. * @return Bool to indicate if at limit.
  126123. */
  126124. private _isRadiusAtLimit;
  126125. /**
  126126. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  126127. * @param radiusDelta The delta by which to animate to. Can be negative.
  126128. */
  126129. private _applyBoundRadiusAnimation;
  126130. /**
  126131. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  126132. */
  126133. protected _clearAnimationLocks(): void;
  126134. /**
  126135. * Stops and removes all animations that have been applied to the camera
  126136. */
  126137. stopAllAnimations(): void;
  126138. }
  126139. }
  126140. declare module BABYLON {
  126141. /**
  126142. * 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.
  126143. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126144. */
  126145. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  126146. /**
  126147. * Gets the name of the behavior.
  126148. */
  126149. get name(): string;
  126150. private _mode;
  126151. private _radiusScale;
  126152. private _positionScale;
  126153. private _defaultElevation;
  126154. private _elevationReturnTime;
  126155. private _elevationReturnWaitTime;
  126156. private _zoomStopsAnimation;
  126157. private _framingTime;
  126158. /**
  126159. * The easing function used by animations
  126160. */
  126161. static EasingFunction: ExponentialEase;
  126162. /**
  126163. * The easing mode used by animations
  126164. */
  126165. static EasingMode: number;
  126166. /**
  126167. * Sets the current mode used by the behavior
  126168. */
  126169. set mode(mode: number);
  126170. /**
  126171. * Gets current mode used by the behavior.
  126172. */
  126173. get mode(): number;
  126174. /**
  126175. * Sets the scale applied to the radius (1 by default)
  126176. */
  126177. set radiusScale(radius: number);
  126178. /**
  126179. * Gets the scale applied to the radius
  126180. */
  126181. get radiusScale(): number;
  126182. /**
  126183. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126184. */
  126185. set positionScale(scale: number);
  126186. /**
  126187. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126188. */
  126189. get positionScale(): number;
  126190. /**
  126191. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126192. * behaviour is triggered, in radians.
  126193. */
  126194. set defaultElevation(elevation: number);
  126195. /**
  126196. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126197. * behaviour is triggered, in radians.
  126198. */
  126199. get defaultElevation(): number;
  126200. /**
  126201. * Sets the time (in milliseconds) taken to return to the default beta position.
  126202. * Negative value indicates camera should not return to default.
  126203. */
  126204. set elevationReturnTime(speed: number);
  126205. /**
  126206. * Gets the time (in milliseconds) taken to return to the default beta position.
  126207. * Negative value indicates camera should not return to default.
  126208. */
  126209. get elevationReturnTime(): number;
  126210. /**
  126211. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126212. */
  126213. set elevationReturnWaitTime(time: number);
  126214. /**
  126215. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126216. */
  126217. get elevationReturnWaitTime(): number;
  126218. /**
  126219. * Sets the flag that indicates if user zooming should stop animation.
  126220. */
  126221. set zoomStopsAnimation(flag: boolean);
  126222. /**
  126223. * Gets the flag that indicates if user zooming should stop animation.
  126224. */
  126225. get zoomStopsAnimation(): boolean;
  126226. /**
  126227. * Sets the transition time when framing the mesh, in milliseconds
  126228. */
  126229. set framingTime(time: number);
  126230. /**
  126231. * Gets the transition time when framing the mesh, in milliseconds
  126232. */
  126233. get framingTime(): number;
  126234. /**
  126235. * Define if the behavior should automatically change the configured
  126236. * camera limits and sensibilities.
  126237. */
  126238. autoCorrectCameraLimitsAndSensibility: boolean;
  126239. private _onPrePointerObservableObserver;
  126240. private _onAfterCheckInputsObserver;
  126241. private _onMeshTargetChangedObserver;
  126242. private _attachedCamera;
  126243. private _isPointerDown;
  126244. private _lastInteractionTime;
  126245. /**
  126246. * Initializes the behavior.
  126247. */
  126248. init(): void;
  126249. /**
  126250. * Attaches the behavior to its arc rotate camera.
  126251. * @param camera Defines the camera to attach the behavior to
  126252. */
  126253. attach(camera: ArcRotateCamera): void;
  126254. /**
  126255. * Detaches the behavior from its current arc rotate camera.
  126256. */
  126257. detach(): void;
  126258. private _animatables;
  126259. private _betaIsAnimating;
  126260. private _betaTransition;
  126261. private _radiusTransition;
  126262. private _vectorTransition;
  126263. /**
  126264. * Targets the given mesh and updates zoom level accordingly.
  126265. * @param mesh The mesh to target.
  126266. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126267. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126268. */
  126269. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126270. /**
  126271. * Targets the given mesh with its children and updates zoom level accordingly.
  126272. * @param mesh The mesh to target.
  126273. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126274. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126275. */
  126276. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126277. /**
  126278. * Targets the given meshes with their children and updates zoom level accordingly.
  126279. * @param meshes The mesh to target.
  126280. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126281. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126282. */
  126283. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126284. /**
  126285. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  126286. * @param minimumWorld Determines the smaller position of the bounding box extend
  126287. * @param maximumWorld Determines the bigger position of the bounding box extend
  126288. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126289. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126290. */
  126291. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126292. /**
  126293. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  126294. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  126295. * frustum width.
  126296. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  126297. * to fully enclose the mesh in the viewing frustum.
  126298. */
  126299. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  126300. /**
  126301. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  126302. * is automatically returned to its default position (expected to be above ground plane).
  126303. */
  126304. private _maintainCameraAboveGround;
  126305. /**
  126306. * Returns the frustum slope based on the canvas ratio and camera FOV
  126307. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  126308. */
  126309. private _getFrustumSlope;
  126310. /**
  126311. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  126312. */
  126313. private _clearAnimationLocks;
  126314. /**
  126315. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126316. */
  126317. private _applyUserInteraction;
  126318. /**
  126319. * Stops and removes all animations that have been applied to the camera
  126320. */
  126321. stopAllAnimations(): void;
  126322. /**
  126323. * Gets a value indicating if the user is moving the camera
  126324. */
  126325. get isUserIsMoving(): boolean;
  126326. /**
  126327. * The camera can move all the way towards the mesh.
  126328. */
  126329. static IgnoreBoundsSizeMode: number;
  126330. /**
  126331. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  126332. */
  126333. static FitFrustumSidesMode: number;
  126334. }
  126335. }
  126336. declare module BABYLON {
  126337. /**
  126338. * Base class for Camera Pointer Inputs.
  126339. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  126340. * for example usage.
  126341. */
  126342. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  126343. /**
  126344. * Defines the camera the input is attached to.
  126345. */
  126346. abstract camera: Camera;
  126347. /**
  126348. * Whether keyboard modifier keys are pressed at time of last mouse event.
  126349. */
  126350. protected _altKey: boolean;
  126351. protected _ctrlKey: boolean;
  126352. protected _metaKey: boolean;
  126353. protected _shiftKey: boolean;
  126354. /**
  126355. * Which mouse buttons were pressed at time of last mouse event.
  126356. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  126357. */
  126358. protected _buttonsPressed: number;
  126359. /**
  126360. * Defines the buttons associated with the input to handle camera move.
  126361. */
  126362. buttons: number[];
  126363. /**
  126364. * Attach the input controls to a specific dom element to get the input from.
  126365. * @param element Defines the element the controls should be listened from
  126366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126367. */
  126368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126369. /**
  126370. * Detach the current controls from the specified dom element.
  126371. * @param element Defines the element to stop listening the inputs from
  126372. */
  126373. detachControl(element: Nullable<HTMLElement>): void;
  126374. /**
  126375. * Gets the class name of the current input.
  126376. * @returns the class name
  126377. */
  126378. getClassName(): string;
  126379. /**
  126380. * Get the friendly name associated with the input class.
  126381. * @returns the input friendly name
  126382. */
  126383. getSimpleName(): string;
  126384. /**
  126385. * Called on pointer POINTERDOUBLETAP event.
  126386. * Override this method to provide functionality on POINTERDOUBLETAP event.
  126387. */
  126388. protected onDoubleTap(type: string): void;
  126389. /**
  126390. * Called on pointer POINTERMOVE event if only a single touch is active.
  126391. * Override this method to provide functionality.
  126392. */
  126393. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126394. /**
  126395. * Called on pointer POINTERMOVE event if multiple touches are active.
  126396. * Override this method to provide functionality.
  126397. */
  126398. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126399. /**
  126400. * Called on JS contextmenu event.
  126401. * Override this method to provide functionality.
  126402. */
  126403. protected onContextMenu(evt: PointerEvent): void;
  126404. /**
  126405. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126406. * press.
  126407. * Override this method to provide functionality.
  126408. */
  126409. protected onButtonDown(evt: PointerEvent): void;
  126410. /**
  126411. * Called each time a new POINTERUP event occurs. Ie, for each button
  126412. * release.
  126413. * Override this method to provide functionality.
  126414. */
  126415. protected onButtonUp(evt: PointerEvent): void;
  126416. /**
  126417. * Called when window becomes inactive.
  126418. * Override this method to provide functionality.
  126419. */
  126420. protected onLostFocus(): void;
  126421. private _pointerInput;
  126422. private _observer;
  126423. private _onLostFocus;
  126424. private pointA;
  126425. private pointB;
  126426. }
  126427. }
  126428. declare module BABYLON {
  126429. /**
  126430. * Manage the pointers inputs to control an arc rotate camera.
  126431. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126432. */
  126433. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  126434. /**
  126435. * Defines the camera the input is attached to.
  126436. */
  126437. camera: ArcRotateCamera;
  126438. /**
  126439. * Gets the class name of the current input.
  126440. * @returns the class name
  126441. */
  126442. getClassName(): string;
  126443. /**
  126444. * Defines the buttons associated with the input to handle camera move.
  126445. */
  126446. buttons: number[];
  126447. /**
  126448. * Defines the pointer angular sensibility along the X axis or how fast is
  126449. * the camera rotating.
  126450. */
  126451. angularSensibilityX: number;
  126452. /**
  126453. * Defines the pointer angular sensibility along the Y axis or how fast is
  126454. * the camera rotating.
  126455. */
  126456. angularSensibilityY: number;
  126457. /**
  126458. * Defines the pointer pinch precision or how fast is the camera zooming.
  126459. */
  126460. pinchPrecision: number;
  126461. /**
  126462. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  126463. * from 0.
  126464. * It defines the percentage of current camera.radius to use as delta when
  126465. * pinch zoom is used.
  126466. */
  126467. pinchDeltaPercentage: number;
  126468. /**
  126469. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126470. * that any object in the plane at the camera's target point will scale
  126471. * perfectly with finger motion.
  126472. * Overrides pinchDeltaPercentage and pinchPrecision.
  126473. */
  126474. useNaturalPinchZoom: boolean;
  126475. /**
  126476. * Defines the pointer panning sensibility or how fast is the camera moving.
  126477. */
  126478. panningSensibility: number;
  126479. /**
  126480. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  126481. */
  126482. multiTouchPanning: boolean;
  126483. /**
  126484. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  126485. * zoom (pinch) through multitouch.
  126486. */
  126487. multiTouchPanAndZoom: boolean;
  126488. /**
  126489. * Revers pinch action direction.
  126490. */
  126491. pinchInwards: boolean;
  126492. private _isPanClick;
  126493. private _twoFingerActivityCount;
  126494. private _isPinching;
  126495. /**
  126496. * Called on pointer POINTERMOVE event if only a single touch is active.
  126497. */
  126498. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126499. /**
  126500. * Called on pointer POINTERDOUBLETAP event.
  126501. */
  126502. protected onDoubleTap(type: string): void;
  126503. /**
  126504. * Called on pointer POINTERMOVE event if multiple touches are active.
  126505. */
  126506. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126507. /**
  126508. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126509. * press.
  126510. */
  126511. protected onButtonDown(evt: PointerEvent): void;
  126512. /**
  126513. * Called each time a new POINTERUP event occurs. Ie, for each button
  126514. * release.
  126515. */
  126516. protected onButtonUp(evt: PointerEvent): void;
  126517. /**
  126518. * Called when window becomes inactive.
  126519. */
  126520. protected onLostFocus(): void;
  126521. }
  126522. }
  126523. declare module BABYLON {
  126524. /**
  126525. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  126526. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126527. */
  126528. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  126529. /**
  126530. * Defines the camera the input is attached to.
  126531. */
  126532. camera: ArcRotateCamera;
  126533. /**
  126534. * Defines the list of key codes associated with the up action (increase alpha)
  126535. */
  126536. keysUp: number[];
  126537. /**
  126538. * Defines the list of key codes associated with the down action (decrease alpha)
  126539. */
  126540. keysDown: number[];
  126541. /**
  126542. * Defines the list of key codes associated with the left action (increase beta)
  126543. */
  126544. keysLeft: number[];
  126545. /**
  126546. * Defines the list of key codes associated with the right action (decrease beta)
  126547. */
  126548. keysRight: number[];
  126549. /**
  126550. * Defines the list of key codes associated with the reset action.
  126551. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  126552. */
  126553. keysReset: number[];
  126554. /**
  126555. * Defines the panning sensibility of the inputs.
  126556. * (How fast is the camera panning)
  126557. */
  126558. panningSensibility: number;
  126559. /**
  126560. * Defines the zooming sensibility of the inputs.
  126561. * (How fast is the camera zooming)
  126562. */
  126563. zoomingSensibility: number;
  126564. /**
  126565. * Defines whether maintaining the alt key down switch the movement mode from
  126566. * orientation to zoom.
  126567. */
  126568. useAltToZoom: boolean;
  126569. /**
  126570. * Rotation speed of the camera
  126571. */
  126572. angularSpeed: number;
  126573. private _keys;
  126574. private _ctrlPressed;
  126575. private _altPressed;
  126576. private _onCanvasBlurObserver;
  126577. private _onKeyboardObserver;
  126578. private _engine;
  126579. private _scene;
  126580. /**
  126581. * Attach the input controls to a specific dom element to get the input from.
  126582. * @param element Defines the element the controls should be listened from
  126583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126584. */
  126585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126586. /**
  126587. * Detach the current controls from the specified dom element.
  126588. * @param element Defines the element to stop listening the inputs from
  126589. */
  126590. detachControl(element: Nullable<HTMLElement>): void;
  126591. /**
  126592. * Update the current camera state depending on the inputs that have been used this frame.
  126593. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  126594. */
  126595. checkInputs(): void;
  126596. /**
  126597. * Gets the class name of the current intput.
  126598. * @returns the class name
  126599. */
  126600. getClassName(): string;
  126601. /**
  126602. * Get the friendly name associated with the input class.
  126603. * @returns the input friendly name
  126604. */
  126605. getSimpleName(): string;
  126606. }
  126607. }
  126608. declare module BABYLON {
  126609. /**
  126610. * Manage the mouse wheel inputs to control an arc rotate camera.
  126611. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126612. */
  126613. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  126614. /**
  126615. * Defines the camera the input is attached to.
  126616. */
  126617. camera: ArcRotateCamera;
  126618. /**
  126619. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126620. */
  126621. wheelPrecision: number;
  126622. /**
  126623. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  126624. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  126625. */
  126626. wheelDeltaPercentage: number;
  126627. private _wheel;
  126628. private _observer;
  126629. private computeDeltaFromMouseWheelLegacyEvent;
  126630. /**
  126631. * Attach the input controls to a specific dom element to get the input from.
  126632. * @param element Defines the element the controls should be listened from
  126633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126634. */
  126635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126636. /**
  126637. * Detach the current controls from the specified dom element.
  126638. * @param element Defines the element to stop listening the inputs from
  126639. */
  126640. detachControl(element: Nullable<HTMLElement>): void;
  126641. /**
  126642. * Gets the class name of the current intput.
  126643. * @returns the class name
  126644. */
  126645. getClassName(): string;
  126646. /**
  126647. * Get the friendly name associated with the input class.
  126648. * @returns the input friendly name
  126649. */
  126650. getSimpleName(): string;
  126651. }
  126652. }
  126653. declare module BABYLON {
  126654. /**
  126655. * Default Inputs manager for the ArcRotateCamera.
  126656. * It groups all the default supported inputs for ease of use.
  126657. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126658. */
  126659. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  126660. /**
  126661. * Instantiates a new ArcRotateCameraInputsManager.
  126662. * @param camera Defines the camera the inputs belong to
  126663. */
  126664. constructor(camera: ArcRotateCamera);
  126665. /**
  126666. * Add mouse wheel input support to the input manager.
  126667. * @returns the current input manager
  126668. */
  126669. addMouseWheel(): ArcRotateCameraInputsManager;
  126670. /**
  126671. * Add pointers input support to the input manager.
  126672. * @returns the current input manager
  126673. */
  126674. addPointers(): ArcRotateCameraInputsManager;
  126675. /**
  126676. * Add keyboard input support to the input manager.
  126677. * @returns the current input manager
  126678. */
  126679. addKeyboard(): ArcRotateCameraInputsManager;
  126680. }
  126681. }
  126682. declare module BABYLON {
  126683. /**
  126684. * This represents an orbital type of camera.
  126685. *
  126686. * 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.
  126687. * 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.
  126688. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  126689. */
  126690. export class ArcRotateCamera extends TargetCamera {
  126691. /**
  126692. * Defines the rotation angle of the camera along the longitudinal axis.
  126693. */
  126694. alpha: number;
  126695. /**
  126696. * Defines the rotation angle of the camera along the latitudinal axis.
  126697. */
  126698. beta: number;
  126699. /**
  126700. * Defines the radius of the camera from it s target point.
  126701. */
  126702. radius: number;
  126703. protected _target: Vector3;
  126704. protected _targetHost: Nullable<AbstractMesh>;
  126705. /**
  126706. * Defines the target point of the camera.
  126707. * The camera looks towards it form the radius distance.
  126708. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  126709. */
  126710. get target(): Vector3;
  126711. set target(value: Vector3);
  126712. /**
  126713. * Define the current local position of the camera in the scene
  126714. */
  126715. get position(): Vector3;
  126716. set position(newPosition: Vector3);
  126717. protected _upToYMatrix: Matrix;
  126718. protected _YToUpMatrix: Matrix;
  126719. /**
  126720. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  126721. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  126722. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  126723. */
  126724. set upVector(vec: Vector3);
  126725. get upVector(): Vector3;
  126726. /**
  126727. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  126728. */
  126729. setMatUp(): void;
  126730. /**
  126731. * Current inertia value on the longitudinal axis.
  126732. * The bigger this number the longer it will take for the camera to stop.
  126733. */
  126734. inertialAlphaOffset: number;
  126735. /**
  126736. * Current inertia value on the latitudinal axis.
  126737. * The bigger this number the longer it will take for the camera to stop.
  126738. */
  126739. inertialBetaOffset: number;
  126740. /**
  126741. * Current inertia value on the radius axis.
  126742. * The bigger this number the longer it will take for the camera to stop.
  126743. */
  126744. inertialRadiusOffset: number;
  126745. /**
  126746. * Minimum allowed angle on the longitudinal axis.
  126747. * This can help limiting how the Camera is able to move in the scene.
  126748. */
  126749. lowerAlphaLimit: Nullable<number>;
  126750. /**
  126751. * Maximum allowed angle on the longitudinal axis.
  126752. * This can help limiting how the Camera is able to move in the scene.
  126753. */
  126754. upperAlphaLimit: Nullable<number>;
  126755. /**
  126756. * Minimum allowed angle on the latitudinal axis.
  126757. * This can help limiting how the Camera is able to move in the scene.
  126758. */
  126759. lowerBetaLimit: number;
  126760. /**
  126761. * Maximum allowed angle on the latitudinal axis.
  126762. * This can help limiting how the Camera is able to move in the scene.
  126763. */
  126764. upperBetaLimit: number;
  126765. /**
  126766. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  126767. * This can help limiting how the Camera is able to move in the scene.
  126768. */
  126769. lowerRadiusLimit: Nullable<number>;
  126770. /**
  126771. * Maximum allowed distance of the camera to the target (The camera can not get further).
  126772. * This can help limiting how the Camera is able to move in the scene.
  126773. */
  126774. upperRadiusLimit: Nullable<number>;
  126775. /**
  126776. * Defines the current inertia value used during panning of the camera along the X axis.
  126777. */
  126778. inertialPanningX: number;
  126779. /**
  126780. * Defines the current inertia value used during panning of the camera along the Y axis.
  126781. */
  126782. inertialPanningY: number;
  126783. /**
  126784. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  126785. * Basically if your fingers moves away from more than this distance you will be considered
  126786. * in pinch mode.
  126787. */
  126788. pinchToPanMaxDistance: number;
  126789. /**
  126790. * Defines the maximum distance the camera can pan.
  126791. * This could help keeping the cammera always in your scene.
  126792. */
  126793. panningDistanceLimit: Nullable<number>;
  126794. /**
  126795. * Defines the target of the camera before paning.
  126796. */
  126797. panningOriginTarget: Vector3;
  126798. /**
  126799. * Defines the value of the inertia used during panning.
  126800. * 0 would mean stop inertia and one would mean no decelleration at all.
  126801. */
  126802. panningInertia: number;
  126803. /**
  126804. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  126805. */
  126806. get angularSensibilityX(): number;
  126807. set angularSensibilityX(value: number);
  126808. /**
  126809. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  126810. */
  126811. get angularSensibilityY(): number;
  126812. set angularSensibilityY(value: number);
  126813. /**
  126814. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  126815. */
  126816. get pinchPrecision(): number;
  126817. set pinchPrecision(value: number);
  126818. /**
  126819. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  126820. * It will be used instead of pinchDeltaPrecision if different from 0.
  126821. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126822. */
  126823. get pinchDeltaPercentage(): number;
  126824. set pinchDeltaPercentage(value: number);
  126825. /**
  126826. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  126827. * and pinch delta percentage.
  126828. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126829. * that any object in the plane at the camera's target point will scale
  126830. * perfectly with finger motion.
  126831. */
  126832. get useNaturalPinchZoom(): boolean;
  126833. set useNaturalPinchZoom(value: boolean);
  126834. /**
  126835. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  126836. */
  126837. get panningSensibility(): number;
  126838. set panningSensibility(value: number);
  126839. /**
  126840. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  126841. */
  126842. get keysUp(): number[];
  126843. set keysUp(value: number[]);
  126844. /**
  126845. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  126846. */
  126847. get keysDown(): number[];
  126848. set keysDown(value: number[]);
  126849. /**
  126850. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  126851. */
  126852. get keysLeft(): number[];
  126853. set keysLeft(value: number[]);
  126854. /**
  126855. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  126856. */
  126857. get keysRight(): number[];
  126858. set keysRight(value: number[]);
  126859. /**
  126860. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126861. */
  126862. get wheelPrecision(): number;
  126863. set wheelPrecision(value: number);
  126864. /**
  126865. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  126866. * It will be used instead of pinchDeltaPrecision if different from 0.
  126867. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126868. */
  126869. get wheelDeltaPercentage(): number;
  126870. set wheelDeltaPercentage(value: number);
  126871. /**
  126872. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  126873. */
  126874. zoomOnFactor: number;
  126875. /**
  126876. * Defines a screen offset for the camera position.
  126877. */
  126878. targetScreenOffset: Vector2;
  126879. /**
  126880. * Allows the camera to be completely reversed.
  126881. * If false the camera can not arrive upside down.
  126882. */
  126883. allowUpsideDown: boolean;
  126884. /**
  126885. * Define if double tap/click is used to restore the previously saved state of the camera.
  126886. */
  126887. useInputToRestoreState: boolean;
  126888. /** @hidden */
  126889. _viewMatrix: Matrix;
  126890. /** @hidden */
  126891. _useCtrlForPanning: boolean;
  126892. /** @hidden */
  126893. _panningMouseButton: number;
  126894. /**
  126895. * Defines the input associated to the camera.
  126896. */
  126897. inputs: ArcRotateCameraInputsManager;
  126898. /** @hidden */
  126899. _reset: () => void;
  126900. /**
  126901. * Defines the allowed panning axis.
  126902. */
  126903. panningAxis: Vector3;
  126904. protected _localDirection: Vector3;
  126905. protected _transformedDirection: Vector3;
  126906. private _bouncingBehavior;
  126907. /**
  126908. * Gets the bouncing behavior of the camera if it has been enabled.
  126909. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126910. */
  126911. get bouncingBehavior(): Nullable<BouncingBehavior>;
  126912. /**
  126913. * Defines if the bouncing behavior of the camera is enabled on the camera.
  126914. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126915. */
  126916. get useBouncingBehavior(): boolean;
  126917. set useBouncingBehavior(value: boolean);
  126918. private _framingBehavior;
  126919. /**
  126920. * Gets the framing behavior of the camera if it has been enabled.
  126921. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126922. */
  126923. get framingBehavior(): Nullable<FramingBehavior>;
  126924. /**
  126925. * Defines if the framing behavior of the camera is enabled on the camera.
  126926. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126927. */
  126928. get useFramingBehavior(): boolean;
  126929. set useFramingBehavior(value: boolean);
  126930. private _autoRotationBehavior;
  126931. /**
  126932. * Gets the auto rotation behavior of the camera if it has been enabled.
  126933. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126934. */
  126935. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  126936. /**
  126937. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  126938. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126939. */
  126940. get useAutoRotationBehavior(): boolean;
  126941. set useAutoRotationBehavior(value: boolean);
  126942. /**
  126943. * Observable triggered when the mesh target has been changed on the camera.
  126944. */
  126945. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  126946. /**
  126947. * Event raised when the camera is colliding with a mesh.
  126948. */
  126949. onCollide: (collidedMesh: AbstractMesh) => void;
  126950. /**
  126951. * Defines whether the camera should check collision with the objects oh the scene.
  126952. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  126953. */
  126954. checkCollisions: boolean;
  126955. /**
  126956. * Defines the collision radius of the camera.
  126957. * This simulates a sphere around the camera.
  126958. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  126959. */
  126960. collisionRadius: Vector3;
  126961. protected _collider: Collider;
  126962. protected _previousPosition: Vector3;
  126963. protected _collisionVelocity: Vector3;
  126964. protected _newPosition: Vector3;
  126965. protected _previousAlpha: number;
  126966. protected _previousBeta: number;
  126967. protected _previousRadius: number;
  126968. protected _collisionTriggered: boolean;
  126969. protected _targetBoundingCenter: Nullable<Vector3>;
  126970. private _computationVector;
  126971. /**
  126972. * Instantiates a new ArcRotateCamera in a given scene
  126973. * @param name Defines the name of the camera
  126974. * @param alpha Defines the camera rotation along the logitudinal axis
  126975. * @param beta Defines the camera rotation along the latitudinal axis
  126976. * @param radius Defines the camera distance from its target
  126977. * @param target Defines the camera target
  126978. * @param scene Defines the scene the camera belongs to
  126979. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  126980. */
  126981. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  126982. /** @hidden */
  126983. _initCache(): void;
  126984. /** @hidden */
  126985. _updateCache(ignoreParentClass?: boolean): void;
  126986. protected _getTargetPosition(): Vector3;
  126987. private _storedAlpha;
  126988. private _storedBeta;
  126989. private _storedRadius;
  126990. private _storedTarget;
  126991. private _storedTargetScreenOffset;
  126992. /**
  126993. * Stores the current state of the camera (alpha, beta, radius and target)
  126994. * @returns the camera itself
  126995. */
  126996. storeState(): Camera;
  126997. /**
  126998. * @hidden
  126999. * Restored camera state. You must call storeState() first
  127000. */
  127001. _restoreStateValues(): boolean;
  127002. /** @hidden */
  127003. _isSynchronizedViewMatrix(): boolean;
  127004. /**
  127005. * Attached controls to the current camera.
  127006. * @param element Defines the element the controls should be listened from
  127007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127008. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  127009. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  127010. */
  127011. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  127012. /**
  127013. * Detach the current controls from the camera.
  127014. * The camera will stop reacting to inputs.
  127015. * @param element Defines the element to stop listening the inputs from
  127016. */
  127017. detachControl(element: HTMLElement): void;
  127018. /** @hidden */
  127019. _checkInputs(): void;
  127020. protected _checkLimits(): void;
  127021. /**
  127022. * Rebuilds angles (alpha, beta) and radius from the give position and target
  127023. */
  127024. rebuildAnglesAndRadius(): void;
  127025. /**
  127026. * Use a position to define the current camera related information like alpha, beta and radius
  127027. * @param position Defines the position to set the camera at
  127028. */
  127029. setPosition(position: Vector3): void;
  127030. /**
  127031. * Defines the target the camera should look at.
  127032. * This will automatically adapt alpha beta and radius to fit within the new target.
  127033. * @param target Defines the new target as a Vector or a mesh
  127034. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  127035. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  127036. */
  127037. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  127038. /** @hidden */
  127039. _getViewMatrix(): Matrix;
  127040. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  127041. /**
  127042. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  127043. * @param meshes Defines the mesh to zoom on
  127044. * @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)
  127045. */
  127046. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  127047. /**
  127048. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  127049. * The target will be changed but the radius
  127050. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  127051. * @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)
  127052. */
  127053. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  127054. min: Vector3;
  127055. max: Vector3;
  127056. distance: number;
  127057. }, doNotUpdateMaxZ?: boolean): void;
  127058. /**
  127059. * @override
  127060. * Override Camera.createRigCamera
  127061. */
  127062. createRigCamera(name: string, cameraIndex: number): Camera;
  127063. /**
  127064. * @hidden
  127065. * @override
  127066. * Override Camera._updateRigCameras
  127067. */
  127068. _updateRigCameras(): void;
  127069. /**
  127070. * Destroy the camera and release the current resources hold by it.
  127071. */
  127072. dispose(): void;
  127073. /**
  127074. * Gets the current object class name.
  127075. * @return the class name
  127076. */
  127077. getClassName(): string;
  127078. }
  127079. }
  127080. declare module BABYLON {
  127081. /**
  127082. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  127083. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127084. */
  127085. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  127086. /**
  127087. * Gets the name of the behavior.
  127088. */
  127089. get name(): string;
  127090. private _zoomStopsAnimation;
  127091. private _idleRotationSpeed;
  127092. private _idleRotationWaitTime;
  127093. private _idleRotationSpinupTime;
  127094. /**
  127095. * Sets the flag that indicates if user zooming should stop animation.
  127096. */
  127097. set zoomStopsAnimation(flag: boolean);
  127098. /**
  127099. * Gets the flag that indicates if user zooming should stop animation.
  127100. */
  127101. get zoomStopsAnimation(): boolean;
  127102. /**
  127103. * Sets the default speed at which the camera rotates around the model.
  127104. */
  127105. set idleRotationSpeed(speed: number);
  127106. /**
  127107. * Gets the default speed at which the camera rotates around the model.
  127108. */
  127109. get idleRotationSpeed(): number;
  127110. /**
  127111. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  127112. */
  127113. set idleRotationWaitTime(time: number);
  127114. /**
  127115. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  127116. */
  127117. get idleRotationWaitTime(): number;
  127118. /**
  127119. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127120. */
  127121. set idleRotationSpinupTime(time: number);
  127122. /**
  127123. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127124. */
  127125. get idleRotationSpinupTime(): number;
  127126. /**
  127127. * Gets a value indicating if the camera is currently rotating because of this behavior
  127128. */
  127129. get rotationInProgress(): boolean;
  127130. private _onPrePointerObservableObserver;
  127131. private _onAfterCheckInputsObserver;
  127132. private _attachedCamera;
  127133. private _isPointerDown;
  127134. private _lastFrameTime;
  127135. private _lastInteractionTime;
  127136. private _cameraRotationSpeed;
  127137. /**
  127138. * Initializes the behavior.
  127139. */
  127140. init(): void;
  127141. /**
  127142. * Attaches the behavior to its arc rotate camera.
  127143. * @param camera Defines the camera to attach the behavior to
  127144. */
  127145. attach(camera: ArcRotateCamera): void;
  127146. /**
  127147. * Detaches the behavior from its current arc rotate camera.
  127148. */
  127149. detach(): void;
  127150. /**
  127151. * Returns true if user is scrolling.
  127152. * @return true if user is scrolling.
  127153. */
  127154. private _userIsZooming;
  127155. private _lastFrameRadius;
  127156. private _shouldAnimationStopForInteraction;
  127157. /**
  127158. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127159. */
  127160. private _applyUserInteraction;
  127161. private _userIsMoving;
  127162. }
  127163. }
  127164. declare module BABYLON {
  127165. /**
  127166. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  127167. */
  127168. export class AttachToBoxBehavior implements Behavior<Mesh> {
  127169. private ui;
  127170. /**
  127171. * The name of the behavior
  127172. */
  127173. name: string;
  127174. /**
  127175. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  127176. */
  127177. distanceAwayFromFace: number;
  127178. /**
  127179. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  127180. */
  127181. distanceAwayFromBottomOfFace: number;
  127182. private _faceVectors;
  127183. private _target;
  127184. private _scene;
  127185. private _onRenderObserver;
  127186. private _tmpMatrix;
  127187. private _tmpVector;
  127188. /**
  127189. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  127190. * @param ui The transform node that should be attched to the mesh
  127191. */
  127192. constructor(ui: TransformNode);
  127193. /**
  127194. * Initializes the behavior
  127195. */
  127196. init(): void;
  127197. private _closestFace;
  127198. private _zeroVector;
  127199. private _lookAtTmpMatrix;
  127200. private _lookAtToRef;
  127201. /**
  127202. * Attaches the AttachToBoxBehavior to the passed in mesh
  127203. * @param target The mesh that the specified node will be attached to
  127204. */
  127205. attach(target: Mesh): void;
  127206. /**
  127207. * Detaches the behavior from the mesh
  127208. */
  127209. detach(): void;
  127210. }
  127211. }
  127212. declare module BABYLON {
  127213. /**
  127214. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  127215. */
  127216. export class FadeInOutBehavior implements Behavior<Mesh> {
  127217. /**
  127218. * Time in milliseconds to delay before fading in (Default: 0)
  127219. */
  127220. delay: number;
  127221. /**
  127222. * Time in milliseconds for the mesh to fade in (Default: 300)
  127223. */
  127224. fadeInTime: number;
  127225. private _millisecondsPerFrame;
  127226. private _hovered;
  127227. private _hoverValue;
  127228. private _ownerNode;
  127229. /**
  127230. * Instatiates the FadeInOutBehavior
  127231. */
  127232. constructor();
  127233. /**
  127234. * The name of the behavior
  127235. */
  127236. get name(): string;
  127237. /**
  127238. * Initializes the behavior
  127239. */
  127240. init(): void;
  127241. /**
  127242. * Attaches the fade behavior on the passed in mesh
  127243. * @param ownerNode The mesh that will be faded in/out once attached
  127244. */
  127245. attach(ownerNode: Mesh): void;
  127246. /**
  127247. * Detaches the behavior from the mesh
  127248. */
  127249. detach(): void;
  127250. /**
  127251. * Triggers the mesh to begin fading in or out
  127252. * @param value if the object should fade in or out (true to fade in)
  127253. */
  127254. fadeIn(value: boolean): void;
  127255. private _update;
  127256. private _setAllVisibility;
  127257. }
  127258. }
  127259. declare module BABYLON {
  127260. /**
  127261. * Class containing a set of static utilities functions for managing Pivots
  127262. * @hidden
  127263. */
  127264. export class PivotTools {
  127265. private static _PivotCached;
  127266. private static _OldPivotPoint;
  127267. private static _PivotTranslation;
  127268. private static _PivotTmpVector;
  127269. private static _PivotPostMultiplyPivotMatrix;
  127270. /** @hidden */
  127271. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  127272. /** @hidden */
  127273. static _RestorePivotPoint(mesh: AbstractMesh): void;
  127274. }
  127275. }
  127276. declare module BABYLON {
  127277. /**
  127278. * Class containing static functions to help procedurally build meshes
  127279. */
  127280. export class PlaneBuilder {
  127281. /**
  127282. * Creates a plane mesh
  127283. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127284. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127285. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127289. * @param name defines the name of the mesh
  127290. * @param options defines the options used to create the mesh
  127291. * @param scene defines the hosting scene
  127292. * @returns the plane mesh
  127293. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127294. */
  127295. static CreatePlane(name: string, options: {
  127296. size?: number;
  127297. width?: number;
  127298. height?: number;
  127299. sideOrientation?: number;
  127300. frontUVs?: Vector4;
  127301. backUVs?: Vector4;
  127302. updatable?: boolean;
  127303. sourcePlane?: Plane;
  127304. }, scene?: Nullable<Scene>): Mesh;
  127305. }
  127306. }
  127307. declare module BABYLON {
  127308. /**
  127309. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  127310. */
  127311. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  127312. private static _AnyMouseID;
  127313. /**
  127314. * Abstract mesh the behavior is set on
  127315. */
  127316. attachedNode: AbstractMesh;
  127317. private _dragPlane;
  127318. private _scene;
  127319. private _pointerObserver;
  127320. private _beforeRenderObserver;
  127321. private static _planeScene;
  127322. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  127323. /**
  127324. * 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)
  127325. */
  127326. maxDragAngle: number;
  127327. /**
  127328. * @hidden
  127329. */
  127330. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  127331. /**
  127332. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127333. */
  127334. currentDraggingPointerID: number;
  127335. /**
  127336. * The last position where the pointer hit the drag plane in world space
  127337. */
  127338. lastDragPosition: Vector3;
  127339. /**
  127340. * If the behavior is currently in a dragging state
  127341. */
  127342. dragging: boolean;
  127343. /**
  127344. * 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)
  127345. */
  127346. dragDeltaRatio: number;
  127347. /**
  127348. * If the drag plane orientation should be updated during the dragging (Default: true)
  127349. */
  127350. updateDragPlane: boolean;
  127351. private _debugMode;
  127352. private _moving;
  127353. /**
  127354. * Fires each time the attached mesh is dragged with the pointer
  127355. * * delta between last drag position and current drag position in world space
  127356. * * dragDistance along the drag axis
  127357. * * dragPlaneNormal normal of the current drag plane used during the drag
  127358. * * dragPlanePoint in world space where the drag intersects the drag plane
  127359. */
  127360. onDragObservable: Observable<{
  127361. delta: Vector3;
  127362. dragPlanePoint: Vector3;
  127363. dragPlaneNormal: Vector3;
  127364. dragDistance: number;
  127365. pointerId: number;
  127366. }>;
  127367. /**
  127368. * Fires each time a drag begins (eg. mouse down on mesh)
  127369. */
  127370. onDragStartObservable: Observable<{
  127371. dragPlanePoint: Vector3;
  127372. pointerId: number;
  127373. }>;
  127374. /**
  127375. * Fires each time a drag ends (eg. mouse release after drag)
  127376. */
  127377. onDragEndObservable: Observable<{
  127378. dragPlanePoint: Vector3;
  127379. pointerId: number;
  127380. }>;
  127381. /**
  127382. * If the attached mesh should be moved when dragged
  127383. */
  127384. moveAttached: boolean;
  127385. /**
  127386. * If the drag behavior will react to drag events (Default: true)
  127387. */
  127388. enabled: boolean;
  127389. /**
  127390. * If pointer events should start and release the drag (Default: true)
  127391. */
  127392. startAndReleaseDragOnPointerEvents: boolean;
  127393. /**
  127394. * If camera controls should be detached during the drag
  127395. */
  127396. detachCameraControls: boolean;
  127397. /**
  127398. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  127399. */
  127400. useObjectOrientationForDragging: boolean;
  127401. private _options;
  127402. /**
  127403. * Gets the options used by the behavior
  127404. */
  127405. get options(): {
  127406. dragAxis?: Vector3;
  127407. dragPlaneNormal?: Vector3;
  127408. };
  127409. /**
  127410. * Sets the options used by the behavior
  127411. */
  127412. set options(options: {
  127413. dragAxis?: Vector3;
  127414. dragPlaneNormal?: Vector3;
  127415. });
  127416. /**
  127417. * Creates a pointer drag behavior that can be attached to a mesh
  127418. * @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)
  127419. */
  127420. constructor(options?: {
  127421. dragAxis?: Vector3;
  127422. dragPlaneNormal?: Vector3;
  127423. });
  127424. /**
  127425. * Predicate to determine if it is valid to move the object to a new position when it is moved
  127426. */
  127427. validateDrag: (targetPosition: Vector3) => boolean;
  127428. /**
  127429. * The name of the behavior
  127430. */
  127431. get name(): string;
  127432. /**
  127433. * Initializes the behavior
  127434. */
  127435. init(): void;
  127436. private _tmpVector;
  127437. private _alternatePickedPoint;
  127438. private _worldDragAxis;
  127439. private _targetPosition;
  127440. private _attachedElement;
  127441. /**
  127442. * Attaches the drag behavior the passed in mesh
  127443. * @param ownerNode The mesh that will be dragged around once attached
  127444. * @param predicate Predicate to use for pick filtering
  127445. */
  127446. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  127447. /**
  127448. * Force relase the drag action by code.
  127449. */
  127450. releaseDrag(): void;
  127451. private _startDragRay;
  127452. private _lastPointerRay;
  127453. /**
  127454. * Simulates the start of a pointer drag event on the behavior
  127455. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  127456. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  127457. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  127458. */
  127459. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127460. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127461. private _dragDelta;
  127462. protected _moveDrag(ray: Ray): void;
  127463. private _pickWithRayOnDragPlane;
  127464. private _pointA;
  127465. private _pointC;
  127466. private _localAxis;
  127467. private _lookAt;
  127468. private _updateDragPlanePosition;
  127469. /**
  127470. * Detaches the behavior from the mesh
  127471. */
  127472. detach(): void;
  127473. }
  127474. }
  127475. declare module BABYLON {
  127476. /**
  127477. * A behavior that when attached to a mesh will allow the mesh to be scaled
  127478. */
  127479. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  127480. private _dragBehaviorA;
  127481. private _dragBehaviorB;
  127482. private _startDistance;
  127483. private _initialScale;
  127484. private _targetScale;
  127485. private _ownerNode;
  127486. private _sceneRenderObserver;
  127487. /**
  127488. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  127489. */
  127490. constructor();
  127491. /**
  127492. * The name of the behavior
  127493. */
  127494. get name(): string;
  127495. /**
  127496. * Initializes the behavior
  127497. */
  127498. init(): void;
  127499. private _getCurrentDistance;
  127500. /**
  127501. * Attaches the scale behavior the passed in mesh
  127502. * @param ownerNode The mesh that will be scaled around once attached
  127503. */
  127504. attach(ownerNode: Mesh): void;
  127505. /**
  127506. * Detaches the behavior from the mesh
  127507. */
  127508. detach(): void;
  127509. }
  127510. }
  127511. declare module BABYLON {
  127512. /**
  127513. * 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
  127514. */
  127515. export class SixDofDragBehavior implements Behavior<Mesh> {
  127516. private static _virtualScene;
  127517. private _ownerNode;
  127518. private _sceneRenderObserver;
  127519. private _scene;
  127520. private _targetPosition;
  127521. private _virtualOriginMesh;
  127522. private _virtualDragMesh;
  127523. private _pointerObserver;
  127524. private _moving;
  127525. private _startingOrientation;
  127526. private _attachedElement;
  127527. /**
  127528. * 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)
  127529. */
  127530. private zDragFactor;
  127531. /**
  127532. * If the object should rotate to face the drag origin
  127533. */
  127534. rotateDraggedObject: boolean;
  127535. /**
  127536. * If the behavior is currently in a dragging state
  127537. */
  127538. dragging: boolean;
  127539. /**
  127540. * 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)
  127541. */
  127542. dragDeltaRatio: number;
  127543. /**
  127544. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127545. */
  127546. currentDraggingPointerID: number;
  127547. /**
  127548. * If camera controls should be detached during the drag
  127549. */
  127550. detachCameraControls: boolean;
  127551. /**
  127552. * Fires each time a drag starts
  127553. */
  127554. onDragStartObservable: Observable<{}>;
  127555. /**
  127556. * Fires each time a drag ends (eg. mouse release after drag)
  127557. */
  127558. onDragEndObservable: Observable<{}>;
  127559. /**
  127560. * 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
  127561. */
  127562. constructor();
  127563. /**
  127564. * The name of the behavior
  127565. */
  127566. get name(): string;
  127567. /**
  127568. * Initializes the behavior
  127569. */
  127570. init(): void;
  127571. /**
  127572. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  127573. */
  127574. private get _pointerCamera();
  127575. /**
  127576. * Attaches the scale behavior the passed in mesh
  127577. * @param ownerNode The mesh that will be scaled around once attached
  127578. */
  127579. attach(ownerNode: Mesh): void;
  127580. /**
  127581. * Detaches the behavior from the mesh
  127582. */
  127583. detach(): void;
  127584. }
  127585. }
  127586. declare module BABYLON {
  127587. /**
  127588. * Class used to apply inverse kinematics to bones
  127589. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  127590. */
  127591. export class BoneIKController {
  127592. private static _tmpVecs;
  127593. private static _tmpQuat;
  127594. private static _tmpMats;
  127595. /**
  127596. * Gets or sets the target mesh
  127597. */
  127598. targetMesh: AbstractMesh;
  127599. /** Gets or sets the mesh used as pole */
  127600. poleTargetMesh: AbstractMesh;
  127601. /**
  127602. * Gets or sets the bone used as pole
  127603. */
  127604. poleTargetBone: Nullable<Bone>;
  127605. /**
  127606. * Gets or sets the target position
  127607. */
  127608. targetPosition: Vector3;
  127609. /**
  127610. * Gets or sets the pole target position
  127611. */
  127612. poleTargetPosition: Vector3;
  127613. /**
  127614. * Gets or sets the pole target local offset
  127615. */
  127616. poleTargetLocalOffset: Vector3;
  127617. /**
  127618. * Gets or sets the pole angle
  127619. */
  127620. poleAngle: number;
  127621. /**
  127622. * Gets or sets the mesh associated with the controller
  127623. */
  127624. mesh: AbstractMesh;
  127625. /**
  127626. * 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)
  127627. */
  127628. slerpAmount: number;
  127629. private _bone1Quat;
  127630. private _bone1Mat;
  127631. private _bone2Ang;
  127632. private _bone1;
  127633. private _bone2;
  127634. private _bone1Length;
  127635. private _bone2Length;
  127636. private _maxAngle;
  127637. private _maxReach;
  127638. private _rightHandedSystem;
  127639. private _bendAxis;
  127640. private _slerping;
  127641. private _adjustRoll;
  127642. /**
  127643. * Gets or sets maximum allowed angle
  127644. */
  127645. get maxAngle(): number;
  127646. set maxAngle(value: number);
  127647. /**
  127648. * Creates a new BoneIKController
  127649. * @param mesh defines the mesh to control
  127650. * @param bone defines the bone to control
  127651. * @param options defines options to set up the controller
  127652. */
  127653. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  127654. targetMesh?: AbstractMesh;
  127655. poleTargetMesh?: AbstractMesh;
  127656. poleTargetBone?: Bone;
  127657. poleTargetLocalOffset?: Vector3;
  127658. poleAngle?: number;
  127659. bendAxis?: Vector3;
  127660. maxAngle?: number;
  127661. slerpAmount?: number;
  127662. });
  127663. private _setMaxAngle;
  127664. /**
  127665. * Force the controller to update the bones
  127666. */
  127667. update(): void;
  127668. }
  127669. }
  127670. declare module BABYLON {
  127671. /**
  127672. * Class used to make a bone look toward a point in space
  127673. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  127674. */
  127675. export class BoneLookController {
  127676. private static _tmpVecs;
  127677. private static _tmpQuat;
  127678. private static _tmpMats;
  127679. /**
  127680. * The target Vector3 that the bone will look at
  127681. */
  127682. target: Vector3;
  127683. /**
  127684. * The mesh that the bone is attached to
  127685. */
  127686. mesh: AbstractMesh;
  127687. /**
  127688. * The bone that will be looking to the target
  127689. */
  127690. bone: Bone;
  127691. /**
  127692. * The up axis of the coordinate system that is used when the bone is rotated
  127693. */
  127694. upAxis: Vector3;
  127695. /**
  127696. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  127697. */
  127698. upAxisSpace: Space;
  127699. /**
  127700. * Used to make an adjustment to the yaw of the bone
  127701. */
  127702. adjustYaw: number;
  127703. /**
  127704. * Used to make an adjustment to the pitch of the bone
  127705. */
  127706. adjustPitch: number;
  127707. /**
  127708. * Used to make an adjustment to the roll of the bone
  127709. */
  127710. adjustRoll: number;
  127711. /**
  127712. * 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)
  127713. */
  127714. slerpAmount: number;
  127715. private _minYaw;
  127716. private _maxYaw;
  127717. private _minPitch;
  127718. private _maxPitch;
  127719. private _minYawSin;
  127720. private _minYawCos;
  127721. private _maxYawSin;
  127722. private _maxYawCos;
  127723. private _midYawConstraint;
  127724. private _minPitchTan;
  127725. private _maxPitchTan;
  127726. private _boneQuat;
  127727. private _slerping;
  127728. private _transformYawPitch;
  127729. private _transformYawPitchInv;
  127730. private _firstFrameSkipped;
  127731. private _yawRange;
  127732. private _fowardAxis;
  127733. /**
  127734. * Gets or sets the minimum yaw angle that the bone can look to
  127735. */
  127736. get minYaw(): number;
  127737. set minYaw(value: number);
  127738. /**
  127739. * Gets or sets the maximum yaw angle that the bone can look to
  127740. */
  127741. get maxYaw(): number;
  127742. set maxYaw(value: number);
  127743. /**
  127744. * Gets or sets the minimum pitch angle that the bone can look to
  127745. */
  127746. get minPitch(): number;
  127747. set minPitch(value: number);
  127748. /**
  127749. * Gets or sets the maximum pitch angle that the bone can look to
  127750. */
  127751. get maxPitch(): number;
  127752. set maxPitch(value: number);
  127753. /**
  127754. * Create a BoneLookController
  127755. * @param mesh the mesh that the bone belongs to
  127756. * @param bone the bone that will be looking to the target
  127757. * @param target the target Vector3 to look at
  127758. * @param options optional settings:
  127759. * * maxYaw: the maximum angle the bone will yaw to
  127760. * * minYaw: the minimum angle the bone will yaw to
  127761. * * maxPitch: the maximum angle the bone will pitch to
  127762. * * minPitch: the minimum angle the bone will yaw to
  127763. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  127764. * * upAxis: the up axis of the coordinate system
  127765. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  127766. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  127767. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  127768. * * adjustYaw: used to make an adjustment to the yaw of the bone
  127769. * * adjustPitch: used to make an adjustment to the pitch of the bone
  127770. * * adjustRoll: used to make an adjustment to the roll of the bone
  127771. **/
  127772. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  127773. maxYaw?: number;
  127774. minYaw?: number;
  127775. maxPitch?: number;
  127776. minPitch?: number;
  127777. slerpAmount?: number;
  127778. upAxis?: Vector3;
  127779. upAxisSpace?: Space;
  127780. yawAxis?: Vector3;
  127781. pitchAxis?: Vector3;
  127782. adjustYaw?: number;
  127783. adjustPitch?: number;
  127784. adjustRoll?: number;
  127785. });
  127786. /**
  127787. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  127788. */
  127789. update(): void;
  127790. private _getAngleDiff;
  127791. private _getAngleBetween;
  127792. private _isAngleBetween;
  127793. }
  127794. }
  127795. declare module BABYLON {
  127796. /**
  127797. * Manage the gamepad inputs to control an arc rotate camera.
  127798. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127799. */
  127800. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  127801. /**
  127802. * Defines the camera the input is attached to.
  127803. */
  127804. camera: ArcRotateCamera;
  127805. /**
  127806. * Defines the gamepad the input is gathering event from.
  127807. */
  127808. gamepad: Nullable<Gamepad>;
  127809. /**
  127810. * Defines the gamepad rotation sensiblity.
  127811. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  127812. */
  127813. gamepadRotationSensibility: number;
  127814. /**
  127815. * Defines the gamepad move sensiblity.
  127816. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  127817. */
  127818. gamepadMoveSensibility: number;
  127819. private _yAxisScale;
  127820. /**
  127821. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  127822. */
  127823. get invertYAxis(): boolean;
  127824. set invertYAxis(value: boolean);
  127825. private _onGamepadConnectedObserver;
  127826. private _onGamepadDisconnectedObserver;
  127827. /**
  127828. * Attach the input controls to a specific dom element to get the input from.
  127829. * @param element Defines the element the controls should be listened from
  127830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127831. */
  127832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127833. /**
  127834. * Detach the current controls from the specified dom element.
  127835. * @param element Defines the element to stop listening the inputs from
  127836. */
  127837. detachControl(element: Nullable<HTMLElement>): void;
  127838. /**
  127839. * Update the current camera state depending on the inputs that have been used this frame.
  127840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127841. */
  127842. checkInputs(): void;
  127843. /**
  127844. * Gets the class name of the current intput.
  127845. * @returns the class name
  127846. */
  127847. getClassName(): string;
  127848. /**
  127849. * Get the friendly name associated with the input class.
  127850. * @returns the input friendly name
  127851. */
  127852. getSimpleName(): string;
  127853. }
  127854. }
  127855. declare module BABYLON {
  127856. interface ArcRotateCameraInputsManager {
  127857. /**
  127858. * Add orientation input support to the input manager.
  127859. * @returns the current input manager
  127860. */
  127861. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  127862. }
  127863. /**
  127864. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  127865. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127866. */
  127867. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  127868. /**
  127869. * Defines the camera the input is attached to.
  127870. */
  127871. camera: ArcRotateCamera;
  127872. /**
  127873. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  127874. */
  127875. alphaCorrection: number;
  127876. /**
  127877. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  127878. */
  127879. gammaCorrection: number;
  127880. private _alpha;
  127881. private _gamma;
  127882. private _dirty;
  127883. private _deviceOrientationHandler;
  127884. /**
  127885. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  127886. */
  127887. constructor();
  127888. /**
  127889. * Attach the input controls to a specific dom element to get the input from.
  127890. * @param element Defines the element the controls should be listened from
  127891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127892. */
  127893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127894. /** @hidden */
  127895. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  127896. /**
  127897. * Update the current camera state depending on the inputs that have been used this frame.
  127898. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127899. */
  127900. checkInputs(): void;
  127901. /**
  127902. * Detach the current controls from the specified dom element.
  127903. * @param element Defines the element to stop listening the inputs from
  127904. */
  127905. detachControl(element: Nullable<HTMLElement>): void;
  127906. /**
  127907. * Gets the class name of the current intput.
  127908. * @returns the class name
  127909. */
  127910. getClassName(): string;
  127911. /**
  127912. * Get the friendly name associated with the input class.
  127913. * @returns the input friendly name
  127914. */
  127915. getSimpleName(): string;
  127916. }
  127917. }
  127918. declare module BABYLON {
  127919. /**
  127920. * Listen to mouse events to control the camera.
  127921. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127922. */
  127923. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  127924. /**
  127925. * Defines the camera the input is attached to.
  127926. */
  127927. camera: FlyCamera;
  127928. /**
  127929. * Defines if touch is enabled. (Default is true.)
  127930. */
  127931. touchEnabled: boolean;
  127932. /**
  127933. * Defines the buttons associated with the input to handle camera rotation.
  127934. */
  127935. buttons: number[];
  127936. /**
  127937. * Assign buttons for Yaw control.
  127938. */
  127939. buttonsYaw: number[];
  127940. /**
  127941. * Assign buttons for Pitch control.
  127942. */
  127943. buttonsPitch: number[];
  127944. /**
  127945. * Assign buttons for Roll control.
  127946. */
  127947. buttonsRoll: number[];
  127948. /**
  127949. * Detect if any button is being pressed while mouse is moved.
  127950. * -1 = Mouse locked.
  127951. * 0 = Left button.
  127952. * 1 = Middle Button.
  127953. * 2 = Right Button.
  127954. */
  127955. activeButton: number;
  127956. /**
  127957. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  127958. * Higher values reduce its sensitivity.
  127959. */
  127960. angularSensibility: number;
  127961. private _observer;
  127962. private _rollObserver;
  127963. private previousPosition;
  127964. private noPreventDefault;
  127965. private element;
  127966. /**
  127967. * Listen to mouse events to control the camera.
  127968. * @param touchEnabled Define if touch is enabled. (Default is true.)
  127969. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127970. */
  127971. constructor(touchEnabled?: boolean);
  127972. /**
  127973. * Attach the mouse control to the HTML DOM element.
  127974. * @param element Defines the element that listens to the input events.
  127975. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  127976. */
  127977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127978. /**
  127979. * Detach the current controls from the specified dom element.
  127980. * @param element Defines the element to stop listening the inputs from
  127981. */
  127982. detachControl(element: Nullable<HTMLElement>): void;
  127983. /**
  127984. * Gets the class name of the current input.
  127985. * @returns the class name.
  127986. */
  127987. getClassName(): string;
  127988. /**
  127989. * Get the friendly name associated with the input class.
  127990. * @returns the input's friendly name.
  127991. */
  127992. getSimpleName(): string;
  127993. private _pointerInput;
  127994. private _onMouseMove;
  127995. /**
  127996. * Rotate camera by mouse offset.
  127997. */
  127998. private rotateCamera;
  127999. }
  128000. }
  128001. declare module BABYLON {
  128002. /**
  128003. * Default Inputs manager for the FlyCamera.
  128004. * It groups all the default supported inputs for ease of use.
  128005. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128006. */
  128007. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  128008. /**
  128009. * Instantiates a new FlyCameraInputsManager.
  128010. * @param camera Defines the camera the inputs belong to.
  128011. */
  128012. constructor(camera: FlyCamera);
  128013. /**
  128014. * Add keyboard input support to the input manager.
  128015. * @returns the new FlyCameraKeyboardMoveInput().
  128016. */
  128017. addKeyboard(): FlyCameraInputsManager;
  128018. /**
  128019. * Add mouse input support to the input manager.
  128020. * @param touchEnabled Enable touch screen support.
  128021. * @returns the new FlyCameraMouseInput().
  128022. */
  128023. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  128024. }
  128025. }
  128026. declare module BABYLON {
  128027. /**
  128028. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128029. * such as in a 3D Space Shooter or a Flight Simulator.
  128030. */
  128031. export class FlyCamera extends TargetCamera {
  128032. /**
  128033. * Define the collision ellipsoid of the camera.
  128034. * This is helpful for simulating a camera body, like a player's body.
  128035. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128036. */
  128037. ellipsoid: Vector3;
  128038. /**
  128039. * Define an offset for the position of the ellipsoid around the camera.
  128040. * This can be helpful if the camera is attached away from the player's body center,
  128041. * such as at its head.
  128042. */
  128043. ellipsoidOffset: Vector3;
  128044. /**
  128045. * Enable or disable collisions of the camera with the rest of the scene objects.
  128046. */
  128047. checkCollisions: boolean;
  128048. /**
  128049. * Enable or disable gravity on the camera.
  128050. */
  128051. applyGravity: boolean;
  128052. /**
  128053. * Define the current direction the camera is moving to.
  128054. */
  128055. cameraDirection: Vector3;
  128056. /**
  128057. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  128058. * This overrides and empties cameraRotation.
  128059. */
  128060. rotationQuaternion: Quaternion;
  128061. /**
  128062. * Track Roll to maintain the wanted Rolling when looking around.
  128063. */
  128064. _trackRoll: number;
  128065. /**
  128066. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  128067. */
  128068. rollCorrect: number;
  128069. /**
  128070. * Mimic a banked turn, Rolling the camera when Yawing.
  128071. * It's recommended to use rollCorrect = 10 for faster banking correction.
  128072. */
  128073. bankedTurn: boolean;
  128074. /**
  128075. * Limit in radians for how much Roll banking will add. (Default: 90°)
  128076. */
  128077. bankedTurnLimit: number;
  128078. /**
  128079. * Value of 0 disables the banked Roll.
  128080. * Value of 1 is equal to the Yaw angle in radians.
  128081. */
  128082. bankedTurnMultiplier: number;
  128083. /**
  128084. * The inputs manager loads all the input sources, such as keyboard and mouse.
  128085. */
  128086. inputs: FlyCameraInputsManager;
  128087. /**
  128088. * Gets the input sensibility for mouse input.
  128089. * Higher values reduce sensitivity.
  128090. */
  128091. get angularSensibility(): number;
  128092. /**
  128093. * Sets the input sensibility for a mouse input.
  128094. * Higher values reduce sensitivity.
  128095. */
  128096. set angularSensibility(value: number);
  128097. /**
  128098. * Get the keys for camera movement forward.
  128099. */
  128100. get keysForward(): number[];
  128101. /**
  128102. * Set the keys for camera movement forward.
  128103. */
  128104. set keysForward(value: number[]);
  128105. /**
  128106. * Get the keys for camera movement backward.
  128107. */
  128108. get keysBackward(): number[];
  128109. set keysBackward(value: number[]);
  128110. /**
  128111. * Get the keys for camera movement up.
  128112. */
  128113. get keysUp(): number[];
  128114. /**
  128115. * Set the keys for camera movement up.
  128116. */
  128117. set keysUp(value: number[]);
  128118. /**
  128119. * Get the keys for camera movement down.
  128120. */
  128121. get keysDown(): number[];
  128122. /**
  128123. * Set the keys for camera movement down.
  128124. */
  128125. set keysDown(value: number[]);
  128126. /**
  128127. * Get the keys for camera movement left.
  128128. */
  128129. get keysLeft(): number[];
  128130. /**
  128131. * Set the keys for camera movement left.
  128132. */
  128133. set keysLeft(value: number[]);
  128134. /**
  128135. * Set the keys for camera movement right.
  128136. */
  128137. get keysRight(): number[];
  128138. /**
  128139. * Set the keys for camera movement right.
  128140. */
  128141. set keysRight(value: number[]);
  128142. /**
  128143. * Event raised when the camera collides with a mesh in the scene.
  128144. */
  128145. onCollide: (collidedMesh: AbstractMesh) => void;
  128146. private _collider;
  128147. private _needMoveForGravity;
  128148. private _oldPosition;
  128149. private _diffPosition;
  128150. private _newPosition;
  128151. /** @hidden */
  128152. _localDirection: Vector3;
  128153. /** @hidden */
  128154. _transformedDirection: Vector3;
  128155. /**
  128156. * Instantiates a FlyCamera.
  128157. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128158. * such as in a 3D Space Shooter or a Flight Simulator.
  128159. * @param name Define the name of the camera in the scene.
  128160. * @param position Define the starting position of the camera in the scene.
  128161. * @param scene Define the scene the camera belongs to.
  128162. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  128163. */
  128164. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128165. /**
  128166. * Attach a control to the HTML DOM element.
  128167. * @param element Defines the element that listens to the input events.
  128168. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  128169. */
  128170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128171. /**
  128172. * Detach a control from the HTML DOM element.
  128173. * The camera will stop reacting to that input.
  128174. * @param element Defines the element that listens to the input events.
  128175. */
  128176. detachControl(element: HTMLElement): void;
  128177. private _collisionMask;
  128178. /**
  128179. * Get the mask that the camera ignores in collision events.
  128180. */
  128181. get collisionMask(): number;
  128182. /**
  128183. * Set the mask that the camera ignores in collision events.
  128184. */
  128185. set collisionMask(mask: number);
  128186. /** @hidden */
  128187. _collideWithWorld(displacement: Vector3): void;
  128188. /** @hidden */
  128189. private _onCollisionPositionChange;
  128190. /** @hidden */
  128191. _checkInputs(): void;
  128192. /** @hidden */
  128193. _decideIfNeedsToMove(): boolean;
  128194. /** @hidden */
  128195. _updatePosition(): void;
  128196. /**
  128197. * Restore the Roll to its target value at the rate specified.
  128198. * @param rate - Higher means slower restoring.
  128199. * @hidden
  128200. */
  128201. restoreRoll(rate: number): void;
  128202. /**
  128203. * Destroy the camera and release the current resources held by it.
  128204. */
  128205. dispose(): void;
  128206. /**
  128207. * Get the current object class name.
  128208. * @returns the class name.
  128209. */
  128210. getClassName(): string;
  128211. }
  128212. }
  128213. declare module BABYLON {
  128214. /**
  128215. * Listen to keyboard events to control the camera.
  128216. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128217. */
  128218. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  128219. /**
  128220. * Defines the camera the input is attached to.
  128221. */
  128222. camera: FlyCamera;
  128223. /**
  128224. * The list of keyboard keys used to control the forward move of the camera.
  128225. */
  128226. keysForward: number[];
  128227. /**
  128228. * The list of keyboard keys used to control the backward move of the camera.
  128229. */
  128230. keysBackward: number[];
  128231. /**
  128232. * The list of keyboard keys used to control the forward move of the camera.
  128233. */
  128234. keysUp: number[];
  128235. /**
  128236. * The list of keyboard keys used to control the backward move of the camera.
  128237. */
  128238. keysDown: number[];
  128239. /**
  128240. * The list of keyboard keys used to control the right strafe move of the camera.
  128241. */
  128242. keysRight: number[];
  128243. /**
  128244. * The list of keyboard keys used to control the left strafe move of the camera.
  128245. */
  128246. keysLeft: number[];
  128247. private _keys;
  128248. private _onCanvasBlurObserver;
  128249. private _onKeyboardObserver;
  128250. private _engine;
  128251. private _scene;
  128252. /**
  128253. * Attach the input controls to a specific dom element to get the input from.
  128254. * @param element Defines the element the controls should be listened from
  128255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128256. */
  128257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128258. /**
  128259. * Detach the current controls from the specified dom element.
  128260. * @param element Defines the element to stop listening the inputs from
  128261. */
  128262. detachControl(element: Nullable<HTMLElement>): void;
  128263. /**
  128264. * Gets the class name of the current intput.
  128265. * @returns the class name
  128266. */
  128267. getClassName(): string;
  128268. /** @hidden */
  128269. _onLostFocus(e: FocusEvent): void;
  128270. /**
  128271. * Get the friendly name associated with the input class.
  128272. * @returns the input friendly name
  128273. */
  128274. getSimpleName(): string;
  128275. /**
  128276. * Update the current camera state depending on the inputs that have been used this frame.
  128277. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128278. */
  128279. checkInputs(): void;
  128280. }
  128281. }
  128282. declare module BABYLON {
  128283. /**
  128284. * Manage the mouse wheel inputs to control a follow camera.
  128285. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128286. */
  128287. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  128288. /**
  128289. * Defines the camera the input is attached to.
  128290. */
  128291. camera: FollowCamera;
  128292. /**
  128293. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  128294. */
  128295. axisControlRadius: boolean;
  128296. /**
  128297. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  128298. */
  128299. axisControlHeight: boolean;
  128300. /**
  128301. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  128302. */
  128303. axisControlRotation: boolean;
  128304. /**
  128305. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  128306. * relation to mouseWheel events.
  128307. */
  128308. wheelPrecision: number;
  128309. /**
  128310. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128311. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128312. */
  128313. wheelDeltaPercentage: number;
  128314. private _wheel;
  128315. private _observer;
  128316. /**
  128317. * Attach the input controls to a specific dom element to get the input from.
  128318. * @param element Defines the element the controls should be listened from
  128319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128320. */
  128321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128322. /**
  128323. * Detach the current controls from the specified dom element.
  128324. * @param element Defines the element to stop listening the inputs from
  128325. */
  128326. detachControl(element: Nullable<HTMLElement>): void;
  128327. /**
  128328. * Gets the class name of the current intput.
  128329. * @returns the class name
  128330. */
  128331. getClassName(): string;
  128332. /**
  128333. * Get the friendly name associated with the input class.
  128334. * @returns the input friendly name
  128335. */
  128336. getSimpleName(): string;
  128337. }
  128338. }
  128339. declare module BABYLON {
  128340. /**
  128341. * Manage the pointers inputs to control an follow camera.
  128342. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128343. */
  128344. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  128345. /**
  128346. * Defines the camera the input is attached to.
  128347. */
  128348. camera: FollowCamera;
  128349. /**
  128350. * Gets the class name of the current input.
  128351. * @returns the class name
  128352. */
  128353. getClassName(): string;
  128354. /**
  128355. * Defines the pointer angular sensibility along the X axis or how fast is
  128356. * the camera rotating.
  128357. * A negative number will reverse the axis direction.
  128358. */
  128359. angularSensibilityX: number;
  128360. /**
  128361. * Defines the pointer angular sensibility along the Y axis or how fast is
  128362. * the camera rotating.
  128363. * A negative number will reverse the axis direction.
  128364. */
  128365. angularSensibilityY: number;
  128366. /**
  128367. * Defines the pointer pinch precision or how fast is the camera zooming.
  128368. * A negative number will reverse the axis direction.
  128369. */
  128370. pinchPrecision: number;
  128371. /**
  128372. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  128373. * from 0.
  128374. * It defines the percentage of current camera.radius to use as delta when
  128375. * pinch zoom is used.
  128376. */
  128377. pinchDeltaPercentage: number;
  128378. /**
  128379. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  128380. */
  128381. axisXControlRadius: boolean;
  128382. /**
  128383. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  128384. */
  128385. axisXControlHeight: boolean;
  128386. /**
  128387. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  128388. */
  128389. axisXControlRotation: boolean;
  128390. /**
  128391. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  128392. */
  128393. axisYControlRadius: boolean;
  128394. /**
  128395. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  128396. */
  128397. axisYControlHeight: boolean;
  128398. /**
  128399. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  128400. */
  128401. axisYControlRotation: boolean;
  128402. /**
  128403. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  128404. */
  128405. axisPinchControlRadius: boolean;
  128406. /**
  128407. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  128408. */
  128409. axisPinchControlHeight: boolean;
  128410. /**
  128411. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  128412. */
  128413. axisPinchControlRotation: boolean;
  128414. /**
  128415. * Log error messages if basic misconfiguration has occurred.
  128416. */
  128417. warningEnable: boolean;
  128418. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  128419. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  128420. private _warningCounter;
  128421. private _warning;
  128422. }
  128423. }
  128424. declare module BABYLON {
  128425. /**
  128426. * Default Inputs manager for the FollowCamera.
  128427. * It groups all the default supported inputs for ease of use.
  128428. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128429. */
  128430. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  128431. /**
  128432. * Instantiates a new FollowCameraInputsManager.
  128433. * @param camera Defines the camera the inputs belong to
  128434. */
  128435. constructor(camera: FollowCamera);
  128436. /**
  128437. * Add keyboard input support to the input manager.
  128438. * @returns the current input manager
  128439. */
  128440. addKeyboard(): FollowCameraInputsManager;
  128441. /**
  128442. * Add mouse wheel input support to the input manager.
  128443. * @returns the current input manager
  128444. */
  128445. addMouseWheel(): FollowCameraInputsManager;
  128446. /**
  128447. * Add pointers input support to the input manager.
  128448. * @returns the current input manager
  128449. */
  128450. addPointers(): FollowCameraInputsManager;
  128451. /**
  128452. * Add orientation input support to the input manager.
  128453. * @returns the current input manager
  128454. */
  128455. addVRDeviceOrientation(): FollowCameraInputsManager;
  128456. }
  128457. }
  128458. declare module BABYLON {
  128459. /**
  128460. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  128461. * an arc rotate version arcFollowCamera are available.
  128462. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128463. */
  128464. export class FollowCamera extends TargetCamera {
  128465. /**
  128466. * Distance the follow camera should follow an object at
  128467. */
  128468. radius: number;
  128469. /**
  128470. * Minimum allowed distance of the camera to the axis of rotation
  128471. * (The camera can not get closer).
  128472. * This can help limiting how the Camera is able to move in the scene.
  128473. */
  128474. lowerRadiusLimit: Nullable<number>;
  128475. /**
  128476. * Maximum allowed distance of the camera to the axis of rotation
  128477. * (The camera can not get further).
  128478. * This can help limiting how the Camera is able to move in the scene.
  128479. */
  128480. upperRadiusLimit: Nullable<number>;
  128481. /**
  128482. * Define a rotation offset between the camera and the object it follows
  128483. */
  128484. rotationOffset: number;
  128485. /**
  128486. * Minimum allowed angle to camera position relative to target object.
  128487. * This can help limiting how the Camera is able to move in the scene.
  128488. */
  128489. lowerRotationOffsetLimit: Nullable<number>;
  128490. /**
  128491. * Maximum allowed angle to camera position relative to target object.
  128492. * This can help limiting how the Camera is able to move in the scene.
  128493. */
  128494. upperRotationOffsetLimit: Nullable<number>;
  128495. /**
  128496. * Define a height offset between the camera and the object it follows.
  128497. * It can help following an object from the top (like a car chaing a plane)
  128498. */
  128499. heightOffset: number;
  128500. /**
  128501. * Minimum allowed height of camera position relative to target object.
  128502. * This can help limiting how the Camera is able to move in the scene.
  128503. */
  128504. lowerHeightOffsetLimit: Nullable<number>;
  128505. /**
  128506. * Maximum allowed height of camera position relative to target object.
  128507. * This can help limiting how the Camera is able to move in the scene.
  128508. */
  128509. upperHeightOffsetLimit: Nullable<number>;
  128510. /**
  128511. * Define how fast the camera can accelerate to follow it s target.
  128512. */
  128513. cameraAcceleration: number;
  128514. /**
  128515. * Define the speed limit of the camera following an object.
  128516. */
  128517. maxCameraSpeed: number;
  128518. /**
  128519. * Define the target of the camera.
  128520. */
  128521. lockedTarget: Nullable<AbstractMesh>;
  128522. /**
  128523. * Defines the input associated with the camera.
  128524. */
  128525. inputs: FollowCameraInputsManager;
  128526. /**
  128527. * Instantiates the follow camera.
  128528. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128529. * @param name Define the name of the camera in the scene
  128530. * @param position Define the position of the camera
  128531. * @param scene Define the scene the camera belong to
  128532. * @param lockedTarget Define the target of the camera
  128533. */
  128534. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  128535. private _follow;
  128536. /**
  128537. * Attached controls to the current camera.
  128538. * @param element Defines the element the controls should be listened from
  128539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128540. */
  128541. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128542. /**
  128543. * Detach the current controls from the camera.
  128544. * The camera will stop reacting to inputs.
  128545. * @param element Defines the element to stop listening the inputs from
  128546. */
  128547. detachControl(element: HTMLElement): void;
  128548. /** @hidden */
  128549. _checkInputs(): void;
  128550. private _checkLimits;
  128551. /**
  128552. * Gets the camera class name.
  128553. * @returns the class name
  128554. */
  128555. getClassName(): string;
  128556. }
  128557. /**
  128558. * Arc Rotate version of the follow camera.
  128559. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  128560. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128561. */
  128562. export class ArcFollowCamera extends TargetCamera {
  128563. /** The longitudinal angle of the camera */
  128564. alpha: number;
  128565. /** The latitudinal angle of the camera */
  128566. beta: number;
  128567. /** The radius of the camera from its target */
  128568. radius: number;
  128569. private _cartesianCoordinates;
  128570. /** Define the camera target (the mesh it should follow) */
  128571. private _meshTarget;
  128572. /**
  128573. * Instantiates a new ArcFollowCamera
  128574. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128575. * @param name Define the name of the camera
  128576. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  128577. * @param beta Define the rotation angle of the camera around the elevation axis
  128578. * @param radius Define the radius of the camera from its target point
  128579. * @param target Define the target of the camera
  128580. * @param scene Define the scene the camera belongs to
  128581. */
  128582. constructor(name: string,
  128583. /** The longitudinal angle of the camera */
  128584. alpha: number,
  128585. /** The latitudinal angle of the camera */
  128586. beta: number,
  128587. /** The radius of the camera from its target */
  128588. radius: number,
  128589. /** Define the camera target (the mesh it should follow) */
  128590. target: Nullable<AbstractMesh>, scene: Scene);
  128591. private _follow;
  128592. /** @hidden */
  128593. _checkInputs(): void;
  128594. /**
  128595. * Returns the class name of the object.
  128596. * It is mostly used internally for serialization purposes.
  128597. */
  128598. getClassName(): string;
  128599. }
  128600. }
  128601. declare module BABYLON {
  128602. /**
  128603. * Manage the keyboard inputs to control the movement of a follow camera.
  128604. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128605. */
  128606. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  128607. /**
  128608. * Defines the camera the input is attached to.
  128609. */
  128610. camera: FollowCamera;
  128611. /**
  128612. * Defines the list of key codes associated with the up action (increase heightOffset)
  128613. */
  128614. keysHeightOffsetIncr: number[];
  128615. /**
  128616. * Defines the list of key codes associated with the down action (decrease heightOffset)
  128617. */
  128618. keysHeightOffsetDecr: number[];
  128619. /**
  128620. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  128621. */
  128622. keysHeightOffsetModifierAlt: boolean;
  128623. /**
  128624. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  128625. */
  128626. keysHeightOffsetModifierCtrl: boolean;
  128627. /**
  128628. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  128629. */
  128630. keysHeightOffsetModifierShift: boolean;
  128631. /**
  128632. * Defines the list of key codes associated with the left action (increase rotationOffset)
  128633. */
  128634. keysRotationOffsetIncr: number[];
  128635. /**
  128636. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  128637. */
  128638. keysRotationOffsetDecr: number[];
  128639. /**
  128640. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  128641. */
  128642. keysRotationOffsetModifierAlt: boolean;
  128643. /**
  128644. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  128645. */
  128646. keysRotationOffsetModifierCtrl: boolean;
  128647. /**
  128648. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  128649. */
  128650. keysRotationOffsetModifierShift: boolean;
  128651. /**
  128652. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  128653. */
  128654. keysRadiusIncr: number[];
  128655. /**
  128656. * Defines the list of key codes associated with the zoom-out action (increase radius)
  128657. */
  128658. keysRadiusDecr: number[];
  128659. /**
  128660. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  128661. */
  128662. keysRadiusModifierAlt: boolean;
  128663. /**
  128664. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  128665. */
  128666. keysRadiusModifierCtrl: boolean;
  128667. /**
  128668. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  128669. */
  128670. keysRadiusModifierShift: boolean;
  128671. /**
  128672. * Defines the rate of change of heightOffset.
  128673. */
  128674. heightSensibility: number;
  128675. /**
  128676. * Defines the rate of change of rotationOffset.
  128677. */
  128678. rotationSensibility: number;
  128679. /**
  128680. * Defines the rate of change of radius.
  128681. */
  128682. radiusSensibility: number;
  128683. private _keys;
  128684. private _ctrlPressed;
  128685. private _altPressed;
  128686. private _shiftPressed;
  128687. private _onCanvasBlurObserver;
  128688. private _onKeyboardObserver;
  128689. private _engine;
  128690. private _scene;
  128691. /**
  128692. * Attach the input controls to a specific dom element to get the input from.
  128693. * @param element Defines the element the controls should be listened from
  128694. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128695. */
  128696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128697. /**
  128698. * Detach the current controls from the specified dom element.
  128699. * @param element Defines the element to stop listening the inputs from
  128700. */
  128701. detachControl(element: Nullable<HTMLElement>): void;
  128702. /**
  128703. * Update the current camera state depending on the inputs that have been used this frame.
  128704. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128705. */
  128706. checkInputs(): void;
  128707. /**
  128708. * Gets the class name of the current input.
  128709. * @returns the class name
  128710. */
  128711. getClassName(): string;
  128712. /**
  128713. * Get the friendly name associated with the input class.
  128714. * @returns the input friendly name
  128715. */
  128716. getSimpleName(): string;
  128717. /**
  128718. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128719. * allow modification of the heightOffset value.
  128720. */
  128721. private _modifierHeightOffset;
  128722. /**
  128723. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128724. * allow modification of the rotationOffset value.
  128725. */
  128726. private _modifierRotationOffset;
  128727. /**
  128728. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128729. * allow modification of the radius value.
  128730. */
  128731. private _modifierRadius;
  128732. }
  128733. }
  128734. declare module BABYLON {
  128735. interface FreeCameraInputsManager {
  128736. /**
  128737. * @hidden
  128738. */
  128739. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  128740. /**
  128741. * Add orientation input support to the input manager.
  128742. * @returns the current input manager
  128743. */
  128744. addDeviceOrientation(): FreeCameraInputsManager;
  128745. }
  128746. /**
  128747. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  128748. * Screen rotation is taken into account.
  128749. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128750. */
  128751. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  128752. private _camera;
  128753. private _screenOrientationAngle;
  128754. private _constantTranform;
  128755. private _screenQuaternion;
  128756. private _alpha;
  128757. private _beta;
  128758. private _gamma;
  128759. /**
  128760. * Can be used to detect if a device orientation sensor is available on a device
  128761. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  128762. * @returns a promise that will resolve on orientation change
  128763. */
  128764. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  128765. /**
  128766. * @hidden
  128767. */
  128768. _onDeviceOrientationChangedObservable: Observable<void>;
  128769. /**
  128770. * Instantiates a new input
  128771. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128772. */
  128773. constructor();
  128774. /**
  128775. * Define the camera controlled by the input.
  128776. */
  128777. get camera(): FreeCamera;
  128778. set camera(camera: FreeCamera);
  128779. /**
  128780. * Attach the input controls to a specific dom element to get the input from.
  128781. * @param element Defines the element the controls should be listened from
  128782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128783. */
  128784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128785. private _orientationChanged;
  128786. private _deviceOrientation;
  128787. /**
  128788. * Detach the current controls from the specified dom element.
  128789. * @param element Defines the element to stop listening the inputs from
  128790. */
  128791. detachControl(element: Nullable<HTMLElement>): void;
  128792. /**
  128793. * Update the current camera state depending on the inputs that have been used this frame.
  128794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128795. */
  128796. checkInputs(): void;
  128797. /**
  128798. * Gets the class name of the current intput.
  128799. * @returns the class name
  128800. */
  128801. getClassName(): string;
  128802. /**
  128803. * Get the friendly name associated with the input class.
  128804. * @returns the input friendly name
  128805. */
  128806. getSimpleName(): string;
  128807. }
  128808. }
  128809. declare module BABYLON {
  128810. /**
  128811. * Manage the gamepad inputs to control a free camera.
  128812. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128813. */
  128814. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  128815. /**
  128816. * Define the camera the input is attached to.
  128817. */
  128818. camera: FreeCamera;
  128819. /**
  128820. * Define the Gamepad controlling the input
  128821. */
  128822. gamepad: Nullable<Gamepad>;
  128823. /**
  128824. * Defines the gamepad rotation sensiblity.
  128825. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128826. */
  128827. gamepadAngularSensibility: number;
  128828. /**
  128829. * Defines the gamepad move sensiblity.
  128830. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128831. */
  128832. gamepadMoveSensibility: number;
  128833. private _yAxisScale;
  128834. /**
  128835. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128836. */
  128837. get invertYAxis(): boolean;
  128838. set invertYAxis(value: boolean);
  128839. private _onGamepadConnectedObserver;
  128840. private _onGamepadDisconnectedObserver;
  128841. private _cameraTransform;
  128842. private _deltaTransform;
  128843. private _vector3;
  128844. private _vector2;
  128845. /**
  128846. * Attach the input controls to a specific dom element to get the input from.
  128847. * @param element Defines the element the controls should be listened from
  128848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128849. */
  128850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128851. /**
  128852. * Detach the current controls from the specified dom element.
  128853. * @param element Defines the element to stop listening the inputs from
  128854. */
  128855. detachControl(element: Nullable<HTMLElement>): void;
  128856. /**
  128857. * Update the current camera state depending on the inputs that have been used this frame.
  128858. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128859. */
  128860. checkInputs(): void;
  128861. /**
  128862. * Gets the class name of the current intput.
  128863. * @returns the class name
  128864. */
  128865. getClassName(): string;
  128866. /**
  128867. * Get the friendly name associated with the input class.
  128868. * @returns the input friendly name
  128869. */
  128870. getSimpleName(): string;
  128871. }
  128872. }
  128873. declare module BABYLON {
  128874. /**
  128875. * Defines the potential axis of a Joystick
  128876. */
  128877. export enum JoystickAxis {
  128878. /** X axis */
  128879. X = 0,
  128880. /** Y axis */
  128881. Y = 1,
  128882. /** Z axis */
  128883. Z = 2
  128884. }
  128885. /**
  128886. * Represents the different customization options available
  128887. * for VirtualJoystick
  128888. */
  128889. interface VirtualJoystickCustomizations {
  128890. /**
  128891. * Size of the joystick's puck
  128892. */
  128893. puckSize: number;
  128894. /**
  128895. * Size of the joystick's container
  128896. */
  128897. containerSize: number;
  128898. /**
  128899. * Color of the joystick && puck
  128900. */
  128901. color: string;
  128902. /**
  128903. * Image URL for the joystick's puck
  128904. */
  128905. puckImage?: string;
  128906. /**
  128907. * Image URL for the joystick's container
  128908. */
  128909. containerImage?: string;
  128910. /**
  128911. * Defines the unmoving position of the joystick container
  128912. */
  128913. position?: {
  128914. x: number;
  128915. y: number;
  128916. };
  128917. /**
  128918. * Defines whether or not the joystick container is always visible
  128919. */
  128920. alwaysVisible: boolean;
  128921. /**
  128922. * Defines whether or not to limit the movement of the puck to the joystick's container
  128923. */
  128924. limitToContainer: boolean;
  128925. }
  128926. /**
  128927. * Class used to define virtual joystick (used in touch mode)
  128928. */
  128929. export class VirtualJoystick {
  128930. /**
  128931. * Gets or sets a boolean indicating that left and right values must be inverted
  128932. */
  128933. reverseLeftRight: boolean;
  128934. /**
  128935. * Gets or sets a boolean indicating that up and down values must be inverted
  128936. */
  128937. reverseUpDown: boolean;
  128938. /**
  128939. * Gets the offset value for the position (ie. the change of the position value)
  128940. */
  128941. deltaPosition: Vector3;
  128942. /**
  128943. * Gets a boolean indicating if the virtual joystick was pressed
  128944. */
  128945. pressed: boolean;
  128946. /**
  128947. * Canvas the virtual joystick will render onto, default z-index of this is 5
  128948. */
  128949. static Canvas: Nullable<HTMLCanvasElement>;
  128950. /**
  128951. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  128952. */
  128953. limitToContainer: boolean;
  128954. private static _globalJoystickIndex;
  128955. private static _alwaysVisibleSticks;
  128956. private static vjCanvasContext;
  128957. private static vjCanvasWidth;
  128958. private static vjCanvasHeight;
  128959. private static halfWidth;
  128960. private static _GetDefaultOptions;
  128961. private _action;
  128962. private _axisTargetedByLeftAndRight;
  128963. private _axisTargetedByUpAndDown;
  128964. private _joystickSensibility;
  128965. private _inversedSensibility;
  128966. private _joystickPointerID;
  128967. private _joystickColor;
  128968. private _joystickPointerPos;
  128969. private _joystickPreviousPointerPos;
  128970. private _joystickPointerStartPos;
  128971. private _deltaJoystickVector;
  128972. private _leftJoystick;
  128973. private _touches;
  128974. private _joystickPosition;
  128975. private _alwaysVisible;
  128976. private _puckImage;
  128977. private _containerImage;
  128978. private _joystickPuckSize;
  128979. private _joystickContainerSize;
  128980. private _clearPuckSize;
  128981. private _clearContainerSize;
  128982. private _clearPuckSizeOffset;
  128983. private _clearContainerSizeOffset;
  128984. private _onPointerDownHandlerRef;
  128985. private _onPointerMoveHandlerRef;
  128986. private _onPointerUpHandlerRef;
  128987. private _onResize;
  128988. /**
  128989. * Creates a new virtual joystick
  128990. * @param leftJoystick defines that the joystick is for left hand (false by default)
  128991. * @param customizations Defines the options we want to customize the VirtualJoystick
  128992. */
  128993. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  128994. /**
  128995. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  128996. * @param newJoystickSensibility defines the new sensibility
  128997. */
  128998. setJoystickSensibility(newJoystickSensibility: number): void;
  128999. private _onPointerDown;
  129000. private _onPointerMove;
  129001. private _onPointerUp;
  129002. /**
  129003. * Change the color of the virtual joystick
  129004. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  129005. */
  129006. setJoystickColor(newColor: string): void;
  129007. /**
  129008. * Size of the joystick's container
  129009. */
  129010. set containerSize(newSize: number);
  129011. get containerSize(): number;
  129012. /**
  129013. * Size of the joystick's puck
  129014. */
  129015. set puckSize(newSize: number);
  129016. get puckSize(): number;
  129017. /**
  129018. * Clears the set position of the joystick
  129019. */
  129020. clearPosition(): void;
  129021. /**
  129022. * Defines whether or not the joystick container is always visible
  129023. */
  129024. set alwaysVisible(value: boolean);
  129025. get alwaysVisible(): boolean;
  129026. /**
  129027. * Sets the constant position of the Joystick container
  129028. * @param x X axis coordinate
  129029. * @param y Y axis coordinate
  129030. */
  129031. setPosition(x: number, y: number): void;
  129032. /**
  129033. * Defines a callback to call when the joystick is touched
  129034. * @param action defines the callback
  129035. */
  129036. setActionOnTouch(action: () => any): void;
  129037. /**
  129038. * Defines which axis you'd like to control for left & right
  129039. * @param axis defines the axis to use
  129040. */
  129041. setAxisForLeftRight(axis: JoystickAxis): void;
  129042. /**
  129043. * Defines which axis you'd like to control for up & down
  129044. * @param axis defines the axis to use
  129045. */
  129046. setAxisForUpDown(axis: JoystickAxis): void;
  129047. /**
  129048. * Clears the canvas from the previous puck / container draw
  129049. */
  129050. private _clearPreviousDraw;
  129051. /**
  129052. * Loads `urlPath` to be used for the container's image
  129053. * @param urlPath defines the urlPath of an image to use
  129054. */
  129055. setContainerImage(urlPath: string): void;
  129056. /**
  129057. * Loads `urlPath` to be used for the puck's image
  129058. * @param urlPath defines the urlPath of an image to use
  129059. */
  129060. setPuckImage(urlPath: string): void;
  129061. /**
  129062. * Draws the Virtual Joystick's container
  129063. */
  129064. private _drawContainer;
  129065. /**
  129066. * Draws the Virtual Joystick's puck
  129067. */
  129068. private _drawPuck;
  129069. private _drawVirtualJoystick;
  129070. /**
  129071. * Release internal HTML canvas
  129072. */
  129073. releaseCanvas(): void;
  129074. }
  129075. }
  129076. declare module BABYLON {
  129077. interface FreeCameraInputsManager {
  129078. /**
  129079. * Add virtual joystick input support to the input manager.
  129080. * @returns the current input manager
  129081. */
  129082. addVirtualJoystick(): FreeCameraInputsManager;
  129083. }
  129084. /**
  129085. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  129086. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129087. */
  129088. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  129089. /**
  129090. * Defines the camera the input is attached to.
  129091. */
  129092. camera: FreeCamera;
  129093. private _leftjoystick;
  129094. private _rightjoystick;
  129095. /**
  129096. * Gets the left stick of the virtual joystick.
  129097. * @returns The virtual Joystick
  129098. */
  129099. getLeftJoystick(): VirtualJoystick;
  129100. /**
  129101. * Gets the right stick of the virtual joystick.
  129102. * @returns The virtual Joystick
  129103. */
  129104. getRightJoystick(): VirtualJoystick;
  129105. /**
  129106. * Update the current camera state depending on the inputs that have been used this frame.
  129107. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129108. */
  129109. checkInputs(): void;
  129110. /**
  129111. * Attach the input controls to a specific dom element to get the input from.
  129112. * @param element Defines the element the controls should be listened from
  129113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129114. */
  129115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  129116. /**
  129117. * Detach the current controls from the specified dom element.
  129118. * @param element Defines the element to stop listening the inputs from
  129119. */
  129120. detachControl(element: Nullable<HTMLElement>): void;
  129121. /**
  129122. * Gets the class name of the current intput.
  129123. * @returns the class name
  129124. */
  129125. getClassName(): string;
  129126. /**
  129127. * Get the friendly name associated with the input class.
  129128. * @returns the input friendly name
  129129. */
  129130. getSimpleName(): string;
  129131. }
  129132. }
  129133. declare module BABYLON {
  129134. /**
  129135. * This represents a FPS type of camera controlled by touch.
  129136. * This is like a universal camera minus the Gamepad controls.
  129137. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129138. */
  129139. export class TouchCamera extends FreeCamera {
  129140. /**
  129141. * Defines the touch sensibility for rotation.
  129142. * The higher the faster.
  129143. */
  129144. get touchAngularSensibility(): number;
  129145. set touchAngularSensibility(value: number);
  129146. /**
  129147. * Defines the touch sensibility for move.
  129148. * The higher the faster.
  129149. */
  129150. get touchMoveSensibility(): number;
  129151. set touchMoveSensibility(value: number);
  129152. /**
  129153. * Instantiates a new touch camera.
  129154. * This represents a FPS type of camera controlled by touch.
  129155. * This is like a universal camera minus the Gamepad controls.
  129156. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129157. * @param name Define the name of the camera in the scene
  129158. * @param position Define the start position of the camera in the scene
  129159. * @param scene Define the scene the camera belongs to
  129160. */
  129161. constructor(name: string, position: Vector3, scene: Scene);
  129162. /**
  129163. * Gets the current object class name.
  129164. * @return the class name
  129165. */
  129166. getClassName(): string;
  129167. /** @hidden */
  129168. _setupInputs(): void;
  129169. }
  129170. }
  129171. declare module BABYLON {
  129172. /**
  129173. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  129174. * being tilted forward or back and left or right.
  129175. */
  129176. export class DeviceOrientationCamera extends FreeCamera {
  129177. private _initialQuaternion;
  129178. private _quaternionCache;
  129179. private _tmpDragQuaternion;
  129180. private _disablePointerInputWhenUsingDeviceOrientation;
  129181. /**
  129182. * Creates a new device orientation camera
  129183. * @param name The name of the camera
  129184. * @param position The start position camera
  129185. * @param scene The scene the camera belongs to
  129186. */
  129187. constructor(name: string, position: Vector3, scene: Scene);
  129188. /**
  129189. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  129190. */
  129191. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  129192. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  129193. private _dragFactor;
  129194. /**
  129195. * Enabled turning on the y axis when the orientation sensor is active
  129196. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  129197. */
  129198. enableHorizontalDragging(dragFactor?: number): void;
  129199. /**
  129200. * Gets the current instance class name ("DeviceOrientationCamera").
  129201. * This helps avoiding instanceof at run time.
  129202. * @returns the class name
  129203. */
  129204. getClassName(): string;
  129205. /**
  129206. * @hidden
  129207. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  129208. */
  129209. _checkInputs(): void;
  129210. /**
  129211. * Reset the camera to its default orientation on the specified axis only.
  129212. * @param axis The axis to reset
  129213. */
  129214. resetToCurrentRotation(axis?: Axis): void;
  129215. }
  129216. }
  129217. declare module BABYLON {
  129218. /**
  129219. * Defines supported buttons for XBox360 compatible gamepads
  129220. */
  129221. export enum Xbox360Button {
  129222. /** A */
  129223. A = 0,
  129224. /** B */
  129225. B = 1,
  129226. /** X */
  129227. X = 2,
  129228. /** Y */
  129229. Y = 3,
  129230. /** Left button */
  129231. LB = 4,
  129232. /** Right button */
  129233. RB = 5,
  129234. /** Back */
  129235. Back = 8,
  129236. /** Start */
  129237. Start = 9,
  129238. /** Left stick */
  129239. LeftStick = 10,
  129240. /** Right stick */
  129241. RightStick = 11
  129242. }
  129243. /** Defines values for XBox360 DPad */
  129244. export enum Xbox360Dpad {
  129245. /** Up */
  129246. Up = 12,
  129247. /** Down */
  129248. Down = 13,
  129249. /** Left */
  129250. Left = 14,
  129251. /** Right */
  129252. Right = 15
  129253. }
  129254. /**
  129255. * Defines a XBox360 gamepad
  129256. */
  129257. export class Xbox360Pad extends Gamepad {
  129258. private _leftTrigger;
  129259. private _rightTrigger;
  129260. private _onlefttriggerchanged;
  129261. private _onrighttriggerchanged;
  129262. private _onbuttondown;
  129263. private _onbuttonup;
  129264. private _ondpaddown;
  129265. private _ondpadup;
  129266. /** Observable raised when a button is pressed */
  129267. onButtonDownObservable: Observable<Xbox360Button>;
  129268. /** Observable raised when a button is released */
  129269. onButtonUpObservable: Observable<Xbox360Button>;
  129270. /** Observable raised when a pad is pressed */
  129271. onPadDownObservable: Observable<Xbox360Dpad>;
  129272. /** Observable raised when a pad is released */
  129273. onPadUpObservable: Observable<Xbox360Dpad>;
  129274. private _buttonA;
  129275. private _buttonB;
  129276. private _buttonX;
  129277. private _buttonY;
  129278. private _buttonBack;
  129279. private _buttonStart;
  129280. private _buttonLB;
  129281. private _buttonRB;
  129282. private _buttonLeftStick;
  129283. private _buttonRightStick;
  129284. private _dPadUp;
  129285. private _dPadDown;
  129286. private _dPadLeft;
  129287. private _dPadRight;
  129288. private _isXboxOnePad;
  129289. /**
  129290. * Creates a new XBox360 gamepad object
  129291. * @param id defines the id of this gamepad
  129292. * @param index defines its index
  129293. * @param gamepad defines the internal HTML gamepad object
  129294. * @param xboxOne defines if it is a XBox One gamepad
  129295. */
  129296. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  129297. /**
  129298. * Defines the callback to call when left trigger is pressed
  129299. * @param callback defines the callback to use
  129300. */
  129301. onlefttriggerchanged(callback: (value: number) => void): void;
  129302. /**
  129303. * Defines the callback to call when right trigger is pressed
  129304. * @param callback defines the callback to use
  129305. */
  129306. onrighttriggerchanged(callback: (value: number) => void): void;
  129307. /**
  129308. * Gets the left trigger value
  129309. */
  129310. get leftTrigger(): number;
  129311. /**
  129312. * Sets the left trigger value
  129313. */
  129314. set leftTrigger(newValue: number);
  129315. /**
  129316. * Gets the right trigger value
  129317. */
  129318. get rightTrigger(): number;
  129319. /**
  129320. * Sets the right trigger value
  129321. */
  129322. set rightTrigger(newValue: number);
  129323. /**
  129324. * Defines the callback to call when a button is pressed
  129325. * @param callback defines the callback to use
  129326. */
  129327. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  129328. /**
  129329. * Defines the callback to call when a button is released
  129330. * @param callback defines the callback to use
  129331. */
  129332. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  129333. /**
  129334. * Defines the callback to call when a pad is pressed
  129335. * @param callback defines the callback to use
  129336. */
  129337. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  129338. /**
  129339. * Defines the callback to call when a pad is released
  129340. * @param callback defines the callback to use
  129341. */
  129342. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  129343. private _setButtonValue;
  129344. private _setDPadValue;
  129345. /**
  129346. * Gets the value of the `A` button
  129347. */
  129348. get buttonA(): number;
  129349. /**
  129350. * Sets the value of the `A` button
  129351. */
  129352. set buttonA(value: number);
  129353. /**
  129354. * Gets the value of the `B` button
  129355. */
  129356. get buttonB(): number;
  129357. /**
  129358. * Sets the value of the `B` button
  129359. */
  129360. set buttonB(value: number);
  129361. /**
  129362. * Gets the value of the `X` button
  129363. */
  129364. get buttonX(): number;
  129365. /**
  129366. * Sets the value of the `X` button
  129367. */
  129368. set buttonX(value: number);
  129369. /**
  129370. * Gets the value of the `Y` button
  129371. */
  129372. get buttonY(): number;
  129373. /**
  129374. * Sets the value of the `Y` button
  129375. */
  129376. set buttonY(value: number);
  129377. /**
  129378. * Gets the value of the `Start` button
  129379. */
  129380. get buttonStart(): number;
  129381. /**
  129382. * Sets the value of the `Start` button
  129383. */
  129384. set buttonStart(value: number);
  129385. /**
  129386. * Gets the value of the `Back` button
  129387. */
  129388. get buttonBack(): number;
  129389. /**
  129390. * Sets the value of the `Back` button
  129391. */
  129392. set buttonBack(value: number);
  129393. /**
  129394. * Gets the value of the `Left` button
  129395. */
  129396. get buttonLB(): number;
  129397. /**
  129398. * Sets the value of the `Left` button
  129399. */
  129400. set buttonLB(value: number);
  129401. /**
  129402. * Gets the value of the `Right` button
  129403. */
  129404. get buttonRB(): number;
  129405. /**
  129406. * Sets the value of the `Right` button
  129407. */
  129408. set buttonRB(value: number);
  129409. /**
  129410. * Gets the value of the Left joystick
  129411. */
  129412. get buttonLeftStick(): number;
  129413. /**
  129414. * Sets the value of the Left joystick
  129415. */
  129416. set buttonLeftStick(value: number);
  129417. /**
  129418. * Gets the value of the Right joystick
  129419. */
  129420. get buttonRightStick(): number;
  129421. /**
  129422. * Sets the value of the Right joystick
  129423. */
  129424. set buttonRightStick(value: number);
  129425. /**
  129426. * Gets the value of D-pad up
  129427. */
  129428. get dPadUp(): number;
  129429. /**
  129430. * Sets the value of D-pad up
  129431. */
  129432. set dPadUp(value: number);
  129433. /**
  129434. * Gets the value of D-pad down
  129435. */
  129436. get dPadDown(): number;
  129437. /**
  129438. * Sets the value of D-pad down
  129439. */
  129440. set dPadDown(value: number);
  129441. /**
  129442. * Gets the value of D-pad left
  129443. */
  129444. get dPadLeft(): number;
  129445. /**
  129446. * Sets the value of D-pad left
  129447. */
  129448. set dPadLeft(value: number);
  129449. /**
  129450. * Gets the value of D-pad right
  129451. */
  129452. get dPadRight(): number;
  129453. /**
  129454. * Sets the value of D-pad right
  129455. */
  129456. set dPadRight(value: number);
  129457. /**
  129458. * Force the gamepad to synchronize with device values
  129459. */
  129460. update(): void;
  129461. /**
  129462. * Disposes the gamepad
  129463. */
  129464. dispose(): void;
  129465. }
  129466. }
  129467. declare module BABYLON {
  129468. /**
  129469. * Defines supported buttons for DualShock compatible gamepads
  129470. */
  129471. export enum DualShockButton {
  129472. /** Cross */
  129473. Cross = 0,
  129474. /** Circle */
  129475. Circle = 1,
  129476. /** Square */
  129477. Square = 2,
  129478. /** Triangle */
  129479. Triangle = 3,
  129480. /** L1 */
  129481. L1 = 4,
  129482. /** R1 */
  129483. R1 = 5,
  129484. /** Share */
  129485. Share = 8,
  129486. /** Options */
  129487. Options = 9,
  129488. /** Left stick */
  129489. LeftStick = 10,
  129490. /** Right stick */
  129491. RightStick = 11
  129492. }
  129493. /** Defines values for DualShock DPad */
  129494. export enum DualShockDpad {
  129495. /** Up */
  129496. Up = 12,
  129497. /** Down */
  129498. Down = 13,
  129499. /** Left */
  129500. Left = 14,
  129501. /** Right */
  129502. Right = 15
  129503. }
  129504. /**
  129505. * Defines a DualShock gamepad
  129506. */
  129507. export class DualShockPad extends Gamepad {
  129508. private _leftTrigger;
  129509. private _rightTrigger;
  129510. private _onlefttriggerchanged;
  129511. private _onrighttriggerchanged;
  129512. private _onbuttondown;
  129513. private _onbuttonup;
  129514. private _ondpaddown;
  129515. private _ondpadup;
  129516. /** Observable raised when a button is pressed */
  129517. onButtonDownObservable: Observable<DualShockButton>;
  129518. /** Observable raised when a button is released */
  129519. onButtonUpObservable: Observable<DualShockButton>;
  129520. /** Observable raised when a pad is pressed */
  129521. onPadDownObservable: Observable<DualShockDpad>;
  129522. /** Observable raised when a pad is released */
  129523. onPadUpObservable: Observable<DualShockDpad>;
  129524. private _buttonCross;
  129525. private _buttonCircle;
  129526. private _buttonSquare;
  129527. private _buttonTriangle;
  129528. private _buttonShare;
  129529. private _buttonOptions;
  129530. private _buttonL1;
  129531. private _buttonR1;
  129532. private _buttonLeftStick;
  129533. private _buttonRightStick;
  129534. private _dPadUp;
  129535. private _dPadDown;
  129536. private _dPadLeft;
  129537. private _dPadRight;
  129538. /**
  129539. * Creates a new DualShock gamepad object
  129540. * @param id defines the id of this gamepad
  129541. * @param index defines its index
  129542. * @param gamepad defines the internal HTML gamepad object
  129543. */
  129544. constructor(id: string, index: number, gamepad: any);
  129545. /**
  129546. * Defines the callback to call when left trigger is pressed
  129547. * @param callback defines the callback to use
  129548. */
  129549. onlefttriggerchanged(callback: (value: number) => void): void;
  129550. /**
  129551. * Defines the callback to call when right trigger is pressed
  129552. * @param callback defines the callback to use
  129553. */
  129554. onrighttriggerchanged(callback: (value: number) => void): void;
  129555. /**
  129556. * Gets the left trigger value
  129557. */
  129558. get leftTrigger(): number;
  129559. /**
  129560. * Sets the left trigger value
  129561. */
  129562. set leftTrigger(newValue: number);
  129563. /**
  129564. * Gets the right trigger value
  129565. */
  129566. get rightTrigger(): number;
  129567. /**
  129568. * Sets the right trigger value
  129569. */
  129570. set rightTrigger(newValue: number);
  129571. /**
  129572. * Defines the callback to call when a button is pressed
  129573. * @param callback defines the callback to use
  129574. */
  129575. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  129576. /**
  129577. * Defines the callback to call when a button is released
  129578. * @param callback defines the callback to use
  129579. */
  129580. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  129581. /**
  129582. * Defines the callback to call when a pad is pressed
  129583. * @param callback defines the callback to use
  129584. */
  129585. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  129586. /**
  129587. * Defines the callback to call when a pad is released
  129588. * @param callback defines the callback to use
  129589. */
  129590. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  129591. private _setButtonValue;
  129592. private _setDPadValue;
  129593. /**
  129594. * Gets the value of the `Cross` button
  129595. */
  129596. get buttonCross(): number;
  129597. /**
  129598. * Sets the value of the `Cross` button
  129599. */
  129600. set buttonCross(value: number);
  129601. /**
  129602. * Gets the value of the `Circle` button
  129603. */
  129604. get buttonCircle(): number;
  129605. /**
  129606. * Sets the value of the `Circle` button
  129607. */
  129608. set buttonCircle(value: number);
  129609. /**
  129610. * Gets the value of the `Square` button
  129611. */
  129612. get buttonSquare(): number;
  129613. /**
  129614. * Sets the value of the `Square` button
  129615. */
  129616. set buttonSquare(value: number);
  129617. /**
  129618. * Gets the value of the `Triangle` button
  129619. */
  129620. get buttonTriangle(): number;
  129621. /**
  129622. * Sets the value of the `Triangle` button
  129623. */
  129624. set buttonTriangle(value: number);
  129625. /**
  129626. * Gets the value of the `Options` button
  129627. */
  129628. get buttonOptions(): number;
  129629. /**
  129630. * Sets the value of the `Options` button
  129631. */
  129632. set buttonOptions(value: number);
  129633. /**
  129634. * Gets the value of the `Share` button
  129635. */
  129636. get buttonShare(): number;
  129637. /**
  129638. * Sets the value of the `Share` button
  129639. */
  129640. set buttonShare(value: number);
  129641. /**
  129642. * Gets the value of the `L1` button
  129643. */
  129644. get buttonL1(): number;
  129645. /**
  129646. * Sets the value of the `L1` button
  129647. */
  129648. set buttonL1(value: number);
  129649. /**
  129650. * Gets the value of the `R1` button
  129651. */
  129652. get buttonR1(): number;
  129653. /**
  129654. * Sets the value of the `R1` button
  129655. */
  129656. set buttonR1(value: number);
  129657. /**
  129658. * Gets the value of the Left joystick
  129659. */
  129660. get buttonLeftStick(): number;
  129661. /**
  129662. * Sets the value of the Left joystick
  129663. */
  129664. set buttonLeftStick(value: number);
  129665. /**
  129666. * Gets the value of the Right joystick
  129667. */
  129668. get buttonRightStick(): number;
  129669. /**
  129670. * Sets the value of the Right joystick
  129671. */
  129672. set buttonRightStick(value: number);
  129673. /**
  129674. * Gets the value of D-pad up
  129675. */
  129676. get dPadUp(): number;
  129677. /**
  129678. * Sets the value of D-pad up
  129679. */
  129680. set dPadUp(value: number);
  129681. /**
  129682. * Gets the value of D-pad down
  129683. */
  129684. get dPadDown(): number;
  129685. /**
  129686. * Sets the value of D-pad down
  129687. */
  129688. set dPadDown(value: number);
  129689. /**
  129690. * Gets the value of D-pad left
  129691. */
  129692. get dPadLeft(): number;
  129693. /**
  129694. * Sets the value of D-pad left
  129695. */
  129696. set dPadLeft(value: number);
  129697. /**
  129698. * Gets the value of D-pad right
  129699. */
  129700. get dPadRight(): number;
  129701. /**
  129702. * Sets the value of D-pad right
  129703. */
  129704. set dPadRight(value: number);
  129705. /**
  129706. * Force the gamepad to synchronize with device values
  129707. */
  129708. update(): void;
  129709. /**
  129710. * Disposes the gamepad
  129711. */
  129712. dispose(): void;
  129713. }
  129714. }
  129715. declare module BABYLON {
  129716. /**
  129717. * Manager for handling gamepads
  129718. */
  129719. export class GamepadManager {
  129720. private _scene?;
  129721. private _babylonGamepads;
  129722. private _oneGamepadConnected;
  129723. /** @hidden */
  129724. _isMonitoring: boolean;
  129725. private _gamepadEventSupported;
  129726. private _gamepadSupport?;
  129727. /**
  129728. * observable to be triggered when the gamepad controller has been connected
  129729. */
  129730. onGamepadConnectedObservable: Observable<Gamepad>;
  129731. /**
  129732. * observable to be triggered when the gamepad controller has been disconnected
  129733. */
  129734. onGamepadDisconnectedObservable: Observable<Gamepad>;
  129735. private _onGamepadConnectedEvent;
  129736. private _onGamepadDisconnectedEvent;
  129737. /**
  129738. * Initializes the gamepad manager
  129739. * @param _scene BabylonJS scene
  129740. */
  129741. constructor(_scene?: Scene | undefined);
  129742. /**
  129743. * The gamepads in the game pad manager
  129744. */
  129745. get gamepads(): Gamepad[];
  129746. /**
  129747. * Get the gamepad controllers based on type
  129748. * @param type The type of gamepad controller
  129749. * @returns Nullable gamepad
  129750. */
  129751. getGamepadByType(type?: number): Nullable<Gamepad>;
  129752. /**
  129753. * Disposes the gamepad manager
  129754. */
  129755. dispose(): void;
  129756. private _addNewGamepad;
  129757. private _startMonitoringGamepads;
  129758. private _stopMonitoringGamepads;
  129759. /** @hidden */
  129760. _checkGamepadsStatus(): void;
  129761. private _updateGamepadObjects;
  129762. }
  129763. }
  129764. declare module BABYLON {
  129765. interface Scene {
  129766. /** @hidden */
  129767. _gamepadManager: Nullable<GamepadManager>;
  129768. /**
  129769. * Gets the gamepad manager associated with the scene
  129770. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  129771. */
  129772. gamepadManager: GamepadManager;
  129773. }
  129774. /**
  129775. * Interface representing a free camera inputs manager
  129776. */
  129777. interface FreeCameraInputsManager {
  129778. /**
  129779. * Adds gamepad input support to the FreeCameraInputsManager.
  129780. * @returns the FreeCameraInputsManager
  129781. */
  129782. addGamepad(): FreeCameraInputsManager;
  129783. }
  129784. /**
  129785. * Interface representing an arc rotate camera inputs manager
  129786. */
  129787. interface ArcRotateCameraInputsManager {
  129788. /**
  129789. * Adds gamepad input support to the ArcRotateCamera InputManager.
  129790. * @returns the camera inputs manager
  129791. */
  129792. addGamepad(): ArcRotateCameraInputsManager;
  129793. }
  129794. /**
  129795. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  129796. */
  129797. export class GamepadSystemSceneComponent implements ISceneComponent {
  129798. /**
  129799. * The component name helpfull to identify the component in the list of scene components.
  129800. */
  129801. readonly name: string;
  129802. /**
  129803. * The scene the component belongs to.
  129804. */
  129805. scene: Scene;
  129806. /**
  129807. * Creates a new instance of the component for the given scene
  129808. * @param scene Defines the scene to register the component in
  129809. */
  129810. constructor(scene: Scene);
  129811. /**
  129812. * Registers the component in a given scene
  129813. */
  129814. register(): void;
  129815. /**
  129816. * Rebuilds the elements related to this component in case of
  129817. * context lost for instance.
  129818. */
  129819. rebuild(): void;
  129820. /**
  129821. * Disposes the component and the associated ressources
  129822. */
  129823. dispose(): void;
  129824. private _beforeCameraUpdate;
  129825. }
  129826. }
  129827. declare module BABYLON {
  129828. /**
  129829. * 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,
  129830. * which still works and will still be found in many Playgrounds.
  129831. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129832. */
  129833. export class UniversalCamera extends TouchCamera {
  129834. /**
  129835. * Defines the gamepad rotation sensiblity.
  129836. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129837. */
  129838. get gamepadAngularSensibility(): number;
  129839. set gamepadAngularSensibility(value: number);
  129840. /**
  129841. * Defines the gamepad move sensiblity.
  129842. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129843. */
  129844. get gamepadMoveSensibility(): number;
  129845. set gamepadMoveSensibility(value: number);
  129846. /**
  129847. * 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,
  129848. * which still works and will still be found in many Playgrounds.
  129849. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129850. * @param name Define the name of the camera in the scene
  129851. * @param position Define the start position of the camera in the scene
  129852. * @param scene Define the scene the camera belongs to
  129853. */
  129854. constructor(name: string, position: Vector3, scene: Scene);
  129855. /**
  129856. * Gets the current object class name.
  129857. * @return the class name
  129858. */
  129859. getClassName(): string;
  129860. }
  129861. }
  129862. declare module BABYLON {
  129863. /**
  129864. * This represents a FPS type of camera. This is only here for back compat purpose.
  129865. * Please use the UniversalCamera instead as both are identical.
  129866. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129867. */
  129868. export class GamepadCamera extends UniversalCamera {
  129869. /**
  129870. * Instantiates a new Gamepad Camera
  129871. * This represents a FPS type of camera. This is only here for back compat purpose.
  129872. * Please use the UniversalCamera instead as both are identical.
  129873. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129874. * @param name Define the name of the camera in the scene
  129875. * @param position Define the start position of the camera in the scene
  129876. * @param scene Define the scene the camera belongs to
  129877. */
  129878. constructor(name: string, position: Vector3, scene: Scene);
  129879. /**
  129880. * Gets the current object class name.
  129881. * @return the class name
  129882. */
  129883. getClassName(): string;
  129884. }
  129885. }
  129886. declare module BABYLON {
  129887. /** @hidden */
  129888. export var passPixelShader: {
  129889. name: string;
  129890. shader: string;
  129891. };
  129892. }
  129893. declare module BABYLON {
  129894. /** @hidden */
  129895. export var passCubePixelShader: {
  129896. name: string;
  129897. shader: string;
  129898. };
  129899. }
  129900. declare module BABYLON {
  129901. /**
  129902. * PassPostProcess which produces an output the same as it's input
  129903. */
  129904. export class PassPostProcess extends PostProcess {
  129905. /**
  129906. * Gets a string identifying the name of the class
  129907. * @returns "PassPostProcess" string
  129908. */
  129909. getClassName(): string;
  129910. /**
  129911. * Creates the PassPostProcess
  129912. * @param name The name of the effect.
  129913. * @param options The required width/height ratio to downsize to before computing the render pass.
  129914. * @param camera The camera to apply the render pass to.
  129915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129916. * @param engine The engine which the post process will be applied. (default: current engine)
  129917. * @param reusable If the post process can be reused on the same frame. (default: false)
  129918. * @param textureType The type of texture to be used when performing the post processing.
  129919. * @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)
  129920. */
  129921. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129922. /** @hidden */
  129923. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  129924. }
  129925. /**
  129926. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  129927. */
  129928. export class PassCubePostProcess extends PostProcess {
  129929. private _face;
  129930. /**
  129931. * Gets or sets the cube face to display.
  129932. * * 0 is +X
  129933. * * 1 is -X
  129934. * * 2 is +Y
  129935. * * 3 is -Y
  129936. * * 4 is +Z
  129937. * * 5 is -Z
  129938. */
  129939. get face(): number;
  129940. set face(value: number);
  129941. /**
  129942. * Gets a string identifying the name of the class
  129943. * @returns "PassCubePostProcess" string
  129944. */
  129945. getClassName(): string;
  129946. /**
  129947. * Creates the PassCubePostProcess
  129948. * @param name The name of the effect.
  129949. * @param options The required width/height ratio to downsize to before computing the render pass.
  129950. * @param camera The camera to apply the render pass to.
  129951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129952. * @param engine The engine which the post process will be applied. (default: current engine)
  129953. * @param reusable If the post process can be reused on the same frame. (default: false)
  129954. * @param textureType The type of texture to be used when performing the post processing.
  129955. * @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)
  129956. */
  129957. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129958. /** @hidden */
  129959. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  129960. }
  129961. }
  129962. declare module BABYLON {
  129963. /** @hidden */
  129964. export var anaglyphPixelShader: {
  129965. name: string;
  129966. shader: string;
  129967. };
  129968. }
  129969. declare module BABYLON {
  129970. /**
  129971. * Postprocess used to generate anaglyphic rendering
  129972. */
  129973. export class AnaglyphPostProcess extends PostProcess {
  129974. private _passedProcess;
  129975. /**
  129976. * Gets a string identifying the name of the class
  129977. * @returns "AnaglyphPostProcess" string
  129978. */
  129979. getClassName(): string;
  129980. /**
  129981. * Creates a new AnaglyphPostProcess
  129982. * @param name defines postprocess name
  129983. * @param options defines creation options or target ratio scale
  129984. * @param rigCameras defines cameras using this postprocess
  129985. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  129986. * @param engine defines hosting engine
  129987. * @param reusable defines if the postprocess will be reused multiple times per frame
  129988. */
  129989. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  129990. }
  129991. }
  129992. declare module BABYLON {
  129993. /**
  129994. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  129995. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129996. */
  129997. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  129998. /**
  129999. * Creates a new AnaglyphArcRotateCamera
  130000. * @param name defines camera name
  130001. * @param alpha defines alpha angle (in radians)
  130002. * @param beta defines beta angle (in radians)
  130003. * @param radius defines radius
  130004. * @param target defines camera target
  130005. * @param interaxialDistance defines distance between each color axis
  130006. * @param scene defines the hosting scene
  130007. */
  130008. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  130009. /**
  130010. * Gets camera class name
  130011. * @returns AnaglyphArcRotateCamera
  130012. */
  130013. getClassName(): string;
  130014. }
  130015. }
  130016. declare module BABYLON {
  130017. /**
  130018. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  130019. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130020. */
  130021. export class AnaglyphFreeCamera extends FreeCamera {
  130022. /**
  130023. * Creates a new AnaglyphFreeCamera
  130024. * @param name defines camera name
  130025. * @param position defines initial position
  130026. * @param interaxialDistance defines distance between each color axis
  130027. * @param scene defines the hosting scene
  130028. */
  130029. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130030. /**
  130031. * Gets camera class name
  130032. * @returns AnaglyphFreeCamera
  130033. */
  130034. getClassName(): string;
  130035. }
  130036. }
  130037. declare module BABYLON {
  130038. /**
  130039. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  130040. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130041. */
  130042. export class AnaglyphGamepadCamera extends GamepadCamera {
  130043. /**
  130044. * Creates a new AnaglyphGamepadCamera
  130045. * @param name defines camera name
  130046. * @param position defines initial position
  130047. * @param interaxialDistance defines distance between each color axis
  130048. * @param scene defines the hosting scene
  130049. */
  130050. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130051. /**
  130052. * Gets camera class name
  130053. * @returns AnaglyphGamepadCamera
  130054. */
  130055. getClassName(): string;
  130056. }
  130057. }
  130058. declare module BABYLON {
  130059. /**
  130060. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  130061. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130062. */
  130063. export class AnaglyphUniversalCamera extends UniversalCamera {
  130064. /**
  130065. * Creates a new AnaglyphUniversalCamera
  130066. * @param name defines camera name
  130067. * @param position defines initial position
  130068. * @param interaxialDistance defines distance between each color axis
  130069. * @param scene defines the hosting scene
  130070. */
  130071. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130072. /**
  130073. * Gets camera class name
  130074. * @returns AnaglyphUniversalCamera
  130075. */
  130076. getClassName(): string;
  130077. }
  130078. }
  130079. declare module BABYLON {
  130080. /**
  130081. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  130082. * @see https://doc.babylonjs.com/features/cameras
  130083. */
  130084. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  130085. /**
  130086. * Creates a new StereoscopicArcRotateCamera
  130087. * @param name defines camera name
  130088. * @param alpha defines alpha angle (in radians)
  130089. * @param beta defines beta angle (in radians)
  130090. * @param radius defines radius
  130091. * @param target defines camera target
  130092. * @param interaxialDistance defines distance between each color axis
  130093. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130094. * @param scene defines the hosting scene
  130095. */
  130096. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130097. /**
  130098. * Gets camera class name
  130099. * @returns StereoscopicArcRotateCamera
  130100. */
  130101. getClassName(): string;
  130102. }
  130103. }
  130104. declare module BABYLON {
  130105. /**
  130106. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  130107. * @see https://doc.babylonjs.com/features/cameras
  130108. */
  130109. export class StereoscopicFreeCamera extends FreeCamera {
  130110. /**
  130111. * Creates a new StereoscopicFreeCamera
  130112. * @param name defines camera name
  130113. * @param position defines initial position
  130114. * @param interaxialDistance defines distance between each color axis
  130115. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130116. * @param scene defines the hosting scene
  130117. */
  130118. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130119. /**
  130120. * Gets camera class name
  130121. * @returns StereoscopicFreeCamera
  130122. */
  130123. getClassName(): string;
  130124. }
  130125. }
  130126. declare module BABYLON {
  130127. /**
  130128. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  130129. * @see https://doc.babylonjs.com/features/cameras
  130130. */
  130131. export class StereoscopicGamepadCamera extends GamepadCamera {
  130132. /**
  130133. * Creates a new StereoscopicGamepadCamera
  130134. * @param name defines camera name
  130135. * @param position defines initial position
  130136. * @param interaxialDistance defines distance between each color axis
  130137. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130138. * @param scene defines the hosting scene
  130139. */
  130140. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130141. /**
  130142. * Gets camera class name
  130143. * @returns StereoscopicGamepadCamera
  130144. */
  130145. getClassName(): string;
  130146. }
  130147. }
  130148. declare module BABYLON {
  130149. /**
  130150. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  130151. * @see https://doc.babylonjs.com/features/cameras
  130152. */
  130153. export class StereoscopicUniversalCamera extends UniversalCamera {
  130154. /**
  130155. * Creates a new StereoscopicUniversalCamera
  130156. * @param name defines camera name
  130157. * @param position defines initial position
  130158. * @param interaxialDistance defines distance between each color axis
  130159. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130160. * @param scene defines the hosting scene
  130161. */
  130162. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130163. /**
  130164. * Gets camera class name
  130165. * @returns StereoscopicUniversalCamera
  130166. */
  130167. getClassName(): string;
  130168. }
  130169. }
  130170. declare module BABYLON {
  130171. /**
  130172. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  130173. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130174. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130175. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130176. */
  130177. export class VirtualJoysticksCamera extends FreeCamera {
  130178. /**
  130179. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  130180. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130181. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130182. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130183. * @param name Define the name of the camera in the scene
  130184. * @param position Define the start position of the camera in the scene
  130185. * @param scene Define the scene the camera belongs to
  130186. */
  130187. constructor(name: string, position: Vector3, scene: Scene);
  130188. /**
  130189. * Gets the current object class name.
  130190. * @return the class name
  130191. */
  130192. getClassName(): string;
  130193. }
  130194. }
  130195. declare module BABYLON {
  130196. /**
  130197. * This represents all the required metrics to create a VR camera.
  130198. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  130199. */
  130200. export class VRCameraMetrics {
  130201. /**
  130202. * Define the horizontal resolution off the screen.
  130203. */
  130204. hResolution: number;
  130205. /**
  130206. * Define the vertical resolution off the screen.
  130207. */
  130208. vResolution: number;
  130209. /**
  130210. * Define the horizontal screen size.
  130211. */
  130212. hScreenSize: number;
  130213. /**
  130214. * Define the vertical screen size.
  130215. */
  130216. vScreenSize: number;
  130217. /**
  130218. * Define the vertical screen center position.
  130219. */
  130220. vScreenCenter: number;
  130221. /**
  130222. * Define the distance of the eyes to the screen.
  130223. */
  130224. eyeToScreenDistance: number;
  130225. /**
  130226. * Define the distance between both lenses
  130227. */
  130228. lensSeparationDistance: number;
  130229. /**
  130230. * Define the distance between both viewer's eyes.
  130231. */
  130232. interpupillaryDistance: number;
  130233. /**
  130234. * Define the distortion factor of the VR postprocess.
  130235. * Please, touch with care.
  130236. */
  130237. distortionK: number[];
  130238. /**
  130239. * Define the chromatic aberration correction factors for the VR post process.
  130240. */
  130241. chromaAbCorrection: number[];
  130242. /**
  130243. * Define the scale factor of the post process.
  130244. * The smaller the better but the slower.
  130245. */
  130246. postProcessScaleFactor: number;
  130247. /**
  130248. * Define an offset for the lens center.
  130249. */
  130250. lensCenterOffset: number;
  130251. /**
  130252. * Define if the current vr camera should compensate the distortion of the lense or not.
  130253. */
  130254. compensateDistortion: boolean;
  130255. /**
  130256. * Defines if multiview should be enabled when rendering (Default: false)
  130257. */
  130258. multiviewEnabled: boolean;
  130259. /**
  130260. * Gets the rendering aspect ratio based on the provided resolutions.
  130261. */
  130262. get aspectRatio(): number;
  130263. /**
  130264. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  130265. */
  130266. get aspectRatioFov(): number;
  130267. /**
  130268. * @hidden
  130269. */
  130270. get leftHMatrix(): Matrix;
  130271. /**
  130272. * @hidden
  130273. */
  130274. get rightHMatrix(): Matrix;
  130275. /**
  130276. * @hidden
  130277. */
  130278. get leftPreViewMatrix(): Matrix;
  130279. /**
  130280. * @hidden
  130281. */
  130282. get rightPreViewMatrix(): Matrix;
  130283. /**
  130284. * Get the default VRMetrics based on the most generic setup.
  130285. * @returns the default vr metrics
  130286. */
  130287. static GetDefault(): VRCameraMetrics;
  130288. }
  130289. }
  130290. declare module BABYLON {
  130291. /** @hidden */
  130292. export var vrDistortionCorrectionPixelShader: {
  130293. name: string;
  130294. shader: string;
  130295. };
  130296. }
  130297. declare module BABYLON {
  130298. /**
  130299. * VRDistortionCorrectionPostProcess used for mobile VR
  130300. */
  130301. export class VRDistortionCorrectionPostProcess extends PostProcess {
  130302. private _isRightEye;
  130303. private _distortionFactors;
  130304. private _postProcessScaleFactor;
  130305. private _lensCenterOffset;
  130306. private _scaleIn;
  130307. private _scaleFactor;
  130308. private _lensCenter;
  130309. /**
  130310. * Gets a string identifying the name of the class
  130311. * @returns "VRDistortionCorrectionPostProcess" string
  130312. */
  130313. getClassName(): string;
  130314. /**
  130315. * Initializes the VRDistortionCorrectionPostProcess
  130316. * @param name The name of the effect.
  130317. * @param camera The camera to apply the render pass to.
  130318. * @param isRightEye If this is for the right eye distortion
  130319. * @param vrMetrics All the required metrics for the VR camera
  130320. */
  130321. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  130322. }
  130323. }
  130324. declare module BABYLON {
  130325. /**
  130326. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  130327. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130328. */
  130329. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  130330. /**
  130331. * Creates a new VRDeviceOrientationArcRotateCamera
  130332. * @param name defines camera name
  130333. * @param alpha defines the camera rotation along the logitudinal axis
  130334. * @param beta defines the camera rotation along the latitudinal axis
  130335. * @param radius defines the camera distance from its target
  130336. * @param target defines the camera target
  130337. * @param scene defines the scene the camera belongs to
  130338. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130339. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130340. */
  130341. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130342. /**
  130343. * Gets camera class name
  130344. * @returns VRDeviceOrientationArcRotateCamera
  130345. */
  130346. getClassName(): string;
  130347. }
  130348. }
  130349. declare module BABYLON {
  130350. /**
  130351. * Camera used to simulate VR rendering (based on FreeCamera)
  130352. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130353. */
  130354. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  130355. /**
  130356. * Creates a new VRDeviceOrientationFreeCamera
  130357. * @param name defines camera name
  130358. * @param position defines the start position of the camera
  130359. * @param scene defines the scene the camera belongs to
  130360. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130361. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130362. */
  130363. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130364. /**
  130365. * Gets camera class name
  130366. * @returns VRDeviceOrientationFreeCamera
  130367. */
  130368. getClassName(): string;
  130369. }
  130370. }
  130371. declare module BABYLON {
  130372. /**
  130373. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  130374. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130375. */
  130376. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  130377. /**
  130378. * Creates a new VRDeviceOrientationGamepadCamera
  130379. * @param name defines camera name
  130380. * @param position defines the start position of the camera
  130381. * @param scene defines the scene the camera belongs to
  130382. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130383. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130384. */
  130385. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130386. /**
  130387. * Gets camera class name
  130388. * @returns VRDeviceOrientationGamepadCamera
  130389. */
  130390. getClassName(): string;
  130391. }
  130392. }
  130393. declare module BABYLON {
  130394. /**
  130395. * A class extending Texture allowing drawing on a texture
  130396. * @see https://doc.babylonjs.com/how_to/dynamictexture
  130397. */
  130398. export class DynamicTexture extends Texture {
  130399. private _generateMipMaps;
  130400. private _canvas;
  130401. private _context;
  130402. /**
  130403. * Creates a DynamicTexture
  130404. * @param name defines the name of the texture
  130405. * @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
  130406. * @param scene defines the scene where you want the texture
  130407. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  130408. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130409. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  130410. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  130411. */
  130412. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  130413. /**
  130414. * Get the current class name of the texture useful for serialization or dynamic coding.
  130415. * @returns "DynamicTexture"
  130416. */
  130417. getClassName(): string;
  130418. /**
  130419. * Gets the current state of canRescale
  130420. */
  130421. get canRescale(): boolean;
  130422. private _recreate;
  130423. /**
  130424. * Scales the texture
  130425. * @param ratio the scale factor to apply to both width and height
  130426. */
  130427. scale(ratio: number): void;
  130428. /**
  130429. * Resizes the texture
  130430. * @param width the new width
  130431. * @param height the new height
  130432. */
  130433. scaleTo(width: number, height: number): void;
  130434. /**
  130435. * Gets the context of the canvas used by the texture
  130436. * @returns the canvas context of the dynamic texture
  130437. */
  130438. getContext(): CanvasRenderingContext2D;
  130439. /**
  130440. * Clears the texture
  130441. */
  130442. clear(): void;
  130443. /**
  130444. * Updates the texture
  130445. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130446. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  130447. */
  130448. update(invertY?: boolean, premulAlpha?: boolean): void;
  130449. /**
  130450. * Draws text onto the texture
  130451. * @param text defines the text to be drawn
  130452. * @param x defines the placement of the text from the left
  130453. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  130454. * @param font defines the font to be used with font-style, font-size, font-name
  130455. * @param color defines the color used for the text
  130456. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  130457. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130458. * @param update defines whether texture is immediately update (default is true)
  130459. */
  130460. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  130461. /**
  130462. * Clones the texture
  130463. * @returns the clone of the texture.
  130464. */
  130465. clone(): DynamicTexture;
  130466. /**
  130467. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  130468. * @returns a serialized dynamic texture object
  130469. */
  130470. serialize(): any;
  130471. private _IsCanvasElement;
  130472. /** @hidden */
  130473. _rebuild(): void;
  130474. }
  130475. }
  130476. declare module BABYLON {
  130477. /**
  130478. * Class containing static functions to help procedurally build meshes
  130479. */
  130480. export class GroundBuilder {
  130481. /**
  130482. * Creates a ground mesh
  130483. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130484. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130486. * @param name defines the name of the mesh
  130487. * @param options defines the options used to create the mesh
  130488. * @param scene defines the hosting scene
  130489. * @returns the ground mesh
  130490. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130491. */
  130492. static CreateGround(name: string, options: {
  130493. width?: number;
  130494. height?: number;
  130495. subdivisions?: number;
  130496. subdivisionsX?: number;
  130497. subdivisionsY?: number;
  130498. updatable?: boolean;
  130499. }, scene: any): Mesh;
  130500. /**
  130501. * Creates a tiled ground mesh
  130502. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130503. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130504. * * 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
  130505. * * 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
  130506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130507. * @param name defines the name of the mesh
  130508. * @param options defines the options used to create the mesh
  130509. * @param scene defines the hosting scene
  130510. * @returns the tiled ground mesh
  130511. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130512. */
  130513. static CreateTiledGround(name: string, options: {
  130514. xmin: number;
  130515. zmin: number;
  130516. xmax: number;
  130517. zmax: number;
  130518. subdivisions?: {
  130519. w: number;
  130520. h: number;
  130521. };
  130522. precision?: {
  130523. w: number;
  130524. h: number;
  130525. };
  130526. updatable?: boolean;
  130527. }, scene?: Nullable<Scene>): Mesh;
  130528. /**
  130529. * Creates a ground mesh from a height map
  130530. * * The parameter `url` sets the URL of the height map image resource.
  130531. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130532. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130533. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130534. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130535. * * 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.
  130536. * * 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).
  130537. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130539. * @param name defines the name of the mesh
  130540. * @param url defines the url to the height map
  130541. * @param options defines the options used to create the mesh
  130542. * @param scene defines the hosting scene
  130543. * @returns the ground mesh
  130544. * @see https://doc.babylonjs.com/babylon101/height_map
  130545. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130546. */
  130547. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130548. width?: number;
  130549. height?: number;
  130550. subdivisions?: number;
  130551. minHeight?: number;
  130552. maxHeight?: number;
  130553. colorFilter?: Color3;
  130554. alphaFilter?: number;
  130555. updatable?: boolean;
  130556. onReady?: (mesh: GroundMesh) => void;
  130557. }, scene?: Nullable<Scene>): GroundMesh;
  130558. }
  130559. }
  130560. declare module BABYLON {
  130561. /**
  130562. * Class containing static functions to help procedurally build meshes
  130563. */
  130564. export class TorusBuilder {
  130565. /**
  130566. * Creates a torus mesh
  130567. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130568. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130569. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130571. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130573. * @param name defines the name of the mesh
  130574. * @param options defines the options used to create the mesh
  130575. * @param scene defines the hosting scene
  130576. * @returns the torus mesh
  130577. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130578. */
  130579. static CreateTorus(name: string, options: {
  130580. diameter?: number;
  130581. thickness?: number;
  130582. tessellation?: number;
  130583. updatable?: boolean;
  130584. sideOrientation?: number;
  130585. frontUVs?: Vector4;
  130586. backUVs?: Vector4;
  130587. }, scene: any): Mesh;
  130588. }
  130589. }
  130590. declare module BABYLON {
  130591. /**
  130592. * Class containing static functions to help procedurally build meshes
  130593. */
  130594. export class CylinderBuilder {
  130595. /**
  130596. * Creates a cylinder or a cone mesh
  130597. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130598. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130599. * * 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.
  130600. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130601. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130602. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130603. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130604. * * 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).
  130605. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130606. * * 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).
  130607. * * 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
  130608. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130609. * * 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
  130610. * * 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.
  130611. * * If `enclose` is false, a ring surface is one element.
  130612. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130613. * * 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
  130614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130617. * @param name defines the name of the mesh
  130618. * @param options defines the options used to create the mesh
  130619. * @param scene defines the hosting scene
  130620. * @returns the cylinder mesh
  130621. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130622. */
  130623. static CreateCylinder(name: string, options: {
  130624. height?: number;
  130625. diameterTop?: number;
  130626. diameterBottom?: number;
  130627. diameter?: number;
  130628. tessellation?: number;
  130629. subdivisions?: number;
  130630. arc?: number;
  130631. faceColors?: Color4[];
  130632. faceUV?: Vector4[];
  130633. updatable?: boolean;
  130634. hasRings?: boolean;
  130635. enclose?: boolean;
  130636. cap?: number;
  130637. sideOrientation?: number;
  130638. frontUVs?: Vector4;
  130639. backUVs?: Vector4;
  130640. }, scene: any): Mesh;
  130641. }
  130642. }
  130643. declare module BABYLON {
  130644. /**
  130645. * States of the webXR experience
  130646. */
  130647. export enum WebXRState {
  130648. /**
  130649. * Transitioning to being in XR mode
  130650. */
  130651. ENTERING_XR = 0,
  130652. /**
  130653. * Transitioning to non XR mode
  130654. */
  130655. EXITING_XR = 1,
  130656. /**
  130657. * In XR mode and presenting
  130658. */
  130659. IN_XR = 2,
  130660. /**
  130661. * Not entered XR mode
  130662. */
  130663. NOT_IN_XR = 3
  130664. }
  130665. /**
  130666. * The state of the XR camera's tracking
  130667. */
  130668. export enum WebXRTrackingState {
  130669. /**
  130670. * No transformation received, device is not being tracked
  130671. */
  130672. NOT_TRACKING = 0,
  130673. /**
  130674. * Tracking lost - using emulated position
  130675. */
  130676. TRACKING_LOST = 1,
  130677. /**
  130678. * Transformation tracking works normally
  130679. */
  130680. TRACKING = 2
  130681. }
  130682. /**
  130683. * Abstraction of the XR render target
  130684. */
  130685. export interface WebXRRenderTarget extends IDisposable {
  130686. /**
  130687. * xrpresent context of the canvas which can be used to display/mirror xr content
  130688. */
  130689. canvasContext: WebGLRenderingContext;
  130690. /**
  130691. * xr layer for the canvas
  130692. */
  130693. xrLayer: Nullable<XRWebGLLayer>;
  130694. /**
  130695. * Initializes the xr layer for the session
  130696. * @param xrSession xr session
  130697. * @returns a promise that will resolve once the XR Layer has been created
  130698. */
  130699. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130700. }
  130701. }
  130702. declare module BABYLON {
  130703. /**
  130704. * COnfiguration object for WebXR output canvas
  130705. */
  130706. export class WebXRManagedOutputCanvasOptions {
  130707. /**
  130708. * An optional canvas in case you wish to create it yourself and provide it here.
  130709. * If not provided, a new canvas will be created
  130710. */
  130711. canvasElement?: HTMLCanvasElement;
  130712. /**
  130713. * Options for this XR Layer output
  130714. */
  130715. canvasOptions?: XRWebGLLayerOptions;
  130716. /**
  130717. * CSS styling for a newly created canvas (if not provided)
  130718. */
  130719. newCanvasCssStyle?: string;
  130720. /**
  130721. * Get the default values of the configuration object
  130722. * @param engine defines the engine to use (can be null)
  130723. * @returns default values of this configuration object
  130724. */
  130725. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  130726. }
  130727. /**
  130728. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  130729. */
  130730. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  130731. private _options;
  130732. private _canvas;
  130733. private _engine;
  130734. private _originalCanvasSize;
  130735. /**
  130736. * Rendering context of the canvas which can be used to display/mirror xr content
  130737. */
  130738. canvasContext: WebGLRenderingContext;
  130739. /**
  130740. * xr layer for the canvas
  130741. */
  130742. xrLayer: Nullable<XRWebGLLayer>;
  130743. /**
  130744. * Obseervers registered here will be triggered when the xr layer was initialized
  130745. */
  130746. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  130747. /**
  130748. * Initializes the canvas to be added/removed upon entering/exiting xr
  130749. * @param _xrSessionManager The XR Session manager
  130750. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  130751. */
  130752. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  130753. /**
  130754. * Disposes of the object
  130755. */
  130756. dispose(): void;
  130757. /**
  130758. * Initializes the xr layer for the session
  130759. * @param xrSession xr session
  130760. * @returns a promise that will resolve once the XR Layer has been created
  130761. */
  130762. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130763. private _addCanvas;
  130764. private _removeCanvas;
  130765. private _setCanvasSize;
  130766. private _setManagedOutputCanvas;
  130767. }
  130768. }
  130769. declare module BABYLON {
  130770. /**
  130771. * Manages an XRSession to work with Babylon's engine
  130772. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  130773. */
  130774. export class WebXRSessionManager implements IDisposable {
  130775. /** The scene which the session should be created for */
  130776. scene: Scene;
  130777. private _referenceSpace;
  130778. private _rttProvider;
  130779. private _sessionEnded;
  130780. private _xrNavigator;
  130781. private baseLayer;
  130782. /**
  130783. * The base reference space from which the session started. good if you want to reset your
  130784. * reference space
  130785. */
  130786. baseReferenceSpace: XRReferenceSpace;
  130787. /**
  130788. * Current XR frame
  130789. */
  130790. currentFrame: Nullable<XRFrame>;
  130791. /** WebXR timestamp updated every frame */
  130792. currentTimestamp: number;
  130793. /**
  130794. * Used just in case of a failure to initialize an immersive session.
  130795. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  130796. */
  130797. defaultHeightCompensation: number;
  130798. /**
  130799. * Fires every time a new xrFrame arrives which can be used to update the camera
  130800. */
  130801. onXRFrameObservable: Observable<XRFrame>;
  130802. /**
  130803. * Fires when the reference space changed
  130804. */
  130805. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  130806. /**
  130807. * Fires when the xr session is ended either by the device or manually done
  130808. */
  130809. onXRSessionEnded: Observable<any>;
  130810. /**
  130811. * Fires when the xr session is ended either by the device or manually done
  130812. */
  130813. onXRSessionInit: Observable<XRSession>;
  130814. /**
  130815. * Underlying xr session
  130816. */
  130817. session: XRSession;
  130818. /**
  130819. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  130820. * or get the offset the player is currently at.
  130821. */
  130822. viewerReferenceSpace: XRReferenceSpace;
  130823. /**
  130824. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  130825. * @param scene The scene which the session should be created for
  130826. */
  130827. constructor(
  130828. /** The scene which the session should be created for */
  130829. scene: Scene);
  130830. /**
  130831. * The current reference space used in this session. This reference space can constantly change!
  130832. * It is mainly used to offset the camera's position.
  130833. */
  130834. get referenceSpace(): XRReferenceSpace;
  130835. /**
  130836. * Set a new reference space and triggers the observable
  130837. */
  130838. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  130839. /**
  130840. * Disposes of the session manager
  130841. */
  130842. dispose(): void;
  130843. /**
  130844. * Stops the xrSession and restores the render loop
  130845. * @returns Promise which resolves after it exits XR
  130846. */
  130847. exitXRAsync(): Promise<void>;
  130848. /**
  130849. * Gets the correct render target texture to be rendered this frame for this eye
  130850. * @param eye the eye for which to get the render target
  130851. * @returns the render target for the specified eye
  130852. */
  130853. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  130854. /**
  130855. * Creates a WebXRRenderTarget object for the XR session
  130856. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  130857. * @param options optional options to provide when creating a new render target
  130858. * @returns a WebXR render target to which the session can render
  130859. */
  130860. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  130861. /**
  130862. * Initializes the manager
  130863. * After initialization enterXR can be called to start an XR session
  130864. * @returns Promise which resolves after it is initialized
  130865. */
  130866. initializeAsync(): Promise<void>;
  130867. /**
  130868. * Initializes an xr session
  130869. * @param xrSessionMode mode to initialize
  130870. * @param xrSessionInit defines optional and required values to pass to the session builder
  130871. * @returns a promise which will resolve once the session has been initialized
  130872. */
  130873. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  130874. /**
  130875. * Checks if a session would be supported for the creation options specified
  130876. * @param sessionMode session mode to check if supported eg. immersive-vr
  130877. * @returns A Promise that resolves to true if supported and false if not
  130878. */
  130879. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130880. /**
  130881. * Resets the reference space to the one started the session
  130882. */
  130883. resetReferenceSpace(): void;
  130884. /**
  130885. * Starts rendering to the xr layer
  130886. */
  130887. runXRRenderLoop(): void;
  130888. /**
  130889. * Sets the reference space on the xr session
  130890. * @param referenceSpaceType space to set
  130891. * @returns a promise that will resolve once the reference space has been set
  130892. */
  130893. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130894. /**
  130895. * Updates the render state of the session
  130896. * @param state state to set
  130897. * @returns a promise that resolves once the render state has been updated
  130898. */
  130899. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  130900. /**
  130901. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  130902. * @param sessionMode defines the session to test
  130903. * @returns a promise with boolean as final value
  130904. */
  130905. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130906. private _createRenderTargetTexture;
  130907. }
  130908. }
  130909. declare module BABYLON {
  130910. /**
  130911. * WebXR Camera which holds the views for the xrSession
  130912. * @see https://doc.babylonjs.com/how_to/webxr_camera
  130913. */
  130914. export class WebXRCamera extends FreeCamera {
  130915. private _xrSessionManager;
  130916. private _firstFrame;
  130917. private _referenceQuaternion;
  130918. private _referencedPosition;
  130919. private _xrInvPositionCache;
  130920. private _xrInvQuaternionCache;
  130921. private _trackingState;
  130922. /**
  130923. * Observable raised before camera teleportation
  130924. */
  130925. onBeforeCameraTeleport: Observable<Vector3>;
  130926. /**
  130927. * Observable raised after camera teleportation
  130928. */
  130929. onAfterCameraTeleport: Observable<Vector3>;
  130930. /**
  130931. * Notifies when the camera's tracking state has changed.
  130932. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  130933. */
  130934. onTrackingStateChanged: Observable<WebXRTrackingState>;
  130935. /**
  130936. * Should position compensation execute on first frame.
  130937. * This is used when copying the position from a native (non XR) camera
  130938. */
  130939. compensateOnFirstFrame: boolean;
  130940. /**
  130941. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  130942. * @param name the name of the camera
  130943. * @param scene the scene to add the camera to
  130944. * @param _xrSessionManager a constructed xr session manager
  130945. */
  130946. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  130947. /**
  130948. * Get the current XR tracking state of the camera
  130949. */
  130950. get trackingState(): WebXRTrackingState;
  130951. private _setTrackingState;
  130952. /**
  130953. * Return the user's height, unrelated to the current ground.
  130954. * This will be the y position of this camera, when ground level is 0.
  130955. */
  130956. get realWorldHeight(): number;
  130957. /** @hidden */
  130958. _updateForDualEyeDebugging(): void;
  130959. /**
  130960. * Sets this camera's transformation based on a non-vr camera
  130961. * @param otherCamera the non-vr camera to copy the transformation from
  130962. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  130963. */
  130964. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  130965. /**
  130966. * Gets the current instance class name ("WebXRCamera").
  130967. * @returns the class name
  130968. */
  130969. getClassName(): string;
  130970. private _rotate180;
  130971. private _updateFromXRSession;
  130972. private _updateNumberOfRigCameras;
  130973. private _updateReferenceSpace;
  130974. private _updateReferenceSpaceOffset;
  130975. }
  130976. }
  130977. declare module BABYLON {
  130978. /**
  130979. * Defining the interface required for a (webxr) feature
  130980. */
  130981. export interface IWebXRFeature extends IDisposable {
  130982. /**
  130983. * Is this feature attached
  130984. */
  130985. attached: boolean;
  130986. /**
  130987. * Should auto-attach be disabled?
  130988. */
  130989. disableAutoAttach: boolean;
  130990. /**
  130991. * Attach the feature to the session
  130992. * Will usually be called by the features manager
  130993. *
  130994. * @param force should attachment be forced (even when already attached)
  130995. * @returns true if successful.
  130996. */
  130997. attach(force?: boolean): boolean;
  130998. /**
  130999. * Detach the feature from the session
  131000. * Will usually be called by the features manager
  131001. *
  131002. * @returns true if successful.
  131003. */
  131004. detach(): boolean;
  131005. /**
  131006. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  131007. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  131008. *
  131009. * @returns whether or not the feature is compatible in this environment
  131010. */
  131011. isCompatible(): boolean;
  131012. /**
  131013. * Was this feature disposed;
  131014. */
  131015. isDisposed: boolean;
  131016. /**
  131017. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  131018. */
  131019. xrNativeFeatureName?: string;
  131020. /**
  131021. * A list of (Babylon WebXR) features this feature depends on
  131022. */
  131023. dependsOn?: string[];
  131024. }
  131025. /**
  131026. * A list of the currently available features without referencing them
  131027. */
  131028. export class WebXRFeatureName {
  131029. /**
  131030. * The name of the anchor system feature
  131031. */
  131032. static readonly ANCHOR_SYSTEM: string;
  131033. /**
  131034. * The name of the background remover feature
  131035. */
  131036. static readonly BACKGROUND_REMOVER: string;
  131037. /**
  131038. * The name of the hit test feature
  131039. */
  131040. static readonly HIT_TEST: string;
  131041. /**
  131042. * physics impostors for xr controllers feature
  131043. */
  131044. static readonly PHYSICS_CONTROLLERS: string;
  131045. /**
  131046. * The name of the plane detection feature
  131047. */
  131048. static readonly PLANE_DETECTION: string;
  131049. /**
  131050. * The name of the pointer selection feature
  131051. */
  131052. static readonly POINTER_SELECTION: string;
  131053. /**
  131054. * The name of the teleportation feature
  131055. */
  131056. static readonly TELEPORTATION: string;
  131057. /**
  131058. * The name of the feature points feature.
  131059. */
  131060. static readonly FEATURE_POINTS: string;
  131061. /**
  131062. * The name of the hand tracking feature.
  131063. */
  131064. static readonly HAND_TRACKING: string;
  131065. }
  131066. /**
  131067. * Defining the constructor of a feature. Used to register the modules.
  131068. */
  131069. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  131070. /**
  131071. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  131072. * It is mainly used in AR sessions.
  131073. *
  131074. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  131075. */
  131076. export class WebXRFeaturesManager implements IDisposable {
  131077. private _xrSessionManager;
  131078. private static readonly _AvailableFeatures;
  131079. private _features;
  131080. /**
  131081. * constructs a new features manages.
  131082. *
  131083. * @param _xrSessionManager an instance of WebXRSessionManager
  131084. */
  131085. constructor(_xrSessionManager: WebXRSessionManager);
  131086. /**
  131087. * Used to register a module. After calling this function a developer can use this feature in the scene.
  131088. * Mainly used internally.
  131089. *
  131090. * @param featureName the name of the feature to register
  131091. * @param constructorFunction the function used to construct the module
  131092. * @param version the (babylon) version of the module
  131093. * @param stable is that a stable version of this module
  131094. */
  131095. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  131096. /**
  131097. * Returns a constructor of a specific feature.
  131098. *
  131099. * @param featureName the name of the feature to construct
  131100. * @param version the version of the feature to load
  131101. * @param xrSessionManager the xrSessionManager. Used to construct the module
  131102. * @param options optional options provided to the module.
  131103. * @returns a function that, when called, will return a new instance of this feature
  131104. */
  131105. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  131106. /**
  131107. * Can be used to return the list of features currently registered
  131108. *
  131109. * @returns an Array of available features
  131110. */
  131111. static GetAvailableFeatures(): string[];
  131112. /**
  131113. * Gets the versions available for a specific feature
  131114. * @param featureName the name of the feature
  131115. * @returns an array with the available versions
  131116. */
  131117. static GetAvailableVersions(featureName: string): string[];
  131118. /**
  131119. * Return the latest unstable version of this feature
  131120. * @param featureName the name of the feature to search
  131121. * @returns the version number. if not found will return -1
  131122. */
  131123. static GetLatestVersionOfFeature(featureName: string): number;
  131124. /**
  131125. * Return the latest stable version of this feature
  131126. * @param featureName the name of the feature to search
  131127. * @returns the version number. if not found will return -1
  131128. */
  131129. static GetStableVersionOfFeature(featureName: string): number;
  131130. /**
  131131. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  131132. * Can be used during a session to start a feature
  131133. * @param featureName the name of feature to attach
  131134. */
  131135. attachFeature(featureName: string): void;
  131136. /**
  131137. * Can be used inside a session or when the session ends to detach a specific feature
  131138. * @param featureName the name of the feature to detach
  131139. */
  131140. detachFeature(featureName: string): void;
  131141. /**
  131142. * Used to disable an already-enabled feature
  131143. * The feature will be disposed and will be recreated once enabled.
  131144. * @param featureName the feature to disable
  131145. * @returns true if disable was successful
  131146. */
  131147. disableFeature(featureName: string | {
  131148. Name: string;
  131149. }): boolean;
  131150. /**
  131151. * dispose this features manager
  131152. */
  131153. dispose(): void;
  131154. /**
  131155. * 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.
  131156. * 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.
  131157. *
  131158. * @param featureName the name of the feature to load or the class of the feature
  131159. * @param version optional version to load. if not provided the latest version will be enabled
  131160. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  131161. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  131162. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  131163. * @returns a new constructed feature or throws an error if feature not found.
  131164. */
  131165. enableFeature(featureName: string | {
  131166. Name: string;
  131167. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  131168. /**
  131169. * get the implementation of an enabled feature.
  131170. * @param featureName the name of the feature to load
  131171. * @returns the feature class, if found
  131172. */
  131173. getEnabledFeature(featureName: string): IWebXRFeature;
  131174. /**
  131175. * Get the list of enabled features
  131176. * @returns an array of enabled features
  131177. */
  131178. getEnabledFeatures(): string[];
  131179. /**
  131180. * This function will exten the session creation configuration object with enabled features.
  131181. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  131182. * according to the defined "required" variable, provided during enableFeature call
  131183. * @param xrSessionInit the xr Session init object to extend
  131184. *
  131185. * @returns an extended XRSessionInit object
  131186. */
  131187. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  131188. }
  131189. }
  131190. declare module BABYLON {
  131191. /**
  131192. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  131193. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  131194. */
  131195. export class WebXRExperienceHelper implements IDisposable {
  131196. private scene;
  131197. private _nonVRCamera;
  131198. private _originalSceneAutoClear;
  131199. private _supported;
  131200. /**
  131201. * Camera used to render xr content
  131202. */
  131203. camera: WebXRCamera;
  131204. /** A features manager for this xr session */
  131205. featuresManager: WebXRFeaturesManager;
  131206. /**
  131207. * Observers registered here will be triggered after the camera's initial transformation is set
  131208. * This can be used to set a different ground level or an extra rotation.
  131209. *
  131210. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  131211. * to the position set after this observable is done executing.
  131212. */
  131213. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  131214. /**
  131215. * Fires when the state of the experience helper has changed
  131216. */
  131217. onStateChangedObservable: Observable<WebXRState>;
  131218. /** Session manager used to keep track of xr session */
  131219. sessionManager: WebXRSessionManager;
  131220. /**
  131221. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  131222. */
  131223. state: WebXRState;
  131224. /**
  131225. * Creates a WebXRExperienceHelper
  131226. * @param scene The scene the helper should be created in
  131227. */
  131228. private constructor();
  131229. /**
  131230. * Creates the experience helper
  131231. * @param scene the scene to attach the experience helper to
  131232. * @returns a promise for the experience helper
  131233. */
  131234. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  131235. /**
  131236. * Disposes of the experience helper
  131237. */
  131238. dispose(): void;
  131239. /**
  131240. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  131241. * @param sessionMode options for the XR session
  131242. * @param referenceSpaceType frame of reference of the XR session
  131243. * @param renderTarget the output canvas that will be used to enter XR mode
  131244. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  131245. * @returns promise that resolves after xr mode has entered
  131246. */
  131247. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  131248. /**
  131249. * Exits XR mode and returns the scene to its original state
  131250. * @returns promise that resolves after xr mode has exited
  131251. */
  131252. exitXRAsync(): Promise<void>;
  131253. private _nonXRToXRCamera;
  131254. private _setState;
  131255. }
  131256. }
  131257. declare module BABYLON {
  131258. /**
  131259. * X-Y values for axes in WebXR
  131260. */
  131261. export interface IWebXRMotionControllerAxesValue {
  131262. /**
  131263. * The value of the x axis
  131264. */
  131265. x: number;
  131266. /**
  131267. * The value of the y-axis
  131268. */
  131269. y: number;
  131270. }
  131271. /**
  131272. * changed / previous values for the values of this component
  131273. */
  131274. export interface IWebXRMotionControllerComponentChangesValues<T> {
  131275. /**
  131276. * current (this frame) value
  131277. */
  131278. current: T;
  131279. /**
  131280. * previous (last change) value
  131281. */
  131282. previous: T;
  131283. }
  131284. /**
  131285. * Represents changes in the component between current frame and last values recorded
  131286. */
  131287. export interface IWebXRMotionControllerComponentChanges {
  131288. /**
  131289. * will be populated with previous and current values if axes changed
  131290. */
  131291. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  131292. /**
  131293. * will be populated with previous and current values if pressed changed
  131294. */
  131295. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131296. /**
  131297. * will be populated with previous and current values if touched changed
  131298. */
  131299. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131300. /**
  131301. * will be populated with previous and current values if value changed
  131302. */
  131303. value?: IWebXRMotionControllerComponentChangesValues<number>;
  131304. }
  131305. /**
  131306. * This class represents a single component (for example button or thumbstick) of a motion controller
  131307. */
  131308. export class WebXRControllerComponent implements IDisposable {
  131309. /**
  131310. * the id of this component
  131311. */
  131312. id: string;
  131313. /**
  131314. * the type of the component
  131315. */
  131316. type: MotionControllerComponentType;
  131317. private _buttonIndex;
  131318. private _axesIndices;
  131319. private _axes;
  131320. private _changes;
  131321. private _currentValue;
  131322. private _hasChanges;
  131323. private _pressed;
  131324. private _touched;
  131325. /**
  131326. * button component type
  131327. */
  131328. static BUTTON_TYPE: MotionControllerComponentType;
  131329. /**
  131330. * squeeze component type
  131331. */
  131332. static SQUEEZE_TYPE: MotionControllerComponentType;
  131333. /**
  131334. * Thumbstick component type
  131335. */
  131336. static THUMBSTICK_TYPE: MotionControllerComponentType;
  131337. /**
  131338. * Touchpad component type
  131339. */
  131340. static TOUCHPAD_TYPE: MotionControllerComponentType;
  131341. /**
  131342. * trigger component type
  131343. */
  131344. static TRIGGER_TYPE: MotionControllerComponentType;
  131345. /**
  131346. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  131347. * the axes data changes
  131348. */
  131349. onAxisValueChangedObservable: Observable<{
  131350. x: number;
  131351. y: number;
  131352. }>;
  131353. /**
  131354. * Observers registered here will be triggered when the state of a button changes
  131355. * State change is either pressed / touched / value
  131356. */
  131357. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  131358. /**
  131359. * Creates a new component for a motion controller.
  131360. * It is created by the motion controller itself
  131361. *
  131362. * @param id the id of this component
  131363. * @param type the type of the component
  131364. * @param _buttonIndex index in the buttons array of the gamepad
  131365. * @param _axesIndices indices of the values in the axes array of the gamepad
  131366. */
  131367. constructor(
  131368. /**
  131369. * the id of this component
  131370. */
  131371. id: string,
  131372. /**
  131373. * the type of the component
  131374. */
  131375. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  131376. /**
  131377. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  131378. */
  131379. get axes(): IWebXRMotionControllerAxesValue;
  131380. /**
  131381. * Get the changes. Elements will be populated only if they changed with their previous and current value
  131382. */
  131383. get changes(): IWebXRMotionControllerComponentChanges;
  131384. /**
  131385. * Return whether or not the component changed the last frame
  131386. */
  131387. get hasChanges(): boolean;
  131388. /**
  131389. * is the button currently pressed
  131390. */
  131391. get pressed(): boolean;
  131392. /**
  131393. * is the button currently touched
  131394. */
  131395. get touched(): boolean;
  131396. /**
  131397. * Get the current value of this component
  131398. */
  131399. get value(): number;
  131400. /**
  131401. * Dispose this component
  131402. */
  131403. dispose(): void;
  131404. /**
  131405. * Are there axes correlating to this component
  131406. * @return true is axes data is available
  131407. */
  131408. isAxes(): boolean;
  131409. /**
  131410. * Is this component a button (hence - pressable)
  131411. * @returns true if can be pressed
  131412. */
  131413. isButton(): boolean;
  131414. /**
  131415. * update this component using the gamepad object it is in. Called on every frame
  131416. * @param nativeController the native gamepad controller object
  131417. */
  131418. update(nativeController: IMinimalMotionControllerObject): void;
  131419. }
  131420. }
  131421. declare module BABYLON {
  131422. /**
  131423. * Interface used to represent data loading progression
  131424. */
  131425. export interface ISceneLoaderProgressEvent {
  131426. /**
  131427. * Defines if data length to load can be evaluated
  131428. */
  131429. readonly lengthComputable: boolean;
  131430. /**
  131431. * Defines the loaded data length
  131432. */
  131433. readonly loaded: number;
  131434. /**
  131435. * Defines the data length to load
  131436. */
  131437. readonly total: number;
  131438. }
  131439. /**
  131440. * Interface used by SceneLoader plugins to define supported file extensions
  131441. */
  131442. export interface ISceneLoaderPluginExtensions {
  131443. /**
  131444. * Defines the list of supported extensions
  131445. */
  131446. [extension: string]: {
  131447. isBinary: boolean;
  131448. };
  131449. }
  131450. /**
  131451. * Interface used by SceneLoader plugin factory
  131452. */
  131453. export interface ISceneLoaderPluginFactory {
  131454. /**
  131455. * Defines the name of the factory
  131456. */
  131457. name: string;
  131458. /**
  131459. * Function called to create a new plugin
  131460. * @return the new plugin
  131461. */
  131462. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  131463. /**
  131464. * The callback that returns true if the data can be directly loaded.
  131465. * @param data string containing the file data
  131466. * @returns if the data can be loaded directly
  131467. */
  131468. canDirectLoad?(data: string): boolean;
  131469. }
  131470. /**
  131471. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  131472. */
  131473. export interface ISceneLoaderPluginBase {
  131474. /**
  131475. * The friendly name of this plugin.
  131476. */
  131477. name: string;
  131478. /**
  131479. * The file extensions supported by this plugin.
  131480. */
  131481. extensions: string | ISceneLoaderPluginExtensions;
  131482. /**
  131483. * The callback called when loading from a url.
  131484. * @param scene scene loading this url
  131485. * @param url url to load
  131486. * @param onSuccess callback called when the file successfully loads
  131487. * @param onProgress callback called while file is loading (if the server supports this mode)
  131488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  131489. * @param onError callback called when the file fails to load
  131490. * @returns a file request object
  131491. */
  131492. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131493. /**
  131494. * The callback called when loading from a file object.
  131495. * @param scene scene loading this file
  131496. * @param file defines the file to load
  131497. * @param onSuccess defines the callback to call when data is loaded
  131498. * @param onProgress defines the callback to call during loading process
  131499. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  131500. * @param onError defines the callback to call when an error occurs
  131501. * @returns a file request object
  131502. */
  131503. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131504. /**
  131505. * The callback that returns true if the data can be directly loaded.
  131506. * @param data string containing the file data
  131507. * @returns if the data can be loaded directly
  131508. */
  131509. canDirectLoad?(data: string): boolean;
  131510. /**
  131511. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  131512. * @param scene scene loading this data
  131513. * @param data string containing the data
  131514. * @returns data to pass to the plugin
  131515. */
  131516. directLoad?(scene: Scene, data: string): any;
  131517. /**
  131518. * The callback that allows custom handling of the root url based on the response url.
  131519. * @param rootUrl the original root url
  131520. * @param responseURL the response url if available
  131521. * @returns the new root url
  131522. */
  131523. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  131524. }
  131525. /**
  131526. * Interface used to define a SceneLoader plugin
  131527. */
  131528. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  131529. /**
  131530. * Import meshes into a scene.
  131531. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131532. * @param scene The scene to import into
  131533. * @param data The data to import
  131534. * @param rootUrl The root url for scene and resources
  131535. * @param meshes The meshes array to import into
  131536. * @param particleSystems The particle systems array to import into
  131537. * @param skeletons The skeletons array to import into
  131538. * @param onError The callback when import fails
  131539. * @returns True if successful or false otherwise
  131540. */
  131541. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  131542. /**
  131543. * Load into a scene.
  131544. * @param scene The scene to load into
  131545. * @param data The data to import
  131546. * @param rootUrl The root url for scene and resources
  131547. * @param onError The callback when import fails
  131548. * @returns True if successful or false otherwise
  131549. */
  131550. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  131551. /**
  131552. * Load into an asset container.
  131553. * @param scene The scene to load into
  131554. * @param data The data to import
  131555. * @param rootUrl The root url for scene and resources
  131556. * @param onError The callback when import fails
  131557. * @returns The loaded asset container
  131558. */
  131559. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  131560. }
  131561. /**
  131562. * Interface used to define an async SceneLoader plugin
  131563. */
  131564. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  131565. /**
  131566. * Import meshes into a scene.
  131567. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131568. * @param scene The scene to import into
  131569. * @param data The data to import
  131570. * @param rootUrl The root url for scene and resources
  131571. * @param onProgress The callback when the load progresses
  131572. * @param fileName Defines the name of the file to load
  131573. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  131574. */
  131575. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  131576. meshes: AbstractMesh[];
  131577. particleSystems: IParticleSystem[];
  131578. skeletons: Skeleton[];
  131579. animationGroups: AnimationGroup[];
  131580. }>;
  131581. /**
  131582. * Load into a scene.
  131583. * @param scene The scene to load into
  131584. * @param data The data to import
  131585. * @param rootUrl The root url for scene and resources
  131586. * @param onProgress The callback when the load progresses
  131587. * @param fileName Defines the name of the file to load
  131588. * @returns Nothing
  131589. */
  131590. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  131591. /**
  131592. * Load into an asset container.
  131593. * @param scene The scene to load into
  131594. * @param data The data to import
  131595. * @param rootUrl The root url for scene and resources
  131596. * @param onProgress The callback when the load progresses
  131597. * @param fileName Defines the name of the file to load
  131598. * @returns The loaded asset container
  131599. */
  131600. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  131601. }
  131602. /**
  131603. * Mode that determines how to handle old animation groups before loading new ones.
  131604. */
  131605. export enum SceneLoaderAnimationGroupLoadingMode {
  131606. /**
  131607. * Reset all old animations to initial state then dispose them.
  131608. */
  131609. Clean = 0,
  131610. /**
  131611. * Stop all old animations.
  131612. */
  131613. Stop = 1,
  131614. /**
  131615. * Restart old animations from first frame.
  131616. */
  131617. Sync = 2,
  131618. /**
  131619. * Old animations remains untouched.
  131620. */
  131621. NoSync = 3
  131622. }
  131623. /**
  131624. * Defines a plugin registered by the SceneLoader
  131625. */
  131626. interface IRegisteredPlugin {
  131627. /**
  131628. * Defines the plugin to use
  131629. */
  131630. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131631. /**
  131632. * Defines if the plugin supports binary data
  131633. */
  131634. isBinary: boolean;
  131635. }
  131636. /**
  131637. * Class used to load scene from various file formats using registered plugins
  131638. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  131639. */
  131640. export class SceneLoader {
  131641. /**
  131642. * No logging while loading
  131643. */
  131644. static readonly NO_LOGGING: number;
  131645. /**
  131646. * Minimal logging while loading
  131647. */
  131648. static readonly MINIMAL_LOGGING: number;
  131649. /**
  131650. * Summary logging while loading
  131651. */
  131652. static readonly SUMMARY_LOGGING: number;
  131653. /**
  131654. * Detailled logging while loading
  131655. */
  131656. static readonly DETAILED_LOGGING: number;
  131657. /**
  131658. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  131659. */
  131660. static get ForceFullSceneLoadingForIncremental(): boolean;
  131661. static set ForceFullSceneLoadingForIncremental(value: boolean);
  131662. /**
  131663. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  131664. */
  131665. static get ShowLoadingScreen(): boolean;
  131666. static set ShowLoadingScreen(value: boolean);
  131667. /**
  131668. * Defines the current logging level (while loading the scene)
  131669. * @ignorenaming
  131670. */
  131671. static get loggingLevel(): number;
  131672. static set loggingLevel(value: number);
  131673. /**
  131674. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  131675. */
  131676. static get CleanBoneMatrixWeights(): boolean;
  131677. static set CleanBoneMatrixWeights(value: boolean);
  131678. /**
  131679. * Event raised when a plugin is used to load a scene
  131680. */
  131681. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  131682. private static _registeredPlugins;
  131683. private static _showingLoadingScreen;
  131684. /**
  131685. * Gets the default plugin (used to load Babylon files)
  131686. * @returns the .babylon plugin
  131687. */
  131688. static GetDefaultPlugin(): IRegisteredPlugin;
  131689. private static _GetPluginForExtension;
  131690. private static _GetPluginForDirectLoad;
  131691. private static _GetPluginForFilename;
  131692. private static _GetDirectLoad;
  131693. private static _LoadData;
  131694. private static _GetFileInfo;
  131695. /**
  131696. * Gets a plugin that can load the given extension
  131697. * @param extension defines the extension to load
  131698. * @returns a plugin or null if none works
  131699. */
  131700. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131701. /**
  131702. * Gets a boolean indicating that the given extension can be loaded
  131703. * @param extension defines the extension to load
  131704. * @returns true if the extension is supported
  131705. */
  131706. static IsPluginForExtensionAvailable(extension: string): boolean;
  131707. /**
  131708. * Adds a new plugin to the list of registered plugins
  131709. * @param plugin defines the plugin to add
  131710. */
  131711. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  131712. /**
  131713. * Import meshes into a scene
  131714. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131715. * @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)
  131716. * @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)
  131717. * @param scene the instance of BABYLON.Scene to append to
  131718. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  131719. * @param onProgress a callback with a progress event for each file being loaded
  131720. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131721. * @param pluginExtension the extension used to determine the plugin
  131722. * @returns The loaded plugin
  131723. */
  131724. 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>;
  131725. /**
  131726. * Import meshes into a scene
  131727. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131728. * @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)
  131729. * @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)
  131730. * @param scene the instance of BABYLON.Scene to append to
  131731. * @param onProgress a callback with a progress event for each file being loaded
  131732. * @param pluginExtension the extension used to determine the plugin
  131733. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  131734. */
  131735. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  131736. meshes: AbstractMesh[];
  131737. particleSystems: IParticleSystem[];
  131738. skeletons: Skeleton[];
  131739. animationGroups: AnimationGroup[];
  131740. }>;
  131741. /**
  131742. * Load a scene
  131743. * @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)
  131744. * @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)
  131745. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131746. * @param onSuccess a callback with the scene when import succeeds
  131747. * @param onProgress a callback with a progress event for each file being loaded
  131748. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131749. * @param pluginExtension the extension used to determine the plugin
  131750. * @returns The loaded plugin
  131751. */
  131752. 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>;
  131753. /**
  131754. * Load a scene
  131755. * @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)
  131756. * @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)
  131757. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131758. * @param onProgress a callback with a progress event for each file being loaded
  131759. * @param pluginExtension the extension used to determine the plugin
  131760. * @returns The loaded scene
  131761. */
  131762. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131763. /**
  131764. * Append a scene
  131765. * @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)
  131766. * @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)
  131767. * @param scene is the instance of BABYLON.Scene to append to
  131768. * @param onSuccess a callback with the scene when import succeeds
  131769. * @param onProgress a callback with a progress event for each file being loaded
  131770. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131771. * @param pluginExtension the extension used to determine the plugin
  131772. * @returns The loaded plugin
  131773. */
  131774. 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>;
  131775. /**
  131776. * Append a scene
  131777. * @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)
  131778. * @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)
  131779. * @param scene is the instance of BABYLON.Scene to append to
  131780. * @param onProgress a callback with a progress event for each file being loaded
  131781. * @param pluginExtension the extension used to determine the plugin
  131782. * @returns The given scene
  131783. */
  131784. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131785. /**
  131786. * Load a scene into an asset container
  131787. * @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)
  131788. * @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)
  131789. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131790. * @param onSuccess a callback with the scene when import succeeds
  131791. * @param onProgress a callback with a progress event for each file being loaded
  131792. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131793. * @param pluginExtension the extension used to determine the plugin
  131794. * @returns The loaded plugin
  131795. */
  131796. 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>;
  131797. /**
  131798. * Load a scene into an asset container
  131799. * @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)
  131800. * @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)
  131801. * @param scene is the instance of Scene to append to
  131802. * @param onProgress a callback with a progress event for each file being loaded
  131803. * @param pluginExtension the extension used to determine the plugin
  131804. * @returns The loaded asset container
  131805. */
  131806. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  131807. /**
  131808. * Import animations from a file into a scene
  131809. * @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)
  131810. * @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)
  131811. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131812. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131813. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131814. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131815. * @param onSuccess a callback with the scene when import succeeds
  131816. * @param onProgress a callback with a progress event for each file being loaded
  131817. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131818. * @param pluginExtension the extension used to determine the plugin
  131819. */
  131820. 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;
  131821. /**
  131822. * Import animations from a file into a scene
  131823. * @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)
  131824. * @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)
  131825. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131826. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131827. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131828. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131829. * @param onSuccess a callback with the scene when import succeeds
  131830. * @param onProgress a callback with a progress event for each file being loaded
  131831. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131832. * @param pluginExtension the extension used to determine the plugin
  131833. * @returns the updated scene with imported animations
  131834. */
  131835. 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>;
  131836. }
  131837. }
  131838. declare module BABYLON {
  131839. /**
  131840. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  131841. */
  131842. export type MotionControllerHandedness = "none" | "left" | "right";
  131843. /**
  131844. * The type of components available in motion controllers.
  131845. * This is not the name of the component.
  131846. */
  131847. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  131848. /**
  131849. * The state of a controller component
  131850. */
  131851. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  131852. /**
  131853. * The schema of motion controller layout.
  131854. * No object will be initialized using this interface
  131855. * This is used just to define the profile.
  131856. */
  131857. export interface IMotionControllerLayout {
  131858. /**
  131859. * Path to load the assets. Usually relative to the base path
  131860. */
  131861. assetPath: string;
  131862. /**
  131863. * Available components (unsorted)
  131864. */
  131865. components: {
  131866. /**
  131867. * A map of component Ids
  131868. */
  131869. [componentId: string]: {
  131870. /**
  131871. * The type of input the component outputs
  131872. */
  131873. type: MotionControllerComponentType;
  131874. /**
  131875. * The indices of this component in the gamepad object
  131876. */
  131877. gamepadIndices: {
  131878. /**
  131879. * Index of button
  131880. */
  131881. button?: number;
  131882. /**
  131883. * If available, index of x-axis
  131884. */
  131885. xAxis?: number;
  131886. /**
  131887. * If available, index of y-axis
  131888. */
  131889. yAxis?: number;
  131890. };
  131891. /**
  131892. * The mesh's root node name
  131893. */
  131894. rootNodeName: string;
  131895. /**
  131896. * Animation definitions for this model
  131897. */
  131898. visualResponses: {
  131899. [stateKey: string]: {
  131900. /**
  131901. * What property will be animated
  131902. */
  131903. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  131904. /**
  131905. * What states influence this visual response
  131906. */
  131907. states: MotionControllerComponentStateType[];
  131908. /**
  131909. * Type of animation - movement or visibility
  131910. */
  131911. valueNodeProperty: "transform" | "visibility";
  131912. /**
  131913. * Base node name to move. Its position will be calculated according to the min and max nodes
  131914. */
  131915. valueNodeName?: string;
  131916. /**
  131917. * Minimum movement node
  131918. */
  131919. minNodeName?: string;
  131920. /**
  131921. * Max movement node
  131922. */
  131923. maxNodeName?: string;
  131924. };
  131925. };
  131926. /**
  131927. * If touch enabled, what is the name of node to display user feedback
  131928. */
  131929. touchPointNodeName?: string;
  131930. };
  131931. };
  131932. /**
  131933. * Is it xr standard mapping or not
  131934. */
  131935. gamepadMapping: "" | "xr-standard";
  131936. /**
  131937. * Base root node of this entire model
  131938. */
  131939. rootNodeName: string;
  131940. /**
  131941. * Defines the main button component id
  131942. */
  131943. selectComponentId: string;
  131944. }
  131945. /**
  131946. * A definition for the layout map in the input profile
  131947. */
  131948. export interface IMotionControllerLayoutMap {
  131949. /**
  131950. * Layouts with handedness type as a key
  131951. */
  131952. [handedness: string]: IMotionControllerLayout;
  131953. }
  131954. /**
  131955. * The XR Input profile schema
  131956. * Profiles can be found here:
  131957. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  131958. */
  131959. export interface IMotionControllerProfile {
  131960. /**
  131961. * fallback profiles for this profileId
  131962. */
  131963. fallbackProfileIds: string[];
  131964. /**
  131965. * The layout map, with handedness as key
  131966. */
  131967. layouts: IMotionControllerLayoutMap;
  131968. /**
  131969. * The id of this profile
  131970. * correlates to the profile(s) in the xrInput.profiles array
  131971. */
  131972. profileId: string;
  131973. }
  131974. /**
  131975. * A helper-interface for the 3 meshes needed for controller button animation
  131976. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  131977. */
  131978. export interface IMotionControllerButtonMeshMap {
  131979. /**
  131980. * the mesh that defines the pressed value mesh position.
  131981. * This is used to find the max-position of this button
  131982. */
  131983. pressedMesh: AbstractMesh;
  131984. /**
  131985. * the mesh that defines the unpressed value mesh position.
  131986. * This is used to find the min (or initial) position of this button
  131987. */
  131988. unpressedMesh: AbstractMesh;
  131989. /**
  131990. * The mesh that will be changed when value changes
  131991. */
  131992. valueMesh: AbstractMesh;
  131993. }
  131994. /**
  131995. * A helper-interface for the 3 meshes needed for controller axis animation.
  131996. * This will be expanded when touchpad animations are fully supported
  131997. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  131998. */
  131999. export interface IMotionControllerMeshMap {
  132000. /**
  132001. * the mesh that defines the maximum value mesh position.
  132002. */
  132003. maxMesh?: AbstractMesh;
  132004. /**
  132005. * the mesh that defines the minimum value mesh position.
  132006. */
  132007. minMesh?: AbstractMesh;
  132008. /**
  132009. * The mesh that will be changed when axis value changes
  132010. */
  132011. valueMesh?: AbstractMesh;
  132012. }
  132013. /**
  132014. * The elements needed for change-detection of the gamepad objects in motion controllers
  132015. */
  132016. export interface IMinimalMotionControllerObject {
  132017. /**
  132018. * Available axes of this controller
  132019. */
  132020. axes: number[];
  132021. /**
  132022. * An array of available buttons
  132023. */
  132024. buttons: Array<{
  132025. /**
  132026. * Value of the button/trigger
  132027. */
  132028. value: number;
  132029. /**
  132030. * If the button/trigger is currently touched
  132031. */
  132032. touched: boolean;
  132033. /**
  132034. * If the button/trigger is currently pressed
  132035. */
  132036. pressed: boolean;
  132037. }>;
  132038. /**
  132039. * EXPERIMENTAL haptic support.
  132040. */
  132041. hapticActuators?: Array<{
  132042. pulse: (value: number, duration: number) => Promise<boolean>;
  132043. }>;
  132044. }
  132045. /**
  132046. * An Abstract Motion controller
  132047. * This class receives an xrInput and a profile layout and uses those to initialize the components
  132048. * Each component has an observable to check for changes in value and state
  132049. */
  132050. export abstract class WebXRAbstractMotionController implements IDisposable {
  132051. protected scene: Scene;
  132052. protected layout: IMotionControllerLayout;
  132053. /**
  132054. * The gamepad object correlating to this controller
  132055. */
  132056. gamepadObject: IMinimalMotionControllerObject;
  132057. /**
  132058. * handedness (left/right/none) of this controller
  132059. */
  132060. handedness: MotionControllerHandedness;
  132061. private _initComponent;
  132062. private _modelReady;
  132063. /**
  132064. * A map of components (WebXRControllerComponent) in this motion controller
  132065. * Components have a ComponentType and can also have both button and axis definitions
  132066. */
  132067. readonly components: {
  132068. [id: string]: WebXRControllerComponent;
  132069. };
  132070. /**
  132071. * Disable the model's animation. Can be set at any time.
  132072. */
  132073. disableAnimation: boolean;
  132074. /**
  132075. * Observers registered here will be triggered when the model of this controller is done loading
  132076. */
  132077. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  132078. /**
  132079. * The profile id of this motion controller
  132080. */
  132081. abstract profileId: string;
  132082. /**
  132083. * The root mesh of the model. It is null if the model was not yet initialized
  132084. */
  132085. rootMesh: Nullable<AbstractMesh>;
  132086. /**
  132087. * constructs a new abstract motion controller
  132088. * @param scene the scene to which the model of the controller will be added
  132089. * @param layout The profile layout to load
  132090. * @param gamepadObject The gamepad object correlating to this controller
  132091. * @param handedness handedness (left/right/none) of this controller
  132092. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  132093. */
  132094. constructor(scene: Scene, layout: IMotionControllerLayout,
  132095. /**
  132096. * The gamepad object correlating to this controller
  132097. */
  132098. gamepadObject: IMinimalMotionControllerObject,
  132099. /**
  132100. * handedness (left/right/none) of this controller
  132101. */
  132102. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  132103. /**
  132104. * Dispose this controller, the model mesh and all its components
  132105. */
  132106. dispose(): void;
  132107. /**
  132108. * Returns all components of specific type
  132109. * @param type the type to search for
  132110. * @return an array of components with this type
  132111. */
  132112. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  132113. /**
  132114. * get a component based an its component id as defined in layout.components
  132115. * @param id the id of the component
  132116. * @returns the component correlates to the id or undefined if not found
  132117. */
  132118. getComponent(id: string): WebXRControllerComponent;
  132119. /**
  132120. * Get the list of components available in this motion controller
  132121. * @returns an array of strings correlating to available components
  132122. */
  132123. getComponentIds(): string[];
  132124. /**
  132125. * Get the first component of specific type
  132126. * @param type type of component to find
  132127. * @return a controller component or null if not found
  132128. */
  132129. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  132130. /**
  132131. * Get the main (Select) component of this controller as defined in the layout
  132132. * @returns the main component of this controller
  132133. */
  132134. getMainComponent(): WebXRControllerComponent;
  132135. /**
  132136. * Loads the model correlating to this controller
  132137. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  132138. * @returns A promise fulfilled with the result of the model loading
  132139. */
  132140. loadModel(): Promise<boolean>;
  132141. /**
  132142. * Update this model using the current XRFrame
  132143. * @param xrFrame the current xr frame to use and update the model
  132144. */
  132145. updateFromXRFrame(xrFrame: XRFrame): void;
  132146. /**
  132147. * Backwards compatibility due to a deeply-integrated typo
  132148. */
  132149. get handness(): XREye;
  132150. /**
  132151. * Pulse (vibrate) this controller
  132152. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  132153. * Consecutive calls to this function will cancel the last pulse call
  132154. *
  132155. * @param value the strength of the pulse in 0.0...1.0 range
  132156. * @param duration Duration of the pulse in milliseconds
  132157. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  132158. * @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
  132159. */
  132160. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  132161. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132162. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132163. /**
  132164. * Moves the axis on the controller mesh based on its current state
  132165. * @param axis the index of the axis
  132166. * @param axisValue the value of the axis which determines the meshes new position
  132167. * @hidden
  132168. */
  132169. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  132170. /**
  132171. * Update the model itself with the current frame data
  132172. * @param xrFrame the frame to use for updating the model mesh
  132173. */
  132174. protected updateModel(xrFrame: XRFrame): void;
  132175. /**
  132176. * Get the filename and path for this controller's model
  132177. * @returns a map of filename and path
  132178. */
  132179. protected abstract _getFilenameAndPath(): {
  132180. filename: string;
  132181. path: string;
  132182. };
  132183. /**
  132184. * This function is called before the mesh is loaded. It checks for loading constraints.
  132185. * For example, this function can check if the GLB loader is available
  132186. * If this function returns false, the generic controller will be loaded instead
  132187. * @returns Is the client ready to load the mesh
  132188. */
  132189. protected abstract _getModelLoadingConstraints(): boolean;
  132190. /**
  132191. * This function will be called after the model was successfully loaded and can be used
  132192. * for mesh transformations before it is available for the user
  132193. * @param meshes the loaded meshes
  132194. */
  132195. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  132196. /**
  132197. * Set the root mesh for this controller. Important for the WebXR controller class
  132198. * @param meshes the loaded meshes
  132199. */
  132200. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  132201. /**
  132202. * A function executed each frame that updates the mesh (if needed)
  132203. * @param xrFrame the current xrFrame
  132204. */
  132205. protected abstract _updateModel(xrFrame: XRFrame): void;
  132206. private _getGenericFilenameAndPath;
  132207. private _getGenericParentMesh;
  132208. }
  132209. }
  132210. declare module BABYLON {
  132211. /**
  132212. * A generic trigger-only motion controller for WebXR
  132213. */
  132214. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  132215. /**
  132216. * Static version of the profile id of this controller
  132217. */
  132218. static ProfileId: string;
  132219. profileId: string;
  132220. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  132221. protected _getFilenameAndPath(): {
  132222. filename: string;
  132223. path: string;
  132224. };
  132225. protected _getModelLoadingConstraints(): boolean;
  132226. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  132227. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132228. protected _updateModel(): void;
  132229. }
  132230. }
  132231. declare module BABYLON {
  132232. /**
  132233. * Class containing static functions to help procedurally build meshes
  132234. */
  132235. export class SphereBuilder {
  132236. /**
  132237. * Creates a sphere mesh
  132238. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  132239. * * 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`)
  132240. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  132241. * * 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
  132242. * * 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)
  132243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132246. * @param name defines the name of the mesh
  132247. * @param options defines the options used to create the mesh
  132248. * @param scene defines the hosting scene
  132249. * @returns the sphere mesh
  132250. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  132251. */
  132252. static CreateSphere(name: string, options: {
  132253. segments?: number;
  132254. diameter?: number;
  132255. diameterX?: number;
  132256. diameterY?: number;
  132257. diameterZ?: number;
  132258. arc?: number;
  132259. slice?: number;
  132260. sideOrientation?: number;
  132261. frontUVs?: Vector4;
  132262. backUVs?: Vector4;
  132263. updatable?: boolean;
  132264. }, scene?: Nullable<Scene>): Mesh;
  132265. }
  132266. }
  132267. declare module BABYLON {
  132268. /**
  132269. * A profiled motion controller has its profile loaded from an online repository.
  132270. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  132271. */
  132272. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  132273. private _repositoryUrl;
  132274. private _buttonMeshMapping;
  132275. private _touchDots;
  132276. /**
  132277. * The profile ID of this controller. Will be populated when the controller initializes.
  132278. */
  132279. profileId: string;
  132280. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  132281. dispose(): void;
  132282. protected _getFilenameAndPath(): {
  132283. filename: string;
  132284. path: string;
  132285. };
  132286. protected _getModelLoadingConstraints(): boolean;
  132287. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  132288. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132289. protected _updateModel(_xrFrame: XRFrame): void;
  132290. }
  132291. }
  132292. declare module BABYLON {
  132293. /**
  132294. * A construction function type to create a new controller based on an xrInput object
  132295. */
  132296. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  132297. /**
  132298. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  132299. *
  132300. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  132301. * it should be replaced with auto-loaded controllers.
  132302. *
  132303. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  132304. */
  132305. export class WebXRMotionControllerManager {
  132306. private static _AvailableControllers;
  132307. private static _Fallbacks;
  132308. private static _ProfileLoadingPromises;
  132309. private static _ProfilesList;
  132310. /**
  132311. * The base URL of the online controller repository. Can be changed at any time.
  132312. */
  132313. static BaseRepositoryUrl: string;
  132314. /**
  132315. * Which repository gets priority - local or online
  132316. */
  132317. static PrioritizeOnlineRepository: boolean;
  132318. /**
  132319. * Use the online repository, or use only locally-defined controllers
  132320. */
  132321. static UseOnlineRepository: boolean;
  132322. /**
  132323. * Clear the cache used for profile loading and reload when requested again
  132324. */
  132325. static ClearProfilesCache(): void;
  132326. /**
  132327. * Register the default fallbacks.
  132328. * This function is called automatically when this file is imported.
  132329. */
  132330. static DefaultFallbacks(): void;
  132331. /**
  132332. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  132333. * @param profileId the profile to which a fallback needs to be found
  132334. * @return an array with corresponding fallback profiles
  132335. */
  132336. static FindFallbackWithProfileId(profileId: string): string[];
  132337. /**
  132338. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  132339. * The order of search:
  132340. *
  132341. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  132342. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  132343. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  132344. * 4) return the generic trigger controller if none were found
  132345. *
  132346. * @param xrInput the xrInput to which a new controller is initialized
  132347. * @param scene the scene to which the model will be added
  132348. * @param forceProfile force a certain profile for this controller
  132349. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  132350. */
  132351. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  132352. /**
  132353. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  132354. *
  132355. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  132356. *
  132357. * @param type the profile type to register
  132358. * @param constructFunction the function to be called when loading this profile
  132359. */
  132360. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  132361. /**
  132362. * Register a fallback to a specific profile.
  132363. * @param profileId the profileId that will receive the fallbacks
  132364. * @param fallbacks A list of fallback profiles
  132365. */
  132366. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  132367. /**
  132368. * Will update the list of profiles available in the repository
  132369. * @return a promise that resolves to a map of profiles available online
  132370. */
  132371. static UpdateProfilesList(): Promise<{
  132372. [profile: string]: string;
  132373. }>;
  132374. private static _LoadProfileFromRepository;
  132375. private static _LoadProfilesFromAvailableControllers;
  132376. }
  132377. }
  132378. declare module BABYLON {
  132379. /**
  132380. * Configuration options for the WebXR controller creation
  132381. */
  132382. export interface IWebXRControllerOptions {
  132383. /**
  132384. * Should the controller mesh be animated when a user interacts with it
  132385. * The pressed buttons / thumbstick and touchpad animations will be disabled
  132386. */
  132387. disableMotionControllerAnimation?: boolean;
  132388. /**
  132389. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  132390. */
  132391. doNotLoadControllerMesh?: boolean;
  132392. /**
  132393. * Force a specific controller type for this controller.
  132394. * This can be used when creating your own profile or when testing different controllers
  132395. */
  132396. forceControllerProfile?: string;
  132397. /**
  132398. * Defines a rendering group ID for meshes that will be loaded.
  132399. * This is for the default controllers only.
  132400. */
  132401. renderingGroupId?: number;
  132402. }
  132403. /**
  132404. * Represents an XR controller
  132405. */
  132406. export class WebXRInputSource {
  132407. private _scene;
  132408. /** The underlying input source for the controller */
  132409. inputSource: XRInputSource;
  132410. private _options;
  132411. private _tmpVector;
  132412. private _uniqueId;
  132413. private _disposed;
  132414. /**
  132415. * 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
  132416. */
  132417. grip?: AbstractMesh;
  132418. /**
  132419. * If available, this is the gamepad object related to this controller.
  132420. * Using this object it is possible to get click events and trackpad changes of the
  132421. * webxr controller that is currently being used.
  132422. */
  132423. motionController?: WebXRAbstractMotionController;
  132424. /**
  132425. * Event that fires when the controller is removed/disposed.
  132426. * The object provided as event data is this controller, after associated assets were disposed.
  132427. * uniqueId is still available.
  132428. */
  132429. onDisposeObservable: Observable<WebXRInputSource>;
  132430. /**
  132431. * Will be triggered when the mesh associated with the motion controller is done loading.
  132432. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  132433. * A shortened version of controller -> motion controller -> on mesh loaded.
  132434. */
  132435. onMeshLoadedObservable: Observable<AbstractMesh>;
  132436. /**
  132437. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  132438. */
  132439. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  132440. /**
  132441. * Pointer which can be used to select objects or attach a visible laser to
  132442. */
  132443. pointer: AbstractMesh;
  132444. /**
  132445. * Creates the input source object
  132446. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  132447. * @param _scene the scene which the controller should be associated to
  132448. * @param inputSource the underlying input source for the controller
  132449. * @param _options options for this controller creation
  132450. */
  132451. constructor(_scene: Scene,
  132452. /** The underlying input source for the controller */
  132453. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  132454. /**
  132455. * Get this controllers unique id
  132456. */
  132457. get uniqueId(): string;
  132458. /**
  132459. * Disposes of the object
  132460. */
  132461. dispose(): void;
  132462. /**
  132463. * Gets a world space ray coming from the pointer or grip
  132464. * @param result the resulting ray
  132465. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  132466. */
  132467. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  132468. /**
  132469. * Updates the controller pose based on the given XRFrame
  132470. * @param xrFrame xr frame to update the pose with
  132471. * @param referenceSpace reference space to use
  132472. */
  132473. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  132474. }
  132475. }
  132476. declare module BABYLON {
  132477. /**
  132478. * The schema for initialization options of the XR Input class
  132479. */
  132480. export interface IWebXRInputOptions {
  132481. /**
  132482. * If set to true no model will be automatically loaded
  132483. */
  132484. doNotLoadControllerMeshes?: boolean;
  132485. /**
  132486. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  132487. * If not found, the xr input profile data will be used.
  132488. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  132489. */
  132490. forceInputProfile?: string;
  132491. /**
  132492. * Do not send a request to the controller repository to load the profile.
  132493. *
  132494. * Instead, use the controllers available in babylon itself.
  132495. */
  132496. disableOnlineControllerRepository?: boolean;
  132497. /**
  132498. * A custom URL for the controllers repository
  132499. */
  132500. customControllersRepositoryURL?: string;
  132501. /**
  132502. * Should the controller model's components not move according to the user input
  132503. */
  132504. disableControllerAnimation?: boolean;
  132505. /**
  132506. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  132507. */
  132508. controllerOptions?: IWebXRControllerOptions;
  132509. }
  132510. /**
  132511. * XR input used to track XR inputs such as controllers/rays
  132512. */
  132513. export class WebXRInput implements IDisposable {
  132514. /**
  132515. * the xr session manager for this session
  132516. */
  132517. xrSessionManager: WebXRSessionManager;
  132518. /**
  132519. * the WebXR camera for this session. Mainly used for teleportation
  132520. */
  132521. xrCamera: WebXRCamera;
  132522. private readonly options;
  132523. /**
  132524. * XR controllers being tracked
  132525. */
  132526. controllers: Array<WebXRInputSource>;
  132527. private _frameObserver;
  132528. private _sessionEndedObserver;
  132529. private _sessionInitObserver;
  132530. /**
  132531. * Event when a controller has been connected/added
  132532. */
  132533. onControllerAddedObservable: Observable<WebXRInputSource>;
  132534. /**
  132535. * Event when a controller has been removed/disconnected
  132536. */
  132537. onControllerRemovedObservable: Observable<WebXRInputSource>;
  132538. /**
  132539. * Initializes the WebXRInput
  132540. * @param xrSessionManager the xr session manager for this session
  132541. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  132542. * @param options = initialization options for this xr input
  132543. */
  132544. constructor(
  132545. /**
  132546. * the xr session manager for this session
  132547. */
  132548. xrSessionManager: WebXRSessionManager,
  132549. /**
  132550. * the WebXR camera for this session. Mainly used for teleportation
  132551. */
  132552. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  132553. private _onInputSourcesChange;
  132554. private _addAndRemoveControllers;
  132555. /**
  132556. * Disposes of the object
  132557. */
  132558. dispose(): void;
  132559. }
  132560. }
  132561. declare module BABYLON {
  132562. /**
  132563. * This is the base class for all WebXR features.
  132564. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  132565. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  132566. */
  132567. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  132568. protected _xrSessionManager: WebXRSessionManager;
  132569. private _attached;
  132570. private _removeOnDetach;
  132571. /**
  132572. * Is this feature disposed?
  132573. */
  132574. isDisposed: boolean;
  132575. /**
  132576. * Should auto-attach be disabled?
  132577. */
  132578. disableAutoAttach: boolean;
  132579. /**
  132580. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  132581. */
  132582. xrNativeFeatureName: string;
  132583. /**
  132584. * Construct a new (abstract) WebXR feature
  132585. * @param _xrSessionManager the xr session manager for this feature
  132586. */
  132587. constructor(_xrSessionManager: WebXRSessionManager);
  132588. /**
  132589. * Is this feature attached
  132590. */
  132591. get attached(): boolean;
  132592. /**
  132593. * attach this feature
  132594. *
  132595. * @param force should attachment be forced (even when already attached)
  132596. * @returns true if successful, false is failed or already attached
  132597. */
  132598. attach(force?: boolean): boolean;
  132599. /**
  132600. * detach this feature.
  132601. *
  132602. * @returns true if successful, false if failed or already detached
  132603. */
  132604. detach(): boolean;
  132605. /**
  132606. * Dispose this feature and all of the resources attached
  132607. */
  132608. dispose(): void;
  132609. /**
  132610. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132611. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132612. *
  132613. * @returns whether or not the feature is compatible in this environment
  132614. */
  132615. isCompatible(): boolean;
  132616. /**
  132617. * This is used to register callbacks that will automatically be removed when detach is called.
  132618. * @param observable the observable to which the observer will be attached
  132619. * @param callback the callback to register
  132620. */
  132621. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  132622. /**
  132623. * Code in this function will be executed on each xrFrame received from the browser.
  132624. * This function will not execute after the feature is detached.
  132625. * @param _xrFrame the current frame
  132626. */
  132627. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  132628. }
  132629. }
  132630. declare module BABYLON {
  132631. /**
  132632. * Renders a layer on top of an existing scene
  132633. */
  132634. export class UtilityLayerRenderer implements IDisposable {
  132635. /** the original scene that will be rendered on top of */
  132636. originalScene: Scene;
  132637. private _pointerCaptures;
  132638. private _lastPointerEvents;
  132639. private static _DefaultUtilityLayer;
  132640. private static _DefaultKeepDepthUtilityLayer;
  132641. private _sharedGizmoLight;
  132642. private _renderCamera;
  132643. /**
  132644. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  132645. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  132646. * @returns the camera that is used when rendering the utility layer
  132647. */
  132648. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  132649. /**
  132650. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  132651. * @param cam the camera that should be used when rendering the utility layer
  132652. */
  132653. setRenderCamera(cam: Nullable<Camera>): void;
  132654. /**
  132655. * @hidden
  132656. * Light which used by gizmos to get light shading
  132657. */
  132658. _getSharedGizmoLight(): HemisphericLight;
  132659. /**
  132660. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  132661. */
  132662. pickUtilitySceneFirst: boolean;
  132663. /**
  132664. * 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)
  132665. */
  132666. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  132667. /**
  132668. * 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)
  132669. */
  132670. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  132671. /**
  132672. * The scene that is rendered on top of the original scene
  132673. */
  132674. utilityLayerScene: Scene;
  132675. /**
  132676. * If the utility layer should automatically be rendered on top of existing scene
  132677. */
  132678. shouldRender: boolean;
  132679. /**
  132680. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  132681. */
  132682. onlyCheckPointerDownEvents: boolean;
  132683. /**
  132684. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  132685. */
  132686. processAllEvents: boolean;
  132687. /**
  132688. * Observable raised when the pointer move from the utility layer scene to the main scene
  132689. */
  132690. onPointerOutObservable: Observable<number>;
  132691. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  132692. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  132693. private _afterRenderObserver;
  132694. private _sceneDisposeObserver;
  132695. private _originalPointerObserver;
  132696. /**
  132697. * Instantiates a UtilityLayerRenderer
  132698. * @param originalScene the original scene that will be rendered on top of
  132699. * @param handleEvents boolean indicating if the utility layer should handle events
  132700. */
  132701. constructor(
  132702. /** the original scene that will be rendered on top of */
  132703. originalScene: Scene, handleEvents?: boolean);
  132704. private _notifyObservers;
  132705. /**
  132706. * Renders the utility layers scene on top of the original scene
  132707. */
  132708. render(): void;
  132709. /**
  132710. * Disposes of the renderer
  132711. */
  132712. dispose(): void;
  132713. private _updateCamera;
  132714. }
  132715. }
  132716. declare module BABYLON {
  132717. /**
  132718. * Options interface for the pointer selection module
  132719. */
  132720. export interface IWebXRControllerPointerSelectionOptions {
  132721. /**
  132722. * if provided, this scene will be used to render meshes.
  132723. */
  132724. customUtilityLayerScene?: Scene;
  132725. /**
  132726. * 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)
  132727. * If not disabled, the last picked point will be used to execute a pointer up event
  132728. * If disabled, pointer up event will be triggered right after the pointer down event.
  132729. * Used in screen and gaze target ray mode only
  132730. */
  132731. disablePointerUpOnTouchOut: boolean;
  132732. /**
  132733. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  132734. */
  132735. forceGazeMode: boolean;
  132736. /**
  132737. * 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
  132738. * to start a new countdown to the pointer down event.
  132739. * Defaults to 1.
  132740. */
  132741. gazeModePointerMovedFactor?: number;
  132742. /**
  132743. * Different button type to use instead of the main component
  132744. */
  132745. overrideButtonId?: string;
  132746. /**
  132747. * use this rendering group id for the meshes (optional)
  132748. */
  132749. renderingGroupId?: number;
  132750. /**
  132751. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  132752. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  132753. * 3000 means 3 seconds between pointing at something and selecting it
  132754. */
  132755. timeToSelect?: number;
  132756. /**
  132757. * Should meshes created here be added to a utility layer or the main scene
  132758. */
  132759. useUtilityLayer?: boolean;
  132760. /**
  132761. * Optional WebXR camera to be used for gaze selection
  132762. */
  132763. gazeCamera?: WebXRCamera;
  132764. /**
  132765. * the xr input to use with this pointer selection
  132766. */
  132767. xrInput: WebXRInput;
  132768. /**
  132769. * Should the scene pointerX and pointerY update be disabled
  132770. * This is required for fullscreen AR GUI, but might slow down other experiences.
  132771. * Disable in VR, if not needed.
  132772. * The first rig camera (left eye) will be used to calculate the projection
  132773. */
  132774. disableScenePointerVectorUpdate: boolean;
  132775. }
  132776. /**
  132777. * A module that will enable pointer selection for motion controllers of XR Input Sources
  132778. */
  132779. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  132780. private readonly _options;
  132781. private static _idCounter;
  132782. private _attachController;
  132783. private _controllers;
  132784. private _scene;
  132785. private _tmpVectorForPickCompare;
  132786. /**
  132787. * The module's name
  132788. */
  132789. static readonly Name: string;
  132790. /**
  132791. * The (Babylon) version of this module.
  132792. * This is an integer representing the implementation version.
  132793. * This number does not correspond to the WebXR specs version
  132794. */
  132795. static readonly Version: number;
  132796. /**
  132797. * Disable lighting on the laser pointer (so it will always be visible)
  132798. */
  132799. disablePointerLighting: boolean;
  132800. /**
  132801. * Disable lighting on the selection mesh (so it will always be visible)
  132802. */
  132803. disableSelectionMeshLighting: boolean;
  132804. /**
  132805. * Should the laser pointer be displayed
  132806. */
  132807. displayLaserPointer: boolean;
  132808. /**
  132809. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  132810. */
  132811. displaySelectionMesh: boolean;
  132812. /**
  132813. * This color will be set to the laser pointer when selection is triggered
  132814. */
  132815. laserPointerPickedColor: Color3;
  132816. /**
  132817. * Default color of the laser pointer
  132818. */
  132819. laserPointerDefaultColor: Color3;
  132820. /**
  132821. * default color of the selection ring
  132822. */
  132823. selectionMeshDefaultColor: Color3;
  132824. /**
  132825. * This color will be applied to the selection ring when selection is triggered
  132826. */
  132827. selectionMeshPickedColor: Color3;
  132828. /**
  132829. * Optional filter to be used for ray selection. This predicate shares behavior with
  132830. * scene.pointerMovePredicate which takes priority if it is also assigned.
  132831. */
  132832. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  132833. /**
  132834. * constructs a new background remover module
  132835. * @param _xrSessionManager the session manager for this module
  132836. * @param _options read-only options to be used in this module
  132837. */
  132838. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  132839. /**
  132840. * attach this feature
  132841. * Will usually be called by the features manager
  132842. *
  132843. * @returns true if successful.
  132844. */
  132845. attach(): boolean;
  132846. /**
  132847. * detach this feature.
  132848. * Will usually be called by the features manager
  132849. *
  132850. * @returns true if successful.
  132851. */
  132852. detach(): boolean;
  132853. /**
  132854. * Will get the mesh under a specific pointer.
  132855. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  132856. * @param controllerId the controllerId to check
  132857. * @returns The mesh under pointer or null if no mesh is under the pointer
  132858. */
  132859. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  132860. /**
  132861. * Get the xr controller that correlates to the pointer id in the pointer event
  132862. *
  132863. * @param id the pointer id to search for
  132864. * @returns the controller that correlates to this id or null if not found
  132865. */
  132866. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  132867. private _identityMatrix;
  132868. private _screenCoordinatesRef;
  132869. private _viewportRef;
  132870. protected _onXRFrame(_xrFrame: XRFrame): void;
  132871. private _attachGazeMode;
  132872. private _attachScreenRayMode;
  132873. private _attachTrackedPointerRayMode;
  132874. private _convertNormalToDirectionOfRay;
  132875. private _detachController;
  132876. private _generateNewMeshPair;
  132877. private _pickingMoved;
  132878. private _updatePointerDistance;
  132879. /** @hidden */
  132880. get lasterPointerDefaultColor(): Color3;
  132881. }
  132882. }
  132883. declare module BABYLON {
  132884. /**
  132885. * Button which can be used to enter a different mode of XR
  132886. */
  132887. export class WebXREnterExitUIButton {
  132888. /** button element */
  132889. element: HTMLElement;
  132890. /** XR initialization options for the button */
  132891. sessionMode: XRSessionMode;
  132892. /** Reference space type */
  132893. referenceSpaceType: XRReferenceSpaceType;
  132894. /**
  132895. * Creates a WebXREnterExitUIButton
  132896. * @param element button element
  132897. * @param sessionMode XR initialization session mode
  132898. * @param referenceSpaceType the type of reference space to be used
  132899. */
  132900. constructor(
  132901. /** button element */
  132902. element: HTMLElement,
  132903. /** XR initialization options for the button */
  132904. sessionMode: XRSessionMode,
  132905. /** Reference space type */
  132906. referenceSpaceType: XRReferenceSpaceType);
  132907. /**
  132908. * Extendable function which can be used to update the button's visuals when the state changes
  132909. * @param activeButton the current active button in the UI
  132910. */
  132911. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  132912. }
  132913. /**
  132914. * Options to create the webXR UI
  132915. */
  132916. export class WebXREnterExitUIOptions {
  132917. /**
  132918. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  132919. */
  132920. customButtons?: Array<WebXREnterExitUIButton>;
  132921. /**
  132922. * A reference space type to use when creating the default button.
  132923. * Default is local-floor
  132924. */
  132925. referenceSpaceType?: XRReferenceSpaceType;
  132926. /**
  132927. * Context to enter xr with
  132928. */
  132929. renderTarget?: Nullable<WebXRRenderTarget>;
  132930. /**
  132931. * A session mode to use when creating the default button.
  132932. * Default is immersive-vr
  132933. */
  132934. sessionMode?: XRSessionMode;
  132935. /**
  132936. * A list of optional features to init the session with
  132937. */
  132938. optionalFeatures?: string[];
  132939. /**
  132940. * A list of optional features to init the session with
  132941. */
  132942. requiredFeatures?: string[];
  132943. }
  132944. /**
  132945. * UI to allow the user to enter/exit XR mode
  132946. */
  132947. export class WebXREnterExitUI implements IDisposable {
  132948. private scene;
  132949. /** version of the options passed to this UI */
  132950. options: WebXREnterExitUIOptions;
  132951. private _activeButton;
  132952. private _buttons;
  132953. /**
  132954. * The HTML Div Element to which buttons are added.
  132955. */
  132956. readonly overlay: HTMLDivElement;
  132957. /**
  132958. * Fired every time the active button is changed.
  132959. *
  132960. * When xr is entered via a button that launches xr that button will be the callback parameter
  132961. *
  132962. * When exiting xr the callback parameter will be null)
  132963. */
  132964. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  132965. /**
  132966. *
  132967. * @param scene babylon scene object to use
  132968. * @param options (read-only) version of the options passed to this UI
  132969. */
  132970. private constructor();
  132971. /**
  132972. * Creates UI to allow the user to enter/exit XR mode
  132973. * @param scene the scene to add the ui to
  132974. * @param helper the xr experience helper to enter/exit xr with
  132975. * @param options options to configure the UI
  132976. * @returns the created ui
  132977. */
  132978. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  132979. /**
  132980. * Disposes of the XR UI component
  132981. */
  132982. dispose(): void;
  132983. private _updateButtons;
  132984. }
  132985. }
  132986. declare module BABYLON {
  132987. /**
  132988. * Class containing static functions to help procedurally build meshes
  132989. */
  132990. export class LinesBuilder {
  132991. /**
  132992. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  132993. * * 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
  132994. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  132995. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  132996. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  132997. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  132998. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  132999. * * 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
  133000. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  133001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  133003. * @param name defines the name of the new line system
  133004. * @param options defines the options used to create the line system
  133005. * @param scene defines the hosting scene
  133006. * @returns a new line system mesh
  133007. */
  133008. static CreateLineSystem(name: string, options: {
  133009. lines: Vector3[][];
  133010. updatable?: boolean;
  133011. instance?: Nullable<LinesMesh>;
  133012. colors?: Nullable<Color4[][]>;
  133013. useVertexAlpha?: boolean;
  133014. }, scene: Nullable<Scene>): LinesMesh;
  133015. /**
  133016. * Creates a line mesh
  133017. * 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
  133018. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133019. * * The parameter `points` is an array successive Vector3
  133020. * * 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
  133021. * * The optional parameter `colors` is an array of successive Color4, one per line point
  133022. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133023. * * When updating an instance, remember that only point positions can change, not the number of points
  133024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133026. * @param name defines the name of the new line system
  133027. * @param options defines the options used to create the line system
  133028. * @param scene defines the hosting scene
  133029. * @returns a new line mesh
  133030. */
  133031. static CreateLines(name: string, options: {
  133032. points: Vector3[];
  133033. updatable?: boolean;
  133034. instance?: Nullable<LinesMesh>;
  133035. colors?: Color4[];
  133036. useVertexAlpha?: boolean;
  133037. }, scene?: Nullable<Scene>): LinesMesh;
  133038. /**
  133039. * Creates a dashed line mesh
  133040. * * 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
  133041. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133042. * * The parameter `points` is an array successive Vector3
  133043. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133044. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133045. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133046. * * 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
  133047. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133048. * * When updating an instance, remember that only point positions can change, not the number of points
  133049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133050. * @param name defines the name of the mesh
  133051. * @param options defines the options used to create the mesh
  133052. * @param scene defines the hosting scene
  133053. * @returns the dashed line mesh
  133054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133055. */
  133056. static CreateDashedLines(name: string, options: {
  133057. points: Vector3[];
  133058. dashSize?: number;
  133059. gapSize?: number;
  133060. dashNb?: number;
  133061. updatable?: boolean;
  133062. instance?: LinesMesh;
  133063. useVertexAlpha?: boolean;
  133064. }, scene?: Nullable<Scene>): LinesMesh;
  133065. }
  133066. }
  133067. declare module BABYLON {
  133068. /**
  133069. * Construction options for a timer
  133070. */
  133071. export interface ITimerOptions<T> {
  133072. /**
  133073. * Time-to-end
  133074. */
  133075. timeout: number;
  133076. /**
  133077. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  133078. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  133079. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  133080. */
  133081. contextObservable: Observable<T>;
  133082. /**
  133083. * Optional parameters when adding an observer to the observable
  133084. */
  133085. observableParameters?: {
  133086. mask?: number;
  133087. insertFirst?: boolean;
  133088. scope?: any;
  133089. };
  133090. /**
  133091. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  133092. */
  133093. breakCondition?: (data?: ITimerData<T>) => boolean;
  133094. /**
  133095. * Will be triggered when the time condition has met
  133096. */
  133097. onEnded?: (data: ITimerData<any>) => void;
  133098. /**
  133099. * Will be triggered when the break condition has met (prematurely ended)
  133100. */
  133101. onAborted?: (data: ITimerData<any>) => void;
  133102. /**
  133103. * Optional function to execute on each tick (or count)
  133104. */
  133105. onTick?: (data: ITimerData<any>) => void;
  133106. }
  133107. /**
  133108. * An interface defining the data sent by the timer
  133109. */
  133110. export interface ITimerData<T> {
  133111. /**
  133112. * When did it start
  133113. */
  133114. startTime: number;
  133115. /**
  133116. * Time now
  133117. */
  133118. currentTime: number;
  133119. /**
  133120. * Time passed since started
  133121. */
  133122. deltaTime: number;
  133123. /**
  133124. * How much is completed, in [0.0...1.0].
  133125. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  133126. */
  133127. completeRate: number;
  133128. /**
  133129. * What the registered observable sent in the last count
  133130. */
  133131. payload: T;
  133132. }
  133133. /**
  133134. * The current state of the timer
  133135. */
  133136. export enum TimerState {
  133137. /**
  133138. * Timer initialized, not yet started
  133139. */
  133140. INIT = 0,
  133141. /**
  133142. * Timer started and counting
  133143. */
  133144. STARTED = 1,
  133145. /**
  133146. * Timer ended (whether aborted or time reached)
  133147. */
  133148. ENDED = 2
  133149. }
  133150. /**
  133151. * A simple version of the timer. Will take options and start the timer immediately after calling it
  133152. *
  133153. * @param options options with which to initialize this timer
  133154. */
  133155. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  133156. /**
  133157. * An advanced implementation of a timer class
  133158. */
  133159. export class AdvancedTimer<T = any> implements IDisposable {
  133160. /**
  133161. * Will notify each time the timer calculates the remaining time
  133162. */
  133163. onEachCountObservable: Observable<ITimerData<T>>;
  133164. /**
  133165. * Will trigger when the timer was aborted due to the break condition
  133166. */
  133167. onTimerAbortedObservable: Observable<ITimerData<T>>;
  133168. /**
  133169. * Will trigger when the timer ended successfully
  133170. */
  133171. onTimerEndedObservable: Observable<ITimerData<T>>;
  133172. /**
  133173. * Will trigger when the timer state has changed
  133174. */
  133175. onStateChangedObservable: Observable<TimerState>;
  133176. private _observer;
  133177. private _contextObservable;
  133178. private _observableParameters;
  133179. private _startTime;
  133180. private _timer;
  133181. private _state;
  133182. private _breakCondition;
  133183. private _timeToEnd;
  133184. private _breakOnNextTick;
  133185. /**
  133186. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  133187. * @param options construction options for this advanced timer
  133188. */
  133189. constructor(options: ITimerOptions<T>);
  133190. /**
  133191. * set a breaking condition for this timer. Default is to never break during count
  133192. * @param predicate the new break condition. Returns true to break, false otherwise
  133193. */
  133194. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  133195. /**
  133196. * Reset ALL associated observables in this advanced timer
  133197. */
  133198. clearObservables(): void;
  133199. /**
  133200. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  133201. *
  133202. * @param timeToEnd how much time to measure until timer ended
  133203. */
  133204. start(timeToEnd?: number): void;
  133205. /**
  133206. * Will force a stop on the next tick.
  133207. */
  133208. stop(): void;
  133209. /**
  133210. * Dispose this timer, clearing all resources
  133211. */
  133212. dispose(): void;
  133213. private _setState;
  133214. private _tick;
  133215. private _stop;
  133216. }
  133217. }
  133218. declare module BABYLON {
  133219. /**
  133220. * The options container for the teleportation module
  133221. */
  133222. export interface IWebXRTeleportationOptions {
  133223. /**
  133224. * if provided, this scene will be used to render meshes.
  133225. */
  133226. customUtilityLayerScene?: Scene;
  133227. /**
  133228. * Values to configure the default target mesh
  133229. */
  133230. defaultTargetMeshOptions?: {
  133231. /**
  133232. * Fill color of the teleportation area
  133233. */
  133234. teleportationFillColor?: string;
  133235. /**
  133236. * Border color for the teleportation area
  133237. */
  133238. teleportationBorderColor?: string;
  133239. /**
  133240. * Disable the mesh's animation sequence
  133241. */
  133242. disableAnimation?: boolean;
  133243. /**
  133244. * Disable lighting on the material or the ring and arrow
  133245. */
  133246. disableLighting?: boolean;
  133247. /**
  133248. * Override the default material of the torus and arrow
  133249. */
  133250. torusArrowMaterial?: Material;
  133251. };
  133252. /**
  133253. * A list of meshes to use as floor meshes.
  133254. * Meshes can be added and removed after initializing the feature using the
  133255. * addFloorMesh and removeFloorMesh functions
  133256. * If empty, rotation will still work
  133257. */
  133258. floorMeshes?: AbstractMesh[];
  133259. /**
  133260. * use this rendering group id for the meshes (optional)
  133261. */
  133262. renderingGroupId?: number;
  133263. /**
  133264. * Should teleportation move only to snap points
  133265. */
  133266. snapPointsOnly?: boolean;
  133267. /**
  133268. * An array of points to which the teleportation will snap to.
  133269. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  133270. */
  133271. snapPositions?: Vector3[];
  133272. /**
  133273. * How close should the teleportation ray be in order to snap to position.
  133274. * Default to 0.8 units (meters)
  133275. */
  133276. snapToPositionRadius?: number;
  133277. /**
  133278. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  133279. * If you want to support rotation, make sure your mesh has a direction indicator.
  133280. *
  133281. * When left untouched, the default mesh will be initialized.
  133282. */
  133283. teleportationTargetMesh?: AbstractMesh;
  133284. /**
  133285. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  133286. */
  133287. timeToTeleport?: number;
  133288. /**
  133289. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  133290. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  133291. */
  133292. useMainComponentOnly?: boolean;
  133293. /**
  133294. * Should meshes created here be added to a utility layer or the main scene
  133295. */
  133296. useUtilityLayer?: boolean;
  133297. /**
  133298. * Babylon XR Input class for controller
  133299. */
  133300. xrInput: WebXRInput;
  133301. /**
  133302. * Meshes that the teleportation ray cannot go through
  133303. */
  133304. pickBlockerMeshes?: AbstractMesh[];
  133305. }
  133306. /**
  133307. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  133308. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  133309. * the input of the attached controllers.
  133310. */
  133311. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  133312. private _options;
  133313. private _controllers;
  133314. private _currentTeleportationControllerId;
  133315. private _floorMeshes;
  133316. private _quadraticBezierCurve;
  133317. private _selectionFeature;
  133318. private _snapToPositions;
  133319. private _snappedToPoint;
  133320. private _teleportationRingMaterial?;
  133321. private _tmpRay;
  133322. private _tmpVector;
  133323. private _tmpQuaternion;
  133324. /**
  133325. * The module's name
  133326. */
  133327. static readonly Name: string;
  133328. /**
  133329. * The (Babylon) version of this module.
  133330. * This is an integer representing the implementation version.
  133331. * This number does not correspond to the webxr specs version
  133332. */
  133333. static readonly Version: number;
  133334. /**
  133335. * Is movement backwards enabled
  133336. */
  133337. backwardsMovementEnabled: boolean;
  133338. /**
  133339. * Distance to travel when moving backwards
  133340. */
  133341. backwardsTeleportationDistance: number;
  133342. /**
  133343. * The distance from the user to the inspection point in the direction of the controller
  133344. * A higher number will allow the user to move further
  133345. * defaults to 5 (meters, in xr units)
  133346. */
  133347. parabolicCheckRadius: number;
  133348. /**
  133349. * Should the module support parabolic ray on top of direct ray
  133350. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  133351. * Very helpful when moving between floors / different heights
  133352. */
  133353. parabolicRayEnabled: boolean;
  133354. /**
  133355. * How much rotation should be applied when rotating right and left
  133356. */
  133357. rotationAngle: number;
  133358. /**
  133359. * Is rotation enabled when moving forward?
  133360. * Disabling this feature will prevent the user from deciding the direction when teleporting
  133361. */
  133362. rotationEnabled: boolean;
  133363. /**
  133364. * constructs a new anchor system
  133365. * @param _xrSessionManager an instance of WebXRSessionManager
  133366. * @param _options configuration object for this feature
  133367. */
  133368. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  133369. /**
  133370. * Get the snapPointsOnly flag
  133371. */
  133372. get snapPointsOnly(): boolean;
  133373. /**
  133374. * Sets the snapPointsOnly flag
  133375. * @param snapToPoints should teleportation be exclusively to snap points
  133376. */
  133377. set snapPointsOnly(snapToPoints: boolean);
  133378. /**
  133379. * Add a new mesh to the floor meshes array
  133380. * @param mesh the mesh to use as floor mesh
  133381. */
  133382. addFloorMesh(mesh: AbstractMesh): void;
  133383. /**
  133384. * Add a new snap-to point to fix teleportation to this position
  133385. * @param newSnapPoint The new Snap-To point
  133386. */
  133387. addSnapPoint(newSnapPoint: Vector3): void;
  133388. attach(): boolean;
  133389. detach(): boolean;
  133390. dispose(): void;
  133391. /**
  133392. * Remove a mesh from the floor meshes array
  133393. * @param mesh the mesh to remove
  133394. */
  133395. removeFloorMesh(mesh: AbstractMesh): void;
  133396. /**
  133397. * Remove a mesh from the floor meshes array using its name
  133398. * @param name the mesh name to remove
  133399. */
  133400. removeFloorMeshByName(name: string): void;
  133401. /**
  133402. * 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
  133403. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  133404. * @returns was the point found and removed or not
  133405. */
  133406. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  133407. /**
  133408. * This function sets a selection feature that will be disabled when
  133409. * the forward ray is shown and will be reattached when hidden.
  133410. * This is used to remove the selection rays when moving.
  133411. * @param selectionFeature the feature to disable when forward movement is enabled
  133412. */
  133413. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  133414. protected _onXRFrame(_xrFrame: XRFrame): void;
  133415. private _attachController;
  133416. private _createDefaultTargetMesh;
  133417. private _detachController;
  133418. private _findClosestSnapPointWithRadius;
  133419. private _setTargetMeshPosition;
  133420. private _setTargetMeshVisibility;
  133421. private _showParabolicPath;
  133422. private _teleportForward;
  133423. }
  133424. }
  133425. declare module BABYLON {
  133426. /**
  133427. * Options for the default xr helper
  133428. */
  133429. export class WebXRDefaultExperienceOptions {
  133430. /**
  133431. * Enable or disable default UI to enter XR
  133432. */
  133433. disableDefaultUI?: boolean;
  133434. /**
  133435. * Should teleportation not initialize. defaults to false.
  133436. */
  133437. disableTeleportation?: boolean;
  133438. /**
  133439. * Floor meshes that will be used for teleport
  133440. */
  133441. floorMeshes?: Array<AbstractMesh>;
  133442. /**
  133443. * If set to true, the first frame will not be used to reset position
  133444. * The first frame is mainly used when copying transformation from the old camera
  133445. * Mainly used in AR
  133446. */
  133447. ignoreNativeCameraTransformation?: boolean;
  133448. /**
  133449. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  133450. */
  133451. inputOptions?: IWebXRInputOptions;
  133452. /**
  133453. * optional configuration for the output canvas
  133454. */
  133455. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  133456. /**
  133457. * optional UI options. This can be used among other to change session mode and reference space type
  133458. */
  133459. uiOptions?: WebXREnterExitUIOptions;
  133460. /**
  133461. * When loading teleportation and pointer select, use stable versions instead of latest.
  133462. */
  133463. useStablePlugins?: boolean;
  133464. /**
  133465. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  133466. */
  133467. renderingGroupId?: number;
  133468. /**
  133469. * A list of optional features to init the session with
  133470. * If set to true, all features we support will be added
  133471. */
  133472. optionalFeatures?: boolean | string[];
  133473. }
  133474. /**
  133475. * Default experience which provides a similar setup to the previous webVRExperience
  133476. */
  133477. export class WebXRDefaultExperience {
  133478. /**
  133479. * Base experience
  133480. */
  133481. baseExperience: WebXRExperienceHelper;
  133482. /**
  133483. * Enables ui for entering/exiting xr
  133484. */
  133485. enterExitUI: WebXREnterExitUI;
  133486. /**
  133487. * Input experience extension
  133488. */
  133489. input: WebXRInput;
  133490. /**
  133491. * Enables laser pointer and selection
  133492. */
  133493. pointerSelection: WebXRControllerPointerSelection;
  133494. /**
  133495. * Default target xr should render to
  133496. */
  133497. renderTarget: WebXRRenderTarget;
  133498. /**
  133499. * Enables teleportation
  133500. */
  133501. teleportation: WebXRMotionControllerTeleportation;
  133502. private constructor();
  133503. /**
  133504. * Creates the default xr experience
  133505. * @param scene scene
  133506. * @param options options for basic configuration
  133507. * @returns resulting WebXRDefaultExperience
  133508. */
  133509. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133510. /**
  133511. * DIsposes of the experience helper
  133512. */
  133513. dispose(): void;
  133514. }
  133515. }
  133516. declare module BABYLON {
  133517. /**
  133518. * Options to modify the vr teleportation behavior.
  133519. */
  133520. export interface VRTeleportationOptions {
  133521. /**
  133522. * The name of the mesh which should be used as the teleportation floor. (default: null)
  133523. */
  133524. floorMeshName?: string;
  133525. /**
  133526. * A list of meshes to be used as the teleportation floor. (default: empty)
  133527. */
  133528. floorMeshes?: Mesh[];
  133529. /**
  133530. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  133531. */
  133532. teleportationMode?: number;
  133533. /**
  133534. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  133535. */
  133536. teleportationTime?: number;
  133537. /**
  133538. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  133539. */
  133540. teleportationSpeed?: number;
  133541. /**
  133542. * The easing function used in the animation or null for Linear. (default CircleEase)
  133543. */
  133544. easingFunction?: EasingFunction;
  133545. }
  133546. /**
  133547. * Options to modify the vr experience helper's behavior.
  133548. */
  133549. export interface VRExperienceHelperOptions extends WebVROptions {
  133550. /**
  133551. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  133552. */
  133553. createDeviceOrientationCamera?: boolean;
  133554. /**
  133555. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  133556. */
  133557. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  133558. /**
  133559. * Uses the main button on the controller to toggle the laser casted. (default: true)
  133560. */
  133561. laserToggle?: boolean;
  133562. /**
  133563. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  133564. */
  133565. floorMeshes?: Mesh[];
  133566. /**
  133567. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  133568. */
  133569. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  133570. /**
  133571. * Defines if WebXR should be used instead of WebVR (if available)
  133572. */
  133573. useXR?: boolean;
  133574. }
  133575. /**
  133576. * Event containing information after VR has been entered
  133577. */
  133578. export class OnAfterEnteringVRObservableEvent {
  133579. /**
  133580. * If entering vr was successful
  133581. */
  133582. success: boolean;
  133583. }
  133584. /**
  133585. * Helps to quickly add VR support to an existing scene.
  133586. * See https://doc.babylonjs.com/how_to/webvr_helper
  133587. */
  133588. export class VRExperienceHelper {
  133589. /** Options to modify the vr experience helper's behavior. */
  133590. webVROptions: VRExperienceHelperOptions;
  133591. private _scene;
  133592. private _position;
  133593. private _btnVR;
  133594. private _btnVRDisplayed;
  133595. private _webVRsupported;
  133596. private _webVRready;
  133597. private _webVRrequesting;
  133598. private _webVRpresenting;
  133599. private _hasEnteredVR;
  133600. private _fullscreenVRpresenting;
  133601. private _inputElement;
  133602. private _webVRCamera;
  133603. private _vrDeviceOrientationCamera;
  133604. private _deviceOrientationCamera;
  133605. private _existingCamera;
  133606. private _onKeyDown;
  133607. private _onVrDisplayPresentChange;
  133608. private _onVRDisplayChanged;
  133609. private _onVRRequestPresentStart;
  133610. private _onVRRequestPresentComplete;
  133611. /**
  133612. * 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)
  133613. */
  133614. enableGazeEvenWhenNoPointerLock: boolean;
  133615. /**
  133616. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  133617. */
  133618. exitVROnDoubleTap: boolean;
  133619. /**
  133620. * Observable raised right before entering VR.
  133621. */
  133622. onEnteringVRObservable: Observable<VRExperienceHelper>;
  133623. /**
  133624. * Observable raised when entering VR has completed.
  133625. */
  133626. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  133627. /**
  133628. * Observable raised when exiting VR.
  133629. */
  133630. onExitingVRObservable: Observable<VRExperienceHelper>;
  133631. /**
  133632. * Observable raised when controller mesh is loaded.
  133633. */
  133634. onControllerMeshLoadedObservable: Observable<WebVRController>;
  133635. /** Return this.onEnteringVRObservable
  133636. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  133637. */
  133638. get onEnteringVR(): Observable<VRExperienceHelper>;
  133639. /** Return this.onExitingVRObservable
  133640. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  133641. */
  133642. get onExitingVR(): Observable<VRExperienceHelper>;
  133643. /** Return this.onControllerMeshLoadedObservable
  133644. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  133645. */
  133646. get onControllerMeshLoaded(): Observable<WebVRController>;
  133647. private _rayLength;
  133648. private _useCustomVRButton;
  133649. private _teleportationRequested;
  133650. private _teleportActive;
  133651. private _floorMeshName;
  133652. private _floorMeshesCollection;
  133653. private _teleportationMode;
  133654. private _teleportationTime;
  133655. private _teleportationSpeed;
  133656. private _teleportationEasing;
  133657. private _rotationAllowed;
  133658. private _teleportBackwardsVector;
  133659. private _teleportationTarget;
  133660. private _isDefaultTeleportationTarget;
  133661. private _postProcessMove;
  133662. private _teleportationFillColor;
  133663. private _teleportationBorderColor;
  133664. private _rotationAngle;
  133665. private _haloCenter;
  133666. private _cameraGazer;
  133667. private _padSensibilityUp;
  133668. private _padSensibilityDown;
  133669. private _leftController;
  133670. private _rightController;
  133671. private _gazeColor;
  133672. private _laserColor;
  133673. private _pickedLaserColor;
  133674. private _pickedGazeColor;
  133675. /**
  133676. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  133677. */
  133678. onNewMeshSelected: Observable<AbstractMesh>;
  133679. /**
  133680. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  133681. * This observable will provide the mesh and the controller used to select the mesh
  133682. */
  133683. onMeshSelectedWithController: Observable<{
  133684. mesh: AbstractMesh;
  133685. controller: WebVRController;
  133686. }>;
  133687. /**
  133688. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  133689. */
  133690. onNewMeshPicked: Observable<PickingInfo>;
  133691. private _circleEase;
  133692. /**
  133693. * Observable raised before camera teleportation
  133694. */
  133695. onBeforeCameraTeleport: Observable<Vector3>;
  133696. /**
  133697. * Observable raised after camera teleportation
  133698. */
  133699. onAfterCameraTeleport: Observable<Vector3>;
  133700. /**
  133701. * Observable raised when current selected mesh gets unselected
  133702. */
  133703. onSelectedMeshUnselected: Observable<AbstractMesh>;
  133704. private _raySelectionPredicate;
  133705. /**
  133706. * To be optionaly changed by user to define custom ray selection
  133707. */
  133708. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133709. /**
  133710. * To be optionaly changed by user to define custom selection logic (after ray selection)
  133711. */
  133712. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  133713. /**
  133714. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  133715. */
  133716. teleportationEnabled: boolean;
  133717. private _defaultHeight;
  133718. private _teleportationInitialized;
  133719. private _interactionsEnabled;
  133720. private _interactionsRequested;
  133721. private _displayGaze;
  133722. private _displayLaserPointer;
  133723. /**
  133724. * The mesh used to display where the user is going to teleport.
  133725. */
  133726. get teleportationTarget(): Mesh;
  133727. /**
  133728. * Sets the mesh to be used to display where the user is going to teleport.
  133729. */
  133730. set teleportationTarget(value: Mesh);
  133731. /**
  133732. * 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
  133733. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  133734. * See https://doc.babylonjs.com/resources/baking_transformations
  133735. */
  133736. get gazeTrackerMesh(): Mesh;
  133737. set gazeTrackerMesh(value: Mesh);
  133738. /**
  133739. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  133740. */
  133741. updateGazeTrackerScale: boolean;
  133742. /**
  133743. * If the gaze trackers color should be updated when selecting meshes
  133744. */
  133745. updateGazeTrackerColor: boolean;
  133746. /**
  133747. * If the controller laser color should be updated when selecting meshes
  133748. */
  133749. updateControllerLaserColor: boolean;
  133750. /**
  133751. * The gaze tracking mesh corresponding to the left controller
  133752. */
  133753. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  133754. /**
  133755. * The gaze tracking mesh corresponding to the right controller
  133756. */
  133757. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  133758. /**
  133759. * If the ray of the gaze should be displayed.
  133760. */
  133761. get displayGaze(): boolean;
  133762. /**
  133763. * Sets if the ray of the gaze should be displayed.
  133764. */
  133765. set displayGaze(value: boolean);
  133766. /**
  133767. * If the ray of the LaserPointer should be displayed.
  133768. */
  133769. get displayLaserPointer(): boolean;
  133770. /**
  133771. * Sets if the ray of the LaserPointer should be displayed.
  133772. */
  133773. set displayLaserPointer(value: boolean);
  133774. /**
  133775. * The deviceOrientationCamera used as the camera when not in VR.
  133776. */
  133777. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  133778. /**
  133779. * Based on the current WebVR support, returns the current VR camera used.
  133780. */
  133781. get currentVRCamera(): Nullable<Camera>;
  133782. /**
  133783. * The webVRCamera which is used when in VR.
  133784. */
  133785. get webVRCamera(): WebVRFreeCamera;
  133786. /**
  133787. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  133788. */
  133789. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  133790. /**
  133791. * The html button that is used to trigger entering into VR.
  133792. */
  133793. get vrButton(): Nullable<HTMLButtonElement>;
  133794. private get _teleportationRequestInitiated();
  133795. /**
  133796. * Defines whether or not Pointer lock should be requested when switching to
  133797. * full screen.
  133798. */
  133799. requestPointerLockOnFullScreen: boolean;
  133800. /**
  133801. * If asking to force XR, this will be populated with the default xr experience
  133802. */
  133803. xr: WebXRDefaultExperience;
  133804. /**
  133805. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  133806. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  133807. */
  133808. xrTestDone: boolean;
  133809. /**
  133810. * Instantiates a VRExperienceHelper.
  133811. * Helps to quickly add VR support to an existing scene.
  133812. * @param scene The scene the VRExperienceHelper belongs to.
  133813. * @param webVROptions Options to modify the vr experience helper's behavior.
  133814. */
  133815. constructor(scene: Scene,
  133816. /** Options to modify the vr experience helper's behavior. */
  133817. webVROptions?: VRExperienceHelperOptions);
  133818. private completeVRInit;
  133819. private _onDefaultMeshLoaded;
  133820. private _onResize;
  133821. private _onFullscreenChange;
  133822. /**
  133823. * Gets a value indicating if we are currently in VR mode.
  133824. */
  133825. get isInVRMode(): boolean;
  133826. private onVrDisplayPresentChange;
  133827. private onVRDisplayChanged;
  133828. private moveButtonToBottomRight;
  133829. private displayVRButton;
  133830. private updateButtonVisibility;
  133831. private _cachedAngularSensibility;
  133832. /**
  133833. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  133834. * Otherwise, will use the fullscreen API.
  133835. */
  133836. enterVR(): void;
  133837. /**
  133838. * Attempt to exit VR, or fullscreen.
  133839. */
  133840. exitVR(): void;
  133841. /**
  133842. * The position of the vr experience helper.
  133843. */
  133844. get position(): Vector3;
  133845. /**
  133846. * Sets the position of the vr experience helper.
  133847. */
  133848. set position(value: Vector3);
  133849. /**
  133850. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  133851. */
  133852. enableInteractions(): void;
  133853. private get _noControllerIsActive();
  133854. private beforeRender;
  133855. private _isTeleportationFloor;
  133856. /**
  133857. * Adds a floor mesh to be used for teleportation.
  133858. * @param floorMesh the mesh to be used for teleportation.
  133859. */
  133860. addFloorMesh(floorMesh: Mesh): void;
  133861. /**
  133862. * Removes a floor mesh from being used for teleportation.
  133863. * @param floorMesh the mesh to be removed.
  133864. */
  133865. removeFloorMesh(floorMesh: Mesh): void;
  133866. /**
  133867. * Enables interactions and teleportation using the VR controllers and gaze.
  133868. * @param vrTeleportationOptions options to modify teleportation behavior.
  133869. */
  133870. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  133871. private _onNewGamepadConnected;
  133872. private _tryEnableInteractionOnController;
  133873. private _onNewGamepadDisconnected;
  133874. private _enableInteractionOnController;
  133875. private _checkTeleportWithRay;
  133876. private _checkRotate;
  133877. private _checkTeleportBackwards;
  133878. private _enableTeleportationOnController;
  133879. private _createTeleportationCircles;
  133880. private _displayTeleportationTarget;
  133881. private _hideTeleportationTarget;
  133882. private _rotateCamera;
  133883. private _moveTeleportationSelectorTo;
  133884. private _workingVector;
  133885. private _workingQuaternion;
  133886. private _workingMatrix;
  133887. /**
  133888. * Time Constant Teleportation Mode
  133889. */
  133890. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  133891. /**
  133892. * Speed Constant Teleportation Mode
  133893. */
  133894. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  133895. /**
  133896. * Teleports the users feet to the desired location
  133897. * @param location The location where the user's feet should be placed
  133898. */
  133899. teleportCamera(location: Vector3): void;
  133900. private _convertNormalToDirectionOfRay;
  133901. private _castRayAndSelectObject;
  133902. private _notifySelectedMeshUnselected;
  133903. /**
  133904. * Permanently set new colors for the laser pointer
  133905. * @param color the new laser color
  133906. * @param pickedColor the new laser color when picked mesh detected
  133907. */
  133908. setLaserColor(color: Color3, pickedColor?: Color3): void;
  133909. /**
  133910. * Set lighting enabled / disabled on the laser pointer of both controllers
  133911. * @param enabled should the lighting be enabled on the laser pointer
  133912. */
  133913. setLaserLightingState(enabled?: boolean): void;
  133914. /**
  133915. * Permanently set new colors for the gaze pointer
  133916. * @param color the new gaze color
  133917. * @param pickedColor the new gaze color when picked mesh detected
  133918. */
  133919. setGazeColor(color: Color3, pickedColor?: Color3): void;
  133920. /**
  133921. * Sets the color of the laser ray from the vr controllers.
  133922. * @param color new color for the ray.
  133923. */
  133924. changeLaserColor(color: Color3): void;
  133925. /**
  133926. * Sets the color of the ray from the vr headsets gaze.
  133927. * @param color new color for the ray.
  133928. */
  133929. changeGazeColor(color: Color3): void;
  133930. /**
  133931. * Exits VR and disposes of the vr experience helper
  133932. */
  133933. dispose(): void;
  133934. /**
  133935. * Gets the name of the VRExperienceHelper class
  133936. * @returns "VRExperienceHelper"
  133937. */
  133938. getClassName(): string;
  133939. }
  133940. }
  133941. declare module BABYLON {
  133942. /**
  133943. * Contains an array of blocks representing the octree
  133944. */
  133945. export interface IOctreeContainer<T> {
  133946. /**
  133947. * Blocks within the octree
  133948. */
  133949. blocks: Array<OctreeBlock<T>>;
  133950. }
  133951. /**
  133952. * Class used to store a cell in an octree
  133953. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133954. */
  133955. export class OctreeBlock<T> {
  133956. /**
  133957. * Gets the content of the current block
  133958. */
  133959. entries: T[];
  133960. /**
  133961. * Gets the list of block children
  133962. */
  133963. blocks: Array<OctreeBlock<T>>;
  133964. private _depth;
  133965. private _maxDepth;
  133966. private _capacity;
  133967. private _minPoint;
  133968. private _maxPoint;
  133969. private _boundingVectors;
  133970. private _creationFunc;
  133971. /**
  133972. * Creates a new block
  133973. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  133974. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  133975. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133976. * @param depth defines the current depth of this block in the octree
  133977. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  133978. * @param creationFunc defines a callback to call when an element is added to the block
  133979. */
  133980. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  133981. /**
  133982. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133983. */
  133984. get capacity(): number;
  133985. /**
  133986. * Gets the minimum vector (in world space) of the block's bounding box
  133987. */
  133988. get minPoint(): Vector3;
  133989. /**
  133990. * Gets the maximum vector (in world space) of the block's bounding box
  133991. */
  133992. get maxPoint(): Vector3;
  133993. /**
  133994. * Add a new element to this block
  133995. * @param entry defines the element to add
  133996. */
  133997. addEntry(entry: T): void;
  133998. /**
  133999. * Remove an element from this block
  134000. * @param entry defines the element to remove
  134001. */
  134002. removeEntry(entry: T): void;
  134003. /**
  134004. * Add an array of elements to this block
  134005. * @param entries defines the array of elements to add
  134006. */
  134007. addEntries(entries: T[]): void;
  134008. /**
  134009. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  134010. * @param frustumPlanes defines the frustum planes to test
  134011. * @param selection defines the array to store current content if selection is positive
  134012. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134013. */
  134014. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134015. /**
  134016. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  134017. * @param sphereCenter defines the bounding sphere center
  134018. * @param sphereRadius defines the bounding sphere radius
  134019. * @param selection defines the array to store current content if selection is positive
  134020. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134021. */
  134022. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134023. /**
  134024. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  134025. * @param ray defines the ray to test with
  134026. * @param selection defines the array to store current content if selection is positive
  134027. */
  134028. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  134029. /**
  134030. * Subdivide the content into child blocks (this block will then be empty)
  134031. */
  134032. createInnerBlocks(): void;
  134033. /**
  134034. * @hidden
  134035. */
  134036. 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;
  134037. }
  134038. }
  134039. declare module BABYLON {
  134040. /**
  134041. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  134042. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134043. */
  134044. export class Octree<T> {
  134045. /** 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.) */
  134046. maxDepth: number;
  134047. /**
  134048. * Blocks within the octree containing objects
  134049. */
  134050. blocks: Array<OctreeBlock<T>>;
  134051. /**
  134052. * Content stored in the octree
  134053. */
  134054. dynamicContent: T[];
  134055. private _maxBlockCapacity;
  134056. private _selectionContent;
  134057. private _creationFunc;
  134058. /**
  134059. * Creates a octree
  134060. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134061. * @param creationFunc function to be used to instatiate the octree
  134062. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  134063. * @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.)
  134064. */
  134065. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  134066. /** 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.) */
  134067. maxDepth?: number);
  134068. /**
  134069. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  134070. * @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);
  134071. * @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);
  134072. * @param entries meshes to be added to the octree blocks
  134073. */
  134074. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  134075. /**
  134076. * Adds a mesh to the octree
  134077. * @param entry Mesh to add to the octree
  134078. */
  134079. addMesh(entry: T): void;
  134080. /**
  134081. * Remove an element from the octree
  134082. * @param entry defines the element to remove
  134083. */
  134084. removeMesh(entry: T): void;
  134085. /**
  134086. * Selects an array of meshes within the frustum
  134087. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  134088. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  134089. * @returns array of meshes within the frustum
  134090. */
  134091. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  134092. /**
  134093. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  134094. * @param sphereCenter defines the bounding sphere center
  134095. * @param sphereRadius defines the bounding sphere radius
  134096. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134097. * @returns an array of objects that intersect the sphere
  134098. */
  134099. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  134100. /**
  134101. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  134102. * @param ray defines the ray to test with
  134103. * @returns array of intersected objects
  134104. */
  134105. intersectsRay(ray: Ray): SmartArray<T>;
  134106. /**
  134107. * Adds a mesh into the octree block if it intersects the block
  134108. */
  134109. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  134110. /**
  134111. * Adds a submesh into the octree block if it intersects the block
  134112. */
  134113. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  134114. }
  134115. }
  134116. declare module BABYLON {
  134117. interface Scene {
  134118. /**
  134119. * @hidden
  134120. * Backing Filed
  134121. */
  134122. _selectionOctree: Octree<AbstractMesh>;
  134123. /**
  134124. * Gets the octree used to boost mesh selection (picking)
  134125. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134126. */
  134127. selectionOctree: Octree<AbstractMesh>;
  134128. /**
  134129. * Creates or updates the octree used to boost selection (picking)
  134130. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134131. * @param maxCapacity defines the maximum capacity per leaf
  134132. * @param maxDepth defines the maximum depth of the octree
  134133. * @returns an octree of AbstractMesh
  134134. */
  134135. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  134136. }
  134137. interface AbstractMesh {
  134138. /**
  134139. * @hidden
  134140. * Backing Field
  134141. */
  134142. _submeshesOctree: Octree<SubMesh>;
  134143. /**
  134144. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  134145. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  134146. * @param maxCapacity defines the maximum size of each block (64 by default)
  134147. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  134148. * @returns the new octree
  134149. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  134150. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134151. */
  134152. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  134153. }
  134154. /**
  134155. * Defines the octree scene component responsible to manage any octrees
  134156. * in a given scene.
  134157. */
  134158. export class OctreeSceneComponent {
  134159. /**
  134160. * The component name help to identify the component in the list of scene components.
  134161. */
  134162. readonly name: string;
  134163. /**
  134164. * The scene the component belongs to.
  134165. */
  134166. scene: Scene;
  134167. /**
  134168. * Indicates if the meshes have been checked to make sure they are isEnabled()
  134169. */
  134170. readonly checksIsEnabled: boolean;
  134171. /**
  134172. * Creates a new instance of the component for the given scene
  134173. * @param scene Defines the scene to register the component in
  134174. */
  134175. constructor(scene: Scene);
  134176. /**
  134177. * Registers the component in a given scene
  134178. */
  134179. register(): void;
  134180. /**
  134181. * Return the list of active meshes
  134182. * @returns the list of active meshes
  134183. */
  134184. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  134185. /**
  134186. * Return the list of active sub meshes
  134187. * @param mesh The mesh to get the candidates sub meshes from
  134188. * @returns the list of active sub meshes
  134189. */
  134190. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  134191. private _tempRay;
  134192. /**
  134193. * Return the list of sub meshes intersecting with a given local ray
  134194. * @param mesh defines the mesh to find the submesh for
  134195. * @param localRay defines the ray in local space
  134196. * @returns the list of intersecting sub meshes
  134197. */
  134198. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  134199. /**
  134200. * Return the list of sub meshes colliding with a collider
  134201. * @param mesh defines the mesh to find the submesh for
  134202. * @param collider defines the collider to evaluate the collision against
  134203. * @returns the list of colliding sub meshes
  134204. */
  134205. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  134206. /**
  134207. * Rebuilds the elements related to this component in case of
  134208. * context lost for instance.
  134209. */
  134210. rebuild(): void;
  134211. /**
  134212. * Disposes the component and the associated ressources.
  134213. */
  134214. dispose(): void;
  134215. }
  134216. }
  134217. declare module BABYLON {
  134218. /**
  134219. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  134220. */
  134221. export class Gizmo implements IDisposable {
  134222. /** The utility layer the gizmo will be added to */
  134223. gizmoLayer: UtilityLayerRenderer;
  134224. /**
  134225. * The root mesh of the gizmo
  134226. */
  134227. _rootMesh: Mesh;
  134228. private _attachedMesh;
  134229. private _attachedNode;
  134230. /**
  134231. * Ratio for the scale of the gizmo (Default: 1)
  134232. */
  134233. protected _scaleRatio: number;
  134234. /**
  134235. * boolean updated by pointermove when a gizmo mesh is hovered
  134236. */
  134237. protected _isHovered: boolean;
  134238. /**
  134239. * Ratio for the scale of the gizmo (Default: 1)
  134240. */
  134241. set scaleRatio(value: number);
  134242. get scaleRatio(): number;
  134243. /**
  134244. * True when the mouse pointer is hovered a gizmo mesh
  134245. */
  134246. get isHovered(): boolean;
  134247. /**
  134248. * If a custom mesh has been set (Default: false)
  134249. */
  134250. protected _customMeshSet: boolean;
  134251. /**
  134252. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  134253. * * When set, interactions will be enabled
  134254. */
  134255. get attachedMesh(): Nullable<AbstractMesh>;
  134256. set attachedMesh(value: Nullable<AbstractMesh>);
  134257. /**
  134258. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  134259. * * When set, interactions will be enabled
  134260. */
  134261. get attachedNode(): Nullable<Node>;
  134262. set attachedNode(value: Nullable<Node>);
  134263. /**
  134264. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134265. * @param mesh The mesh to replace the default mesh of the gizmo
  134266. */
  134267. setCustomMesh(mesh: Mesh): void;
  134268. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  134269. /**
  134270. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  134271. */
  134272. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134273. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134274. /**
  134275. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  134276. */
  134277. updateGizmoPositionToMatchAttachedMesh: boolean;
  134278. /**
  134279. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  134280. */
  134281. updateScale: boolean;
  134282. protected _interactionsEnabled: boolean;
  134283. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134284. private _beforeRenderObserver;
  134285. private _tempQuaternion;
  134286. private _tempVector;
  134287. private _tempVector2;
  134288. private _tempMatrix1;
  134289. private _tempMatrix2;
  134290. private _rightHandtoLeftHandMatrix;
  134291. /**
  134292. * Creates a gizmo
  134293. * @param gizmoLayer The utility layer the gizmo will be added to
  134294. */
  134295. constructor(
  134296. /** The utility layer the gizmo will be added to */
  134297. gizmoLayer?: UtilityLayerRenderer);
  134298. /**
  134299. * Updates the gizmo to match the attached mesh's position/rotation
  134300. */
  134301. protected _update(): void;
  134302. /**
  134303. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  134304. * @param value Node, TransformNode or mesh
  134305. */
  134306. protected _matrixChanged(): void;
  134307. /**
  134308. * Disposes of the gizmo
  134309. */
  134310. dispose(): void;
  134311. }
  134312. }
  134313. declare module BABYLON {
  134314. /**
  134315. * Single plane drag gizmo
  134316. */
  134317. export class PlaneDragGizmo extends Gizmo {
  134318. /**
  134319. * Drag behavior responsible for the gizmos dragging interactions
  134320. */
  134321. dragBehavior: PointerDragBehavior;
  134322. private _pointerObserver;
  134323. /**
  134324. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134325. */
  134326. snapDistance: number;
  134327. /**
  134328. * Event that fires each time the gizmo snaps to a new location.
  134329. * * snapDistance is the the change in distance
  134330. */
  134331. onSnapObservable: Observable<{
  134332. snapDistance: number;
  134333. }>;
  134334. private _plane;
  134335. private _coloredMaterial;
  134336. private _hoverMaterial;
  134337. private _isEnabled;
  134338. private _parent;
  134339. /** @hidden */
  134340. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  134341. /** @hidden */
  134342. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134343. /**
  134344. * Creates a PlaneDragGizmo
  134345. * @param gizmoLayer The utility layer the gizmo will be added to
  134346. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  134347. * @param color The color of the gizmo
  134348. */
  134349. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  134350. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134351. /**
  134352. * If the gizmo is enabled
  134353. */
  134354. set isEnabled(value: boolean);
  134355. get isEnabled(): boolean;
  134356. /**
  134357. * Disposes of the gizmo
  134358. */
  134359. dispose(): void;
  134360. }
  134361. }
  134362. declare module BABYLON {
  134363. /**
  134364. * Gizmo that enables dragging a mesh along 3 axis
  134365. */
  134366. export class PositionGizmo extends Gizmo {
  134367. /**
  134368. * Internal gizmo used for interactions on the x axis
  134369. */
  134370. xGizmo: AxisDragGizmo;
  134371. /**
  134372. * Internal gizmo used for interactions on the y axis
  134373. */
  134374. yGizmo: AxisDragGizmo;
  134375. /**
  134376. * Internal gizmo used for interactions on the z axis
  134377. */
  134378. zGizmo: AxisDragGizmo;
  134379. /**
  134380. * Internal gizmo used for interactions on the yz plane
  134381. */
  134382. xPlaneGizmo: PlaneDragGizmo;
  134383. /**
  134384. * Internal gizmo used for interactions on the xz plane
  134385. */
  134386. yPlaneGizmo: PlaneDragGizmo;
  134387. /**
  134388. * Internal gizmo used for interactions on the xy plane
  134389. */
  134390. zPlaneGizmo: PlaneDragGizmo;
  134391. /**
  134392. * private variables
  134393. */
  134394. private _meshAttached;
  134395. private _nodeAttached;
  134396. private _snapDistance;
  134397. /** Fires an event when any of it's sub gizmos are dragged */
  134398. onDragStartObservable: Observable<unknown>;
  134399. /** Fires an event when any of it's sub gizmos are released from dragging */
  134400. onDragEndObservable: Observable<unknown>;
  134401. /**
  134402. * If set to true, planar drag is enabled
  134403. */
  134404. private _planarGizmoEnabled;
  134405. get attachedMesh(): Nullable<AbstractMesh>;
  134406. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134407. get attachedNode(): Nullable<Node>;
  134408. set attachedNode(node: Nullable<Node>);
  134409. /**
  134410. * True when the mouse pointer is hovering a gizmo mesh
  134411. */
  134412. get isHovered(): boolean;
  134413. /**
  134414. * Creates a PositionGizmo
  134415. * @param gizmoLayer The utility layer the gizmo will be added to
  134416. @param thickness display gizmo axis thickness
  134417. */
  134418. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134419. /**
  134420. * If the planar drag gizmo is enabled
  134421. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  134422. */
  134423. set planarGizmoEnabled(value: boolean);
  134424. get planarGizmoEnabled(): boolean;
  134425. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134426. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134427. /**
  134428. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134429. */
  134430. set snapDistance(value: number);
  134431. get snapDistance(): number;
  134432. /**
  134433. * Ratio for the scale of the gizmo (Default: 1)
  134434. */
  134435. set scaleRatio(value: number);
  134436. get scaleRatio(): number;
  134437. /**
  134438. * Disposes of the gizmo
  134439. */
  134440. dispose(): void;
  134441. /**
  134442. * CustomMeshes are not supported by this gizmo
  134443. * @param mesh The mesh to replace the default mesh of the gizmo
  134444. */
  134445. setCustomMesh(mesh: Mesh): void;
  134446. }
  134447. }
  134448. declare module BABYLON {
  134449. /**
  134450. * Single axis drag gizmo
  134451. */
  134452. export class AxisDragGizmo extends Gizmo {
  134453. /**
  134454. * Drag behavior responsible for the gizmos dragging interactions
  134455. */
  134456. dragBehavior: PointerDragBehavior;
  134457. private _pointerObserver;
  134458. /**
  134459. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134460. */
  134461. snapDistance: number;
  134462. /**
  134463. * Event that fires each time the gizmo snaps to a new location.
  134464. * * snapDistance is the the change in distance
  134465. */
  134466. onSnapObservable: Observable<{
  134467. snapDistance: number;
  134468. }>;
  134469. private _isEnabled;
  134470. private _parent;
  134471. private _arrow;
  134472. private _coloredMaterial;
  134473. private _hoverMaterial;
  134474. /** @hidden */
  134475. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  134476. /** @hidden */
  134477. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134478. /**
  134479. * Creates an AxisDragGizmo
  134480. * @param gizmoLayer The utility layer the gizmo will be added to
  134481. * @param dragAxis The axis which the gizmo will be able to drag on
  134482. * @param color The color of the gizmo
  134483. * @param thickness display gizmo axis thickness
  134484. */
  134485. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  134486. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134487. /**
  134488. * If the gizmo is enabled
  134489. */
  134490. set isEnabled(value: boolean);
  134491. get isEnabled(): boolean;
  134492. /**
  134493. * Disposes of the gizmo
  134494. */
  134495. dispose(): void;
  134496. }
  134497. }
  134498. declare module BABYLON.Debug {
  134499. /**
  134500. * The Axes viewer will show 3 axes in a specific point in space
  134501. */
  134502. export class AxesViewer {
  134503. private _xAxis;
  134504. private _yAxis;
  134505. private _zAxis;
  134506. private _scaleLinesFactor;
  134507. private _instanced;
  134508. /**
  134509. * Gets the hosting scene
  134510. */
  134511. scene: Nullable<Scene>;
  134512. /**
  134513. * Gets or sets a number used to scale line length
  134514. */
  134515. scaleLines: number;
  134516. /** Gets the node hierarchy used to render x-axis */
  134517. get xAxis(): TransformNode;
  134518. /** Gets the node hierarchy used to render y-axis */
  134519. get yAxis(): TransformNode;
  134520. /** Gets the node hierarchy used to render z-axis */
  134521. get zAxis(): TransformNode;
  134522. /**
  134523. * Creates a new AxesViewer
  134524. * @param scene defines the hosting scene
  134525. * @param scaleLines defines a number used to scale line length (1 by default)
  134526. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  134527. * @param xAxis defines the node hierarchy used to render the x-axis
  134528. * @param yAxis defines the node hierarchy used to render the y-axis
  134529. * @param zAxis defines the node hierarchy used to render the z-axis
  134530. */
  134531. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  134532. /**
  134533. * Force the viewer to update
  134534. * @param position defines the position of the viewer
  134535. * @param xaxis defines the x axis of the viewer
  134536. * @param yaxis defines the y axis of the viewer
  134537. * @param zaxis defines the z axis of the viewer
  134538. */
  134539. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  134540. /**
  134541. * Creates an instance of this axes viewer.
  134542. * @returns a new axes viewer with instanced meshes
  134543. */
  134544. createInstance(): AxesViewer;
  134545. /** Releases resources */
  134546. dispose(): void;
  134547. private static _SetRenderingGroupId;
  134548. }
  134549. }
  134550. declare module BABYLON.Debug {
  134551. /**
  134552. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  134553. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  134554. */
  134555. export class BoneAxesViewer extends AxesViewer {
  134556. /**
  134557. * Gets or sets the target mesh where to display the axes viewer
  134558. */
  134559. mesh: Nullable<Mesh>;
  134560. /**
  134561. * Gets or sets the target bone where to display the axes viewer
  134562. */
  134563. bone: Nullable<Bone>;
  134564. /** Gets current position */
  134565. pos: Vector3;
  134566. /** Gets direction of X axis */
  134567. xaxis: Vector3;
  134568. /** Gets direction of Y axis */
  134569. yaxis: Vector3;
  134570. /** Gets direction of Z axis */
  134571. zaxis: Vector3;
  134572. /**
  134573. * Creates a new BoneAxesViewer
  134574. * @param scene defines the hosting scene
  134575. * @param bone defines the target bone
  134576. * @param mesh defines the target mesh
  134577. * @param scaleLines defines a scaling factor for line length (1 by default)
  134578. */
  134579. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  134580. /**
  134581. * Force the viewer to update
  134582. */
  134583. update(): void;
  134584. /** Releases resources */
  134585. dispose(): void;
  134586. }
  134587. }
  134588. declare module BABYLON {
  134589. /**
  134590. * Interface used to define scene explorer extensibility option
  134591. */
  134592. export interface IExplorerExtensibilityOption {
  134593. /**
  134594. * Define the option label
  134595. */
  134596. label: string;
  134597. /**
  134598. * Defines the action to execute on click
  134599. */
  134600. action: (entity: any) => void;
  134601. }
  134602. /**
  134603. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  134604. */
  134605. export interface IExplorerExtensibilityGroup {
  134606. /**
  134607. * Defines a predicate to test if a given type mut be extended
  134608. */
  134609. predicate: (entity: any) => boolean;
  134610. /**
  134611. * Gets the list of options added to a type
  134612. */
  134613. entries: IExplorerExtensibilityOption[];
  134614. }
  134615. /**
  134616. * Interface used to define the options to use to create the Inspector
  134617. */
  134618. export interface IInspectorOptions {
  134619. /**
  134620. * Display in overlay mode (default: false)
  134621. */
  134622. overlay?: boolean;
  134623. /**
  134624. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  134625. */
  134626. globalRoot?: HTMLElement;
  134627. /**
  134628. * Display the Scene explorer
  134629. */
  134630. showExplorer?: boolean;
  134631. /**
  134632. * Display the property inspector
  134633. */
  134634. showInspector?: boolean;
  134635. /**
  134636. * Display in embed mode (both panes on the right)
  134637. */
  134638. embedMode?: boolean;
  134639. /**
  134640. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  134641. */
  134642. handleResize?: boolean;
  134643. /**
  134644. * Allow the panes to popup (default: true)
  134645. */
  134646. enablePopup?: boolean;
  134647. /**
  134648. * Allow the panes to be closed by users (default: true)
  134649. */
  134650. enableClose?: boolean;
  134651. /**
  134652. * Optional list of extensibility entries
  134653. */
  134654. explorerExtensibility?: IExplorerExtensibilityGroup[];
  134655. /**
  134656. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  134657. */
  134658. inspectorURL?: string;
  134659. /**
  134660. * Optional initial tab (default to DebugLayerTab.Properties)
  134661. */
  134662. initialTab?: DebugLayerTab;
  134663. }
  134664. interface Scene {
  134665. /**
  134666. * @hidden
  134667. * Backing field
  134668. */
  134669. _debugLayer: DebugLayer;
  134670. /**
  134671. * Gets the debug layer (aka Inspector) associated with the scene
  134672. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134673. */
  134674. debugLayer: DebugLayer;
  134675. }
  134676. /**
  134677. * Enum of inspector action tab
  134678. */
  134679. export enum DebugLayerTab {
  134680. /**
  134681. * Properties tag (default)
  134682. */
  134683. Properties = 0,
  134684. /**
  134685. * Debug tab
  134686. */
  134687. Debug = 1,
  134688. /**
  134689. * Statistics tab
  134690. */
  134691. Statistics = 2,
  134692. /**
  134693. * Tools tab
  134694. */
  134695. Tools = 3,
  134696. /**
  134697. * Settings tab
  134698. */
  134699. Settings = 4
  134700. }
  134701. /**
  134702. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134703. * what is happening in your scene
  134704. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134705. */
  134706. export class DebugLayer {
  134707. /**
  134708. * Define the url to get the inspector script from.
  134709. * By default it uses the babylonjs CDN.
  134710. * @ignoreNaming
  134711. */
  134712. static InspectorURL: string;
  134713. private _scene;
  134714. private BJSINSPECTOR;
  134715. private _onPropertyChangedObservable?;
  134716. /**
  134717. * Observable triggered when a property is changed through the inspector.
  134718. */
  134719. get onPropertyChangedObservable(): any;
  134720. /**
  134721. * Instantiates a new debug layer.
  134722. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134723. * what is happening in your scene
  134724. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134725. * @param scene Defines the scene to inspect
  134726. */
  134727. constructor(scene: Scene);
  134728. /** Creates the inspector window. */
  134729. private _createInspector;
  134730. /**
  134731. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  134732. * @param entity defines the entity to select
  134733. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  134734. */
  134735. select(entity: any, lineContainerTitles?: string | string[]): void;
  134736. /** Get the inspector from bundle or global */
  134737. private _getGlobalInspector;
  134738. /**
  134739. * Get if the inspector is visible or not.
  134740. * @returns true if visible otherwise, false
  134741. */
  134742. isVisible(): boolean;
  134743. /**
  134744. * Hide the inspector and close its window.
  134745. */
  134746. hide(): void;
  134747. /**
  134748. * Update the scene in the inspector
  134749. */
  134750. setAsActiveScene(): void;
  134751. /**
  134752. * Launch the debugLayer.
  134753. * @param config Define the configuration of the inspector
  134754. * @return a promise fulfilled when the debug layer is visible
  134755. */
  134756. show(config?: IInspectorOptions): Promise<DebugLayer>;
  134757. }
  134758. }
  134759. declare module BABYLON {
  134760. /**
  134761. * Class containing static functions to help procedurally build meshes
  134762. */
  134763. export class BoxBuilder {
  134764. /**
  134765. * Creates a box mesh
  134766. * * The parameter `size` sets the size (float) of each box side (default 1)
  134767. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134768. * * 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)
  134769. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134773. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134774. * @param name defines the name of the mesh
  134775. * @param options defines the options used to create the mesh
  134776. * @param scene defines the hosting scene
  134777. * @returns the box mesh
  134778. */
  134779. static CreateBox(name: string, options: {
  134780. size?: number;
  134781. width?: number;
  134782. height?: number;
  134783. depth?: number;
  134784. faceUV?: Vector4[];
  134785. faceColors?: Color4[];
  134786. sideOrientation?: number;
  134787. frontUVs?: Vector4;
  134788. backUVs?: Vector4;
  134789. wrap?: boolean;
  134790. topBaseAt?: number;
  134791. bottomBaseAt?: number;
  134792. updatable?: boolean;
  134793. }, scene?: Nullable<Scene>): Mesh;
  134794. }
  134795. }
  134796. declare module BABYLON.Debug {
  134797. /**
  134798. * Used to show the physics impostor around the specific mesh
  134799. */
  134800. export class PhysicsViewer {
  134801. /** @hidden */
  134802. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  134803. /** @hidden */
  134804. protected _meshes: Array<Nullable<AbstractMesh>>;
  134805. /** @hidden */
  134806. protected _scene: Nullable<Scene>;
  134807. /** @hidden */
  134808. protected _numMeshes: number;
  134809. /** @hidden */
  134810. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  134811. private _renderFunction;
  134812. private _utilityLayer;
  134813. private _debugBoxMesh;
  134814. private _debugSphereMesh;
  134815. private _debugCylinderMesh;
  134816. private _debugMaterial;
  134817. private _debugMeshMeshes;
  134818. /**
  134819. * Creates a new PhysicsViewer
  134820. * @param scene defines the hosting scene
  134821. */
  134822. constructor(scene: Scene);
  134823. /** @hidden */
  134824. protected _updateDebugMeshes(): void;
  134825. /**
  134826. * Renders a specified physic impostor
  134827. * @param impostor defines the impostor to render
  134828. * @param targetMesh defines the mesh represented by the impostor
  134829. * @returns the new debug mesh used to render the impostor
  134830. */
  134831. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  134832. /**
  134833. * Hides a specified physic impostor
  134834. * @param impostor defines the impostor to hide
  134835. */
  134836. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  134837. private _getDebugMaterial;
  134838. private _getDebugBoxMesh;
  134839. private _getDebugSphereMesh;
  134840. private _getDebugCylinderMesh;
  134841. private _getDebugMeshMesh;
  134842. private _getDebugMesh;
  134843. /** Releases all resources */
  134844. dispose(): void;
  134845. }
  134846. }
  134847. declare module BABYLON {
  134848. /**
  134849. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134850. * in order to better appreciate the issue one might have.
  134851. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134852. */
  134853. export class RayHelper {
  134854. /**
  134855. * Defines the ray we are currently tryin to visualize.
  134856. */
  134857. ray: Nullable<Ray>;
  134858. private _renderPoints;
  134859. private _renderLine;
  134860. private _renderFunction;
  134861. private _scene;
  134862. private _onAfterRenderObserver;
  134863. private _onAfterStepObserver;
  134864. private _attachedToMesh;
  134865. private _meshSpaceDirection;
  134866. private _meshSpaceOrigin;
  134867. /**
  134868. * Helper function to create a colored helper in a scene in one line.
  134869. * @param ray Defines the ray we are currently tryin to visualize
  134870. * @param scene Defines the scene the ray is used in
  134871. * @param color Defines the color we want to see the ray in
  134872. * @returns The newly created ray helper.
  134873. */
  134874. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  134875. /**
  134876. * Instantiate a new ray helper.
  134877. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134878. * in order to better appreciate the issue one might have.
  134879. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134880. * @param ray Defines the ray we are currently tryin to visualize
  134881. */
  134882. constructor(ray: Ray);
  134883. /**
  134884. * Shows the ray we are willing to debug.
  134885. * @param scene Defines the scene the ray needs to be rendered in
  134886. * @param color Defines the color the ray needs to be rendered in
  134887. */
  134888. show(scene: Scene, color?: Color3): void;
  134889. /**
  134890. * Hides the ray we are debugging.
  134891. */
  134892. hide(): void;
  134893. private _render;
  134894. /**
  134895. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  134896. * @param mesh Defines the mesh we want the helper attached to
  134897. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  134898. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  134899. * @param length Defines the length of the ray
  134900. */
  134901. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  134902. /**
  134903. * Detach the ray helper from the mesh it has previously been attached to.
  134904. */
  134905. detachFromMesh(): void;
  134906. private _updateToMesh;
  134907. /**
  134908. * Dispose the helper and release its associated resources.
  134909. */
  134910. dispose(): void;
  134911. }
  134912. }
  134913. declare module BABYLON {
  134914. /**
  134915. * Defines the options associated with the creation of a SkeletonViewer.
  134916. */
  134917. export interface ISkeletonViewerOptions {
  134918. /** Should the system pause animations before building the Viewer? */
  134919. pauseAnimations: boolean;
  134920. /** Should the system return the skeleton to rest before building? */
  134921. returnToRest: boolean;
  134922. /** public Display Mode of the Viewer */
  134923. displayMode: number;
  134924. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134925. displayOptions: ISkeletonViewerDisplayOptions;
  134926. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134927. computeBonesUsingShaders: boolean;
  134928. /** Flag ignore non weighted bones */
  134929. useAllBones: boolean;
  134930. }
  134931. /**
  134932. * Defines how to display the various bone meshes for the viewer.
  134933. */
  134934. export interface ISkeletonViewerDisplayOptions {
  134935. /** How far down to start tapering the bone spurs */
  134936. midStep?: number;
  134937. /** How big is the midStep? */
  134938. midStepFactor?: number;
  134939. /** Base for the Sphere Size */
  134940. sphereBaseSize?: number;
  134941. /** The ratio of the sphere to the longest bone in units */
  134942. sphereScaleUnit?: number;
  134943. /** Ratio for the Sphere Size */
  134944. sphereFactor?: number;
  134945. /** Whether a spur should attach its far end to the child bone position */
  134946. spurFollowsChild?: boolean;
  134947. /** Whether to show local axes or not */
  134948. showLocalAxes?: boolean;
  134949. /** Length of each local axis */
  134950. localAxesSize?: number;
  134951. }
  134952. /**
  134953. * Defines the constructor options for the BoneWeight Shader.
  134954. */
  134955. export interface IBoneWeightShaderOptions {
  134956. /** Skeleton to Map */
  134957. skeleton: Skeleton;
  134958. /** Colors for Uninfluenced bones */
  134959. colorBase?: Color3;
  134960. /** Colors for 0.0-0.25 Weight bones */
  134961. colorZero?: Color3;
  134962. /** Color for 0.25-0.5 Weight Influence */
  134963. colorQuarter?: Color3;
  134964. /** Color for 0.5-0.75 Weight Influence */
  134965. colorHalf?: Color3;
  134966. /** Color for 0.75-1 Weight Influence */
  134967. colorFull?: Color3;
  134968. /** Color for Zero Weight Influence */
  134969. targetBoneIndex?: number;
  134970. }
  134971. /**
  134972. * Simple structure of the gradient steps for the Color Map.
  134973. */
  134974. export interface ISkeletonMapShaderColorMapKnot {
  134975. /** Color of the Knot */
  134976. color: Color3;
  134977. /** Location of the Knot */
  134978. location: number;
  134979. }
  134980. /**
  134981. * Defines the constructor options for the SkeletonMap Shader.
  134982. */
  134983. export interface ISkeletonMapShaderOptions {
  134984. /** Skeleton to Map */
  134985. skeleton: Skeleton;
  134986. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  134987. colorMap?: ISkeletonMapShaderColorMapKnot[];
  134988. }
  134989. }
  134990. declare module BABYLON {
  134991. /**
  134992. * Class containing static functions to help procedurally build meshes
  134993. */
  134994. export class RibbonBuilder {
  134995. /**
  134996. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134997. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134998. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134999. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135000. * * 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
  135001. * * 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
  135002. * * 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
  135003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135004. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135005. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135006. * * 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
  135007. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135008. * * 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
  135009. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135011. * @param name defines the name of the mesh
  135012. * @param options defines the options used to create the mesh
  135013. * @param scene defines the hosting scene
  135014. * @returns the ribbon mesh
  135015. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135016. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135017. */
  135018. static CreateRibbon(name: string, options: {
  135019. pathArray: Vector3[][];
  135020. closeArray?: boolean;
  135021. closePath?: boolean;
  135022. offset?: number;
  135023. updatable?: boolean;
  135024. sideOrientation?: number;
  135025. frontUVs?: Vector4;
  135026. backUVs?: Vector4;
  135027. instance?: Mesh;
  135028. invertUV?: boolean;
  135029. uvs?: Vector2[];
  135030. colors?: Color4[];
  135031. }, scene?: Nullable<Scene>): Mesh;
  135032. }
  135033. }
  135034. declare module BABYLON {
  135035. /**
  135036. * Class containing static functions to help procedurally build meshes
  135037. */
  135038. export class ShapeBuilder {
  135039. /**
  135040. * 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.
  135041. * * 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.
  135042. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135043. * * 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.
  135044. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135045. * * 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
  135046. * * 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
  135047. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135049. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135050. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135052. * @param name defines the name of the mesh
  135053. * @param options defines the options used to create the mesh
  135054. * @param scene defines the hosting scene
  135055. * @returns the extruded shape mesh
  135056. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135058. */
  135059. static ExtrudeShape(name: string, options: {
  135060. shape: Vector3[];
  135061. path: Vector3[];
  135062. scale?: number;
  135063. rotation?: number;
  135064. cap?: number;
  135065. updatable?: boolean;
  135066. sideOrientation?: number;
  135067. frontUVs?: Vector4;
  135068. backUVs?: Vector4;
  135069. instance?: Mesh;
  135070. invertUV?: boolean;
  135071. }, scene?: Nullable<Scene>): Mesh;
  135072. /**
  135073. * Creates an custom extruded shape mesh.
  135074. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135075. * * 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.
  135076. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135077. * * 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
  135078. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135079. * * 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
  135080. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135081. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135082. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135083. * * 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
  135084. * * 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
  135085. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135088. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135090. * @param name defines the name of the mesh
  135091. * @param options defines the options used to create the mesh
  135092. * @param scene defines the hosting scene
  135093. * @returns the custom extruded shape mesh
  135094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135095. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135097. */
  135098. static ExtrudeShapeCustom(name: string, options: {
  135099. shape: Vector3[];
  135100. path: Vector3[];
  135101. scaleFunction?: any;
  135102. rotationFunction?: any;
  135103. ribbonCloseArray?: boolean;
  135104. ribbonClosePath?: boolean;
  135105. cap?: number;
  135106. updatable?: boolean;
  135107. sideOrientation?: number;
  135108. frontUVs?: Vector4;
  135109. backUVs?: Vector4;
  135110. instance?: Mesh;
  135111. invertUV?: boolean;
  135112. }, scene?: Nullable<Scene>): Mesh;
  135113. private static _ExtrudeShapeGeneric;
  135114. }
  135115. }
  135116. declare module BABYLON.Debug {
  135117. /**
  135118. * Class used to render a debug view of a given skeleton
  135119. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  135120. */
  135121. export class SkeletonViewer {
  135122. /** defines the skeleton to render */
  135123. skeleton: Skeleton;
  135124. /** defines the mesh attached to the skeleton */
  135125. mesh: AbstractMesh;
  135126. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135127. autoUpdateBonesMatrices: boolean;
  135128. /** defines the rendering group id to use with the viewer */
  135129. renderingGroupId: number;
  135130. /** is the options for the viewer */
  135131. options: Partial<ISkeletonViewerOptions>;
  135132. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  135133. static readonly DISPLAY_LINES: number;
  135134. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  135135. static readonly DISPLAY_SPHERES: number;
  135136. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  135137. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  135138. /** public static method to create a BoneWeight Shader
  135139. * @param options The constructor options
  135140. * @param scene The scene that the shader is scoped to
  135141. * @returns The created ShaderMaterial
  135142. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  135143. */
  135144. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  135145. /** public static method to create a BoneWeight Shader
  135146. * @param options The constructor options
  135147. * @param scene The scene that the shader is scoped to
  135148. * @returns The created ShaderMaterial
  135149. */
  135150. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  135151. /** private static method to create a BoneWeight Shader
  135152. * @param size The size of the buffer to create (usually the bone count)
  135153. * @param colorMap The gradient data to generate
  135154. * @param scene The scene that the shader is scoped to
  135155. * @returns an Array of floats from the color gradient values
  135156. */
  135157. private static _CreateBoneMapColorBuffer;
  135158. /** If SkeletonViewer scene scope. */
  135159. private _scene;
  135160. /** Gets or sets the color used to render the skeleton */
  135161. color: Color3;
  135162. /** Array of the points of the skeleton fo the line view. */
  135163. private _debugLines;
  135164. /** The SkeletonViewers Mesh. */
  135165. private _debugMesh;
  135166. /** The local axes Meshes. */
  135167. private _localAxes;
  135168. /** If SkeletonViewer is enabled. */
  135169. private _isEnabled;
  135170. /** If SkeletonViewer is ready. */
  135171. private _ready;
  135172. /** SkeletonViewer render observable. */
  135173. private _obs;
  135174. /** The Utility Layer to render the gizmos in. */
  135175. private _utilityLayer;
  135176. private _boneIndices;
  135177. /** Gets the Scene. */
  135178. get scene(): Scene;
  135179. /** Gets the utilityLayer. */
  135180. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  135181. /** Checks Ready Status. */
  135182. get isReady(): Boolean;
  135183. /** Sets Ready Status. */
  135184. set ready(value: boolean);
  135185. /** Gets the debugMesh */
  135186. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  135187. /** Sets the debugMesh */
  135188. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  135189. /** Gets the displayMode */
  135190. get displayMode(): number;
  135191. /** Sets the displayMode */
  135192. set displayMode(value: number);
  135193. /**
  135194. * Creates a new SkeletonViewer
  135195. * @param skeleton defines the skeleton to render
  135196. * @param mesh defines the mesh attached to the skeleton
  135197. * @param scene defines the hosting scene
  135198. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  135199. * @param renderingGroupId defines the rendering group id to use with the viewer
  135200. * @param options All of the extra constructor options for the SkeletonViewer
  135201. */
  135202. constructor(
  135203. /** defines the skeleton to render */
  135204. skeleton: Skeleton,
  135205. /** defines the mesh attached to the skeleton */
  135206. mesh: AbstractMesh,
  135207. /** The Scene scope*/
  135208. scene: Scene,
  135209. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135210. autoUpdateBonesMatrices?: boolean,
  135211. /** defines the rendering group id to use with the viewer */
  135212. renderingGroupId?: number,
  135213. /** is the options for the viewer */
  135214. options?: Partial<ISkeletonViewerOptions>);
  135215. /** The Dynamic bindings for the update functions */
  135216. private _bindObs;
  135217. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  135218. update(): void;
  135219. /** Gets or sets a boolean indicating if the viewer is enabled */
  135220. set isEnabled(value: boolean);
  135221. get isEnabled(): boolean;
  135222. private _getBonePosition;
  135223. private _getLinesForBonesWithLength;
  135224. private _getLinesForBonesNoLength;
  135225. /** function to revert the mesh and scene back to the initial state. */
  135226. private _revert;
  135227. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  135228. private _getAbsoluteBindPoseToRef;
  135229. /** function to build and bind sphere joint points and spur bone representations. */
  135230. private _buildSpheresAndSpurs;
  135231. private _buildLocalAxes;
  135232. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  135233. private _displayLinesUpdate;
  135234. /** Changes the displayMode of the skeleton viewer
  135235. * @param mode The displayMode numerical value
  135236. */
  135237. changeDisplayMode(mode: number): void;
  135238. /** Sets a display option of the skeleton viewer
  135239. *
  135240. * | Option | Type | Default | Description |
  135241. * | ---------------- | ------- | ------- | ----------- |
  135242. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135243. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135244. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135245. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135246. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  135247. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  135248. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  135249. *
  135250. * @param option String of the option name
  135251. * @param value The numerical option value
  135252. */
  135253. changeDisplayOptions(option: string, value: number): void;
  135254. /** Release associated resources */
  135255. dispose(): void;
  135256. }
  135257. }
  135258. declare module BABYLON {
  135259. /**
  135260. * Enum for Device Types
  135261. */
  135262. export enum DeviceType {
  135263. /** Generic */
  135264. Generic = 0,
  135265. /** Keyboard */
  135266. Keyboard = 1,
  135267. /** Mouse */
  135268. Mouse = 2,
  135269. /** Touch Pointers */
  135270. Touch = 3,
  135271. /** PS4 Dual Shock */
  135272. DualShock = 4,
  135273. /** Xbox */
  135274. Xbox = 5,
  135275. /** Switch Controller */
  135276. Switch = 6
  135277. }
  135278. /**
  135279. * Enum for All Pointers (Touch/Mouse)
  135280. */
  135281. export enum PointerInput {
  135282. /** Horizontal Axis */
  135283. Horizontal = 0,
  135284. /** Vertical Axis */
  135285. Vertical = 1,
  135286. /** Left Click or Touch */
  135287. LeftClick = 2,
  135288. /** Middle Click */
  135289. MiddleClick = 3,
  135290. /** Right Click */
  135291. RightClick = 4,
  135292. /** Browser Back */
  135293. BrowserBack = 5,
  135294. /** Browser Forward */
  135295. BrowserForward = 6
  135296. }
  135297. /**
  135298. * Enum for Dual Shock Gamepad
  135299. */
  135300. export enum DualShockInput {
  135301. /** Cross */
  135302. Cross = 0,
  135303. /** Circle */
  135304. Circle = 1,
  135305. /** Square */
  135306. Square = 2,
  135307. /** Triangle */
  135308. Triangle = 3,
  135309. /** L1 */
  135310. L1 = 4,
  135311. /** R1 */
  135312. R1 = 5,
  135313. /** L2 */
  135314. L2 = 6,
  135315. /** R2 */
  135316. R2 = 7,
  135317. /** Share */
  135318. Share = 8,
  135319. /** Options */
  135320. Options = 9,
  135321. /** L3 */
  135322. L3 = 10,
  135323. /** R3 */
  135324. R3 = 11,
  135325. /** DPadUp */
  135326. DPadUp = 12,
  135327. /** DPadDown */
  135328. DPadDown = 13,
  135329. /** DPadLeft */
  135330. DPadLeft = 14,
  135331. /** DRight */
  135332. DPadRight = 15,
  135333. /** Home */
  135334. Home = 16,
  135335. /** TouchPad */
  135336. TouchPad = 17,
  135337. /** LStickXAxis */
  135338. LStickXAxis = 18,
  135339. /** LStickYAxis */
  135340. LStickYAxis = 19,
  135341. /** RStickXAxis */
  135342. RStickXAxis = 20,
  135343. /** RStickYAxis */
  135344. RStickYAxis = 21
  135345. }
  135346. /**
  135347. * Enum for Xbox Gamepad
  135348. */
  135349. export enum XboxInput {
  135350. /** A */
  135351. A = 0,
  135352. /** B */
  135353. B = 1,
  135354. /** X */
  135355. X = 2,
  135356. /** Y */
  135357. Y = 3,
  135358. /** LB */
  135359. LB = 4,
  135360. /** RB */
  135361. RB = 5,
  135362. /** LT */
  135363. LT = 6,
  135364. /** RT */
  135365. RT = 7,
  135366. /** Back */
  135367. Back = 8,
  135368. /** Start */
  135369. Start = 9,
  135370. /** LS */
  135371. LS = 10,
  135372. /** RS */
  135373. RS = 11,
  135374. /** DPadUp */
  135375. DPadUp = 12,
  135376. /** DPadDown */
  135377. DPadDown = 13,
  135378. /** DPadLeft */
  135379. DPadLeft = 14,
  135380. /** DRight */
  135381. DPadRight = 15,
  135382. /** Home */
  135383. Home = 16,
  135384. /** LStickXAxis */
  135385. LStickXAxis = 17,
  135386. /** LStickYAxis */
  135387. LStickYAxis = 18,
  135388. /** RStickXAxis */
  135389. RStickXAxis = 19,
  135390. /** RStickYAxis */
  135391. RStickYAxis = 20
  135392. }
  135393. /**
  135394. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  135395. */
  135396. export enum SwitchInput {
  135397. /** B */
  135398. B = 0,
  135399. /** A */
  135400. A = 1,
  135401. /** Y */
  135402. Y = 2,
  135403. /** X */
  135404. X = 3,
  135405. /** L */
  135406. L = 4,
  135407. /** R */
  135408. R = 5,
  135409. /** ZL */
  135410. ZL = 6,
  135411. /** ZR */
  135412. ZR = 7,
  135413. /** Minus */
  135414. Minus = 8,
  135415. /** Plus */
  135416. Plus = 9,
  135417. /** LS */
  135418. LS = 10,
  135419. /** RS */
  135420. RS = 11,
  135421. /** DPadUp */
  135422. DPadUp = 12,
  135423. /** DPadDown */
  135424. DPadDown = 13,
  135425. /** DPadLeft */
  135426. DPadLeft = 14,
  135427. /** DRight */
  135428. DPadRight = 15,
  135429. /** Home */
  135430. Home = 16,
  135431. /** Capture */
  135432. Capture = 17,
  135433. /** LStickXAxis */
  135434. LStickXAxis = 18,
  135435. /** LStickYAxis */
  135436. LStickYAxis = 19,
  135437. /** RStickXAxis */
  135438. RStickXAxis = 20,
  135439. /** RStickYAxis */
  135440. RStickYAxis = 21
  135441. }
  135442. }
  135443. declare module BABYLON {
  135444. /**
  135445. * This class will take all inputs from Keyboard, Pointer, and
  135446. * any Gamepads and provide a polling system that all devices
  135447. * will use. This class assumes that there will only be one
  135448. * pointer device and one keyboard.
  135449. */
  135450. export class DeviceInputSystem implements IDisposable {
  135451. /**
  135452. * Callback to be triggered when a device is connected
  135453. */
  135454. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135455. /**
  135456. * Callback to be triggered when a device is disconnected
  135457. */
  135458. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135459. /**
  135460. * Callback to be triggered when event driven input is updated
  135461. */
  135462. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  135463. private _inputs;
  135464. private _gamepads;
  135465. private _keyboardActive;
  135466. private _pointerActive;
  135467. private _elementToAttachTo;
  135468. private _keyboardDownEvent;
  135469. private _keyboardUpEvent;
  135470. private _pointerMoveEvent;
  135471. private _pointerDownEvent;
  135472. private _pointerUpEvent;
  135473. private _gamepadConnectedEvent;
  135474. private _gamepadDisconnectedEvent;
  135475. private static _MAX_KEYCODES;
  135476. private static _MAX_POINTER_INPUTS;
  135477. private constructor();
  135478. /**
  135479. * Creates a new DeviceInputSystem instance
  135480. * @param engine Engine to pull input element from
  135481. * @returns The new instance
  135482. */
  135483. static Create(engine: Engine): DeviceInputSystem;
  135484. /**
  135485. * Checks for current device input value, given an id and input index
  135486. * @param deviceName Id of connected device
  135487. * @param inputIndex Index of device input
  135488. * @returns Current value of input
  135489. */
  135490. /**
  135491. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  135492. * @param deviceType Enum specifiying device type
  135493. * @param deviceSlot "Slot" or index that device is referenced in
  135494. * @param inputIndex Id of input to be checked
  135495. * @returns Current value of input
  135496. */
  135497. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  135498. /**
  135499. * Dispose of all the eventlisteners
  135500. */
  135501. dispose(): void;
  135502. /**
  135503. * Add device and inputs to device array
  135504. * @param deviceType Enum specifiying device type
  135505. * @param deviceSlot "Slot" or index that device is referenced in
  135506. * @param numberOfInputs Number of input entries to create for given device
  135507. */
  135508. private _registerDevice;
  135509. /**
  135510. * Given a specific device name, remove that device from the device map
  135511. * @param deviceType Enum specifiying device type
  135512. * @param deviceSlot "Slot" or index that device is referenced in
  135513. */
  135514. private _unregisterDevice;
  135515. /**
  135516. * Handle all actions that come from keyboard interaction
  135517. */
  135518. private _handleKeyActions;
  135519. /**
  135520. * Handle all actions that come from pointer interaction
  135521. */
  135522. private _handlePointerActions;
  135523. /**
  135524. * Handle all actions that come from gamepad interaction
  135525. */
  135526. private _handleGamepadActions;
  135527. /**
  135528. * Update all non-event based devices with each frame
  135529. * @param deviceType Enum specifiying device type
  135530. * @param deviceSlot "Slot" or index that device is referenced in
  135531. * @param inputIndex Id of input to be checked
  135532. */
  135533. private _updateDevice;
  135534. /**
  135535. * Gets DeviceType from the device name
  135536. * @param deviceName Name of Device from DeviceInputSystem
  135537. * @returns DeviceType enum value
  135538. */
  135539. private _getGamepadDeviceType;
  135540. }
  135541. }
  135542. declare module BABYLON {
  135543. /**
  135544. * Type to handle enforcement of inputs
  135545. */
  135546. 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;
  135547. }
  135548. declare module BABYLON {
  135549. /**
  135550. * Class that handles all input for a specific device
  135551. */
  135552. export class DeviceSource<T extends DeviceType> {
  135553. /** Type of device */
  135554. readonly deviceType: DeviceType;
  135555. /** "Slot" or index that device is referenced in */
  135556. readonly deviceSlot: number;
  135557. /**
  135558. * Observable to handle device input changes per device
  135559. */
  135560. readonly onInputChangedObservable: Observable<{
  135561. inputIndex: DeviceInput<T>;
  135562. previousState: Nullable<number>;
  135563. currentState: Nullable<number>;
  135564. }>;
  135565. private readonly _deviceInputSystem;
  135566. /**
  135567. * Default Constructor
  135568. * @param deviceInputSystem Reference to DeviceInputSystem
  135569. * @param deviceType Type of device
  135570. * @param deviceSlot "Slot" or index that device is referenced in
  135571. */
  135572. constructor(deviceInputSystem: DeviceInputSystem,
  135573. /** Type of device */
  135574. deviceType: DeviceType,
  135575. /** "Slot" or index that device is referenced in */
  135576. deviceSlot?: number);
  135577. /**
  135578. * Get input for specific input
  135579. * @param inputIndex index of specific input on device
  135580. * @returns Input value from DeviceInputSystem
  135581. */
  135582. getInput(inputIndex: DeviceInput<T>): number;
  135583. }
  135584. /**
  135585. * Class to keep track of devices
  135586. */
  135587. export class DeviceSourceManager implements IDisposable {
  135588. /**
  135589. * Observable to be triggered when before a device is connected
  135590. */
  135591. readonly onBeforeDeviceConnectedObservable: Observable<{
  135592. deviceType: DeviceType;
  135593. deviceSlot: number;
  135594. }>;
  135595. /**
  135596. * Observable to be triggered when before a device is disconnected
  135597. */
  135598. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  135599. deviceType: DeviceType;
  135600. deviceSlot: number;
  135601. }>;
  135602. /**
  135603. * Observable to be triggered when after a device is connected
  135604. */
  135605. readonly onAfterDeviceConnectedObservable: Observable<{
  135606. deviceType: DeviceType;
  135607. deviceSlot: number;
  135608. }>;
  135609. /**
  135610. * Observable to be triggered when after a device is disconnected
  135611. */
  135612. readonly onAfterDeviceDisconnectedObservable: Observable<{
  135613. deviceType: DeviceType;
  135614. deviceSlot: number;
  135615. }>;
  135616. private readonly _devices;
  135617. private readonly _firstDevice;
  135618. private readonly _deviceInputSystem;
  135619. /**
  135620. * Default Constructor
  135621. * @param engine engine to pull input element from
  135622. */
  135623. constructor(engine: Engine);
  135624. /**
  135625. * Gets a DeviceSource, given a type and slot
  135626. * @param deviceType Enum specifying device type
  135627. * @param deviceSlot "Slot" or index that device is referenced in
  135628. * @returns DeviceSource object
  135629. */
  135630. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  135631. /**
  135632. * Gets an array of DeviceSource objects for a given device type
  135633. * @param deviceType Enum specifying device type
  135634. * @returns Array of DeviceSource objects
  135635. */
  135636. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  135637. /**
  135638. * Dispose of DeviceInputSystem and other parts
  135639. */
  135640. dispose(): void;
  135641. /**
  135642. * Function to add device name to device list
  135643. * @param deviceType Enum specifying device type
  135644. * @param deviceSlot "Slot" or index that device is referenced in
  135645. */
  135646. private _addDevice;
  135647. /**
  135648. * Function to remove device name to device list
  135649. * @param deviceType Enum specifying device type
  135650. * @param deviceSlot "Slot" or index that device is referenced in
  135651. */
  135652. private _removeDevice;
  135653. /**
  135654. * Updates array storing first connected device of each type
  135655. * @param type Type of Device
  135656. */
  135657. private _updateFirstDevices;
  135658. }
  135659. }
  135660. declare module BABYLON {
  135661. /**
  135662. * Options to create the null engine
  135663. */
  135664. export class NullEngineOptions {
  135665. /**
  135666. * Render width (Default: 512)
  135667. */
  135668. renderWidth: number;
  135669. /**
  135670. * Render height (Default: 256)
  135671. */
  135672. renderHeight: number;
  135673. /**
  135674. * Texture size (Default: 512)
  135675. */
  135676. textureSize: number;
  135677. /**
  135678. * If delta time between frames should be constant
  135679. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135680. */
  135681. deterministicLockstep: boolean;
  135682. /**
  135683. * Maximum about of steps between frames (Default: 4)
  135684. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135685. */
  135686. lockstepMaxSteps: number;
  135687. /**
  135688. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  135689. */
  135690. useHighPrecisionMatrix?: boolean;
  135691. }
  135692. /**
  135693. * The null engine class provides support for headless version of babylon.js.
  135694. * This can be used in server side scenario or for testing purposes
  135695. */
  135696. export class NullEngine extends Engine {
  135697. private _options;
  135698. /**
  135699. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  135700. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135701. * @returns true if engine is in deterministic lock step mode
  135702. */
  135703. isDeterministicLockStep(): boolean;
  135704. /**
  135705. * Gets the max steps when engine is running in deterministic lock step
  135706. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135707. * @returns the max steps
  135708. */
  135709. getLockstepMaxSteps(): number;
  135710. /**
  135711. * Gets the current hardware scaling level.
  135712. * By default the hardware scaling level is computed from the window device ratio.
  135713. * 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.
  135714. * @returns a number indicating the current hardware scaling level
  135715. */
  135716. getHardwareScalingLevel(): number;
  135717. constructor(options?: NullEngineOptions);
  135718. /**
  135719. * Creates a vertex buffer
  135720. * @param vertices the data for the vertex buffer
  135721. * @returns the new WebGL static buffer
  135722. */
  135723. createVertexBuffer(vertices: FloatArray): DataBuffer;
  135724. /**
  135725. * Creates a new index buffer
  135726. * @param indices defines the content of the index buffer
  135727. * @param updatable defines if the index buffer must be updatable
  135728. * @returns a new webGL buffer
  135729. */
  135730. createIndexBuffer(indices: IndicesArray): DataBuffer;
  135731. /**
  135732. * Clear the current render buffer or the current render target (if any is set up)
  135733. * @param color defines the color to use
  135734. * @param backBuffer defines if the back buffer must be cleared
  135735. * @param depth defines if the depth buffer must be cleared
  135736. * @param stencil defines if the stencil buffer must be cleared
  135737. */
  135738. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  135739. /**
  135740. * Gets the current render width
  135741. * @param useScreen defines if screen size must be used (or the current render target if any)
  135742. * @returns a number defining the current render width
  135743. */
  135744. getRenderWidth(useScreen?: boolean): number;
  135745. /**
  135746. * Gets the current render height
  135747. * @param useScreen defines if screen size must be used (or the current render target if any)
  135748. * @returns a number defining the current render height
  135749. */
  135750. getRenderHeight(useScreen?: boolean): number;
  135751. /**
  135752. * Set the WebGL's viewport
  135753. * @param viewport defines the viewport element to be used
  135754. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  135755. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  135756. */
  135757. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  135758. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  135759. /**
  135760. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  135761. * @param pipelineContext defines the pipeline context to use
  135762. * @param uniformsNames defines the list of uniform names
  135763. * @returns an array of webGL uniform locations
  135764. */
  135765. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  135766. /**
  135767. * Gets the lsit of active attributes for a given webGL program
  135768. * @param pipelineContext defines the pipeline context to use
  135769. * @param attributesNames defines the list of attribute names to get
  135770. * @returns an array of indices indicating the offset of each attribute
  135771. */
  135772. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  135773. /**
  135774. * Binds an effect to the webGL context
  135775. * @param effect defines the effect to bind
  135776. */
  135777. bindSamplers(effect: Effect): void;
  135778. /**
  135779. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  135780. * @param effect defines the effect to activate
  135781. */
  135782. enableEffect(effect: Effect): void;
  135783. /**
  135784. * Set various states to the webGL context
  135785. * @param culling defines backface culling state
  135786. * @param zOffset defines the value to apply to zOffset (0 by default)
  135787. * @param force defines if states must be applied even if cache is up to date
  135788. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  135789. */
  135790. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  135791. /**
  135792. * Set the value of an uniform to an array of int32
  135793. * @param uniform defines the webGL uniform location where to store the value
  135794. * @param array defines the array of int32 to store
  135795. * @returns true if value was set
  135796. */
  135797. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135798. /**
  135799. * Set the value of an uniform to an array of int32 (stored as vec2)
  135800. * @param uniform defines the webGL uniform location where to store the value
  135801. * @param array defines the array of int32 to store
  135802. * @returns true if value was set
  135803. */
  135804. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135805. /**
  135806. * Set the value of an uniform to an array of int32 (stored as vec3)
  135807. * @param uniform defines the webGL uniform location where to store the value
  135808. * @param array defines the array of int32 to store
  135809. * @returns true if value was set
  135810. */
  135811. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135812. /**
  135813. * Set the value of an uniform to an array of int32 (stored as vec4)
  135814. * @param uniform defines the webGL uniform location where to store the value
  135815. * @param array defines the array of int32 to store
  135816. * @returns true if value was set
  135817. */
  135818. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135819. /**
  135820. * Set the value of an uniform to an array of float32
  135821. * @param uniform defines the webGL uniform location where to store the value
  135822. * @param array defines the array of float32 to store
  135823. * @returns true if value was set
  135824. */
  135825. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135826. /**
  135827. * Set the value of an uniform to an array of float32 (stored as vec2)
  135828. * @param uniform defines the webGL uniform location where to store the value
  135829. * @param array defines the array of float32 to store
  135830. * @returns true if value was set
  135831. */
  135832. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135833. /**
  135834. * Set the value of an uniform to an array of float32 (stored as vec3)
  135835. * @param uniform defines the webGL uniform location where to store the value
  135836. * @param array defines the array of float32 to store
  135837. * @returns true if value was set
  135838. */
  135839. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135840. /**
  135841. * Set the value of an uniform to an array of float32 (stored as vec4)
  135842. * @param uniform defines the webGL uniform location where to store the value
  135843. * @param array defines the array of float32 to store
  135844. * @returns true if value was set
  135845. */
  135846. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135847. /**
  135848. * Set the value of an uniform to an array of number
  135849. * @param uniform defines the webGL uniform location where to store the value
  135850. * @param array defines the array of number to store
  135851. * @returns true if value was set
  135852. */
  135853. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  135854. /**
  135855. * Set the value of an uniform to an array of number (stored as vec2)
  135856. * @param uniform defines the webGL uniform location where to store the value
  135857. * @param array defines the array of number to store
  135858. * @returns true if value was set
  135859. */
  135860. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  135861. /**
  135862. * Set the value of an uniform to an array of number (stored as vec3)
  135863. * @param uniform defines the webGL uniform location where to store the value
  135864. * @param array defines the array of number to store
  135865. * @returns true if value was set
  135866. */
  135867. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  135868. /**
  135869. * Set the value of an uniform to an array of number (stored as vec4)
  135870. * @param uniform defines the webGL uniform location where to store the value
  135871. * @param array defines the array of number to store
  135872. * @returns true if value was set
  135873. */
  135874. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  135875. /**
  135876. * Set the value of an uniform to an array of float32 (stored as matrices)
  135877. * @param uniform defines the webGL uniform location where to store the value
  135878. * @param matrices defines the array of float32 to store
  135879. * @returns true if value was set
  135880. */
  135881. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  135882. /**
  135883. * Set the value of an uniform to a matrix (3x3)
  135884. * @param uniform defines the webGL uniform location where to store the value
  135885. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  135886. * @returns true if value was set
  135887. */
  135888. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135889. /**
  135890. * Set the value of an uniform to a matrix (2x2)
  135891. * @param uniform defines the webGL uniform location where to store the value
  135892. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  135893. * @returns true if value was set
  135894. */
  135895. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135896. /**
  135897. * Set the value of an uniform to a number (float)
  135898. * @param uniform defines the webGL uniform location where to store the value
  135899. * @param value defines the float number to store
  135900. * @returns true if value was set
  135901. */
  135902. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  135903. /**
  135904. * Set the value of an uniform to a vec2
  135905. * @param uniform defines the webGL uniform location where to store the value
  135906. * @param x defines the 1st component of the value
  135907. * @param y defines the 2nd component of the value
  135908. * @returns true if value was set
  135909. */
  135910. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  135911. /**
  135912. * Set the value of an uniform to a vec3
  135913. * @param uniform defines the webGL uniform location where to store the value
  135914. * @param x defines the 1st component of the value
  135915. * @param y defines the 2nd component of the value
  135916. * @param z defines the 3rd component of the value
  135917. * @returns true if value was set
  135918. */
  135919. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  135920. /**
  135921. * Set the value of an uniform to a boolean
  135922. * @param uniform defines the webGL uniform location where to store the value
  135923. * @param bool defines the boolean to store
  135924. * @returns true if value was set
  135925. */
  135926. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  135927. /**
  135928. * Set the value of an uniform to a vec4
  135929. * @param uniform defines the webGL uniform location where to store the value
  135930. * @param x defines the 1st component of the value
  135931. * @param y defines the 2nd component of the value
  135932. * @param z defines the 3rd component of the value
  135933. * @param w defines the 4th component of the value
  135934. * @returns true if value was set
  135935. */
  135936. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  135937. /**
  135938. * Sets the current alpha mode
  135939. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  135940. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  135941. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  135942. */
  135943. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  135944. /**
  135945. * Bind webGl buffers directly to the webGL context
  135946. * @param vertexBuffers defines the vertex buffer to bind
  135947. * @param indexBuffer defines the index buffer to bind
  135948. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  135949. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  135950. * @param effect defines the effect associated with the vertex buffer
  135951. */
  135952. bindBuffers(vertexBuffers: {
  135953. [key: string]: VertexBuffer;
  135954. }, indexBuffer: DataBuffer, effect: Effect): void;
  135955. /**
  135956. * Force the entire cache to be cleared
  135957. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  135958. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  135959. */
  135960. wipeCaches(bruteForce?: boolean): void;
  135961. /**
  135962. * Send a draw order
  135963. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  135964. * @param indexStart defines the starting index
  135965. * @param indexCount defines the number of index to draw
  135966. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135967. */
  135968. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  135969. /**
  135970. * Draw a list of indexed primitives
  135971. * @param fillMode defines the primitive to use
  135972. * @param indexStart defines the starting index
  135973. * @param indexCount defines the number of index to draw
  135974. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135975. */
  135976. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  135977. /**
  135978. * Draw a list of unindexed primitives
  135979. * @param fillMode defines the primitive to use
  135980. * @param verticesStart defines the index of first vertex to draw
  135981. * @param verticesCount defines the count of vertices to draw
  135982. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135983. */
  135984. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  135985. /** @hidden */
  135986. _createTexture(): WebGLTexture;
  135987. /** @hidden */
  135988. _releaseTexture(texture: InternalTexture): void;
  135989. /**
  135990. * Usually called from Texture.ts.
  135991. * Passed information to create a WebGLTexture
  135992. * @param urlArg defines a value which contains one of the following:
  135993. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  135994. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  135995. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  135996. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  135997. * @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)
  135998. * @param scene needed for loading to the correct scene
  135999. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136000. * @param onLoad optional callback to be called upon successful completion
  136001. * @param onError optional callback to be called upon failure
  136002. * @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
  136003. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136004. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136005. * @param forcedExtension defines the extension to use to pick the right loader
  136006. * @param mimeType defines an optional mime type
  136007. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136008. */
  136009. 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;
  136010. /**
  136011. * Creates a new render target texture
  136012. * @param size defines the size of the texture
  136013. * @param options defines the options used to create the texture
  136014. * @returns a new render target texture stored in an InternalTexture
  136015. */
  136016. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  136017. /**
  136018. * Update the sampling mode of a given texture
  136019. * @param samplingMode defines the required sampling mode
  136020. * @param texture defines the texture to update
  136021. */
  136022. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136023. /**
  136024. * Binds the frame buffer to the specified texture.
  136025. * @param texture The texture to render to or null for the default canvas
  136026. * @param faceIndex The face of the texture to render to in case of cube texture
  136027. * @param requiredWidth The width of the target to render to
  136028. * @param requiredHeight The height of the target to render to
  136029. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  136030. * @param lodLevel defines le lod level to bind to the frame buffer
  136031. */
  136032. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136033. /**
  136034. * Unbind the current render target texture from the webGL context
  136035. * @param texture defines the render target texture to unbind
  136036. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  136037. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  136038. */
  136039. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136040. /**
  136041. * Creates a dynamic vertex buffer
  136042. * @param vertices the data for the dynamic vertex buffer
  136043. * @returns the new WebGL dynamic buffer
  136044. */
  136045. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  136046. /**
  136047. * Update the content of a dynamic texture
  136048. * @param texture defines the texture to update
  136049. * @param canvas defines the canvas containing the source
  136050. * @param invertY defines if data must be stored with Y axis inverted
  136051. * @param premulAlpha defines if alpha is stored as premultiplied
  136052. * @param format defines the format of the data
  136053. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136054. */
  136055. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136056. /**
  136057. * Gets a boolean indicating if all created effects are ready
  136058. * @returns true if all effects are ready
  136059. */
  136060. areAllEffectsReady(): boolean;
  136061. /**
  136062. * @hidden
  136063. * Get the current error code of the webGL context
  136064. * @returns the error code
  136065. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  136066. */
  136067. getError(): number;
  136068. /** @hidden */
  136069. _getUnpackAlignement(): number;
  136070. /** @hidden */
  136071. _unpackFlipY(value: boolean): void;
  136072. /**
  136073. * Update a dynamic index buffer
  136074. * @param indexBuffer defines the target index buffer
  136075. * @param indices defines the data to update
  136076. * @param offset defines the offset in the target index buffer where update should start
  136077. */
  136078. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  136079. /**
  136080. * Updates a dynamic vertex buffer.
  136081. * @param vertexBuffer the vertex buffer to update
  136082. * @param vertices the data used to update the vertex buffer
  136083. * @param byteOffset the byte offset of the data (optional)
  136084. * @param byteLength the byte length of the data (optional)
  136085. */
  136086. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  136087. /** @hidden */
  136088. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  136089. /** @hidden */
  136090. _bindTexture(channel: number, texture: InternalTexture): void;
  136091. protected _deleteBuffer(buffer: WebGLBuffer): void;
  136092. /**
  136093. * 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
  136094. */
  136095. releaseEffects(): void;
  136096. displayLoadingUI(): void;
  136097. hideLoadingUI(): void;
  136098. /** @hidden */
  136099. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136100. /** @hidden */
  136101. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136102. /** @hidden */
  136103. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136104. /** @hidden */
  136105. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136106. }
  136107. }
  136108. declare module BABYLON {
  136109. /**
  136110. * @hidden
  136111. **/
  136112. export class _TimeToken {
  136113. _startTimeQuery: Nullable<WebGLQuery>;
  136114. _endTimeQuery: Nullable<WebGLQuery>;
  136115. _timeElapsedQuery: Nullable<WebGLQuery>;
  136116. _timeElapsedQueryEnded: boolean;
  136117. }
  136118. }
  136119. declare module BABYLON {
  136120. /** @hidden */
  136121. export class _OcclusionDataStorage {
  136122. /** @hidden */
  136123. occlusionInternalRetryCounter: number;
  136124. /** @hidden */
  136125. isOcclusionQueryInProgress: boolean;
  136126. /** @hidden */
  136127. isOccluded: boolean;
  136128. /** @hidden */
  136129. occlusionRetryCount: number;
  136130. /** @hidden */
  136131. occlusionType: number;
  136132. /** @hidden */
  136133. occlusionQueryAlgorithmType: number;
  136134. }
  136135. interface Engine {
  136136. /**
  136137. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  136138. * @return the new query
  136139. */
  136140. createQuery(): WebGLQuery;
  136141. /**
  136142. * Delete and release a webGL query
  136143. * @param query defines the query to delete
  136144. * @return the current engine
  136145. */
  136146. deleteQuery(query: WebGLQuery): Engine;
  136147. /**
  136148. * Check if a given query has resolved and got its value
  136149. * @param query defines the query to check
  136150. * @returns true if the query got its value
  136151. */
  136152. isQueryResultAvailable(query: WebGLQuery): boolean;
  136153. /**
  136154. * Gets the value of a given query
  136155. * @param query defines the query to check
  136156. * @returns the value of the query
  136157. */
  136158. getQueryResult(query: WebGLQuery): number;
  136159. /**
  136160. * Initiates an occlusion query
  136161. * @param algorithmType defines the algorithm to use
  136162. * @param query defines the query to use
  136163. * @returns the current engine
  136164. * @see https://doc.babylonjs.com/features/occlusionquery
  136165. */
  136166. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  136167. /**
  136168. * Ends an occlusion query
  136169. * @see https://doc.babylonjs.com/features/occlusionquery
  136170. * @param algorithmType defines the algorithm to use
  136171. * @returns the current engine
  136172. */
  136173. endOcclusionQuery(algorithmType: number): Engine;
  136174. /**
  136175. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  136176. * Please note that only one query can be issued at a time
  136177. * @returns a time token used to track the time span
  136178. */
  136179. startTimeQuery(): Nullable<_TimeToken>;
  136180. /**
  136181. * Ends a time query
  136182. * @param token defines the token used to measure the time span
  136183. * @returns the time spent (in ns)
  136184. */
  136185. endTimeQuery(token: _TimeToken): int;
  136186. /** @hidden */
  136187. _currentNonTimestampToken: Nullable<_TimeToken>;
  136188. /** @hidden */
  136189. _createTimeQuery(): WebGLQuery;
  136190. /** @hidden */
  136191. _deleteTimeQuery(query: WebGLQuery): void;
  136192. /** @hidden */
  136193. _getGlAlgorithmType(algorithmType: number): number;
  136194. /** @hidden */
  136195. _getTimeQueryResult(query: WebGLQuery): any;
  136196. /** @hidden */
  136197. _getTimeQueryAvailability(query: WebGLQuery): any;
  136198. }
  136199. interface AbstractMesh {
  136200. /**
  136201. * Backing filed
  136202. * @hidden
  136203. */
  136204. __occlusionDataStorage: _OcclusionDataStorage;
  136205. /**
  136206. * Access property
  136207. * @hidden
  136208. */
  136209. _occlusionDataStorage: _OcclusionDataStorage;
  136210. /**
  136211. * 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.
  136212. * The default value is -1 which means don't break the query and wait till the result
  136213. * @see https://doc.babylonjs.com/features/occlusionquery
  136214. */
  136215. occlusionRetryCount: number;
  136216. /**
  136217. * 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:
  136218. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  136219. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  136220. * * 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.
  136221. * @see https://doc.babylonjs.com/features/occlusionquery
  136222. */
  136223. occlusionType: number;
  136224. /**
  136225. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  136226. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  136227. * * 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.
  136228. * @see https://doc.babylonjs.com/features/occlusionquery
  136229. */
  136230. occlusionQueryAlgorithmType: number;
  136231. /**
  136232. * 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
  136233. * @see https://doc.babylonjs.com/features/occlusionquery
  136234. */
  136235. isOccluded: boolean;
  136236. /**
  136237. * Flag to check the progress status of the query
  136238. * @see https://doc.babylonjs.com/features/occlusionquery
  136239. */
  136240. isOcclusionQueryInProgress: boolean;
  136241. }
  136242. }
  136243. declare module BABYLON {
  136244. /** @hidden */
  136245. export var _forceTransformFeedbackToBundle: boolean;
  136246. interface Engine {
  136247. /**
  136248. * Creates a webGL transform feedback object
  136249. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  136250. * @returns the webGL transform feedback object
  136251. */
  136252. createTransformFeedback(): WebGLTransformFeedback;
  136253. /**
  136254. * Delete a webGL transform feedback object
  136255. * @param value defines the webGL transform feedback object to delete
  136256. */
  136257. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  136258. /**
  136259. * Bind a webGL transform feedback object to the webgl context
  136260. * @param value defines the webGL transform feedback object to bind
  136261. */
  136262. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  136263. /**
  136264. * Begins a transform feedback operation
  136265. * @param usePoints defines if points or triangles must be used
  136266. */
  136267. beginTransformFeedback(usePoints: boolean): void;
  136268. /**
  136269. * Ends a transform feedback operation
  136270. */
  136271. endTransformFeedback(): void;
  136272. /**
  136273. * Specify the varyings to use with transform feedback
  136274. * @param program defines the associated webGL program
  136275. * @param value defines the list of strings representing the varying names
  136276. */
  136277. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  136278. /**
  136279. * Bind a webGL buffer for a transform feedback operation
  136280. * @param value defines the webGL buffer to bind
  136281. */
  136282. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  136283. }
  136284. }
  136285. declare module BABYLON {
  136286. /**
  136287. * Class used to define an additional view for the engine
  136288. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136289. */
  136290. export class EngineView {
  136291. /** Defines the canvas where to render the view */
  136292. target: HTMLCanvasElement;
  136293. /** Defines an optional camera used to render the view (will use active camera else) */
  136294. camera?: Camera;
  136295. }
  136296. interface Engine {
  136297. /**
  136298. * Gets or sets the HTML element to use for attaching events
  136299. */
  136300. inputElement: Nullable<HTMLElement>;
  136301. /**
  136302. * Gets the current engine view
  136303. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136304. */
  136305. activeView: Nullable<EngineView>;
  136306. /** Gets or sets the list of views */
  136307. views: EngineView[];
  136308. /**
  136309. * Register a new child canvas
  136310. * @param canvas defines the canvas to register
  136311. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  136312. * @returns the associated view
  136313. */
  136314. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  136315. /**
  136316. * Remove a registered child canvas
  136317. * @param canvas defines the canvas to remove
  136318. * @returns the current engine
  136319. */
  136320. unRegisterView(canvas: HTMLCanvasElement): Engine;
  136321. }
  136322. }
  136323. declare module BABYLON {
  136324. interface Engine {
  136325. /** @hidden */
  136326. _excludedCompressedTextures: string[];
  136327. /** @hidden */
  136328. _textureFormatInUse: string;
  136329. /**
  136330. * Gets the list of texture formats supported
  136331. */
  136332. readonly texturesSupported: Array<string>;
  136333. /**
  136334. * Gets the texture format in use
  136335. */
  136336. readonly textureFormatInUse: Nullable<string>;
  136337. /**
  136338. * Set the compressed texture extensions or file names to skip.
  136339. *
  136340. * @param skippedFiles defines the list of those texture files you want to skip
  136341. * Example: [".dds", ".env", "myfile.png"]
  136342. */
  136343. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  136344. /**
  136345. * Set the compressed texture format to use, based on the formats you have, and the formats
  136346. * supported by the hardware / browser.
  136347. *
  136348. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  136349. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  136350. * to API arguments needed to compressed textures. This puts the burden on the container
  136351. * generator to house the arcane code for determining these for current & future formats.
  136352. *
  136353. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136354. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136355. *
  136356. * Note: The result of this call is not taken into account when a texture is base64.
  136357. *
  136358. * @param formatsAvailable defines the list of those format families you have created
  136359. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  136360. *
  136361. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  136362. * @returns The extension selected.
  136363. */
  136364. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  136365. }
  136366. }
  136367. declare module BABYLON {
  136368. /** @hidden */
  136369. export var rgbdEncodePixelShader: {
  136370. name: string;
  136371. shader: string;
  136372. };
  136373. }
  136374. declare module BABYLON {
  136375. /**
  136376. * Raw texture data and descriptor sufficient for WebGL texture upload
  136377. */
  136378. export interface EnvironmentTextureInfo {
  136379. /**
  136380. * Version of the environment map
  136381. */
  136382. version: number;
  136383. /**
  136384. * Width of image
  136385. */
  136386. width: number;
  136387. /**
  136388. * Irradiance information stored in the file.
  136389. */
  136390. irradiance: any;
  136391. /**
  136392. * Specular information stored in the file.
  136393. */
  136394. specular: any;
  136395. }
  136396. /**
  136397. * Defines One Image in the file. It requires only the position in the file
  136398. * as well as the length.
  136399. */
  136400. interface BufferImageData {
  136401. /**
  136402. * Length of the image data.
  136403. */
  136404. length: number;
  136405. /**
  136406. * Position of the data from the null terminator delimiting the end of the JSON.
  136407. */
  136408. position: number;
  136409. }
  136410. /**
  136411. * Defines the specular data enclosed in the file.
  136412. * This corresponds to the version 1 of the data.
  136413. */
  136414. export interface EnvironmentTextureSpecularInfoV1 {
  136415. /**
  136416. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  136417. */
  136418. specularDataPosition?: number;
  136419. /**
  136420. * This contains all the images data needed to reconstruct the cubemap.
  136421. */
  136422. mipmaps: Array<BufferImageData>;
  136423. /**
  136424. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  136425. */
  136426. lodGenerationScale: number;
  136427. }
  136428. /**
  136429. * Sets of helpers addressing the serialization and deserialization of environment texture
  136430. * stored in a BabylonJS env file.
  136431. * Those files are usually stored as .env files.
  136432. */
  136433. export class EnvironmentTextureTools {
  136434. /**
  136435. * Magic number identifying the env file.
  136436. */
  136437. private static _MagicBytes;
  136438. /**
  136439. * Gets the environment info from an env file.
  136440. * @param data The array buffer containing the .env bytes.
  136441. * @returns the environment file info (the json header) if successfully parsed.
  136442. */
  136443. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  136444. /**
  136445. * Creates an environment texture from a loaded cube texture.
  136446. * @param texture defines the cube texture to convert in env file
  136447. * @return a promise containing the environment data if succesfull.
  136448. */
  136449. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  136450. /**
  136451. * Creates a JSON representation of the spherical data.
  136452. * @param texture defines the texture containing the polynomials
  136453. * @return the JSON representation of the spherical info
  136454. */
  136455. private static _CreateEnvTextureIrradiance;
  136456. /**
  136457. * Creates the ArrayBufferViews used for initializing environment texture image data.
  136458. * @param data the image data
  136459. * @param info parameters that determine what views will be created for accessing the underlying buffer
  136460. * @return the views described by info providing access to the underlying buffer
  136461. */
  136462. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  136463. /**
  136464. * Uploads the texture info contained in the env file to the GPU.
  136465. * @param texture defines the internal texture to upload to
  136466. * @param data defines the data to load
  136467. * @param info defines the texture info retrieved through the GetEnvInfo method
  136468. * @returns a promise
  136469. */
  136470. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  136471. private static _OnImageReadyAsync;
  136472. /**
  136473. * Uploads the levels of image data to the GPU.
  136474. * @param texture defines the internal texture to upload to
  136475. * @param imageData defines the array buffer views of image data [mipmap][face]
  136476. * @returns a promise
  136477. */
  136478. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  136479. /**
  136480. * Uploads spherical polynomials information to the texture.
  136481. * @param texture defines the texture we are trying to upload the information to
  136482. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  136483. */
  136484. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  136485. /** @hidden */
  136486. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  136487. }
  136488. }
  136489. declare module BABYLON {
  136490. /**
  136491. * Class used to inline functions in shader code
  136492. */
  136493. export class ShaderCodeInliner {
  136494. private static readonly _RegexpFindFunctionNameAndType;
  136495. private _sourceCode;
  136496. private _functionDescr;
  136497. private _numMaxIterations;
  136498. /** Gets or sets the token used to mark the functions to inline */
  136499. inlineToken: string;
  136500. /** Gets or sets the debug mode */
  136501. debug: boolean;
  136502. /** Gets the code after the inlining process */
  136503. get code(): string;
  136504. /**
  136505. * Initializes the inliner
  136506. * @param sourceCode shader code source to inline
  136507. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  136508. */
  136509. constructor(sourceCode: string, numMaxIterations?: number);
  136510. /**
  136511. * Start the processing of the shader code
  136512. */
  136513. processCode(): void;
  136514. private _collectFunctions;
  136515. private _processInlining;
  136516. private _extractBetweenMarkers;
  136517. private _skipWhitespaces;
  136518. private _removeComments;
  136519. private _replaceFunctionCallsByCode;
  136520. private _findBackward;
  136521. private _escapeRegExp;
  136522. private _replaceNames;
  136523. }
  136524. }
  136525. declare module BABYLON {
  136526. /**
  136527. * Container for accessors for natively-stored mesh data buffers.
  136528. */
  136529. class NativeDataBuffer extends DataBuffer {
  136530. /**
  136531. * Accessor value used to identify/retrieve a natively-stored index buffer.
  136532. */
  136533. nativeIndexBuffer?: any;
  136534. /**
  136535. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  136536. */
  136537. nativeVertexBuffer?: any;
  136538. }
  136539. /** @hidden */
  136540. class NativeTexture extends InternalTexture {
  136541. getInternalTexture(): InternalTexture;
  136542. getViewCount(): number;
  136543. }
  136544. /** @hidden */
  136545. export class NativeEngine extends Engine {
  136546. private readonly _native;
  136547. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  136548. private readonly INVALID_HANDLE;
  136549. private _boundBuffersVertexArray;
  136550. private _currentDepthTest;
  136551. getHardwareScalingLevel(): number;
  136552. constructor();
  136553. dispose(): void;
  136554. /**
  136555. * Can be used to override the current requestAnimationFrame requester.
  136556. * @hidden
  136557. */
  136558. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  136559. /**
  136560. * Override default engine behavior.
  136561. * @param color
  136562. * @param backBuffer
  136563. * @param depth
  136564. * @param stencil
  136565. */
  136566. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  136567. /**
  136568. * Gets host document
  136569. * @returns the host document object
  136570. */
  136571. getHostDocument(): Nullable<Document>;
  136572. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136573. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  136574. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  136575. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  136576. [key: string]: VertexBuffer;
  136577. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136578. bindBuffers(vertexBuffers: {
  136579. [key: string]: VertexBuffer;
  136580. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136581. recordVertexArrayObject(vertexBuffers: {
  136582. [key: string]: VertexBuffer;
  136583. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  136584. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136585. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136586. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136587. /**
  136588. * Draw a list of indexed primitives
  136589. * @param fillMode defines the primitive to use
  136590. * @param indexStart defines the starting index
  136591. * @param indexCount defines the number of index to draw
  136592. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136593. */
  136594. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136595. /**
  136596. * Draw a list of unindexed primitives
  136597. * @param fillMode defines the primitive to use
  136598. * @param verticesStart defines the index of first vertex to draw
  136599. * @param verticesCount defines the count of vertices to draw
  136600. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136601. */
  136602. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136603. createPipelineContext(): IPipelineContext;
  136604. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  136605. /** @hidden */
  136606. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  136607. /** @hidden */
  136608. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  136609. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136610. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136611. protected _setProgram(program: WebGLProgram): void;
  136612. _releaseEffect(effect: Effect): void;
  136613. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  136614. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  136615. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  136616. bindSamplers(effect: Effect): void;
  136617. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  136618. getRenderWidth(useScreen?: boolean): number;
  136619. getRenderHeight(useScreen?: boolean): number;
  136620. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  136621. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136622. /**
  136623. * Set the z offset to apply to current rendering
  136624. * @param value defines the offset to apply
  136625. */
  136626. setZOffset(value: number): void;
  136627. /**
  136628. * Gets the current value of the zOffset
  136629. * @returns the current zOffset state
  136630. */
  136631. getZOffset(): number;
  136632. /**
  136633. * Enable or disable depth buffering
  136634. * @param enable defines the state to set
  136635. */
  136636. setDepthBuffer(enable: boolean): void;
  136637. /**
  136638. * Gets a boolean indicating if depth writing is enabled
  136639. * @returns the current depth writing state
  136640. */
  136641. getDepthWrite(): boolean;
  136642. setDepthFunctionToGreater(): void;
  136643. setDepthFunctionToGreaterOrEqual(): void;
  136644. setDepthFunctionToLess(): void;
  136645. setDepthFunctionToLessOrEqual(): void;
  136646. /**
  136647. * Enable or disable depth writing
  136648. * @param enable defines the state to set
  136649. */
  136650. setDepthWrite(enable: boolean): void;
  136651. /**
  136652. * Enable or disable color writing
  136653. * @param enable defines the state to set
  136654. */
  136655. setColorWrite(enable: boolean): void;
  136656. /**
  136657. * Gets a boolean indicating if color writing is enabled
  136658. * @returns the current color writing state
  136659. */
  136660. getColorWrite(): boolean;
  136661. /**
  136662. * Sets alpha constants used by some alpha blending modes
  136663. * @param r defines the red component
  136664. * @param g defines the green component
  136665. * @param b defines the blue component
  136666. * @param a defines the alpha component
  136667. */
  136668. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  136669. /**
  136670. * Sets the current alpha mode
  136671. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  136672. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136673. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136674. */
  136675. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136676. /**
  136677. * Gets the current alpha mode
  136678. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136679. * @returns the current alpha mode
  136680. */
  136681. getAlphaMode(): number;
  136682. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  136683. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136684. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136685. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136686. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136687. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136688. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136689. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136690. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136691. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136692. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136693. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136694. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136695. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136696. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136697. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136698. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136699. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136700. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136701. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136702. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  136703. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  136704. wipeCaches(bruteForce?: boolean): void;
  136705. _createTexture(): WebGLTexture;
  136706. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  136707. /**
  136708. * Update the content of a dynamic texture
  136709. * @param texture defines the texture to update
  136710. * @param canvas defines the canvas containing the source
  136711. * @param invertY defines if data must be stored with Y axis inverted
  136712. * @param premulAlpha defines if alpha is stored as premultiplied
  136713. * @param format defines the format of the data
  136714. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136715. */
  136716. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136717. /**
  136718. * Usually called from Texture.ts.
  136719. * Passed information to create a WebGLTexture
  136720. * @param url defines a value which contains one of the following:
  136721. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136722. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136723. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136724. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136725. * @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)
  136726. * @param scene needed for loading to the correct scene
  136727. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136728. * @param onLoad optional callback to be called upon successful completion
  136729. * @param onError optional callback to be called upon failure
  136730. * @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
  136731. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136732. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136733. * @param forcedExtension defines the extension to use to pick the right loader
  136734. * @param mimeType defines an optional mime type
  136735. * @param loaderOptions options to be passed to the loader
  136736. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136737. */
  136738. 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, loaderOptions?: any): InternalTexture;
  136739. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  136740. _releaseFramebufferObjects(texture: InternalTexture): void;
  136741. /**
  136742. * Creates a cube texture
  136743. * @param rootUrl defines the url where the files to load is located
  136744. * @param scene defines the current scene
  136745. * @param files defines the list of files to load (1 per face)
  136746. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  136747. * @param onLoad defines an optional callback raised when the texture is loaded
  136748. * @param onError defines an optional callback raised if there is an issue to load the texture
  136749. * @param format defines the format of the data
  136750. * @param forcedExtension defines the extension to use to pick the right loader
  136751. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  136752. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  136753. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  136754. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  136755. * @returns the cube texture as an InternalTexture
  136756. */
  136757. 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;
  136758. createRenderTargetTexture(size: number | {
  136759. width: number;
  136760. height: number;
  136761. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  136762. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136763. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136764. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136765. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  136766. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  136767. /**
  136768. * Updates a dynamic vertex buffer.
  136769. * @param vertexBuffer the vertex buffer to update
  136770. * @param data the data used to update the vertex buffer
  136771. * @param byteOffset the byte offset of the data (optional)
  136772. * @param byteLength the byte length of the data (optional)
  136773. */
  136774. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  136775. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  136776. private _updateAnisotropicLevel;
  136777. private _getAddressMode;
  136778. /** @hidden */
  136779. _bindTexture(channel: number, texture: InternalTexture): void;
  136780. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  136781. releaseEffects(): void;
  136782. /** @hidden */
  136783. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136784. /** @hidden */
  136785. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136786. /** @hidden */
  136787. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136788. /** @hidden */
  136789. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136790. private _getNativeSamplingMode;
  136791. private _getNativeTextureFormat;
  136792. private _getNativeAlphaMode;
  136793. private _getNativeAttribType;
  136794. }
  136795. }
  136796. declare module BABYLON {
  136797. /**
  136798. * Gather the list of clipboard event types as constants.
  136799. */
  136800. export class ClipboardEventTypes {
  136801. /**
  136802. * The clipboard event is fired when a copy command is active (pressed).
  136803. */
  136804. static readonly COPY: number;
  136805. /**
  136806. * The clipboard event is fired when a cut command is active (pressed).
  136807. */
  136808. static readonly CUT: number;
  136809. /**
  136810. * The clipboard event is fired when a paste command is active (pressed).
  136811. */
  136812. static readonly PASTE: number;
  136813. }
  136814. /**
  136815. * This class is used to store clipboard related info for the onClipboardObservable event.
  136816. */
  136817. export class ClipboardInfo {
  136818. /**
  136819. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136820. */
  136821. type: number;
  136822. /**
  136823. * Defines the related dom event
  136824. */
  136825. event: ClipboardEvent;
  136826. /**
  136827. *Creates an instance of ClipboardInfo.
  136828. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  136829. * @param event Defines the related dom event
  136830. */
  136831. constructor(
  136832. /**
  136833. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136834. */
  136835. type: number,
  136836. /**
  136837. * Defines the related dom event
  136838. */
  136839. event: ClipboardEvent);
  136840. /**
  136841. * Get the clipboard event's type from the keycode.
  136842. * @param keyCode Defines the keyCode for the current keyboard event.
  136843. * @return {number}
  136844. */
  136845. static GetTypeFromCharacter(keyCode: number): number;
  136846. }
  136847. }
  136848. declare module BABYLON {
  136849. /**
  136850. * Google Daydream controller
  136851. */
  136852. export class DaydreamController extends WebVRController {
  136853. /**
  136854. * Base Url for the controller model.
  136855. */
  136856. static MODEL_BASE_URL: string;
  136857. /**
  136858. * File name for the controller model.
  136859. */
  136860. static MODEL_FILENAME: string;
  136861. /**
  136862. * Gamepad Id prefix used to identify Daydream Controller.
  136863. */
  136864. static readonly GAMEPAD_ID_PREFIX: string;
  136865. /**
  136866. * Creates a new DaydreamController from a gamepad
  136867. * @param vrGamepad the gamepad that the controller should be created from
  136868. */
  136869. constructor(vrGamepad: any);
  136870. /**
  136871. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136872. * @param scene scene in which to add meshes
  136873. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136874. */
  136875. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136876. /**
  136877. * Called once for each button that changed state since the last frame
  136878. * @param buttonIdx Which button index changed
  136879. * @param state New state of the button
  136880. * @param changes Which properties on the state changed since last frame
  136881. */
  136882. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136883. }
  136884. }
  136885. declare module BABYLON {
  136886. /**
  136887. * Gear VR Controller
  136888. */
  136889. export class GearVRController extends WebVRController {
  136890. /**
  136891. * Base Url for the controller model.
  136892. */
  136893. static MODEL_BASE_URL: string;
  136894. /**
  136895. * File name for the controller model.
  136896. */
  136897. static MODEL_FILENAME: string;
  136898. /**
  136899. * Gamepad Id prefix used to identify this controller.
  136900. */
  136901. static readonly GAMEPAD_ID_PREFIX: string;
  136902. private readonly _buttonIndexToObservableNameMap;
  136903. /**
  136904. * Creates a new GearVRController from a gamepad
  136905. * @param vrGamepad the gamepad that the controller should be created from
  136906. */
  136907. constructor(vrGamepad: any);
  136908. /**
  136909. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136910. * @param scene scene in which to add meshes
  136911. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136912. */
  136913. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136914. /**
  136915. * Called once for each button that changed state since the last frame
  136916. * @param buttonIdx Which button index changed
  136917. * @param state New state of the button
  136918. * @param changes Which properties on the state changed since last frame
  136919. */
  136920. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136921. }
  136922. }
  136923. declare module BABYLON {
  136924. /**
  136925. * Generic Controller
  136926. */
  136927. export class GenericController extends WebVRController {
  136928. /**
  136929. * Base Url for the controller model.
  136930. */
  136931. static readonly MODEL_BASE_URL: string;
  136932. /**
  136933. * File name for the controller model.
  136934. */
  136935. static readonly MODEL_FILENAME: string;
  136936. /**
  136937. * Creates a new GenericController from a gamepad
  136938. * @param vrGamepad the gamepad that the controller should be created from
  136939. */
  136940. constructor(vrGamepad: any);
  136941. /**
  136942. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136943. * @param scene scene in which to add meshes
  136944. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136945. */
  136946. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136947. /**
  136948. * Called once for each button that changed state since the last frame
  136949. * @param buttonIdx Which button index changed
  136950. * @param state New state of the button
  136951. * @param changes Which properties on the state changed since last frame
  136952. */
  136953. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136954. }
  136955. }
  136956. declare module BABYLON {
  136957. /**
  136958. * Oculus Touch Controller
  136959. */
  136960. export class OculusTouchController extends WebVRController {
  136961. /**
  136962. * Base Url for the controller model.
  136963. */
  136964. static MODEL_BASE_URL: string;
  136965. /**
  136966. * File name for the left controller model.
  136967. */
  136968. static MODEL_LEFT_FILENAME: string;
  136969. /**
  136970. * File name for the right controller model.
  136971. */
  136972. static MODEL_RIGHT_FILENAME: string;
  136973. /**
  136974. * Base Url for the Quest controller model.
  136975. */
  136976. static QUEST_MODEL_BASE_URL: string;
  136977. /**
  136978. * @hidden
  136979. * If the controllers are running on a device that needs the updated Quest controller models
  136980. */
  136981. static _IsQuest: boolean;
  136982. /**
  136983. * Fired when the secondary trigger on this controller is modified
  136984. */
  136985. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  136986. /**
  136987. * Fired when the thumb rest on this controller is modified
  136988. */
  136989. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  136990. /**
  136991. * Creates a new OculusTouchController from a gamepad
  136992. * @param vrGamepad the gamepad that the controller should be created from
  136993. */
  136994. constructor(vrGamepad: any);
  136995. /**
  136996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136997. * @param scene scene in which to add meshes
  136998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136999. */
  137000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137001. /**
  137002. * Fired when the A button on this controller is modified
  137003. */
  137004. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137005. /**
  137006. * Fired when the B button on this controller is modified
  137007. */
  137008. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137009. /**
  137010. * Fired when the X button on this controller is modified
  137011. */
  137012. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137013. /**
  137014. * Fired when the Y button on this controller is modified
  137015. */
  137016. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137017. /**
  137018. * Called once for each button that changed state since the last frame
  137019. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  137020. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  137021. * 2) secondary trigger (same)
  137022. * 3) A (right) X (left), touch, pressed = value
  137023. * 4) B / Y
  137024. * 5) thumb rest
  137025. * @param buttonIdx Which button index changed
  137026. * @param state New state of the button
  137027. * @param changes Which properties on the state changed since last frame
  137028. */
  137029. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137030. }
  137031. }
  137032. declare module BABYLON {
  137033. /**
  137034. * Vive Controller
  137035. */
  137036. export class ViveController extends WebVRController {
  137037. /**
  137038. * Base Url for the controller model.
  137039. */
  137040. static MODEL_BASE_URL: string;
  137041. /**
  137042. * File name for the controller model.
  137043. */
  137044. static MODEL_FILENAME: string;
  137045. /**
  137046. * Creates a new ViveController from a gamepad
  137047. * @param vrGamepad the gamepad that the controller should be created from
  137048. */
  137049. constructor(vrGamepad: any);
  137050. /**
  137051. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137052. * @param scene scene in which to add meshes
  137053. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137054. */
  137055. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137056. /**
  137057. * Fired when the left button on this controller is modified
  137058. */
  137059. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137060. /**
  137061. * Fired when the right button on this controller is modified
  137062. */
  137063. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137064. /**
  137065. * Fired when the menu button on this controller is modified
  137066. */
  137067. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137068. /**
  137069. * Called once for each button that changed state since the last frame
  137070. * Vive mapping:
  137071. * 0: touchpad
  137072. * 1: trigger
  137073. * 2: left AND right buttons
  137074. * 3: menu button
  137075. * @param buttonIdx Which button index changed
  137076. * @param state New state of the button
  137077. * @param changes Which properties on the state changed since last frame
  137078. */
  137079. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137080. }
  137081. }
  137082. declare module BABYLON {
  137083. /**
  137084. * Defines the WindowsMotionController object that the state of the windows motion controller
  137085. */
  137086. export class WindowsMotionController extends WebVRController {
  137087. /**
  137088. * The base url used to load the left and right controller models
  137089. */
  137090. static MODEL_BASE_URL: string;
  137091. /**
  137092. * The name of the left controller model file
  137093. */
  137094. static MODEL_LEFT_FILENAME: string;
  137095. /**
  137096. * The name of the right controller model file
  137097. */
  137098. static MODEL_RIGHT_FILENAME: string;
  137099. /**
  137100. * The controller name prefix for this controller type
  137101. */
  137102. static readonly GAMEPAD_ID_PREFIX: string;
  137103. /**
  137104. * The controller id pattern for this controller type
  137105. */
  137106. private static readonly GAMEPAD_ID_PATTERN;
  137107. private _loadedMeshInfo;
  137108. protected readonly _mapping: {
  137109. buttons: string[];
  137110. buttonMeshNames: {
  137111. trigger: string;
  137112. menu: string;
  137113. grip: string;
  137114. thumbstick: string;
  137115. trackpad: string;
  137116. };
  137117. buttonObservableNames: {
  137118. trigger: string;
  137119. menu: string;
  137120. grip: string;
  137121. thumbstick: string;
  137122. trackpad: string;
  137123. };
  137124. axisMeshNames: string[];
  137125. pointingPoseMeshName: string;
  137126. };
  137127. /**
  137128. * Fired when the trackpad on this controller is clicked
  137129. */
  137130. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137131. /**
  137132. * Fired when the trackpad on this controller is modified
  137133. */
  137134. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137135. /**
  137136. * The current x and y values of this controller's trackpad
  137137. */
  137138. trackpad: StickValues;
  137139. /**
  137140. * Creates a new WindowsMotionController from a gamepad
  137141. * @param vrGamepad the gamepad that the controller should be created from
  137142. */
  137143. constructor(vrGamepad: any);
  137144. /**
  137145. * Fired when the trigger on this controller is modified
  137146. */
  137147. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137148. /**
  137149. * Fired when the menu button on this controller is modified
  137150. */
  137151. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137152. /**
  137153. * Fired when the grip button on this controller is modified
  137154. */
  137155. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137156. /**
  137157. * Fired when the thumbstick button on this controller is modified
  137158. */
  137159. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137160. /**
  137161. * Fired when the touchpad button on this controller is modified
  137162. */
  137163. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137164. /**
  137165. * Fired when the touchpad values on this controller are modified
  137166. */
  137167. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  137168. protected _updateTrackpad(): void;
  137169. /**
  137170. * Called once per frame by the engine.
  137171. */
  137172. update(): void;
  137173. /**
  137174. * Called once for each button that changed state since the last frame
  137175. * @param buttonIdx Which button index changed
  137176. * @param state New state of the button
  137177. * @param changes Which properties on the state changed since last frame
  137178. */
  137179. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137180. /**
  137181. * Moves the buttons on the controller mesh based on their current state
  137182. * @param buttonName the name of the button to move
  137183. * @param buttonValue the value of the button which determines the buttons new position
  137184. */
  137185. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  137186. /**
  137187. * Moves the axis on the controller mesh based on its current state
  137188. * @param axis the index of the axis
  137189. * @param axisValue the value of the axis which determines the meshes new position
  137190. * @hidden
  137191. */
  137192. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  137193. /**
  137194. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137195. * @param scene scene in which to add meshes
  137196. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137197. */
  137198. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  137199. /**
  137200. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  137201. * can be transformed by button presses and axes values, based on this._mapping.
  137202. *
  137203. * @param scene scene in which the meshes exist
  137204. * @param meshes list of meshes that make up the controller model to process
  137205. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  137206. */
  137207. private processModel;
  137208. private createMeshInfo;
  137209. /**
  137210. * Gets the ray of the controller in the direction the controller is pointing
  137211. * @param length the length the resulting ray should be
  137212. * @returns a ray in the direction the controller is pointing
  137213. */
  137214. getForwardRay(length?: number): Ray;
  137215. /**
  137216. * Disposes of the controller
  137217. */
  137218. dispose(): void;
  137219. }
  137220. /**
  137221. * This class represents a new windows motion controller in XR.
  137222. */
  137223. export class XRWindowsMotionController extends WindowsMotionController {
  137224. /**
  137225. * Changing the original WIndowsMotionController mapping to fir the new mapping
  137226. */
  137227. protected readonly _mapping: {
  137228. buttons: string[];
  137229. buttonMeshNames: {
  137230. trigger: string;
  137231. menu: string;
  137232. grip: string;
  137233. thumbstick: string;
  137234. trackpad: string;
  137235. };
  137236. buttonObservableNames: {
  137237. trigger: string;
  137238. menu: string;
  137239. grip: string;
  137240. thumbstick: string;
  137241. trackpad: string;
  137242. };
  137243. axisMeshNames: string[];
  137244. pointingPoseMeshName: string;
  137245. };
  137246. /**
  137247. * Construct a new XR-Based windows motion controller
  137248. *
  137249. * @param gamepadInfo the gamepad object from the browser
  137250. */
  137251. constructor(gamepadInfo: any);
  137252. /**
  137253. * holds the thumbstick values (X,Y)
  137254. */
  137255. thumbstickValues: StickValues;
  137256. /**
  137257. * Fired when the thumbstick on this controller is clicked
  137258. */
  137259. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  137260. /**
  137261. * Fired when the thumbstick on this controller is modified
  137262. */
  137263. onThumbstickValuesChangedObservable: Observable<StickValues>;
  137264. /**
  137265. * Fired when the touchpad button on this controller is modified
  137266. */
  137267. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137268. /**
  137269. * Fired when the touchpad values on this controller are modified
  137270. */
  137271. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137272. /**
  137273. * Fired when the thumbstick button on this controller is modified
  137274. * here to prevent breaking changes
  137275. */
  137276. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137277. /**
  137278. * updating the thumbstick(!) and not the trackpad.
  137279. * This is named this way due to the difference between WebVR and XR and to avoid
  137280. * changing the parent class.
  137281. */
  137282. protected _updateTrackpad(): void;
  137283. /**
  137284. * Disposes the class with joy
  137285. */
  137286. dispose(): void;
  137287. }
  137288. }
  137289. declare module BABYLON {
  137290. /**
  137291. * Class containing static functions to help procedurally build meshes
  137292. */
  137293. export class PolyhedronBuilder {
  137294. /**
  137295. * Creates a polyhedron mesh
  137296. * * 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
  137297. * * The parameter `size` (positive float, default 1) sets the polygon size
  137298. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  137299. * * 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`
  137300. * * 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
  137301. * * 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)`)
  137302. * * 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
  137303. * * 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
  137304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137307. * @param name defines the name of the mesh
  137308. * @param options defines the options used to create the mesh
  137309. * @param scene defines the hosting scene
  137310. * @returns the polyhedron mesh
  137311. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  137312. */
  137313. static CreatePolyhedron(name: string, options: {
  137314. type?: number;
  137315. size?: number;
  137316. sizeX?: number;
  137317. sizeY?: number;
  137318. sizeZ?: number;
  137319. custom?: any;
  137320. faceUV?: Vector4[];
  137321. faceColors?: Color4[];
  137322. flat?: boolean;
  137323. updatable?: boolean;
  137324. sideOrientation?: number;
  137325. frontUVs?: Vector4;
  137326. backUVs?: Vector4;
  137327. }, scene?: Nullable<Scene>): Mesh;
  137328. }
  137329. }
  137330. declare module BABYLON {
  137331. /**
  137332. * Gizmo that enables scaling a mesh along 3 axis
  137333. */
  137334. export class ScaleGizmo extends Gizmo {
  137335. /**
  137336. * Internal gizmo used for interactions on the x axis
  137337. */
  137338. xGizmo: AxisScaleGizmo;
  137339. /**
  137340. * Internal gizmo used for interactions on the y axis
  137341. */
  137342. yGizmo: AxisScaleGizmo;
  137343. /**
  137344. * Internal gizmo used for interactions on the z axis
  137345. */
  137346. zGizmo: AxisScaleGizmo;
  137347. /**
  137348. * Internal gizmo used to scale all axis equally
  137349. */
  137350. uniformScaleGizmo: AxisScaleGizmo;
  137351. private _meshAttached;
  137352. private _nodeAttached;
  137353. private _snapDistance;
  137354. private _uniformScalingMesh;
  137355. private _octahedron;
  137356. private _sensitivity;
  137357. /** Fires an event when any of it's sub gizmos are dragged */
  137358. onDragStartObservable: Observable<unknown>;
  137359. /** Fires an event when any of it's sub gizmos are released from dragging */
  137360. onDragEndObservable: Observable<unknown>;
  137361. get attachedMesh(): Nullable<AbstractMesh>;
  137362. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137363. get attachedNode(): Nullable<Node>;
  137364. set attachedNode(node: Nullable<Node>);
  137365. /**
  137366. * True when the mouse pointer is hovering a gizmo mesh
  137367. */
  137368. get isHovered(): boolean;
  137369. /**
  137370. * Creates a ScaleGizmo
  137371. * @param gizmoLayer The utility layer the gizmo will be added to
  137372. * @param thickness display gizmo axis thickness
  137373. */
  137374. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  137375. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137376. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137377. /**
  137378. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137379. */
  137380. set snapDistance(value: number);
  137381. get snapDistance(): number;
  137382. /**
  137383. * Ratio for the scale of the gizmo (Default: 1)
  137384. */
  137385. set scaleRatio(value: number);
  137386. get scaleRatio(): number;
  137387. /**
  137388. * Sensitivity factor for dragging (Default: 1)
  137389. */
  137390. set sensitivity(value: number);
  137391. get sensitivity(): number;
  137392. /**
  137393. * Disposes of the gizmo
  137394. */
  137395. dispose(): void;
  137396. }
  137397. }
  137398. declare module BABYLON {
  137399. /**
  137400. * Single axis scale gizmo
  137401. */
  137402. export class AxisScaleGizmo extends Gizmo {
  137403. /**
  137404. * Drag behavior responsible for the gizmos dragging interactions
  137405. */
  137406. dragBehavior: PointerDragBehavior;
  137407. private _pointerObserver;
  137408. /**
  137409. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137410. */
  137411. snapDistance: number;
  137412. /**
  137413. * Event that fires each time the gizmo snaps to a new location.
  137414. * * snapDistance is the the change in distance
  137415. */
  137416. onSnapObservable: Observable<{
  137417. snapDistance: number;
  137418. }>;
  137419. /**
  137420. * If the scaling operation should be done on all axis (default: false)
  137421. */
  137422. uniformScaling: boolean;
  137423. /**
  137424. * Custom sensitivity value for the drag strength
  137425. */
  137426. sensitivity: number;
  137427. private _isEnabled;
  137428. private _parent;
  137429. private _arrow;
  137430. private _coloredMaterial;
  137431. private _hoverMaterial;
  137432. /**
  137433. * Creates an AxisScaleGizmo
  137434. * @param gizmoLayer The utility layer the gizmo will be added to
  137435. * @param dragAxis The axis which the gizmo will be able to scale on
  137436. * @param color The color of the gizmo
  137437. * @param thickness display gizmo axis thickness
  137438. */
  137439. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  137440. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137441. /**
  137442. * If the gizmo is enabled
  137443. */
  137444. set isEnabled(value: boolean);
  137445. get isEnabled(): boolean;
  137446. /**
  137447. * Disposes of the gizmo
  137448. */
  137449. dispose(): void;
  137450. /**
  137451. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  137452. * @param mesh The mesh to replace the default mesh of the gizmo
  137453. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  137454. */
  137455. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  137456. }
  137457. }
  137458. declare module BABYLON {
  137459. /**
  137460. * Bounding box gizmo
  137461. */
  137462. export class BoundingBoxGizmo extends Gizmo {
  137463. private _lineBoundingBox;
  137464. private _rotateSpheresParent;
  137465. private _scaleBoxesParent;
  137466. private _boundingDimensions;
  137467. private _renderObserver;
  137468. private _pointerObserver;
  137469. private _scaleDragSpeed;
  137470. private _tmpQuaternion;
  137471. private _tmpVector;
  137472. private _tmpRotationMatrix;
  137473. /**
  137474. * 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)
  137475. */
  137476. ignoreChildren: boolean;
  137477. /**
  137478. * 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)
  137479. */
  137480. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  137481. /**
  137482. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  137483. */
  137484. rotationSphereSize: number;
  137485. /**
  137486. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  137487. */
  137488. scaleBoxSize: number;
  137489. /**
  137490. * 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)
  137491. */
  137492. fixedDragMeshScreenSize: boolean;
  137493. /**
  137494. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  137495. */
  137496. fixedDragMeshScreenSizeDistanceFactor: number;
  137497. /**
  137498. * Fired when a rotation sphere or scale box is dragged
  137499. */
  137500. onDragStartObservable: Observable<{}>;
  137501. /**
  137502. * Fired when a scale box is dragged
  137503. */
  137504. onScaleBoxDragObservable: Observable<{}>;
  137505. /**
  137506. * Fired when a scale box drag is ended
  137507. */
  137508. onScaleBoxDragEndObservable: Observable<{}>;
  137509. /**
  137510. * Fired when a rotation sphere is dragged
  137511. */
  137512. onRotationSphereDragObservable: Observable<{}>;
  137513. /**
  137514. * Fired when a rotation sphere drag is ended
  137515. */
  137516. onRotationSphereDragEndObservable: Observable<{}>;
  137517. /**
  137518. * 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)
  137519. */
  137520. scalePivot: Nullable<Vector3>;
  137521. /**
  137522. * Mesh used as a pivot to rotate the attached node
  137523. */
  137524. private _anchorMesh;
  137525. private _existingMeshScale;
  137526. private _dragMesh;
  137527. private pointerDragBehavior;
  137528. private coloredMaterial;
  137529. private hoverColoredMaterial;
  137530. /**
  137531. * Sets the color of the bounding box gizmo
  137532. * @param color the color to set
  137533. */
  137534. setColor(color: Color3): void;
  137535. /**
  137536. * Creates an BoundingBoxGizmo
  137537. * @param gizmoLayer The utility layer the gizmo will be added to
  137538. * @param color The color of the gizmo
  137539. */
  137540. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  137541. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  137542. private _selectNode;
  137543. /**
  137544. * Updates the bounding box information for the Gizmo
  137545. */
  137546. updateBoundingBox(): void;
  137547. private _updateRotationSpheres;
  137548. private _updateScaleBoxes;
  137549. /**
  137550. * Enables rotation on the specified axis and disables rotation on the others
  137551. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  137552. */
  137553. setEnabledRotationAxis(axis: string): void;
  137554. /**
  137555. * Enables/disables scaling
  137556. * @param enable if scaling should be enabled
  137557. * @param homogeneousScaling defines if scaling should only be homogeneous
  137558. */
  137559. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  137560. private _updateDummy;
  137561. /**
  137562. * Enables a pointer drag behavior on the bounding box of the gizmo
  137563. */
  137564. enableDragBehavior(): void;
  137565. /**
  137566. * Disposes of the gizmo
  137567. */
  137568. dispose(): void;
  137569. /**
  137570. * 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)
  137571. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  137572. * @returns the bounding box mesh with the passed in mesh as a child
  137573. */
  137574. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  137575. /**
  137576. * CustomMeshes are not supported by this gizmo
  137577. * @param mesh The mesh to replace the default mesh of the gizmo
  137578. */
  137579. setCustomMesh(mesh: Mesh): void;
  137580. }
  137581. }
  137582. declare module BABYLON {
  137583. /**
  137584. * Single plane rotation gizmo
  137585. */
  137586. export class PlaneRotationGizmo extends Gizmo {
  137587. /**
  137588. * Drag behavior responsible for the gizmos dragging interactions
  137589. */
  137590. dragBehavior: PointerDragBehavior;
  137591. private _pointerObserver;
  137592. /**
  137593. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  137594. */
  137595. snapDistance: number;
  137596. /**
  137597. * Event that fires each time the gizmo snaps to a new location.
  137598. * * snapDistance is the the change in distance
  137599. */
  137600. onSnapObservable: Observable<{
  137601. snapDistance: number;
  137602. }>;
  137603. private _isEnabled;
  137604. private _parent;
  137605. /**
  137606. * Creates a PlaneRotationGizmo
  137607. * @param gizmoLayer The utility layer the gizmo will be added to
  137608. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  137609. * @param color The color of the gizmo
  137610. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137611. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137612. * @param thickness display gizmo axis thickness
  137613. */
  137614. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  137615. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137616. /**
  137617. * If the gizmo is enabled
  137618. */
  137619. set isEnabled(value: boolean);
  137620. get isEnabled(): boolean;
  137621. /**
  137622. * Disposes of the gizmo
  137623. */
  137624. dispose(): void;
  137625. }
  137626. }
  137627. declare module BABYLON {
  137628. /**
  137629. * Gizmo that enables rotating a mesh along 3 axis
  137630. */
  137631. export class RotationGizmo extends Gizmo {
  137632. /**
  137633. * Internal gizmo used for interactions on the x axis
  137634. */
  137635. xGizmo: PlaneRotationGizmo;
  137636. /**
  137637. * Internal gizmo used for interactions on the y axis
  137638. */
  137639. yGizmo: PlaneRotationGizmo;
  137640. /**
  137641. * Internal gizmo used for interactions on the z axis
  137642. */
  137643. zGizmo: PlaneRotationGizmo;
  137644. /** Fires an event when any of it's sub gizmos are dragged */
  137645. onDragStartObservable: Observable<unknown>;
  137646. /** Fires an event when any of it's sub gizmos are released from dragging */
  137647. onDragEndObservable: Observable<unknown>;
  137648. private _meshAttached;
  137649. private _nodeAttached;
  137650. get attachedMesh(): Nullable<AbstractMesh>;
  137651. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137652. get attachedNode(): Nullable<Node>;
  137653. set attachedNode(node: Nullable<Node>);
  137654. protected _checkBillboardTransform(): void;
  137655. /**
  137656. * True when the mouse pointer is hovering a gizmo mesh
  137657. */
  137658. get isHovered(): boolean;
  137659. /**
  137660. * Creates a RotationGizmo
  137661. * @param gizmoLayer The utility layer the gizmo will be added to
  137662. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137663. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137664. * @param thickness display gizmo axis thickness
  137665. */
  137666. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  137667. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137668. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137669. /**
  137670. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137671. */
  137672. set snapDistance(value: number);
  137673. get snapDistance(): number;
  137674. /**
  137675. * Ratio for the scale of the gizmo (Default: 1)
  137676. */
  137677. set scaleRatio(value: number);
  137678. get scaleRatio(): number;
  137679. /**
  137680. * Disposes of the gizmo
  137681. */
  137682. dispose(): void;
  137683. /**
  137684. * CustomMeshes are not supported by this gizmo
  137685. * @param mesh The mesh to replace the default mesh of the gizmo
  137686. */
  137687. setCustomMesh(mesh: Mesh): void;
  137688. }
  137689. }
  137690. declare module BABYLON {
  137691. /**
  137692. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  137693. */
  137694. export class GizmoManager implements IDisposable {
  137695. private scene;
  137696. /**
  137697. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  137698. */
  137699. gizmos: {
  137700. positionGizmo: Nullable<PositionGizmo>;
  137701. rotationGizmo: Nullable<RotationGizmo>;
  137702. scaleGizmo: Nullable<ScaleGizmo>;
  137703. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  137704. };
  137705. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  137706. clearGizmoOnEmptyPointerEvent: boolean;
  137707. /** Fires an event when the manager is attached to a mesh */
  137708. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  137709. /** Fires an event when the manager is attached to a node */
  137710. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  137711. private _gizmosEnabled;
  137712. private _pointerObserver;
  137713. private _attachedMesh;
  137714. private _attachedNode;
  137715. private _boundingBoxColor;
  137716. private _defaultUtilityLayer;
  137717. private _defaultKeepDepthUtilityLayer;
  137718. private _thickness;
  137719. /**
  137720. * When bounding box gizmo is enabled, this can be used to track drag/end events
  137721. */
  137722. boundingBoxDragBehavior: SixDofDragBehavior;
  137723. /**
  137724. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  137725. */
  137726. attachableMeshes: Nullable<Array<AbstractMesh>>;
  137727. /**
  137728. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  137729. */
  137730. attachableNodes: Nullable<Array<Node>>;
  137731. /**
  137732. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  137733. */
  137734. usePointerToAttachGizmos: boolean;
  137735. /**
  137736. * Utility layer that the bounding box gizmo belongs to
  137737. */
  137738. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  137739. /**
  137740. * Utility layer that all gizmos besides bounding box belong to
  137741. */
  137742. get utilityLayer(): UtilityLayerRenderer;
  137743. /**
  137744. * True when the mouse pointer is hovering a gizmo mesh
  137745. */
  137746. get isHovered(): boolean;
  137747. /**
  137748. * Instatiates a gizmo manager
  137749. * @param scene the scene to overlay the gizmos on top of
  137750. * @param thickness display gizmo axis thickness
  137751. */
  137752. constructor(scene: Scene, thickness?: number);
  137753. /**
  137754. * Attaches a set of gizmos to the specified mesh
  137755. * @param mesh The mesh the gizmo's should be attached to
  137756. */
  137757. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137758. /**
  137759. * Attaches a set of gizmos to the specified node
  137760. * @param node The node the gizmo's should be attached to
  137761. */
  137762. attachToNode(node: Nullable<Node>): void;
  137763. /**
  137764. * If the position gizmo is enabled
  137765. */
  137766. set positionGizmoEnabled(value: boolean);
  137767. get positionGizmoEnabled(): boolean;
  137768. /**
  137769. * If the rotation gizmo is enabled
  137770. */
  137771. set rotationGizmoEnabled(value: boolean);
  137772. get rotationGizmoEnabled(): boolean;
  137773. /**
  137774. * If the scale gizmo is enabled
  137775. */
  137776. set scaleGizmoEnabled(value: boolean);
  137777. get scaleGizmoEnabled(): boolean;
  137778. /**
  137779. * If the boundingBox gizmo is enabled
  137780. */
  137781. set boundingBoxGizmoEnabled(value: boolean);
  137782. get boundingBoxGizmoEnabled(): boolean;
  137783. /**
  137784. * Disposes of the gizmo manager
  137785. */
  137786. dispose(): void;
  137787. }
  137788. }
  137789. declare module BABYLON {
  137790. /**
  137791. * A directional light is defined by a direction (what a surprise!).
  137792. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  137793. * 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.
  137794. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137795. */
  137796. export class DirectionalLight extends ShadowLight {
  137797. private _shadowFrustumSize;
  137798. /**
  137799. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  137800. */
  137801. get shadowFrustumSize(): number;
  137802. /**
  137803. * Specifies a fix frustum size for the shadow generation.
  137804. */
  137805. set shadowFrustumSize(value: number);
  137806. private _shadowOrthoScale;
  137807. /**
  137808. * Gets the shadow projection scale against the optimal computed one.
  137809. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137810. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137811. */
  137812. get shadowOrthoScale(): number;
  137813. /**
  137814. * Sets the shadow projection scale against the optimal computed one.
  137815. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137816. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137817. */
  137818. set shadowOrthoScale(value: number);
  137819. /**
  137820. * Automatically compute the projection matrix to best fit (including all the casters)
  137821. * on each frame.
  137822. */
  137823. autoUpdateExtends: boolean;
  137824. /**
  137825. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  137826. * on each frame. autoUpdateExtends must be set to true for this to work
  137827. */
  137828. autoCalcShadowZBounds: boolean;
  137829. private _orthoLeft;
  137830. private _orthoRight;
  137831. private _orthoTop;
  137832. private _orthoBottom;
  137833. /**
  137834. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  137835. * The directional light is emitted from everywhere in the given direction.
  137836. * It can cast shadows.
  137837. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137838. * @param name The friendly name of the light
  137839. * @param direction The direction of the light
  137840. * @param scene The scene the light belongs to
  137841. */
  137842. constructor(name: string, direction: Vector3, scene: Scene);
  137843. /**
  137844. * Returns the string "DirectionalLight".
  137845. * @return The class name
  137846. */
  137847. getClassName(): string;
  137848. /**
  137849. * Returns the integer 1.
  137850. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137851. */
  137852. getTypeID(): number;
  137853. /**
  137854. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  137855. * Returns the DirectionalLight Shadow projection matrix.
  137856. */
  137857. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137858. /**
  137859. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  137860. * Returns the DirectionalLight Shadow projection matrix.
  137861. */
  137862. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  137863. /**
  137864. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  137865. * Returns the DirectionalLight Shadow projection matrix.
  137866. */
  137867. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137868. protected _buildUniformLayout(): void;
  137869. /**
  137870. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  137871. * @param effect The effect to update
  137872. * @param lightIndex The index of the light in the effect to update
  137873. * @returns The directional light
  137874. */
  137875. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  137876. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  137877. /**
  137878. * Gets the minZ used for shadow according to both the scene and the light.
  137879. *
  137880. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137881. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137882. * @param activeCamera The camera we are returning the min for
  137883. * @returns the depth min z
  137884. */
  137885. getDepthMinZ(activeCamera: Camera): number;
  137886. /**
  137887. * Gets the maxZ used for shadow according to both the scene and the light.
  137888. *
  137889. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137890. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137891. * @param activeCamera The camera we are returning the max for
  137892. * @returns the depth max z
  137893. */
  137894. getDepthMaxZ(activeCamera: Camera): number;
  137895. /**
  137896. * Prepares the list of defines specific to the light type.
  137897. * @param defines the list of defines
  137898. * @param lightIndex defines the index of the light for the effect
  137899. */
  137900. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137901. }
  137902. }
  137903. declare module BABYLON {
  137904. /**
  137905. * Class containing static functions to help procedurally build meshes
  137906. */
  137907. export class HemisphereBuilder {
  137908. /**
  137909. * Creates a hemisphere mesh
  137910. * @param name defines the name of the mesh
  137911. * @param options defines the options used to create the mesh
  137912. * @param scene defines the hosting scene
  137913. * @returns the hemisphere mesh
  137914. */
  137915. static CreateHemisphere(name: string, options: {
  137916. segments?: number;
  137917. diameter?: number;
  137918. sideOrientation?: number;
  137919. }, scene: any): Mesh;
  137920. }
  137921. }
  137922. declare module BABYLON {
  137923. /**
  137924. * A spot light is defined by a position, a direction, an angle, and an exponent.
  137925. * These values define a cone of light starting from the position, emitting toward the direction.
  137926. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  137927. * and the exponent defines the speed of the decay of the light with distance (reach).
  137928. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137929. */
  137930. export class SpotLight extends ShadowLight {
  137931. private _angle;
  137932. private _innerAngle;
  137933. private _cosHalfAngle;
  137934. private _lightAngleScale;
  137935. private _lightAngleOffset;
  137936. /**
  137937. * Gets the cone angle of the spot light in Radians.
  137938. */
  137939. get angle(): number;
  137940. /**
  137941. * Sets the cone angle of the spot light in Radians.
  137942. */
  137943. set angle(value: number);
  137944. /**
  137945. * Only used in gltf falloff mode, this defines the angle where
  137946. * the directional falloff will start before cutting at angle which could be seen
  137947. * as outer angle.
  137948. */
  137949. get innerAngle(): number;
  137950. /**
  137951. * Only used in gltf falloff mode, this defines the angle where
  137952. * the directional falloff will start before cutting at angle which could be seen
  137953. * as outer angle.
  137954. */
  137955. set innerAngle(value: number);
  137956. private _shadowAngleScale;
  137957. /**
  137958. * Allows scaling the angle of the light for shadow generation only.
  137959. */
  137960. get shadowAngleScale(): number;
  137961. /**
  137962. * Allows scaling the angle of the light for shadow generation only.
  137963. */
  137964. set shadowAngleScale(value: number);
  137965. /**
  137966. * The light decay speed with the distance from the emission spot.
  137967. */
  137968. exponent: number;
  137969. private _projectionTextureMatrix;
  137970. /**
  137971. * Allows reading the projecton texture
  137972. */
  137973. get projectionTextureMatrix(): Matrix;
  137974. protected _projectionTextureLightNear: number;
  137975. /**
  137976. * Gets the near clip of the Spotlight for texture projection.
  137977. */
  137978. get projectionTextureLightNear(): number;
  137979. /**
  137980. * Sets the near clip of the Spotlight for texture projection.
  137981. */
  137982. set projectionTextureLightNear(value: number);
  137983. protected _projectionTextureLightFar: number;
  137984. /**
  137985. * Gets the far clip of the Spotlight for texture projection.
  137986. */
  137987. get projectionTextureLightFar(): number;
  137988. /**
  137989. * Sets the far clip of the Spotlight for texture projection.
  137990. */
  137991. set projectionTextureLightFar(value: number);
  137992. protected _projectionTextureUpDirection: Vector3;
  137993. /**
  137994. * Gets the Up vector of the Spotlight for texture projection.
  137995. */
  137996. get projectionTextureUpDirection(): Vector3;
  137997. /**
  137998. * Sets the Up vector of the Spotlight for texture projection.
  137999. */
  138000. set projectionTextureUpDirection(value: Vector3);
  138001. private _projectionTexture;
  138002. /**
  138003. * Gets the projection texture of the light.
  138004. */
  138005. get projectionTexture(): Nullable<BaseTexture>;
  138006. /**
  138007. * Sets the projection texture of the light.
  138008. */
  138009. set projectionTexture(value: Nullable<BaseTexture>);
  138010. private _projectionTextureViewLightDirty;
  138011. private _projectionTextureProjectionLightDirty;
  138012. private _projectionTextureDirty;
  138013. private _projectionTextureViewTargetVector;
  138014. private _projectionTextureViewLightMatrix;
  138015. private _projectionTextureProjectionLightMatrix;
  138016. private _projectionTextureScalingMatrix;
  138017. /**
  138018. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  138019. * It can cast shadows.
  138020. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138021. * @param name The light friendly name
  138022. * @param position The position of the spot light in the scene
  138023. * @param direction The direction of the light in the scene
  138024. * @param angle The cone angle of the light in Radians
  138025. * @param exponent The light decay speed with the distance from the emission spot
  138026. * @param scene The scene the lights belongs to
  138027. */
  138028. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  138029. /**
  138030. * Returns the string "SpotLight".
  138031. * @returns the class name
  138032. */
  138033. getClassName(): string;
  138034. /**
  138035. * Returns the integer 2.
  138036. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138037. */
  138038. getTypeID(): number;
  138039. /**
  138040. * Overrides the direction setter to recompute the projection texture view light Matrix.
  138041. */
  138042. protected _setDirection(value: Vector3): void;
  138043. /**
  138044. * Overrides the position setter to recompute the projection texture view light Matrix.
  138045. */
  138046. protected _setPosition(value: Vector3): void;
  138047. /**
  138048. * 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.
  138049. * Returns the SpotLight.
  138050. */
  138051. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138052. protected _computeProjectionTextureViewLightMatrix(): void;
  138053. protected _computeProjectionTextureProjectionLightMatrix(): void;
  138054. /**
  138055. * Main function for light texture projection matrix computing.
  138056. */
  138057. protected _computeProjectionTextureMatrix(): void;
  138058. protected _buildUniformLayout(): void;
  138059. private _computeAngleValues;
  138060. /**
  138061. * Sets the passed Effect "effect" with the Light textures.
  138062. * @param effect The effect to update
  138063. * @param lightIndex The index of the light in the effect to update
  138064. * @returns The light
  138065. */
  138066. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  138067. /**
  138068. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  138069. * @param effect The effect to update
  138070. * @param lightIndex The index of the light in the effect to update
  138071. * @returns The spot light
  138072. */
  138073. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  138074. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138075. /**
  138076. * Disposes the light and the associated resources.
  138077. */
  138078. dispose(): void;
  138079. /**
  138080. * Prepares the list of defines specific to the light type.
  138081. * @param defines the list of defines
  138082. * @param lightIndex defines the index of the light for the effect
  138083. */
  138084. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138085. }
  138086. }
  138087. declare module BABYLON {
  138088. /**
  138089. * Gizmo that enables viewing a light
  138090. */
  138091. export class LightGizmo extends Gizmo {
  138092. private _lightMesh;
  138093. private _material;
  138094. private _cachedPosition;
  138095. private _cachedForward;
  138096. private _attachedMeshParent;
  138097. private _pointerObserver;
  138098. /**
  138099. * Event that fires each time the gizmo is clicked
  138100. */
  138101. onClickedObservable: Observable<Light>;
  138102. /**
  138103. * Creates a LightGizmo
  138104. * @param gizmoLayer The utility layer the gizmo will be added to
  138105. */
  138106. constructor(gizmoLayer?: UtilityLayerRenderer);
  138107. private _light;
  138108. /**
  138109. * The light that the gizmo is attached to
  138110. */
  138111. set light(light: Nullable<Light>);
  138112. get light(): Nullable<Light>;
  138113. /**
  138114. * Gets the material used to render the light gizmo
  138115. */
  138116. get material(): StandardMaterial;
  138117. /**
  138118. * @hidden
  138119. * Updates the gizmo to match the attached mesh's position/rotation
  138120. */
  138121. protected _update(): void;
  138122. private static _Scale;
  138123. /**
  138124. * Creates the lines for a light mesh
  138125. */
  138126. private static _CreateLightLines;
  138127. /**
  138128. * Disposes of the light gizmo
  138129. */
  138130. dispose(): void;
  138131. private static _CreateHemisphericLightMesh;
  138132. private static _CreatePointLightMesh;
  138133. private static _CreateSpotLightMesh;
  138134. private static _CreateDirectionalLightMesh;
  138135. }
  138136. }
  138137. declare module BABYLON {
  138138. /**
  138139. * Gizmo that enables viewing a camera
  138140. */
  138141. export class CameraGizmo extends Gizmo {
  138142. private _cameraMesh;
  138143. private _cameraLinesMesh;
  138144. private _material;
  138145. private _pointerObserver;
  138146. /**
  138147. * Event that fires each time the gizmo is clicked
  138148. */
  138149. onClickedObservable: Observable<Camera>;
  138150. /**
  138151. * Creates a CameraGizmo
  138152. * @param gizmoLayer The utility layer the gizmo will be added to
  138153. */
  138154. constructor(gizmoLayer?: UtilityLayerRenderer);
  138155. private _camera;
  138156. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  138157. get displayFrustum(): boolean;
  138158. set displayFrustum(value: boolean);
  138159. /**
  138160. * The camera that the gizmo is attached to
  138161. */
  138162. set camera(camera: Nullable<Camera>);
  138163. get camera(): Nullable<Camera>;
  138164. /**
  138165. * Gets the material used to render the camera gizmo
  138166. */
  138167. get material(): StandardMaterial;
  138168. /**
  138169. * @hidden
  138170. * Updates the gizmo to match the attached mesh's position/rotation
  138171. */
  138172. protected _update(): void;
  138173. private static _Scale;
  138174. private _invProjection;
  138175. /**
  138176. * Disposes of the camera gizmo
  138177. */
  138178. dispose(): void;
  138179. private static _CreateCameraMesh;
  138180. private static _CreateCameraFrustum;
  138181. }
  138182. }
  138183. declare module BABYLON {
  138184. /** @hidden */
  138185. export var backgroundFragmentDeclaration: {
  138186. name: string;
  138187. shader: string;
  138188. };
  138189. }
  138190. declare module BABYLON {
  138191. /** @hidden */
  138192. export var backgroundUboDeclaration: {
  138193. name: string;
  138194. shader: string;
  138195. };
  138196. }
  138197. declare module BABYLON {
  138198. /** @hidden */
  138199. export var backgroundPixelShader: {
  138200. name: string;
  138201. shader: string;
  138202. };
  138203. }
  138204. declare module BABYLON {
  138205. /** @hidden */
  138206. export var backgroundVertexDeclaration: {
  138207. name: string;
  138208. shader: string;
  138209. };
  138210. }
  138211. declare module BABYLON {
  138212. /** @hidden */
  138213. export var backgroundVertexShader: {
  138214. name: string;
  138215. shader: string;
  138216. };
  138217. }
  138218. declare module BABYLON {
  138219. /**
  138220. * Background material used to create an efficient environement around your scene.
  138221. */
  138222. export class BackgroundMaterial extends PushMaterial {
  138223. /**
  138224. * Standard reflectance value at parallel view angle.
  138225. */
  138226. static StandardReflectance0: number;
  138227. /**
  138228. * Standard reflectance value at grazing angle.
  138229. */
  138230. static StandardReflectance90: number;
  138231. protected _primaryColor: Color3;
  138232. /**
  138233. * Key light Color (multiply against the environement texture)
  138234. */
  138235. primaryColor: Color3;
  138236. protected __perceptualColor: Nullable<Color3>;
  138237. /**
  138238. * Experimental Internal Use Only.
  138239. *
  138240. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  138241. * This acts as a helper to set the primary color to a more "human friendly" value.
  138242. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  138243. * output color as close as possible from the chosen value.
  138244. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  138245. * part of lighting setup.)
  138246. */
  138247. get _perceptualColor(): Nullable<Color3>;
  138248. set _perceptualColor(value: Nullable<Color3>);
  138249. protected _primaryColorShadowLevel: float;
  138250. /**
  138251. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  138252. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  138253. */
  138254. get primaryColorShadowLevel(): float;
  138255. set primaryColorShadowLevel(value: float);
  138256. protected _primaryColorHighlightLevel: float;
  138257. /**
  138258. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  138259. * The primary color is used at the level chosen to define what the white area would look.
  138260. */
  138261. get primaryColorHighlightLevel(): float;
  138262. set primaryColorHighlightLevel(value: float);
  138263. protected _reflectionTexture: Nullable<BaseTexture>;
  138264. /**
  138265. * Reflection Texture used in the material.
  138266. * Should be author in a specific way for the best result (refer to the documentation).
  138267. */
  138268. reflectionTexture: Nullable<BaseTexture>;
  138269. protected _reflectionBlur: float;
  138270. /**
  138271. * Reflection Texture level of blur.
  138272. *
  138273. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  138274. * texture twice.
  138275. */
  138276. reflectionBlur: float;
  138277. protected _diffuseTexture: Nullable<BaseTexture>;
  138278. /**
  138279. * Diffuse Texture used in the material.
  138280. * Should be author in a specific way for the best result (refer to the documentation).
  138281. */
  138282. diffuseTexture: Nullable<BaseTexture>;
  138283. protected _shadowLights: Nullable<IShadowLight[]>;
  138284. /**
  138285. * Specify the list of lights casting shadow on the material.
  138286. * All scene shadow lights will be included if null.
  138287. */
  138288. shadowLights: Nullable<IShadowLight[]>;
  138289. protected _shadowLevel: float;
  138290. /**
  138291. * Helps adjusting the shadow to a softer level if required.
  138292. * 0 means black shadows and 1 means no shadows.
  138293. */
  138294. shadowLevel: float;
  138295. protected _sceneCenter: Vector3;
  138296. /**
  138297. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  138298. * It is usually zero but might be interesting to modify according to your setup.
  138299. */
  138300. sceneCenter: Vector3;
  138301. protected _opacityFresnel: boolean;
  138302. /**
  138303. * This helps specifying that the material is falling off to the sky box at grazing angle.
  138304. * This helps ensuring a nice transition when the camera goes under the ground.
  138305. */
  138306. opacityFresnel: boolean;
  138307. protected _reflectionFresnel: boolean;
  138308. /**
  138309. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  138310. * This helps adding a mirror texture on the ground.
  138311. */
  138312. reflectionFresnel: boolean;
  138313. protected _reflectionFalloffDistance: number;
  138314. /**
  138315. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  138316. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  138317. */
  138318. reflectionFalloffDistance: number;
  138319. protected _reflectionAmount: number;
  138320. /**
  138321. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  138322. */
  138323. reflectionAmount: number;
  138324. protected _reflectionReflectance0: number;
  138325. /**
  138326. * This specifies the weight of the reflection at grazing angle.
  138327. */
  138328. reflectionReflectance0: number;
  138329. protected _reflectionReflectance90: number;
  138330. /**
  138331. * This specifies the weight of the reflection at a perpendicular point of view.
  138332. */
  138333. reflectionReflectance90: number;
  138334. /**
  138335. * Sets the reflection reflectance fresnel values according to the default standard
  138336. * empirically know to work well :-)
  138337. */
  138338. set reflectionStandardFresnelWeight(value: number);
  138339. protected _useRGBColor: boolean;
  138340. /**
  138341. * Helps to directly use the maps channels instead of their level.
  138342. */
  138343. useRGBColor: boolean;
  138344. protected _enableNoise: boolean;
  138345. /**
  138346. * This helps reducing the banding effect that could occur on the background.
  138347. */
  138348. enableNoise: boolean;
  138349. /**
  138350. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138351. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  138352. * Recommended to be keep at 1.0 except for special cases.
  138353. */
  138354. get fovMultiplier(): number;
  138355. set fovMultiplier(value: number);
  138356. private _fovMultiplier;
  138357. /**
  138358. * Enable the FOV adjustment feature controlled by fovMultiplier.
  138359. */
  138360. useEquirectangularFOV: boolean;
  138361. private _maxSimultaneousLights;
  138362. /**
  138363. * Number of Simultaneous lights allowed on the material.
  138364. */
  138365. maxSimultaneousLights: int;
  138366. private _shadowOnly;
  138367. /**
  138368. * Make the material only render shadows
  138369. */
  138370. shadowOnly: boolean;
  138371. /**
  138372. * Default configuration related to image processing available in the Background Material.
  138373. */
  138374. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  138375. /**
  138376. * Keep track of the image processing observer to allow dispose and replace.
  138377. */
  138378. private _imageProcessingObserver;
  138379. /**
  138380. * Attaches a new image processing configuration to the PBR Material.
  138381. * @param configuration (if null the scene configuration will be use)
  138382. */
  138383. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  138384. /**
  138385. * Gets the image processing configuration used either in this material.
  138386. */
  138387. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  138388. /**
  138389. * Sets the Default image processing configuration used either in the this material.
  138390. *
  138391. * If sets to null, the scene one is in use.
  138392. */
  138393. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  138394. /**
  138395. * Gets wether the color curves effect is enabled.
  138396. */
  138397. get cameraColorCurvesEnabled(): boolean;
  138398. /**
  138399. * Sets wether the color curves effect is enabled.
  138400. */
  138401. set cameraColorCurvesEnabled(value: boolean);
  138402. /**
  138403. * Gets wether the color grading effect is enabled.
  138404. */
  138405. get cameraColorGradingEnabled(): boolean;
  138406. /**
  138407. * Gets wether the color grading effect is enabled.
  138408. */
  138409. set cameraColorGradingEnabled(value: boolean);
  138410. /**
  138411. * Gets wether tonemapping is enabled or not.
  138412. */
  138413. get cameraToneMappingEnabled(): boolean;
  138414. /**
  138415. * Sets wether tonemapping is enabled or not
  138416. */
  138417. set cameraToneMappingEnabled(value: boolean);
  138418. /**
  138419. * The camera exposure used on this material.
  138420. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138421. * This corresponds to a photographic exposure.
  138422. */
  138423. get cameraExposure(): float;
  138424. /**
  138425. * The camera exposure used on this material.
  138426. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138427. * This corresponds to a photographic exposure.
  138428. */
  138429. set cameraExposure(value: float);
  138430. /**
  138431. * Gets The camera contrast used on this material.
  138432. */
  138433. get cameraContrast(): float;
  138434. /**
  138435. * Sets The camera contrast used on this material.
  138436. */
  138437. set cameraContrast(value: float);
  138438. /**
  138439. * Gets the Color Grading 2D Lookup Texture.
  138440. */
  138441. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  138442. /**
  138443. * Sets the Color Grading 2D Lookup Texture.
  138444. */
  138445. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  138446. /**
  138447. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138448. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138449. * 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;
  138450. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138451. */
  138452. get cameraColorCurves(): Nullable<ColorCurves>;
  138453. /**
  138454. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138455. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138456. * 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;
  138457. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138458. */
  138459. set cameraColorCurves(value: Nullable<ColorCurves>);
  138460. /**
  138461. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  138462. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  138463. */
  138464. switchToBGR: boolean;
  138465. private _renderTargets;
  138466. private _reflectionControls;
  138467. private _white;
  138468. private _primaryShadowColor;
  138469. private _primaryHighlightColor;
  138470. /**
  138471. * Instantiates a Background Material in the given scene
  138472. * @param name The friendly name of the material
  138473. * @param scene The scene to add the material to
  138474. */
  138475. constructor(name: string, scene: Scene);
  138476. /**
  138477. * Gets a boolean indicating that current material needs to register RTT
  138478. */
  138479. get hasRenderTargetTextures(): boolean;
  138480. /**
  138481. * The entire material has been created in order to prevent overdraw.
  138482. * @returns false
  138483. */
  138484. needAlphaTesting(): boolean;
  138485. /**
  138486. * The entire material has been created in order to prevent overdraw.
  138487. * @returns true if blending is enable
  138488. */
  138489. needAlphaBlending(): boolean;
  138490. /**
  138491. * Checks wether the material is ready to be rendered for a given mesh.
  138492. * @param mesh The mesh to render
  138493. * @param subMesh The submesh to check against
  138494. * @param useInstances Specify wether or not the material is used with instances
  138495. * @returns true if all the dependencies are ready (Textures, Effects...)
  138496. */
  138497. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  138498. /**
  138499. * Compute the primary color according to the chosen perceptual color.
  138500. */
  138501. private _computePrimaryColorFromPerceptualColor;
  138502. /**
  138503. * Compute the highlights and shadow colors according to their chosen levels.
  138504. */
  138505. private _computePrimaryColors;
  138506. /**
  138507. * Build the uniform buffer used in the material.
  138508. */
  138509. buildUniformLayout(): void;
  138510. /**
  138511. * Unbind the material.
  138512. */
  138513. unbind(): void;
  138514. /**
  138515. * Bind only the world matrix to the material.
  138516. * @param world The world matrix to bind.
  138517. */
  138518. bindOnlyWorldMatrix(world: Matrix): void;
  138519. /**
  138520. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  138521. * @param world The world matrix to bind.
  138522. * @param subMesh The submesh to bind for.
  138523. */
  138524. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  138525. /**
  138526. * Checks to see if a texture is used in the material.
  138527. * @param texture - Base texture to use.
  138528. * @returns - Boolean specifying if a texture is used in the material.
  138529. */
  138530. hasTexture(texture: BaseTexture): boolean;
  138531. /**
  138532. * Dispose the material.
  138533. * @param forceDisposeEffect Force disposal of the associated effect.
  138534. * @param forceDisposeTextures Force disposal of the associated textures.
  138535. */
  138536. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  138537. /**
  138538. * Clones the material.
  138539. * @param name The cloned name.
  138540. * @returns The cloned material.
  138541. */
  138542. clone(name: string): BackgroundMaterial;
  138543. /**
  138544. * Serializes the current material to its JSON representation.
  138545. * @returns The JSON representation.
  138546. */
  138547. serialize(): any;
  138548. /**
  138549. * Gets the class name of the material
  138550. * @returns "BackgroundMaterial"
  138551. */
  138552. getClassName(): string;
  138553. /**
  138554. * Parse a JSON input to create back a background material.
  138555. * @param source The JSON data to parse
  138556. * @param scene The scene to create the parsed material in
  138557. * @param rootUrl The root url of the assets the material depends upon
  138558. * @returns the instantiated BackgroundMaterial.
  138559. */
  138560. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  138561. }
  138562. }
  138563. declare module BABYLON {
  138564. /**
  138565. * Represents the different options available during the creation of
  138566. * a Environment helper.
  138567. *
  138568. * This can control the default ground, skybox and image processing setup of your scene.
  138569. */
  138570. export interface IEnvironmentHelperOptions {
  138571. /**
  138572. * Specifies whether or not to create a ground.
  138573. * True by default.
  138574. */
  138575. createGround: boolean;
  138576. /**
  138577. * Specifies the ground size.
  138578. * 15 by default.
  138579. */
  138580. groundSize: number;
  138581. /**
  138582. * The texture used on the ground for the main color.
  138583. * Comes from the BabylonJS CDN by default.
  138584. *
  138585. * Remarks: Can be either a texture or a url.
  138586. */
  138587. groundTexture: string | BaseTexture;
  138588. /**
  138589. * The color mixed in the ground texture by default.
  138590. * BabylonJS clearColor by default.
  138591. */
  138592. groundColor: Color3;
  138593. /**
  138594. * Specifies the ground opacity.
  138595. * 1 by default.
  138596. */
  138597. groundOpacity: number;
  138598. /**
  138599. * Enables the ground to receive shadows.
  138600. * True by default.
  138601. */
  138602. enableGroundShadow: boolean;
  138603. /**
  138604. * Helps preventing the shadow to be fully black on the ground.
  138605. * 0.5 by default.
  138606. */
  138607. groundShadowLevel: number;
  138608. /**
  138609. * Creates a mirror texture attach to the ground.
  138610. * false by default.
  138611. */
  138612. enableGroundMirror: boolean;
  138613. /**
  138614. * Specifies the ground mirror size ratio.
  138615. * 0.3 by default as the default kernel is 64.
  138616. */
  138617. groundMirrorSizeRatio: number;
  138618. /**
  138619. * Specifies the ground mirror blur kernel size.
  138620. * 64 by default.
  138621. */
  138622. groundMirrorBlurKernel: number;
  138623. /**
  138624. * Specifies the ground mirror visibility amount.
  138625. * 1 by default
  138626. */
  138627. groundMirrorAmount: number;
  138628. /**
  138629. * Specifies the ground mirror reflectance weight.
  138630. * This uses the standard weight of the background material to setup the fresnel effect
  138631. * of the mirror.
  138632. * 1 by default.
  138633. */
  138634. groundMirrorFresnelWeight: number;
  138635. /**
  138636. * Specifies the ground mirror Falloff distance.
  138637. * This can helps reducing the size of the reflection.
  138638. * 0 by Default.
  138639. */
  138640. groundMirrorFallOffDistance: number;
  138641. /**
  138642. * Specifies the ground mirror texture type.
  138643. * Unsigned Int by Default.
  138644. */
  138645. groundMirrorTextureType: number;
  138646. /**
  138647. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  138648. * the shown objects.
  138649. */
  138650. groundYBias: number;
  138651. /**
  138652. * Specifies whether or not to create a skybox.
  138653. * True by default.
  138654. */
  138655. createSkybox: boolean;
  138656. /**
  138657. * Specifies the skybox size.
  138658. * 20 by default.
  138659. */
  138660. skyboxSize: number;
  138661. /**
  138662. * The texture used on the skybox for the main color.
  138663. * Comes from the BabylonJS CDN by default.
  138664. *
  138665. * Remarks: Can be either a texture or a url.
  138666. */
  138667. skyboxTexture: string | BaseTexture;
  138668. /**
  138669. * The color mixed in the skybox texture by default.
  138670. * BabylonJS clearColor by default.
  138671. */
  138672. skyboxColor: Color3;
  138673. /**
  138674. * The background rotation around the Y axis of the scene.
  138675. * This helps aligning the key lights of your scene with the background.
  138676. * 0 by default.
  138677. */
  138678. backgroundYRotation: number;
  138679. /**
  138680. * Compute automatically the size of the elements to best fit with the scene.
  138681. */
  138682. sizeAuto: boolean;
  138683. /**
  138684. * Default position of the rootMesh if autoSize is not true.
  138685. */
  138686. rootPosition: Vector3;
  138687. /**
  138688. * Sets up the image processing in the scene.
  138689. * true by default.
  138690. */
  138691. setupImageProcessing: boolean;
  138692. /**
  138693. * The texture used as your environment texture in the scene.
  138694. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  138695. *
  138696. * Remarks: Can be either a texture or a url.
  138697. */
  138698. environmentTexture: string | BaseTexture;
  138699. /**
  138700. * The value of the exposure to apply to the scene.
  138701. * 0.6 by default if setupImageProcessing is true.
  138702. */
  138703. cameraExposure: number;
  138704. /**
  138705. * The value of the contrast to apply to the scene.
  138706. * 1.6 by default if setupImageProcessing is true.
  138707. */
  138708. cameraContrast: number;
  138709. /**
  138710. * Specifies whether or not tonemapping should be enabled in the scene.
  138711. * true by default if setupImageProcessing is true.
  138712. */
  138713. toneMappingEnabled: boolean;
  138714. }
  138715. /**
  138716. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  138717. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  138718. * It also helps with the default setup of your imageProcessing configuration.
  138719. */
  138720. export class EnvironmentHelper {
  138721. /**
  138722. * Default ground texture URL.
  138723. */
  138724. private static _groundTextureCDNUrl;
  138725. /**
  138726. * Default skybox texture URL.
  138727. */
  138728. private static _skyboxTextureCDNUrl;
  138729. /**
  138730. * Default environment texture URL.
  138731. */
  138732. private static _environmentTextureCDNUrl;
  138733. /**
  138734. * Creates the default options for the helper.
  138735. */
  138736. private static _getDefaultOptions;
  138737. private _rootMesh;
  138738. /**
  138739. * Gets the root mesh created by the helper.
  138740. */
  138741. get rootMesh(): Mesh;
  138742. private _skybox;
  138743. /**
  138744. * Gets the skybox created by the helper.
  138745. */
  138746. get skybox(): Nullable<Mesh>;
  138747. private _skyboxTexture;
  138748. /**
  138749. * Gets the skybox texture created by the helper.
  138750. */
  138751. get skyboxTexture(): Nullable<BaseTexture>;
  138752. private _skyboxMaterial;
  138753. /**
  138754. * Gets the skybox material created by the helper.
  138755. */
  138756. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  138757. private _ground;
  138758. /**
  138759. * Gets the ground mesh created by the helper.
  138760. */
  138761. get ground(): Nullable<Mesh>;
  138762. private _groundTexture;
  138763. /**
  138764. * Gets the ground texture created by the helper.
  138765. */
  138766. get groundTexture(): Nullable<BaseTexture>;
  138767. private _groundMirror;
  138768. /**
  138769. * Gets the ground mirror created by the helper.
  138770. */
  138771. get groundMirror(): Nullable<MirrorTexture>;
  138772. /**
  138773. * Gets the ground mirror render list to helps pushing the meshes
  138774. * you wish in the ground reflection.
  138775. */
  138776. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  138777. private _groundMaterial;
  138778. /**
  138779. * Gets the ground material created by the helper.
  138780. */
  138781. get groundMaterial(): Nullable<BackgroundMaterial>;
  138782. /**
  138783. * Stores the creation options.
  138784. */
  138785. private readonly _scene;
  138786. private _options;
  138787. /**
  138788. * This observable will be notified with any error during the creation of the environment,
  138789. * mainly texture creation errors.
  138790. */
  138791. onErrorObservable: Observable<{
  138792. message?: string;
  138793. exception?: any;
  138794. }>;
  138795. /**
  138796. * constructor
  138797. * @param options Defines the options we want to customize the helper
  138798. * @param scene The scene to add the material to
  138799. */
  138800. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  138801. /**
  138802. * Updates the background according to the new options
  138803. * @param options
  138804. */
  138805. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  138806. /**
  138807. * Sets the primary color of all the available elements.
  138808. * @param color the main color to affect to the ground and the background
  138809. */
  138810. setMainColor(color: Color3): void;
  138811. /**
  138812. * Setup the image processing according to the specified options.
  138813. */
  138814. private _setupImageProcessing;
  138815. /**
  138816. * Setup the environment texture according to the specified options.
  138817. */
  138818. private _setupEnvironmentTexture;
  138819. /**
  138820. * Setup the background according to the specified options.
  138821. */
  138822. private _setupBackground;
  138823. /**
  138824. * Get the scene sizes according to the setup.
  138825. */
  138826. private _getSceneSize;
  138827. /**
  138828. * Setup the ground according to the specified options.
  138829. */
  138830. private _setupGround;
  138831. /**
  138832. * Setup the ground material according to the specified options.
  138833. */
  138834. private _setupGroundMaterial;
  138835. /**
  138836. * Setup the ground diffuse texture according to the specified options.
  138837. */
  138838. private _setupGroundDiffuseTexture;
  138839. /**
  138840. * Setup the ground mirror texture according to the specified options.
  138841. */
  138842. private _setupGroundMirrorTexture;
  138843. /**
  138844. * Setup the ground to receive the mirror texture.
  138845. */
  138846. private _setupMirrorInGroundMaterial;
  138847. /**
  138848. * Setup the skybox according to the specified options.
  138849. */
  138850. private _setupSkybox;
  138851. /**
  138852. * Setup the skybox material according to the specified options.
  138853. */
  138854. private _setupSkyboxMaterial;
  138855. /**
  138856. * Setup the skybox reflection texture according to the specified options.
  138857. */
  138858. private _setupSkyboxReflectionTexture;
  138859. private _errorHandler;
  138860. /**
  138861. * Dispose all the elements created by the Helper.
  138862. */
  138863. dispose(): void;
  138864. }
  138865. }
  138866. declare module BABYLON {
  138867. /**
  138868. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  138869. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  138870. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138871. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138872. */
  138873. export abstract class TextureDome<T extends Texture> extends TransformNode {
  138874. protected onError: Nullable<(message?: string, exception?: any) => void>;
  138875. /**
  138876. * Define the source as a Monoscopic panoramic 360/180.
  138877. */
  138878. static readonly MODE_MONOSCOPIC: number;
  138879. /**
  138880. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  138881. */
  138882. static readonly MODE_TOPBOTTOM: number;
  138883. /**
  138884. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  138885. */
  138886. static readonly MODE_SIDEBYSIDE: number;
  138887. private _halfDome;
  138888. private _crossEye;
  138889. protected _useDirectMapping: boolean;
  138890. /**
  138891. * The texture being displayed on the sphere
  138892. */
  138893. protected _texture: T;
  138894. /**
  138895. * Gets the texture being displayed on the sphere
  138896. */
  138897. get texture(): T;
  138898. /**
  138899. * Sets the texture being displayed on the sphere
  138900. */
  138901. set texture(newTexture: T);
  138902. /**
  138903. * The skybox material
  138904. */
  138905. protected _material: BackgroundMaterial;
  138906. /**
  138907. * The surface used for the dome
  138908. */
  138909. protected _mesh: Mesh;
  138910. /**
  138911. * Gets the mesh used for the dome.
  138912. */
  138913. get mesh(): Mesh;
  138914. /**
  138915. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  138916. */
  138917. private _halfDomeMask;
  138918. /**
  138919. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138920. * Also see the options.resolution property.
  138921. */
  138922. get fovMultiplier(): number;
  138923. set fovMultiplier(value: number);
  138924. protected _textureMode: number;
  138925. /**
  138926. * Gets or set the current texture mode for the texture. It can be:
  138927. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138928. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138929. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138930. */
  138931. get textureMode(): number;
  138932. /**
  138933. * Sets the current texture mode for the texture. It can be:
  138934. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138935. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138936. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138937. */
  138938. set textureMode(value: number);
  138939. /**
  138940. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  138941. */
  138942. get halfDome(): boolean;
  138943. /**
  138944. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  138945. */
  138946. set halfDome(enabled: boolean);
  138947. /**
  138948. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  138949. */
  138950. set crossEye(enabled: boolean);
  138951. /**
  138952. * Is it a cross-eye texture?
  138953. */
  138954. get crossEye(): boolean;
  138955. /**
  138956. * The background material of this dome.
  138957. */
  138958. get material(): BackgroundMaterial;
  138959. /**
  138960. * Oberserver used in Stereoscopic VR Mode.
  138961. */
  138962. private _onBeforeCameraRenderObserver;
  138963. /**
  138964. * Observable raised when an error occured while loading the 360 image
  138965. */
  138966. onLoadErrorObservable: Observable<string>;
  138967. /**
  138968. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  138969. * @param name Element's name, child elements will append suffixes for their own names.
  138970. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  138971. * @param options An object containing optional or exposed sub element properties
  138972. */
  138973. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  138974. resolution?: number;
  138975. clickToPlay?: boolean;
  138976. autoPlay?: boolean;
  138977. loop?: boolean;
  138978. size?: number;
  138979. poster?: string;
  138980. faceForward?: boolean;
  138981. useDirectMapping?: boolean;
  138982. halfDomeMode?: boolean;
  138983. crossEyeMode?: boolean;
  138984. generateMipMaps?: boolean;
  138985. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  138986. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  138987. protected _changeTextureMode(value: number): void;
  138988. /**
  138989. * Releases resources associated with this node.
  138990. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  138991. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  138992. */
  138993. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  138994. }
  138995. }
  138996. declare module BABYLON {
  138997. /**
  138998. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  138999. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  139000. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  139001. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139002. */
  139003. export class PhotoDome extends TextureDome<Texture> {
  139004. /**
  139005. * Define the image as a Monoscopic panoramic 360 image.
  139006. */
  139007. static readonly MODE_MONOSCOPIC: number;
  139008. /**
  139009. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  139010. */
  139011. static readonly MODE_TOPBOTTOM: number;
  139012. /**
  139013. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  139014. */
  139015. static readonly MODE_SIDEBYSIDE: number;
  139016. /**
  139017. * Gets or sets the texture being displayed on the sphere
  139018. */
  139019. get photoTexture(): Texture;
  139020. /**
  139021. * sets the texture being displayed on the sphere
  139022. */
  139023. set photoTexture(value: Texture);
  139024. /**
  139025. * Gets the current video mode for the video. It can be:
  139026. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139027. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139028. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139029. */
  139030. get imageMode(): number;
  139031. /**
  139032. * Sets the current video mode for the video. It can be:
  139033. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139034. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139035. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139036. */
  139037. set imageMode(value: number);
  139038. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  139039. }
  139040. }
  139041. declare module BABYLON {
  139042. /**
  139043. * Direct draw surface info
  139044. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  139045. */
  139046. export interface DDSInfo {
  139047. /**
  139048. * Width of the texture
  139049. */
  139050. width: number;
  139051. /**
  139052. * Width of the texture
  139053. */
  139054. height: number;
  139055. /**
  139056. * Number of Mipmaps for the texture
  139057. * @see https://en.wikipedia.org/wiki/Mipmap
  139058. */
  139059. mipmapCount: number;
  139060. /**
  139061. * If the textures format is a known fourCC format
  139062. * @see https://www.fourcc.org/
  139063. */
  139064. isFourCC: boolean;
  139065. /**
  139066. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  139067. */
  139068. isRGB: boolean;
  139069. /**
  139070. * If the texture is a lumincance format
  139071. */
  139072. isLuminance: boolean;
  139073. /**
  139074. * If this is a cube texture
  139075. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  139076. */
  139077. isCube: boolean;
  139078. /**
  139079. * If the texture is a compressed format eg. FOURCC_DXT1
  139080. */
  139081. isCompressed: boolean;
  139082. /**
  139083. * The dxgiFormat of the texture
  139084. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  139085. */
  139086. dxgiFormat: number;
  139087. /**
  139088. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  139089. */
  139090. textureType: number;
  139091. /**
  139092. * Sphericle polynomial created for the dds texture
  139093. */
  139094. sphericalPolynomial?: SphericalPolynomial;
  139095. }
  139096. /**
  139097. * Class used to provide DDS decompression tools
  139098. */
  139099. export class DDSTools {
  139100. /**
  139101. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  139102. */
  139103. static StoreLODInAlphaChannel: boolean;
  139104. /**
  139105. * Gets DDS information from an array buffer
  139106. * @param data defines the array buffer view to read data from
  139107. * @returns the DDS information
  139108. */
  139109. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  139110. private static _FloatView;
  139111. private static _Int32View;
  139112. private static _ToHalfFloat;
  139113. private static _FromHalfFloat;
  139114. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  139115. private static _GetHalfFloatRGBAArrayBuffer;
  139116. private static _GetFloatRGBAArrayBuffer;
  139117. private static _GetFloatAsUIntRGBAArrayBuffer;
  139118. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  139119. private static _GetRGBAArrayBuffer;
  139120. private static _ExtractLongWordOrder;
  139121. private static _GetRGBArrayBuffer;
  139122. private static _GetLuminanceArrayBuffer;
  139123. /**
  139124. * Uploads DDS Levels to a Babylon Texture
  139125. * @hidden
  139126. */
  139127. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  139128. }
  139129. interface ThinEngine {
  139130. /**
  139131. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  139132. * @param rootUrl defines the url where the file to load is located
  139133. * @param scene defines the current scene
  139134. * @param lodScale defines scale to apply to the mip map selection
  139135. * @param lodOffset defines offset to apply to the mip map selection
  139136. * @param onLoad defines an optional callback raised when the texture is loaded
  139137. * @param onError defines an optional callback raised if there is an issue to load the texture
  139138. * @param format defines the format of the data
  139139. * @param forcedExtension defines the extension to use to pick the right loader
  139140. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  139141. * @returns the cube texture as an InternalTexture
  139142. */
  139143. 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;
  139144. }
  139145. }
  139146. declare module BABYLON {
  139147. /**
  139148. * Implementation of the DDS Texture Loader.
  139149. * @hidden
  139150. */
  139151. export class _DDSTextureLoader implements IInternalTextureLoader {
  139152. /**
  139153. * Defines wether the loader supports cascade loading the different faces.
  139154. */
  139155. readonly supportCascades: boolean;
  139156. /**
  139157. * This returns if the loader support the current file information.
  139158. * @param extension defines the file extension of the file being loaded
  139159. * @returns true if the loader can load the specified file
  139160. */
  139161. canLoad(extension: string): boolean;
  139162. /**
  139163. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139164. * @param data contains the texture data
  139165. * @param texture defines the BabylonJS internal texture
  139166. * @param createPolynomials will be true if polynomials have been requested
  139167. * @param onLoad defines the callback to trigger once the texture is ready
  139168. * @param onError defines the callback to trigger in case of error
  139169. */
  139170. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139171. /**
  139172. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139173. * @param data contains the texture data
  139174. * @param texture defines the BabylonJS internal texture
  139175. * @param callback defines the method to call once ready to upload
  139176. */
  139177. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139178. }
  139179. }
  139180. declare module BABYLON {
  139181. /**
  139182. * Implementation of the ENV Texture Loader.
  139183. * @hidden
  139184. */
  139185. export class _ENVTextureLoader implements IInternalTextureLoader {
  139186. /**
  139187. * Defines wether the loader supports cascade loading the different faces.
  139188. */
  139189. readonly supportCascades: boolean;
  139190. /**
  139191. * This returns if the loader support the current file information.
  139192. * @param extension defines the file extension of the file being loaded
  139193. * @returns true if the loader can load the specified file
  139194. */
  139195. canLoad(extension: string): boolean;
  139196. /**
  139197. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139198. * @param data contains the texture data
  139199. * @param texture defines the BabylonJS internal texture
  139200. * @param createPolynomials will be true if polynomials have been requested
  139201. * @param onLoad defines the callback to trigger once the texture is ready
  139202. * @param onError defines the callback to trigger in case of error
  139203. */
  139204. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139205. /**
  139206. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139207. * @param data contains the texture data
  139208. * @param texture defines the BabylonJS internal texture
  139209. * @param callback defines the method to call once ready to upload
  139210. */
  139211. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139212. }
  139213. }
  139214. declare module BABYLON {
  139215. /**
  139216. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  139217. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  139218. */
  139219. export class KhronosTextureContainer {
  139220. /** contents of the KTX container file */
  139221. data: ArrayBufferView;
  139222. private static HEADER_LEN;
  139223. private static COMPRESSED_2D;
  139224. private static COMPRESSED_3D;
  139225. private static TEX_2D;
  139226. private static TEX_3D;
  139227. /**
  139228. * Gets the openGL type
  139229. */
  139230. glType: number;
  139231. /**
  139232. * Gets the openGL type size
  139233. */
  139234. glTypeSize: number;
  139235. /**
  139236. * Gets the openGL format
  139237. */
  139238. glFormat: number;
  139239. /**
  139240. * Gets the openGL internal format
  139241. */
  139242. glInternalFormat: number;
  139243. /**
  139244. * Gets the base internal format
  139245. */
  139246. glBaseInternalFormat: number;
  139247. /**
  139248. * Gets image width in pixel
  139249. */
  139250. pixelWidth: number;
  139251. /**
  139252. * Gets image height in pixel
  139253. */
  139254. pixelHeight: number;
  139255. /**
  139256. * Gets image depth in pixels
  139257. */
  139258. pixelDepth: number;
  139259. /**
  139260. * Gets the number of array elements
  139261. */
  139262. numberOfArrayElements: number;
  139263. /**
  139264. * Gets the number of faces
  139265. */
  139266. numberOfFaces: number;
  139267. /**
  139268. * Gets the number of mipmap levels
  139269. */
  139270. numberOfMipmapLevels: number;
  139271. /**
  139272. * Gets the bytes of key value data
  139273. */
  139274. bytesOfKeyValueData: number;
  139275. /**
  139276. * Gets the load type
  139277. */
  139278. loadType: number;
  139279. /**
  139280. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  139281. */
  139282. isInvalid: boolean;
  139283. /**
  139284. * Creates a new KhronosTextureContainer
  139285. * @param data contents of the KTX container file
  139286. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  139287. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  139288. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  139289. */
  139290. constructor(
  139291. /** contents of the KTX container file */
  139292. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  139293. /**
  139294. * Uploads KTX content to a Babylon Texture.
  139295. * It is assumed that the texture has already been created & is currently bound
  139296. * @hidden
  139297. */
  139298. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  139299. private _upload2DCompressedLevels;
  139300. /**
  139301. * Checks if the given data starts with a KTX file identifier.
  139302. * @param data the data to check
  139303. * @returns true if the data is a KTX file or false otherwise
  139304. */
  139305. static IsValid(data: ArrayBufferView): boolean;
  139306. }
  139307. }
  139308. declare module BABYLON {
  139309. /**
  139310. * Helper class to push actions to a pool of workers.
  139311. */
  139312. export class WorkerPool implements IDisposable {
  139313. private _workerInfos;
  139314. private _pendingActions;
  139315. /**
  139316. * Constructor
  139317. * @param workers Array of workers to use for actions
  139318. */
  139319. constructor(workers: Array<Worker>);
  139320. /**
  139321. * Terminates all workers and clears any pending actions.
  139322. */
  139323. dispose(): void;
  139324. /**
  139325. * Pushes an action to the worker pool. If all the workers are active, the action will be
  139326. * pended until a worker has completed its action.
  139327. * @param action The action to perform. Call onComplete when the action is complete.
  139328. */
  139329. push(action: (worker: Worker, onComplete: () => void) => void): void;
  139330. private _execute;
  139331. }
  139332. }
  139333. declare module BABYLON {
  139334. /**
  139335. * Class for loading KTX2 files
  139336. */
  139337. export class KhronosTextureContainer2 {
  139338. private static _WorkerPoolPromise?;
  139339. private static _Initialized;
  139340. private static _Ktx2Decoder;
  139341. /**
  139342. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  139343. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  139344. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  139345. * Urls you can change:
  139346. * URLConfig.jsDecoderModule
  139347. * URLConfig.wasmUASTCToASTC
  139348. * URLConfig.wasmUASTCToBC7
  139349. * URLConfig.jsMSCTranscoder
  139350. * URLConfig.wasmMSCTranscoder
  139351. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  139352. */
  139353. static URLConfig: {
  139354. jsDecoderModule: string;
  139355. wasmUASTCToASTC: null;
  139356. wasmUASTCToBC7: null;
  139357. jsMSCTranscoder: null;
  139358. wasmMSCTranscoder: null;
  139359. };
  139360. /**
  139361. * Default number of workers used to handle data decoding
  139362. */
  139363. static DefaultNumWorkers: number;
  139364. private static GetDefaultNumWorkers;
  139365. private _engine;
  139366. private static _CreateWorkerPool;
  139367. /**
  139368. * Constructor
  139369. * @param engine The engine to use
  139370. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  139371. */
  139372. constructor(engine: ThinEngine, numWorkers?: number);
  139373. /** @hidden */
  139374. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  139375. /**
  139376. * Stop all async operations and release resources.
  139377. */
  139378. dispose(): void;
  139379. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  139380. /**
  139381. * Checks if the given data starts with a KTX2 file identifier.
  139382. * @param data the data to check
  139383. * @returns true if the data is a KTX2 file or false otherwise
  139384. */
  139385. static IsValid(data: ArrayBufferView): boolean;
  139386. }
  139387. }
  139388. declare module BABYLON {
  139389. /**
  139390. * Implementation of the KTX Texture Loader.
  139391. * @hidden
  139392. */
  139393. export class _KTXTextureLoader implements IInternalTextureLoader {
  139394. /**
  139395. * Defines wether the loader supports cascade loading the different faces.
  139396. */
  139397. readonly supportCascades: boolean;
  139398. /**
  139399. * This returns if the loader support the current file information.
  139400. * @param extension defines the file extension of the file being loaded
  139401. * @param mimeType defines the optional mime type of the file being loaded
  139402. * @returns true if the loader can load the specified file
  139403. */
  139404. canLoad(extension: string, mimeType?: string): boolean;
  139405. /**
  139406. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139407. * @param data contains the texture data
  139408. * @param texture defines the BabylonJS internal texture
  139409. * @param createPolynomials will be true if polynomials have been requested
  139410. * @param onLoad defines the callback to trigger once the texture is ready
  139411. * @param onError defines the callback to trigger in case of error
  139412. */
  139413. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139414. /**
  139415. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139416. * @param data contains the texture data
  139417. * @param texture defines the BabylonJS internal texture
  139418. * @param callback defines the method to call once ready to upload
  139419. */
  139420. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  139421. }
  139422. }
  139423. declare module BABYLON {
  139424. /** @hidden */
  139425. export var _forceSceneHelpersToBundle: boolean;
  139426. interface Scene {
  139427. /**
  139428. * Creates a default light for the scene.
  139429. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  139430. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  139431. */
  139432. createDefaultLight(replace?: boolean): void;
  139433. /**
  139434. * Creates a default camera for the scene.
  139435. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  139436. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139437. * @param replace has default false, when true replaces the active camera in the scene
  139438. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  139439. */
  139440. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139441. /**
  139442. * Creates a default camera and a default light.
  139443. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  139444. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139445. * @param replace has the default false, when true replaces the active camera/light in the scene
  139446. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  139447. */
  139448. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139449. /**
  139450. * Creates a new sky box
  139451. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  139452. * @param environmentTexture defines the texture to use as environment texture
  139453. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  139454. * @param scale defines the overall scale of the skybox
  139455. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  139456. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  139457. * @returns a new mesh holding the sky box
  139458. */
  139459. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  139460. /**
  139461. * Creates a new environment
  139462. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  139463. * @param options defines the options you can use to configure the environment
  139464. * @returns the new EnvironmentHelper
  139465. */
  139466. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  139467. /**
  139468. * Creates a new VREXperienceHelper
  139469. * @see https://doc.babylonjs.com/how_to/webvr_helper
  139470. * @param webVROptions defines the options used to create the new VREXperienceHelper
  139471. * @returns a new VREXperienceHelper
  139472. */
  139473. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  139474. /**
  139475. * Creates a new WebXRDefaultExperience
  139476. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  139477. * @param options experience options
  139478. * @returns a promise for a new WebXRDefaultExperience
  139479. */
  139480. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  139481. }
  139482. }
  139483. declare module BABYLON {
  139484. /**
  139485. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  139486. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  139487. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  139488. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139489. */
  139490. export class VideoDome extends TextureDome<VideoTexture> {
  139491. /**
  139492. * Define the video source as a Monoscopic panoramic 360 video.
  139493. */
  139494. static readonly MODE_MONOSCOPIC: number;
  139495. /**
  139496. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  139497. */
  139498. static readonly MODE_TOPBOTTOM: number;
  139499. /**
  139500. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  139501. */
  139502. static readonly MODE_SIDEBYSIDE: number;
  139503. /**
  139504. * Get the video texture associated with this video dome
  139505. */
  139506. get videoTexture(): VideoTexture;
  139507. /**
  139508. * Get the video mode of this dome
  139509. */
  139510. get videoMode(): number;
  139511. /**
  139512. * Set the video mode of this dome.
  139513. * @see textureMode
  139514. */
  139515. set videoMode(value: number);
  139516. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  139517. }
  139518. }
  139519. declare module BABYLON {
  139520. /**
  139521. * This class can be used to get instrumentation data from a Babylon engine
  139522. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139523. */
  139524. export class EngineInstrumentation implements IDisposable {
  139525. /**
  139526. * Define the instrumented engine.
  139527. */
  139528. engine: Engine;
  139529. private _captureGPUFrameTime;
  139530. private _gpuFrameTimeToken;
  139531. private _gpuFrameTime;
  139532. private _captureShaderCompilationTime;
  139533. private _shaderCompilationTime;
  139534. private _onBeginFrameObserver;
  139535. private _onEndFrameObserver;
  139536. private _onBeforeShaderCompilationObserver;
  139537. private _onAfterShaderCompilationObserver;
  139538. /**
  139539. * Gets the perf counter used for GPU frame time
  139540. */
  139541. get gpuFrameTimeCounter(): PerfCounter;
  139542. /**
  139543. * Gets the GPU frame time capture status
  139544. */
  139545. get captureGPUFrameTime(): boolean;
  139546. /**
  139547. * Enable or disable the GPU frame time capture
  139548. */
  139549. set captureGPUFrameTime(value: boolean);
  139550. /**
  139551. * Gets the perf counter used for shader compilation time
  139552. */
  139553. get shaderCompilationTimeCounter(): PerfCounter;
  139554. /**
  139555. * Gets the shader compilation time capture status
  139556. */
  139557. get captureShaderCompilationTime(): boolean;
  139558. /**
  139559. * Enable or disable the shader compilation time capture
  139560. */
  139561. set captureShaderCompilationTime(value: boolean);
  139562. /**
  139563. * Instantiates a new engine instrumentation.
  139564. * This class can be used to get instrumentation data from a Babylon engine
  139565. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139566. * @param engine Defines the engine to instrument
  139567. */
  139568. constructor(
  139569. /**
  139570. * Define the instrumented engine.
  139571. */
  139572. engine: Engine);
  139573. /**
  139574. * Dispose and release associated resources.
  139575. */
  139576. dispose(): void;
  139577. }
  139578. }
  139579. declare module BABYLON {
  139580. /**
  139581. * This class can be used to get instrumentation data from a Babylon engine
  139582. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139583. */
  139584. export class SceneInstrumentation implements IDisposable {
  139585. /**
  139586. * Defines the scene to instrument
  139587. */
  139588. scene: Scene;
  139589. private _captureActiveMeshesEvaluationTime;
  139590. private _activeMeshesEvaluationTime;
  139591. private _captureRenderTargetsRenderTime;
  139592. private _renderTargetsRenderTime;
  139593. private _captureFrameTime;
  139594. private _frameTime;
  139595. private _captureRenderTime;
  139596. private _renderTime;
  139597. private _captureInterFrameTime;
  139598. private _interFrameTime;
  139599. private _captureParticlesRenderTime;
  139600. private _particlesRenderTime;
  139601. private _captureSpritesRenderTime;
  139602. private _spritesRenderTime;
  139603. private _capturePhysicsTime;
  139604. private _physicsTime;
  139605. private _captureAnimationsTime;
  139606. private _animationsTime;
  139607. private _captureCameraRenderTime;
  139608. private _cameraRenderTime;
  139609. private _onBeforeActiveMeshesEvaluationObserver;
  139610. private _onAfterActiveMeshesEvaluationObserver;
  139611. private _onBeforeRenderTargetsRenderObserver;
  139612. private _onAfterRenderTargetsRenderObserver;
  139613. private _onAfterRenderObserver;
  139614. private _onBeforeDrawPhaseObserver;
  139615. private _onAfterDrawPhaseObserver;
  139616. private _onBeforeAnimationsObserver;
  139617. private _onBeforeParticlesRenderingObserver;
  139618. private _onAfterParticlesRenderingObserver;
  139619. private _onBeforeSpritesRenderingObserver;
  139620. private _onAfterSpritesRenderingObserver;
  139621. private _onBeforePhysicsObserver;
  139622. private _onAfterPhysicsObserver;
  139623. private _onAfterAnimationsObserver;
  139624. private _onBeforeCameraRenderObserver;
  139625. private _onAfterCameraRenderObserver;
  139626. /**
  139627. * Gets the perf counter used for active meshes evaluation time
  139628. */
  139629. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  139630. /**
  139631. * Gets the active meshes evaluation time capture status
  139632. */
  139633. get captureActiveMeshesEvaluationTime(): boolean;
  139634. /**
  139635. * Enable or disable the active meshes evaluation time capture
  139636. */
  139637. set captureActiveMeshesEvaluationTime(value: boolean);
  139638. /**
  139639. * Gets the perf counter used for render targets render time
  139640. */
  139641. get renderTargetsRenderTimeCounter(): PerfCounter;
  139642. /**
  139643. * Gets the render targets render time capture status
  139644. */
  139645. get captureRenderTargetsRenderTime(): boolean;
  139646. /**
  139647. * Enable or disable the render targets render time capture
  139648. */
  139649. set captureRenderTargetsRenderTime(value: boolean);
  139650. /**
  139651. * Gets the perf counter used for particles render time
  139652. */
  139653. get particlesRenderTimeCounter(): PerfCounter;
  139654. /**
  139655. * Gets the particles render time capture status
  139656. */
  139657. get captureParticlesRenderTime(): boolean;
  139658. /**
  139659. * Enable or disable the particles render time capture
  139660. */
  139661. set captureParticlesRenderTime(value: boolean);
  139662. /**
  139663. * Gets the perf counter used for sprites render time
  139664. */
  139665. get spritesRenderTimeCounter(): PerfCounter;
  139666. /**
  139667. * Gets the sprites render time capture status
  139668. */
  139669. get captureSpritesRenderTime(): boolean;
  139670. /**
  139671. * Enable or disable the sprites render time capture
  139672. */
  139673. set captureSpritesRenderTime(value: boolean);
  139674. /**
  139675. * Gets the perf counter used for physics time
  139676. */
  139677. get physicsTimeCounter(): PerfCounter;
  139678. /**
  139679. * Gets the physics time capture status
  139680. */
  139681. get capturePhysicsTime(): boolean;
  139682. /**
  139683. * Enable or disable the physics time capture
  139684. */
  139685. set capturePhysicsTime(value: boolean);
  139686. /**
  139687. * Gets the perf counter used for animations time
  139688. */
  139689. get animationsTimeCounter(): PerfCounter;
  139690. /**
  139691. * Gets the animations time capture status
  139692. */
  139693. get captureAnimationsTime(): boolean;
  139694. /**
  139695. * Enable or disable the animations time capture
  139696. */
  139697. set captureAnimationsTime(value: boolean);
  139698. /**
  139699. * Gets the perf counter used for frame time capture
  139700. */
  139701. get frameTimeCounter(): PerfCounter;
  139702. /**
  139703. * Gets the frame time capture status
  139704. */
  139705. get captureFrameTime(): boolean;
  139706. /**
  139707. * Enable or disable the frame time capture
  139708. */
  139709. set captureFrameTime(value: boolean);
  139710. /**
  139711. * Gets the perf counter used for inter-frames time capture
  139712. */
  139713. get interFrameTimeCounter(): PerfCounter;
  139714. /**
  139715. * Gets the inter-frames time capture status
  139716. */
  139717. get captureInterFrameTime(): boolean;
  139718. /**
  139719. * Enable or disable the inter-frames time capture
  139720. */
  139721. set captureInterFrameTime(value: boolean);
  139722. /**
  139723. * Gets the perf counter used for render time capture
  139724. */
  139725. get renderTimeCounter(): PerfCounter;
  139726. /**
  139727. * Gets the render time capture status
  139728. */
  139729. get captureRenderTime(): boolean;
  139730. /**
  139731. * Enable or disable the render time capture
  139732. */
  139733. set captureRenderTime(value: boolean);
  139734. /**
  139735. * Gets the perf counter used for camera render time capture
  139736. */
  139737. get cameraRenderTimeCounter(): PerfCounter;
  139738. /**
  139739. * Gets the camera render time capture status
  139740. */
  139741. get captureCameraRenderTime(): boolean;
  139742. /**
  139743. * Enable or disable the camera render time capture
  139744. */
  139745. set captureCameraRenderTime(value: boolean);
  139746. /**
  139747. * Gets the perf counter used for draw calls
  139748. */
  139749. get drawCallsCounter(): PerfCounter;
  139750. /**
  139751. * Instantiates a new scene instrumentation.
  139752. * This class can be used to get instrumentation data from a Babylon engine
  139753. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139754. * @param scene Defines the scene to instrument
  139755. */
  139756. constructor(
  139757. /**
  139758. * Defines the scene to instrument
  139759. */
  139760. scene: Scene);
  139761. /**
  139762. * Dispose and release associated resources.
  139763. */
  139764. dispose(): void;
  139765. }
  139766. }
  139767. declare module BABYLON {
  139768. /** @hidden */
  139769. export var glowMapGenerationPixelShader: {
  139770. name: string;
  139771. shader: string;
  139772. };
  139773. }
  139774. declare module BABYLON {
  139775. /** @hidden */
  139776. export var glowMapGenerationVertexShader: {
  139777. name: string;
  139778. shader: string;
  139779. };
  139780. }
  139781. declare module BABYLON {
  139782. /**
  139783. * Effect layer options. This helps customizing the behaviour
  139784. * of the effect layer.
  139785. */
  139786. export interface IEffectLayerOptions {
  139787. /**
  139788. * Multiplication factor apply to the canvas size to compute the render target size
  139789. * used to generated the objects (the smaller the faster).
  139790. */
  139791. mainTextureRatio: number;
  139792. /**
  139793. * Enforces a fixed size texture to ensure effect stability across devices.
  139794. */
  139795. mainTextureFixedSize?: number;
  139796. /**
  139797. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  139798. */
  139799. alphaBlendingMode: number;
  139800. /**
  139801. * The camera attached to the layer.
  139802. */
  139803. camera: Nullable<Camera>;
  139804. /**
  139805. * The rendering group to draw the layer in.
  139806. */
  139807. renderingGroupId: number;
  139808. }
  139809. /**
  139810. * The effect layer Helps adding post process effect blended with the main pass.
  139811. *
  139812. * This can be for instance use to generate glow or higlight effects on the scene.
  139813. *
  139814. * The effect layer class can not be used directly and is intented to inherited from to be
  139815. * customized per effects.
  139816. */
  139817. export abstract class EffectLayer {
  139818. private _vertexBuffers;
  139819. private _indexBuffer;
  139820. private _cachedDefines;
  139821. private _effectLayerMapGenerationEffect;
  139822. private _effectLayerOptions;
  139823. private _mergeEffect;
  139824. protected _scene: Scene;
  139825. protected _engine: Engine;
  139826. protected _maxSize: number;
  139827. protected _mainTextureDesiredSize: ISize;
  139828. protected _mainTexture: RenderTargetTexture;
  139829. protected _shouldRender: boolean;
  139830. protected _postProcesses: PostProcess[];
  139831. protected _textures: BaseTexture[];
  139832. protected _emissiveTextureAndColor: {
  139833. texture: Nullable<BaseTexture>;
  139834. color: Color4;
  139835. };
  139836. /**
  139837. * The name of the layer
  139838. */
  139839. name: string;
  139840. /**
  139841. * The clear color of the texture used to generate the glow map.
  139842. */
  139843. neutralColor: Color4;
  139844. /**
  139845. * Specifies whether the highlight layer is enabled or not.
  139846. */
  139847. isEnabled: boolean;
  139848. /**
  139849. * Gets the camera attached to the layer.
  139850. */
  139851. get camera(): Nullable<Camera>;
  139852. /**
  139853. * Gets the rendering group id the layer should render in.
  139854. */
  139855. get renderingGroupId(): number;
  139856. set renderingGroupId(renderingGroupId: number);
  139857. /**
  139858. * An event triggered when the effect layer has been disposed.
  139859. */
  139860. onDisposeObservable: Observable<EffectLayer>;
  139861. /**
  139862. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  139863. */
  139864. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  139865. /**
  139866. * An event triggered when the generated texture is being merged in the scene.
  139867. */
  139868. onBeforeComposeObservable: Observable<EffectLayer>;
  139869. /**
  139870. * An event triggered when the mesh is rendered into the effect render target.
  139871. */
  139872. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  139873. /**
  139874. * An event triggered after the mesh has been rendered into the effect render target.
  139875. */
  139876. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  139877. /**
  139878. * An event triggered when the generated texture has been merged in the scene.
  139879. */
  139880. onAfterComposeObservable: Observable<EffectLayer>;
  139881. /**
  139882. * An event triggered when the efffect layer changes its size.
  139883. */
  139884. onSizeChangedObservable: Observable<EffectLayer>;
  139885. /** @hidden */
  139886. static _SceneComponentInitialization: (scene: Scene) => void;
  139887. /**
  139888. * Instantiates a new effect Layer and references it in the scene.
  139889. * @param name The name of the layer
  139890. * @param scene The scene to use the layer in
  139891. */
  139892. constructor(
  139893. /** The Friendly of the effect in the scene */
  139894. name: string, scene: Scene);
  139895. /**
  139896. * Get the effect name of the layer.
  139897. * @return The effect name
  139898. */
  139899. abstract getEffectName(): string;
  139900. /**
  139901. * Checks for the readiness of the element composing the layer.
  139902. * @param subMesh the mesh to check for
  139903. * @param useInstances specify whether or not to use instances to render the mesh
  139904. * @return true if ready otherwise, false
  139905. */
  139906. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139907. /**
  139908. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139909. * @returns true if the effect requires stencil during the main canvas render pass.
  139910. */
  139911. abstract needStencil(): boolean;
  139912. /**
  139913. * Create the merge effect. This is the shader use to blit the information back
  139914. * to the main canvas at the end of the scene rendering.
  139915. * @returns The effect containing the shader used to merge the effect on the main canvas
  139916. */
  139917. protected abstract _createMergeEffect(): Effect;
  139918. /**
  139919. * Creates the render target textures and post processes used in the effect layer.
  139920. */
  139921. protected abstract _createTextureAndPostProcesses(): void;
  139922. /**
  139923. * Implementation specific of rendering the generating effect on the main canvas.
  139924. * @param effect The effect used to render through
  139925. */
  139926. protected abstract _internalRender(effect: Effect): void;
  139927. /**
  139928. * Sets the required values for both the emissive texture and and the main color.
  139929. */
  139930. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139931. /**
  139932. * Free any resources and references associated to a mesh.
  139933. * Internal use
  139934. * @param mesh The mesh to free.
  139935. */
  139936. abstract _disposeMesh(mesh: Mesh): void;
  139937. /**
  139938. * Serializes this layer (Glow or Highlight for example)
  139939. * @returns a serialized layer object
  139940. */
  139941. abstract serialize?(): any;
  139942. /**
  139943. * Initializes the effect layer with the required options.
  139944. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  139945. */
  139946. protected _init(options: Partial<IEffectLayerOptions>): void;
  139947. /**
  139948. * Generates the index buffer of the full screen quad blending to the main canvas.
  139949. */
  139950. private _generateIndexBuffer;
  139951. /**
  139952. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  139953. */
  139954. private _generateVertexBuffer;
  139955. /**
  139956. * Sets the main texture desired size which is the closest power of two
  139957. * of the engine canvas size.
  139958. */
  139959. private _setMainTextureSize;
  139960. /**
  139961. * Creates the main texture for the effect layer.
  139962. */
  139963. protected _createMainTexture(): void;
  139964. /**
  139965. * Adds specific effects defines.
  139966. * @param defines The defines to add specifics to.
  139967. */
  139968. protected _addCustomEffectDefines(defines: string[]): void;
  139969. /**
  139970. * Checks for the readiness of the element composing the layer.
  139971. * @param subMesh the mesh to check for
  139972. * @param useInstances specify whether or not to use instances to render the mesh
  139973. * @param emissiveTexture the associated emissive texture used to generate the glow
  139974. * @return true if ready otherwise, false
  139975. */
  139976. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  139977. /**
  139978. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  139979. */
  139980. render(): void;
  139981. /**
  139982. * Determine if a given mesh will be used in the current effect.
  139983. * @param mesh mesh to test
  139984. * @returns true if the mesh will be used
  139985. */
  139986. hasMesh(mesh: AbstractMesh): boolean;
  139987. /**
  139988. * Returns true if the layer contains information to display, otherwise false.
  139989. * @returns true if the glow layer should be rendered
  139990. */
  139991. shouldRender(): boolean;
  139992. /**
  139993. * Returns true if the mesh should render, otherwise false.
  139994. * @param mesh The mesh to render
  139995. * @returns true if it should render otherwise false
  139996. */
  139997. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  139998. /**
  139999. * Returns true if the mesh can be rendered, otherwise false.
  140000. * @param mesh The mesh to render
  140001. * @param material The material used on the mesh
  140002. * @returns true if it can be rendered otherwise false
  140003. */
  140004. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140005. /**
  140006. * Returns true if the mesh should render, otherwise false.
  140007. * @param mesh The mesh to render
  140008. * @returns true if it should render otherwise false
  140009. */
  140010. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  140011. /**
  140012. * Renders the submesh passed in parameter to the generation map.
  140013. */
  140014. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  140015. /**
  140016. * Defines whether the current material of the mesh should be use to render the effect.
  140017. * @param mesh defines the current mesh to render
  140018. */
  140019. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140020. /**
  140021. * Rebuild the required buffers.
  140022. * @hidden Internal use only.
  140023. */
  140024. _rebuild(): void;
  140025. /**
  140026. * Dispose only the render target textures and post process.
  140027. */
  140028. private _disposeTextureAndPostProcesses;
  140029. /**
  140030. * Dispose the highlight layer and free resources.
  140031. */
  140032. dispose(): void;
  140033. /**
  140034. * Gets the class name of the effect layer
  140035. * @returns the string with the class name of the effect layer
  140036. */
  140037. getClassName(): string;
  140038. /**
  140039. * Creates an effect layer from parsed effect layer data
  140040. * @param parsedEffectLayer defines effect layer data
  140041. * @param scene defines the current scene
  140042. * @param rootUrl defines the root URL containing the effect layer information
  140043. * @returns a parsed effect Layer
  140044. */
  140045. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  140046. }
  140047. }
  140048. declare module BABYLON {
  140049. interface AbstractScene {
  140050. /**
  140051. * The list of effect layers (highlights/glow) added to the scene
  140052. * @see https://doc.babylonjs.com/how_to/highlight_layer
  140053. * @see https://doc.babylonjs.com/how_to/glow_layer
  140054. */
  140055. effectLayers: Array<EffectLayer>;
  140056. /**
  140057. * Removes the given effect layer from this scene.
  140058. * @param toRemove defines the effect layer to remove
  140059. * @returns the index of the removed effect layer
  140060. */
  140061. removeEffectLayer(toRemove: EffectLayer): number;
  140062. /**
  140063. * Adds the given effect layer to this scene
  140064. * @param newEffectLayer defines the effect layer to add
  140065. */
  140066. addEffectLayer(newEffectLayer: EffectLayer): void;
  140067. }
  140068. /**
  140069. * Defines the layer scene component responsible to manage any effect layers
  140070. * in a given scene.
  140071. */
  140072. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  140073. /**
  140074. * The component name helpfull to identify the component in the list of scene components.
  140075. */
  140076. readonly name: string;
  140077. /**
  140078. * The scene the component belongs to.
  140079. */
  140080. scene: Scene;
  140081. private _engine;
  140082. private _renderEffects;
  140083. private _needStencil;
  140084. private _previousStencilState;
  140085. /**
  140086. * Creates a new instance of the component for the given scene
  140087. * @param scene Defines the scene to register the component in
  140088. */
  140089. constructor(scene: Scene);
  140090. /**
  140091. * Registers the component in a given scene
  140092. */
  140093. register(): void;
  140094. /**
  140095. * Rebuilds the elements related to this component in case of
  140096. * context lost for instance.
  140097. */
  140098. rebuild(): void;
  140099. /**
  140100. * Serializes the component data to the specified json object
  140101. * @param serializationObject The object to serialize to
  140102. */
  140103. serialize(serializationObject: any): void;
  140104. /**
  140105. * Adds all the elements from the container to the scene
  140106. * @param container the container holding the elements
  140107. */
  140108. addFromContainer(container: AbstractScene): void;
  140109. /**
  140110. * Removes all the elements in the container from the scene
  140111. * @param container contains the elements to remove
  140112. * @param dispose if the removed element should be disposed (default: false)
  140113. */
  140114. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140115. /**
  140116. * Disposes the component and the associated ressources.
  140117. */
  140118. dispose(): void;
  140119. private _isReadyForMesh;
  140120. private _renderMainTexture;
  140121. private _setStencil;
  140122. private _setStencilBack;
  140123. private _draw;
  140124. private _drawCamera;
  140125. private _drawRenderingGroup;
  140126. }
  140127. }
  140128. declare module BABYLON {
  140129. /** @hidden */
  140130. export var glowMapMergePixelShader: {
  140131. name: string;
  140132. shader: string;
  140133. };
  140134. }
  140135. declare module BABYLON {
  140136. /** @hidden */
  140137. export var glowMapMergeVertexShader: {
  140138. name: string;
  140139. shader: string;
  140140. };
  140141. }
  140142. declare module BABYLON {
  140143. interface AbstractScene {
  140144. /**
  140145. * Return a the first highlight layer of the scene with a given name.
  140146. * @param name The name of the highlight layer to look for.
  140147. * @return The highlight layer if found otherwise null.
  140148. */
  140149. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  140150. }
  140151. /**
  140152. * Glow layer options. This helps customizing the behaviour
  140153. * of the glow layer.
  140154. */
  140155. export interface IGlowLayerOptions {
  140156. /**
  140157. * Multiplication factor apply to the canvas size to compute the render target size
  140158. * used to generated the glowing objects (the smaller the faster).
  140159. */
  140160. mainTextureRatio: number;
  140161. /**
  140162. * Enforces a fixed size texture to ensure resize independant blur.
  140163. */
  140164. mainTextureFixedSize?: number;
  140165. /**
  140166. * How big is the kernel of the blur texture.
  140167. */
  140168. blurKernelSize: number;
  140169. /**
  140170. * The camera attached to the layer.
  140171. */
  140172. camera: Nullable<Camera>;
  140173. /**
  140174. * Enable MSAA by chosing the number of samples.
  140175. */
  140176. mainTextureSamples?: number;
  140177. /**
  140178. * The rendering group to draw the layer in.
  140179. */
  140180. renderingGroupId: number;
  140181. }
  140182. /**
  140183. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  140184. *
  140185. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  140186. *
  140187. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  140188. */
  140189. export class GlowLayer extends EffectLayer {
  140190. /**
  140191. * Effect Name of the layer.
  140192. */
  140193. static readonly EffectName: string;
  140194. /**
  140195. * The default blur kernel size used for the glow.
  140196. */
  140197. static DefaultBlurKernelSize: number;
  140198. /**
  140199. * The default texture size ratio used for the glow.
  140200. */
  140201. static DefaultTextureRatio: number;
  140202. /**
  140203. * Sets the kernel size of the blur.
  140204. */
  140205. set blurKernelSize(value: number);
  140206. /**
  140207. * Gets the kernel size of the blur.
  140208. */
  140209. get blurKernelSize(): number;
  140210. /**
  140211. * Sets the glow intensity.
  140212. */
  140213. set intensity(value: number);
  140214. /**
  140215. * Gets the glow intensity.
  140216. */
  140217. get intensity(): number;
  140218. private _options;
  140219. private _intensity;
  140220. private _horizontalBlurPostprocess1;
  140221. private _verticalBlurPostprocess1;
  140222. private _horizontalBlurPostprocess2;
  140223. private _verticalBlurPostprocess2;
  140224. private _blurTexture1;
  140225. private _blurTexture2;
  140226. private _postProcesses1;
  140227. private _postProcesses2;
  140228. private _includedOnlyMeshes;
  140229. private _excludedMeshes;
  140230. private _meshesUsingTheirOwnMaterials;
  140231. /**
  140232. * Callback used to let the user override the color selection on a per mesh basis
  140233. */
  140234. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  140235. /**
  140236. * Callback used to let the user override the texture selection on a per mesh basis
  140237. */
  140238. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  140239. /**
  140240. * Instantiates a new glow Layer and references it to the scene.
  140241. * @param name The name of the layer
  140242. * @param scene The scene to use the layer in
  140243. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  140244. */
  140245. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  140246. /**
  140247. * Get the effect name of the layer.
  140248. * @return The effect name
  140249. */
  140250. getEffectName(): string;
  140251. /**
  140252. * Create the merge effect. This is the shader use to blit the information back
  140253. * to the main canvas at the end of the scene rendering.
  140254. */
  140255. protected _createMergeEffect(): Effect;
  140256. /**
  140257. * Creates the render target textures and post processes used in the glow layer.
  140258. */
  140259. protected _createTextureAndPostProcesses(): void;
  140260. /**
  140261. * Checks for the readiness of the element composing the layer.
  140262. * @param subMesh the mesh to check for
  140263. * @param useInstances specify wether or not to use instances to render the mesh
  140264. * @param emissiveTexture the associated emissive texture used to generate the glow
  140265. * @return true if ready otherwise, false
  140266. */
  140267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140268. /**
  140269. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140270. */
  140271. needStencil(): boolean;
  140272. /**
  140273. * Returns true if the mesh can be rendered, otherwise false.
  140274. * @param mesh The mesh to render
  140275. * @param material The material used on the mesh
  140276. * @returns true if it can be rendered otherwise false
  140277. */
  140278. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140279. /**
  140280. * Implementation specific of rendering the generating effect on the main canvas.
  140281. * @param effect The effect used to render through
  140282. */
  140283. protected _internalRender(effect: Effect): void;
  140284. /**
  140285. * Sets the required values for both the emissive texture and and the main color.
  140286. */
  140287. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140288. /**
  140289. * Returns true if the mesh should render, otherwise false.
  140290. * @param mesh The mesh to render
  140291. * @returns true if it should render otherwise false
  140292. */
  140293. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140294. /**
  140295. * Adds specific effects defines.
  140296. * @param defines The defines to add specifics to.
  140297. */
  140298. protected _addCustomEffectDefines(defines: string[]): void;
  140299. /**
  140300. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  140301. * @param mesh The mesh to exclude from the glow layer
  140302. */
  140303. addExcludedMesh(mesh: Mesh): void;
  140304. /**
  140305. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  140306. * @param mesh The mesh to remove
  140307. */
  140308. removeExcludedMesh(mesh: Mesh): void;
  140309. /**
  140310. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  140311. * @param mesh The mesh to include in the glow layer
  140312. */
  140313. addIncludedOnlyMesh(mesh: Mesh): void;
  140314. /**
  140315. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  140316. * @param mesh The mesh to remove
  140317. */
  140318. removeIncludedOnlyMesh(mesh: Mesh): void;
  140319. /**
  140320. * Determine if a given mesh will be used in the glow layer
  140321. * @param mesh The mesh to test
  140322. * @returns true if the mesh will be highlighted by the current glow layer
  140323. */
  140324. hasMesh(mesh: AbstractMesh): boolean;
  140325. /**
  140326. * Defines whether the current material of the mesh should be use to render the effect.
  140327. * @param mesh defines the current mesh to render
  140328. */
  140329. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140330. /**
  140331. * Add a mesh to be rendered through its own material and not with emissive only.
  140332. * @param mesh The mesh for which we need to use its material
  140333. */
  140334. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  140335. /**
  140336. * Remove a mesh from being rendered through its own material and not with emissive only.
  140337. * @param mesh The mesh for which we need to not use its material
  140338. */
  140339. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  140340. /**
  140341. * Free any resources and references associated to a mesh.
  140342. * Internal use
  140343. * @param mesh The mesh to free.
  140344. * @hidden
  140345. */
  140346. _disposeMesh(mesh: Mesh): void;
  140347. /**
  140348. * Gets the class name of the effect layer
  140349. * @returns the string with the class name of the effect layer
  140350. */
  140351. getClassName(): string;
  140352. /**
  140353. * Serializes this glow layer
  140354. * @returns a serialized glow layer object
  140355. */
  140356. serialize(): any;
  140357. /**
  140358. * Creates a Glow Layer from parsed glow layer data
  140359. * @param parsedGlowLayer defines glow layer data
  140360. * @param scene defines the current scene
  140361. * @param rootUrl defines the root URL containing the glow layer information
  140362. * @returns a parsed Glow Layer
  140363. */
  140364. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  140365. }
  140366. }
  140367. declare module BABYLON {
  140368. /** @hidden */
  140369. export var glowBlurPostProcessPixelShader: {
  140370. name: string;
  140371. shader: string;
  140372. };
  140373. }
  140374. declare module BABYLON {
  140375. interface AbstractScene {
  140376. /**
  140377. * Return a the first highlight layer of the scene with a given name.
  140378. * @param name The name of the highlight layer to look for.
  140379. * @return The highlight layer if found otherwise null.
  140380. */
  140381. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  140382. }
  140383. /**
  140384. * Highlight layer options. This helps customizing the behaviour
  140385. * of the highlight layer.
  140386. */
  140387. export interface IHighlightLayerOptions {
  140388. /**
  140389. * Multiplication factor apply to the canvas size to compute the render target size
  140390. * used to generated the glowing objects (the smaller the faster).
  140391. */
  140392. mainTextureRatio: number;
  140393. /**
  140394. * Enforces a fixed size texture to ensure resize independant blur.
  140395. */
  140396. mainTextureFixedSize?: number;
  140397. /**
  140398. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  140399. * of the picture to blur (the smaller the faster).
  140400. */
  140401. blurTextureSizeRatio: number;
  140402. /**
  140403. * How big in texel of the blur texture is the vertical blur.
  140404. */
  140405. blurVerticalSize: number;
  140406. /**
  140407. * How big in texel of the blur texture is the horizontal blur.
  140408. */
  140409. blurHorizontalSize: number;
  140410. /**
  140411. * Alpha blending mode used to apply the blur. Default is combine.
  140412. */
  140413. alphaBlendingMode: number;
  140414. /**
  140415. * The camera attached to the layer.
  140416. */
  140417. camera: Nullable<Camera>;
  140418. /**
  140419. * Should we display highlight as a solid stroke?
  140420. */
  140421. isStroke?: boolean;
  140422. /**
  140423. * The rendering group to draw the layer in.
  140424. */
  140425. renderingGroupId: number;
  140426. }
  140427. /**
  140428. * The highlight layer Helps adding a glow effect around a mesh.
  140429. *
  140430. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  140431. * glowy meshes to your scene.
  140432. *
  140433. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  140434. */
  140435. export class HighlightLayer extends EffectLayer {
  140436. name: string;
  140437. /**
  140438. * Effect Name of the highlight layer.
  140439. */
  140440. static readonly EffectName: string;
  140441. /**
  140442. * The neutral color used during the preparation of the glow effect.
  140443. * This is black by default as the blend operation is a blend operation.
  140444. */
  140445. static NeutralColor: Color4;
  140446. /**
  140447. * Stencil value used for glowing meshes.
  140448. */
  140449. static GlowingMeshStencilReference: number;
  140450. /**
  140451. * Stencil value used for the other meshes in the scene.
  140452. */
  140453. static NormalMeshStencilReference: number;
  140454. /**
  140455. * Specifies whether or not the inner glow is ACTIVE in the layer.
  140456. */
  140457. innerGlow: boolean;
  140458. /**
  140459. * Specifies whether or not the outer glow is ACTIVE in the layer.
  140460. */
  140461. outerGlow: boolean;
  140462. /**
  140463. * Specifies the horizontal size of the blur.
  140464. */
  140465. set blurHorizontalSize(value: number);
  140466. /**
  140467. * Specifies the vertical size of the blur.
  140468. */
  140469. set blurVerticalSize(value: number);
  140470. /**
  140471. * Gets the horizontal size of the blur.
  140472. */
  140473. get blurHorizontalSize(): number;
  140474. /**
  140475. * Gets the vertical size of the blur.
  140476. */
  140477. get blurVerticalSize(): number;
  140478. /**
  140479. * An event triggered when the highlight layer is being blurred.
  140480. */
  140481. onBeforeBlurObservable: Observable<HighlightLayer>;
  140482. /**
  140483. * An event triggered when the highlight layer has been blurred.
  140484. */
  140485. onAfterBlurObservable: Observable<HighlightLayer>;
  140486. private _instanceGlowingMeshStencilReference;
  140487. private _options;
  140488. private _downSamplePostprocess;
  140489. private _horizontalBlurPostprocess;
  140490. private _verticalBlurPostprocess;
  140491. private _blurTexture;
  140492. private _meshes;
  140493. private _excludedMeshes;
  140494. /**
  140495. * Instantiates a new highlight Layer and references it to the scene..
  140496. * @param name The name of the layer
  140497. * @param scene The scene to use the layer in
  140498. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  140499. */
  140500. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  140501. /**
  140502. * Get the effect name of the layer.
  140503. * @return The effect name
  140504. */
  140505. getEffectName(): string;
  140506. /**
  140507. * Create the merge effect. This is the shader use to blit the information back
  140508. * to the main canvas at the end of the scene rendering.
  140509. */
  140510. protected _createMergeEffect(): Effect;
  140511. /**
  140512. * Creates the render target textures and post processes used in the highlight layer.
  140513. */
  140514. protected _createTextureAndPostProcesses(): void;
  140515. /**
  140516. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  140517. */
  140518. needStencil(): boolean;
  140519. /**
  140520. * Checks for the readiness of the element composing the layer.
  140521. * @param subMesh the mesh to check for
  140522. * @param useInstances specify wether or not to use instances to render the mesh
  140523. * @param emissiveTexture the associated emissive texture used to generate the glow
  140524. * @return true if ready otherwise, false
  140525. */
  140526. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140527. /**
  140528. * Implementation specific of rendering the generating effect on the main canvas.
  140529. * @param effect The effect used to render through
  140530. */
  140531. protected _internalRender(effect: Effect): void;
  140532. /**
  140533. * Returns true if the layer contains information to display, otherwise false.
  140534. */
  140535. shouldRender(): boolean;
  140536. /**
  140537. * Returns true if the mesh should render, otherwise false.
  140538. * @param mesh The mesh to render
  140539. * @returns true if it should render otherwise false
  140540. */
  140541. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140542. /**
  140543. * Returns true if the mesh can be rendered, otherwise false.
  140544. * @param mesh The mesh to render
  140545. * @param material The material used on the mesh
  140546. * @returns true if it can be rendered otherwise false
  140547. */
  140548. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140549. /**
  140550. * Adds specific effects defines.
  140551. * @param defines The defines to add specifics to.
  140552. */
  140553. protected _addCustomEffectDefines(defines: string[]): void;
  140554. /**
  140555. * Sets the required values for both the emissive texture and and the main color.
  140556. */
  140557. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140558. /**
  140559. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  140560. * @param mesh The mesh to exclude from the highlight layer
  140561. */
  140562. addExcludedMesh(mesh: Mesh): void;
  140563. /**
  140564. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  140565. * @param mesh The mesh to highlight
  140566. */
  140567. removeExcludedMesh(mesh: Mesh): void;
  140568. /**
  140569. * Determine if a given mesh will be highlighted by the current HighlightLayer
  140570. * @param mesh mesh to test
  140571. * @returns true if the mesh will be highlighted by the current HighlightLayer
  140572. */
  140573. hasMesh(mesh: AbstractMesh): boolean;
  140574. /**
  140575. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  140576. * @param mesh The mesh to highlight
  140577. * @param color The color of the highlight
  140578. * @param glowEmissiveOnly Extract the glow from the emissive texture
  140579. */
  140580. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  140581. /**
  140582. * Remove a mesh from the highlight layer in order to make it stop glowing.
  140583. * @param mesh The mesh to highlight
  140584. */
  140585. removeMesh(mesh: Mesh): void;
  140586. /**
  140587. * Remove all the meshes currently referenced in the highlight layer
  140588. */
  140589. removeAllMeshes(): void;
  140590. /**
  140591. * Force the stencil to the normal expected value for none glowing parts
  140592. */
  140593. private _defaultStencilReference;
  140594. /**
  140595. * Free any resources and references associated to a mesh.
  140596. * Internal use
  140597. * @param mesh The mesh to free.
  140598. * @hidden
  140599. */
  140600. _disposeMesh(mesh: Mesh): void;
  140601. /**
  140602. * Dispose the highlight layer and free resources.
  140603. */
  140604. dispose(): void;
  140605. /**
  140606. * Gets the class name of the effect layer
  140607. * @returns the string with the class name of the effect layer
  140608. */
  140609. getClassName(): string;
  140610. /**
  140611. * Serializes this Highlight layer
  140612. * @returns a serialized Highlight layer object
  140613. */
  140614. serialize(): any;
  140615. /**
  140616. * Creates a Highlight layer from parsed Highlight layer data
  140617. * @param parsedHightlightLayer defines the Highlight layer data
  140618. * @param scene defines the current scene
  140619. * @param rootUrl defines the root URL containing the Highlight layer information
  140620. * @returns a parsed Highlight layer
  140621. */
  140622. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  140623. }
  140624. }
  140625. declare module BABYLON {
  140626. interface AbstractScene {
  140627. /**
  140628. * The list of layers (background and foreground) of the scene
  140629. */
  140630. layers: Array<Layer>;
  140631. }
  140632. /**
  140633. * Defines the layer scene component responsible to manage any layers
  140634. * in a given scene.
  140635. */
  140636. export class LayerSceneComponent implements ISceneComponent {
  140637. /**
  140638. * The component name helpfull to identify the component in the list of scene components.
  140639. */
  140640. readonly name: string;
  140641. /**
  140642. * The scene the component belongs to.
  140643. */
  140644. scene: Scene;
  140645. private _engine;
  140646. /**
  140647. * Creates a new instance of the component for the given scene
  140648. * @param scene Defines the scene to register the component in
  140649. */
  140650. constructor(scene: Scene);
  140651. /**
  140652. * Registers the component in a given scene
  140653. */
  140654. register(): void;
  140655. /**
  140656. * Rebuilds the elements related to this component in case of
  140657. * context lost for instance.
  140658. */
  140659. rebuild(): void;
  140660. /**
  140661. * Disposes the component and the associated ressources.
  140662. */
  140663. dispose(): void;
  140664. private _draw;
  140665. private _drawCameraPredicate;
  140666. private _drawCameraBackground;
  140667. private _drawCameraForeground;
  140668. private _drawRenderTargetPredicate;
  140669. private _drawRenderTargetBackground;
  140670. private _drawRenderTargetForeground;
  140671. /**
  140672. * Adds all the elements from the container to the scene
  140673. * @param container the container holding the elements
  140674. */
  140675. addFromContainer(container: AbstractScene): void;
  140676. /**
  140677. * Removes all the elements in the container from the scene
  140678. * @param container contains the elements to remove
  140679. * @param dispose if the removed element should be disposed (default: false)
  140680. */
  140681. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140682. }
  140683. }
  140684. declare module BABYLON {
  140685. /** @hidden */
  140686. export var layerPixelShader: {
  140687. name: string;
  140688. shader: string;
  140689. };
  140690. }
  140691. declare module BABYLON {
  140692. /** @hidden */
  140693. export var layerVertexShader: {
  140694. name: string;
  140695. shader: string;
  140696. };
  140697. }
  140698. declare module BABYLON {
  140699. /**
  140700. * This represents a full screen 2d layer.
  140701. * This can be useful to display a picture in the background of your scene for instance.
  140702. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140703. */
  140704. export class Layer {
  140705. /**
  140706. * Define the name of the layer.
  140707. */
  140708. name: string;
  140709. /**
  140710. * Define the texture the layer should display.
  140711. */
  140712. texture: Nullable<Texture>;
  140713. /**
  140714. * Is the layer in background or foreground.
  140715. */
  140716. isBackground: boolean;
  140717. /**
  140718. * Define the color of the layer (instead of texture).
  140719. */
  140720. color: Color4;
  140721. /**
  140722. * Define the scale of the layer in order to zoom in out of the texture.
  140723. */
  140724. scale: Vector2;
  140725. /**
  140726. * Define an offset for the layer in order to shift the texture.
  140727. */
  140728. offset: Vector2;
  140729. /**
  140730. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  140731. */
  140732. alphaBlendingMode: number;
  140733. /**
  140734. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  140735. * Alpha test will not mix with the background color in case of transparency.
  140736. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  140737. */
  140738. alphaTest: boolean;
  140739. /**
  140740. * Define a mask to restrict the layer to only some of the scene cameras.
  140741. */
  140742. layerMask: number;
  140743. /**
  140744. * Define the list of render target the layer is visible into.
  140745. */
  140746. renderTargetTextures: RenderTargetTexture[];
  140747. /**
  140748. * Define if the layer is only used in renderTarget or if it also
  140749. * renders in the main frame buffer of the canvas.
  140750. */
  140751. renderOnlyInRenderTargetTextures: boolean;
  140752. private _scene;
  140753. private _vertexBuffers;
  140754. private _indexBuffer;
  140755. private _effect;
  140756. private _previousDefines;
  140757. /**
  140758. * An event triggered when the layer is disposed.
  140759. */
  140760. onDisposeObservable: Observable<Layer>;
  140761. private _onDisposeObserver;
  140762. /**
  140763. * Back compatibility with callback before the onDisposeObservable existed.
  140764. * The set callback will be triggered when the layer has been disposed.
  140765. */
  140766. set onDispose(callback: () => void);
  140767. /**
  140768. * An event triggered before rendering the scene
  140769. */
  140770. onBeforeRenderObservable: Observable<Layer>;
  140771. private _onBeforeRenderObserver;
  140772. /**
  140773. * Back compatibility with callback before the onBeforeRenderObservable existed.
  140774. * The set callback will be triggered just before rendering the layer.
  140775. */
  140776. set onBeforeRender(callback: () => void);
  140777. /**
  140778. * An event triggered after rendering the scene
  140779. */
  140780. onAfterRenderObservable: Observable<Layer>;
  140781. private _onAfterRenderObserver;
  140782. /**
  140783. * Back compatibility with callback before the onAfterRenderObservable existed.
  140784. * The set callback will be triggered just after rendering the layer.
  140785. */
  140786. set onAfterRender(callback: () => void);
  140787. /**
  140788. * Instantiates a new layer.
  140789. * This represents a full screen 2d layer.
  140790. * This can be useful to display a picture in the background of your scene for instance.
  140791. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140792. * @param name Define the name of the layer in the scene
  140793. * @param imgUrl Define the url of the texture to display in the layer
  140794. * @param scene Define the scene the layer belongs to
  140795. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  140796. * @param color Defines a color for the layer
  140797. */
  140798. constructor(
  140799. /**
  140800. * Define the name of the layer.
  140801. */
  140802. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  140803. private _createIndexBuffer;
  140804. /** @hidden */
  140805. _rebuild(): void;
  140806. /**
  140807. * Renders the layer in the scene.
  140808. */
  140809. render(): void;
  140810. /**
  140811. * Disposes and releases the associated ressources.
  140812. */
  140813. dispose(): void;
  140814. }
  140815. }
  140816. declare module BABYLON {
  140817. /** @hidden */
  140818. export var lensFlarePixelShader: {
  140819. name: string;
  140820. shader: string;
  140821. };
  140822. }
  140823. declare module BABYLON {
  140824. /** @hidden */
  140825. export var lensFlareVertexShader: {
  140826. name: string;
  140827. shader: string;
  140828. };
  140829. }
  140830. declare module BABYLON {
  140831. /**
  140832. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140833. * It is usually composed of several `lensFlare`.
  140834. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140835. */
  140836. export class LensFlareSystem {
  140837. /**
  140838. * Define the name of the lens flare system
  140839. */
  140840. name: string;
  140841. /**
  140842. * List of lens flares used in this system.
  140843. */
  140844. lensFlares: LensFlare[];
  140845. /**
  140846. * Define a limit from the border the lens flare can be visible.
  140847. */
  140848. borderLimit: number;
  140849. /**
  140850. * Define a viewport border we do not want to see the lens flare in.
  140851. */
  140852. viewportBorder: number;
  140853. /**
  140854. * Define a predicate which could limit the list of meshes able to occlude the effect.
  140855. */
  140856. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140857. /**
  140858. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  140859. */
  140860. layerMask: number;
  140861. /**
  140862. * Define the id of the lens flare system in the scene.
  140863. * (equal to name by default)
  140864. */
  140865. id: string;
  140866. private _scene;
  140867. private _emitter;
  140868. private _vertexBuffers;
  140869. private _indexBuffer;
  140870. private _effect;
  140871. private _positionX;
  140872. private _positionY;
  140873. private _isEnabled;
  140874. /** @hidden */
  140875. static _SceneComponentInitialization: (scene: Scene) => void;
  140876. /**
  140877. * Instantiates a lens flare system.
  140878. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140879. * It is usually composed of several `lensFlare`.
  140880. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140881. * @param name Define the name of the lens flare system in the scene
  140882. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  140883. * @param scene Define the scene the lens flare system belongs to
  140884. */
  140885. constructor(
  140886. /**
  140887. * Define the name of the lens flare system
  140888. */
  140889. name: string, emitter: any, scene: Scene);
  140890. /**
  140891. * Define if the lens flare system is enabled.
  140892. */
  140893. get isEnabled(): boolean;
  140894. set isEnabled(value: boolean);
  140895. /**
  140896. * Get the scene the effects belongs to.
  140897. * @returns the scene holding the lens flare system
  140898. */
  140899. getScene(): Scene;
  140900. /**
  140901. * Get the emitter of the lens flare system.
  140902. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140903. * @returns the emitter of the lens flare system
  140904. */
  140905. getEmitter(): any;
  140906. /**
  140907. * Set the emitter of the lens flare system.
  140908. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140909. * @param newEmitter Define the new emitter of the system
  140910. */
  140911. setEmitter(newEmitter: any): void;
  140912. /**
  140913. * Get the lens flare system emitter position.
  140914. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  140915. * @returns the position
  140916. */
  140917. getEmitterPosition(): Vector3;
  140918. /**
  140919. * @hidden
  140920. */
  140921. computeEffectivePosition(globalViewport: Viewport): boolean;
  140922. /** @hidden */
  140923. _isVisible(): boolean;
  140924. /**
  140925. * @hidden
  140926. */
  140927. render(): boolean;
  140928. /**
  140929. * Dispose and release the lens flare with its associated resources.
  140930. */
  140931. dispose(): void;
  140932. /**
  140933. * Parse a lens flare system from a JSON repressentation
  140934. * @param parsedLensFlareSystem Define the JSON to parse
  140935. * @param scene Define the scene the parsed system should be instantiated in
  140936. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  140937. * @returns the parsed system
  140938. */
  140939. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  140940. /**
  140941. * Serialize the current Lens Flare System into a JSON representation.
  140942. * @returns the serialized JSON
  140943. */
  140944. serialize(): any;
  140945. }
  140946. }
  140947. declare module BABYLON {
  140948. /**
  140949. * This represents one of the lens effect in a `lensFlareSystem`.
  140950. * It controls one of the indiviual texture used in the effect.
  140951. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140952. */
  140953. export class LensFlare {
  140954. /**
  140955. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140956. */
  140957. size: number;
  140958. /**
  140959. * 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.
  140960. */
  140961. position: number;
  140962. /**
  140963. * Define the lens color.
  140964. */
  140965. color: Color3;
  140966. /**
  140967. * Define the lens texture.
  140968. */
  140969. texture: Nullable<Texture>;
  140970. /**
  140971. * Define the alpha mode to render this particular lens.
  140972. */
  140973. alphaMode: number;
  140974. private _system;
  140975. /**
  140976. * Creates a new Lens Flare.
  140977. * This represents one of the lens effect in a `lensFlareSystem`.
  140978. * It controls one of the indiviual texture used in the effect.
  140979. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140980. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  140981. * @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.
  140982. * @param color Define the lens color
  140983. * @param imgUrl Define the lens texture url
  140984. * @param system Define the `lensFlareSystem` this flare is part of
  140985. * @returns The newly created Lens Flare
  140986. */
  140987. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  140988. /**
  140989. * Instantiates a new Lens Flare.
  140990. * This represents one of the lens effect in a `lensFlareSystem`.
  140991. * It controls one of the indiviual texture used in the effect.
  140992. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140993. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  140994. * @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.
  140995. * @param color Define the lens color
  140996. * @param imgUrl Define the lens texture url
  140997. * @param system Define the `lensFlareSystem` this flare is part of
  140998. */
  140999. constructor(
  141000. /**
  141001. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141002. */
  141003. size: number,
  141004. /**
  141005. * 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.
  141006. */
  141007. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  141008. /**
  141009. * Dispose and release the lens flare with its associated resources.
  141010. */
  141011. dispose(): void;
  141012. }
  141013. }
  141014. declare module BABYLON {
  141015. interface AbstractScene {
  141016. /**
  141017. * The list of lens flare system added to the scene
  141018. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141019. */
  141020. lensFlareSystems: Array<LensFlareSystem>;
  141021. /**
  141022. * Removes the given lens flare system from this scene.
  141023. * @param toRemove The lens flare system to remove
  141024. * @returns The index of the removed lens flare system
  141025. */
  141026. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  141027. /**
  141028. * Adds the given lens flare system to this scene
  141029. * @param newLensFlareSystem The lens flare system to add
  141030. */
  141031. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  141032. /**
  141033. * Gets a lens flare system using its name
  141034. * @param name defines the name to look for
  141035. * @returns the lens flare system or null if not found
  141036. */
  141037. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  141038. /**
  141039. * Gets a lens flare system using its id
  141040. * @param id defines the id to look for
  141041. * @returns the lens flare system or null if not found
  141042. */
  141043. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  141044. }
  141045. /**
  141046. * Defines the lens flare scene component responsible to manage any lens flares
  141047. * in a given scene.
  141048. */
  141049. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  141050. /**
  141051. * The component name helpfull to identify the component in the list of scene components.
  141052. */
  141053. readonly name: string;
  141054. /**
  141055. * The scene the component belongs to.
  141056. */
  141057. scene: Scene;
  141058. /**
  141059. * Creates a new instance of the component for the given scene
  141060. * @param scene Defines the scene to register the component in
  141061. */
  141062. constructor(scene: Scene);
  141063. /**
  141064. * Registers the component in a given scene
  141065. */
  141066. register(): void;
  141067. /**
  141068. * Rebuilds the elements related to this component in case of
  141069. * context lost for instance.
  141070. */
  141071. rebuild(): void;
  141072. /**
  141073. * Adds all the elements from the container to the scene
  141074. * @param container the container holding the elements
  141075. */
  141076. addFromContainer(container: AbstractScene): void;
  141077. /**
  141078. * Removes all the elements in the container from the scene
  141079. * @param container contains the elements to remove
  141080. * @param dispose if the removed element should be disposed (default: false)
  141081. */
  141082. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141083. /**
  141084. * Serializes the component data to the specified json object
  141085. * @param serializationObject The object to serialize to
  141086. */
  141087. serialize(serializationObject: any): void;
  141088. /**
  141089. * Disposes the component and the associated ressources.
  141090. */
  141091. dispose(): void;
  141092. private _draw;
  141093. }
  141094. }
  141095. declare module BABYLON {
  141096. /** @hidden */
  141097. export var depthPixelShader: {
  141098. name: string;
  141099. shader: string;
  141100. };
  141101. }
  141102. declare module BABYLON {
  141103. /** @hidden */
  141104. export var depthVertexShader: {
  141105. name: string;
  141106. shader: string;
  141107. };
  141108. }
  141109. declare module BABYLON {
  141110. /**
  141111. * This represents a depth renderer in Babylon.
  141112. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  141113. */
  141114. export class DepthRenderer {
  141115. private _scene;
  141116. private _depthMap;
  141117. private _effect;
  141118. private readonly _storeNonLinearDepth;
  141119. private readonly _clearColor;
  141120. /** Get if the depth renderer is using packed depth or not */
  141121. readonly isPacked: boolean;
  141122. private _cachedDefines;
  141123. private _camera;
  141124. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  141125. enabled: boolean;
  141126. /**
  141127. * Specifiess that the depth renderer will only be used within
  141128. * the camera it is created for.
  141129. * This can help forcing its rendering during the camera processing.
  141130. */
  141131. useOnlyInActiveCamera: boolean;
  141132. /** @hidden */
  141133. static _SceneComponentInitialization: (scene: Scene) => void;
  141134. /**
  141135. * Instantiates a depth renderer
  141136. * @param scene The scene the renderer belongs to
  141137. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  141138. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  141139. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141140. */
  141141. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  141142. /**
  141143. * Creates the depth rendering effect and checks if the effect is ready.
  141144. * @param subMesh The submesh to be used to render the depth map of
  141145. * @param useInstances If multiple world instances should be used
  141146. * @returns if the depth renderer is ready to render the depth map
  141147. */
  141148. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141149. /**
  141150. * Gets the texture which the depth map will be written to.
  141151. * @returns The depth map texture
  141152. */
  141153. getDepthMap(): RenderTargetTexture;
  141154. /**
  141155. * Disposes of the depth renderer.
  141156. */
  141157. dispose(): void;
  141158. }
  141159. }
  141160. declare module BABYLON {
  141161. /** @hidden */
  141162. export var minmaxReduxPixelShader: {
  141163. name: string;
  141164. shader: string;
  141165. };
  141166. }
  141167. declare module BABYLON {
  141168. /**
  141169. * This class computes a min/max reduction from a texture: it means it computes the minimum
  141170. * and maximum values from all values of the texture.
  141171. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  141172. * The source values are read from the red channel of the texture.
  141173. */
  141174. export class MinMaxReducer {
  141175. /**
  141176. * Observable triggered when the computation has been performed
  141177. */
  141178. onAfterReductionPerformed: Observable<{
  141179. min: number;
  141180. max: number;
  141181. }>;
  141182. protected _camera: Camera;
  141183. protected _sourceTexture: Nullable<RenderTargetTexture>;
  141184. protected _reductionSteps: Nullable<Array<PostProcess>>;
  141185. protected _postProcessManager: PostProcessManager;
  141186. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  141187. protected _forceFullscreenViewport: boolean;
  141188. /**
  141189. * Creates a min/max reducer
  141190. * @param camera The camera to use for the post processes
  141191. */
  141192. constructor(camera: Camera);
  141193. /**
  141194. * Gets the texture used to read the values from.
  141195. */
  141196. get sourceTexture(): Nullable<RenderTargetTexture>;
  141197. /**
  141198. * Sets the source texture to read the values from.
  141199. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  141200. * because in such textures '1' value must not be taken into account to compute the maximum
  141201. * as this value is used to clear the texture.
  141202. * Note that the computation is not activated by calling this function, you must call activate() for that!
  141203. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  141204. * @param depthRedux Indicates if the texture is a depth texture or not
  141205. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  141206. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141207. */
  141208. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141209. /**
  141210. * Defines the refresh rate of the computation.
  141211. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141212. */
  141213. get refreshRate(): number;
  141214. set refreshRate(value: number);
  141215. protected _activated: boolean;
  141216. /**
  141217. * Gets the activation status of the reducer
  141218. */
  141219. get activated(): boolean;
  141220. /**
  141221. * Activates the reduction computation.
  141222. * When activated, the observers registered in onAfterReductionPerformed are
  141223. * called after the compuation is performed
  141224. */
  141225. activate(): void;
  141226. /**
  141227. * Deactivates the reduction computation.
  141228. */
  141229. deactivate(): void;
  141230. /**
  141231. * Disposes the min/max reducer
  141232. * @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.
  141233. */
  141234. dispose(disposeAll?: boolean): void;
  141235. }
  141236. }
  141237. declare module BABYLON {
  141238. /**
  141239. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  141240. */
  141241. export class DepthReducer extends MinMaxReducer {
  141242. private _depthRenderer;
  141243. private _depthRendererId;
  141244. /**
  141245. * Gets the depth renderer used for the computation.
  141246. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  141247. */
  141248. get depthRenderer(): Nullable<DepthRenderer>;
  141249. /**
  141250. * Creates a depth reducer
  141251. * @param camera The camera used to render the depth texture
  141252. */
  141253. constructor(camera: Camera);
  141254. /**
  141255. * Sets the depth renderer to use to generate the depth map
  141256. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  141257. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  141258. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141259. */
  141260. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  141261. /** @hidden */
  141262. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141263. /**
  141264. * Activates the reduction computation.
  141265. * When activated, the observers registered in onAfterReductionPerformed are
  141266. * called after the compuation is performed
  141267. */
  141268. activate(): void;
  141269. /**
  141270. * Deactivates the reduction computation.
  141271. */
  141272. deactivate(): void;
  141273. /**
  141274. * Disposes the depth reducer
  141275. * @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.
  141276. */
  141277. dispose(disposeAll?: boolean): void;
  141278. }
  141279. }
  141280. declare module BABYLON {
  141281. /**
  141282. * A CSM implementation allowing casting shadows on large scenes.
  141283. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141284. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  141285. */
  141286. export class CascadedShadowGenerator extends ShadowGenerator {
  141287. private static readonly frustumCornersNDCSpace;
  141288. /**
  141289. * Name of the CSM class
  141290. */
  141291. static CLASSNAME: string;
  141292. /**
  141293. * Defines the default number of cascades used by the CSM.
  141294. */
  141295. static readonly DEFAULT_CASCADES_COUNT: number;
  141296. /**
  141297. * Defines the minimum number of cascades used by the CSM.
  141298. */
  141299. static readonly MIN_CASCADES_COUNT: number;
  141300. /**
  141301. * Defines the maximum number of cascades used by the CSM.
  141302. */
  141303. static readonly MAX_CASCADES_COUNT: number;
  141304. protected _validateFilter(filter: number): number;
  141305. /**
  141306. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  141307. */
  141308. penumbraDarkness: number;
  141309. private _numCascades;
  141310. /**
  141311. * Gets or set the number of cascades used by the CSM.
  141312. */
  141313. get numCascades(): number;
  141314. set numCascades(value: number);
  141315. /**
  141316. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  141317. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  141318. */
  141319. stabilizeCascades: boolean;
  141320. private _freezeShadowCastersBoundingInfo;
  141321. private _freezeShadowCastersBoundingInfoObservable;
  141322. /**
  141323. * Enables or disables the shadow casters bounding info computation.
  141324. * If your shadow casters don't move, you can disable this feature.
  141325. * If it is enabled, the bounding box computation is done every frame.
  141326. */
  141327. get freezeShadowCastersBoundingInfo(): boolean;
  141328. set freezeShadowCastersBoundingInfo(freeze: boolean);
  141329. private _scbiMin;
  141330. private _scbiMax;
  141331. protected _computeShadowCastersBoundingInfo(): void;
  141332. protected _shadowCastersBoundingInfo: BoundingInfo;
  141333. /**
  141334. * Gets or sets the shadow casters bounding info.
  141335. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  141336. * so that the system won't overwrite the bounds you provide
  141337. */
  141338. get shadowCastersBoundingInfo(): BoundingInfo;
  141339. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  141340. protected _breaksAreDirty: boolean;
  141341. protected _minDistance: number;
  141342. protected _maxDistance: number;
  141343. /**
  141344. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  141345. *
  141346. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  141347. * If you don't know these values, simply leave them to their defaults and don't call this function.
  141348. * @param min minimal distance for the breaks (default to 0.)
  141349. * @param max maximal distance for the breaks (default to 1.)
  141350. */
  141351. setMinMaxDistance(min: number, max: number): void;
  141352. /** Gets the minimal distance used in the cascade break computation */
  141353. get minDistance(): number;
  141354. /** Gets the maximal distance used in the cascade break computation */
  141355. get maxDistance(): number;
  141356. /**
  141357. * Gets the class name of that object
  141358. * @returns "CascadedShadowGenerator"
  141359. */
  141360. getClassName(): string;
  141361. private _cascadeMinExtents;
  141362. private _cascadeMaxExtents;
  141363. /**
  141364. * Gets a cascade minimum extents
  141365. * @param cascadeIndex index of the cascade
  141366. * @returns the minimum cascade extents
  141367. */
  141368. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  141369. /**
  141370. * Gets a cascade maximum extents
  141371. * @param cascadeIndex index of the cascade
  141372. * @returns the maximum cascade extents
  141373. */
  141374. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  141375. private _cascades;
  141376. private _currentLayer;
  141377. private _viewSpaceFrustumsZ;
  141378. private _viewMatrices;
  141379. private _projectionMatrices;
  141380. private _transformMatrices;
  141381. private _transformMatricesAsArray;
  141382. private _frustumLengths;
  141383. private _lightSizeUVCorrection;
  141384. private _depthCorrection;
  141385. private _frustumCornersWorldSpace;
  141386. private _frustumCenter;
  141387. private _shadowCameraPos;
  141388. private _shadowMaxZ;
  141389. /**
  141390. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  141391. * It defaults to camera.maxZ
  141392. */
  141393. get shadowMaxZ(): number;
  141394. /**
  141395. * Sets the shadow max z distance.
  141396. */
  141397. set shadowMaxZ(value: number);
  141398. protected _debug: boolean;
  141399. /**
  141400. * Gets or sets the debug flag.
  141401. * When enabled, the cascades are materialized by different colors on the screen.
  141402. */
  141403. get debug(): boolean;
  141404. set debug(dbg: boolean);
  141405. private _depthClamp;
  141406. /**
  141407. * Gets or sets the depth clamping value.
  141408. *
  141409. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  141410. * to account for the shadow casters far away.
  141411. *
  141412. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  141413. */
  141414. get depthClamp(): boolean;
  141415. set depthClamp(value: boolean);
  141416. private _cascadeBlendPercentage;
  141417. /**
  141418. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  141419. * It defaults to 0.1 (10% blending).
  141420. */
  141421. get cascadeBlendPercentage(): number;
  141422. set cascadeBlendPercentage(value: number);
  141423. private _lambda;
  141424. /**
  141425. * Gets or set the lambda parameter.
  141426. * This parameter is used to split the camera frustum and create the cascades.
  141427. * 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.
  141428. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  141429. */
  141430. get lambda(): number;
  141431. set lambda(value: number);
  141432. /**
  141433. * Gets the view matrix corresponding to a given cascade
  141434. * @param cascadeNum cascade to retrieve the view matrix from
  141435. * @returns the cascade view matrix
  141436. */
  141437. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  141438. /**
  141439. * Gets the projection matrix corresponding to a given cascade
  141440. * @param cascadeNum cascade to retrieve the projection matrix from
  141441. * @returns the cascade projection matrix
  141442. */
  141443. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  141444. /**
  141445. * Gets the transformation matrix corresponding to a given cascade
  141446. * @param cascadeNum cascade to retrieve the transformation matrix from
  141447. * @returns the cascade transformation matrix
  141448. */
  141449. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  141450. private _depthRenderer;
  141451. /**
  141452. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  141453. *
  141454. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  141455. *
  141456. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  141457. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  141458. * @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
  141459. */
  141460. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  141461. private _depthReducer;
  141462. private _autoCalcDepthBounds;
  141463. /**
  141464. * Gets or sets the autoCalcDepthBounds property.
  141465. *
  141466. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  141467. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  141468. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  141469. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  141470. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  141471. */
  141472. get autoCalcDepthBounds(): boolean;
  141473. set autoCalcDepthBounds(value: boolean);
  141474. /**
  141475. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  141476. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141477. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  141478. * for setting the refresh rate on the renderer yourself!
  141479. */
  141480. get autoCalcDepthBoundsRefreshRate(): number;
  141481. set autoCalcDepthBoundsRefreshRate(value: number);
  141482. /**
  141483. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  141484. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  141485. * you change the camera near/far planes!
  141486. */
  141487. splitFrustum(): void;
  141488. private _splitFrustum;
  141489. private _computeMatrices;
  141490. private _computeFrustumInWorldSpace;
  141491. private _computeCascadeFrustum;
  141492. /**
  141493. * Support test.
  141494. */
  141495. static get IsSupported(): boolean;
  141496. /** @hidden */
  141497. static _SceneComponentInitialization: (scene: Scene) => void;
  141498. /**
  141499. * Creates a Cascaded Shadow Generator object.
  141500. * A ShadowGenerator is the required tool to use the shadows.
  141501. * Each directional light casting shadows needs to use its own ShadowGenerator.
  141502. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141503. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  141504. * @param light The directional light object generating the shadows.
  141505. * @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.
  141506. */
  141507. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  141508. protected _initializeGenerator(): void;
  141509. protected _createTargetRenderTexture(): void;
  141510. protected _initializeShadowMap(): void;
  141511. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  141512. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  141513. /**
  141514. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  141515. * @param defines Defines of the material we want to update
  141516. * @param lightIndex Index of the light in the enabled light list of the material
  141517. */
  141518. prepareDefines(defines: any, lightIndex: number): void;
  141519. /**
  141520. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  141521. * defined in the generator but impacting the effect).
  141522. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  141523. * @param effect The effect we are binfing the information for
  141524. */
  141525. bindShadowLight(lightIndex: string, effect: Effect): void;
  141526. /**
  141527. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  141528. * (eq to view projection * shadow projection matrices)
  141529. * @returns The transform matrix used to create the shadow map
  141530. */
  141531. getTransformMatrix(): Matrix;
  141532. /**
  141533. * Disposes the ShadowGenerator.
  141534. * Returns nothing.
  141535. */
  141536. dispose(): void;
  141537. /**
  141538. * Serializes the shadow generator setup to a json object.
  141539. * @returns The serialized JSON object
  141540. */
  141541. serialize(): any;
  141542. /**
  141543. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  141544. * @param parsedShadowGenerator The JSON object to parse
  141545. * @param scene The scene to create the shadow map for
  141546. * @returns The parsed shadow generator
  141547. */
  141548. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  141549. }
  141550. }
  141551. declare module BABYLON {
  141552. /**
  141553. * Defines the shadow generator component responsible to manage any shadow generators
  141554. * in a given scene.
  141555. */
  141556. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  141557. /**
  141558. * The component name helpfull to identify the component in the list of scene components.
  141559. */
  141560. readonly name: string;
  141561. /**
  141562. * The scene the component belongs to.
  141563. */
  141564. scene: Scene;
  141565. /**
  141566. * Creates a new instance of the component for the given scene
  141567. * @param scene Defines the scene to register the component in
  141568. */
  141569. constructor(scene: Scene);
  141570. /**
  141571. * Registers the component in a given scene
  141572. */
  141573. register(): void;
  141574. /**
  141575. * Rebuilds the elements related to this component in case of
  141576. * context lost for instance.
  141577. */
  141578. rebuild(): void;
  141579. /**
  141580. * Serializes the component data to the specified json object
  141581. * @param serializationObject The object to serialize to
  141582. */
  141583. serialize(serializationObject: any): void;
  141584. /**
  141585. * Adds all the elements from the container to the scene
  141586. * @param container the container holding the elements
  141587. */
  141588. addFromContainer(container: AbstractScene): void;
  141589. /**
  141590. * Removes all the elements in the container from the scene
  141591. * @param container contains the elements to remove
  141592. * @param dispose if the removed element should be disposed (default: false)
  141593. */
  141594. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141595. /**
  141596. * Rebuilds the elements related to this component in case of
  141597. * context lost for instance.
  141598. */
  141599. dispose(): void;
  141600. private _gatherRenderTargets;
  141601. }
  141602. }
  141603. declare module BABYLON {
  141604. /**
  141605. * A point light is a light defined by an unique point in world space.
  141606. * The light is emitted in every direction from this point.
  141607. * A good example of a point light is a standard light bulb.
  141608. * Documentation: https://doc.babylonjs.com/babylon101/lights
  141609. */
  141610. export class PointLight extends ShadowLight {
  141611. private _shadowAngle;
  141612. /**
  141613. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141614. * This specifies what angle the shadow will use to be created.
  141615. *
  141616. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141617. */
  141618. get shadowAngle(): number;
  141619. /**
  141620. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141621. * This specifies what angle the shadow will use to be created.
  141622. *
  141623. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141624. */
  141625. set shadowAngle(value: number);
  141626. /**
  141627. * Gets the direction if it has been set.
  141628. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141629. */
  141630. get direction(): Vector3;
  141631. /**
  141632. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141633. */
  141634. set direction(value: Vector3);
  141635. /**
  141636. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  141637. * A PointLight emits the light in every direction.
  141638. * It can cast shadows.
  141639. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  141640. * ```javascript
  141641. * var pointLight = new PointLight("pl", camera.position, scene);
  141642. * ```
  141643. * Documentation : https://doc.babylonjs.com/babylon101/lights
  141644. * @param name The light friendly name
  141645. * @param position The position of the point light in the scene
  141646. * @param scene The scene the lights belongs to
  141647. */
  141648. constructor(name: string, position: Vector3, scene: Scene);
  141649. /**
  141650. * Returns the string "PointLight"
  141651. * @returns the class name
  141652. */
  141653. getClassName(): string;
  141654. /**
  141655. * Returns the integer 0.
  141656. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  141657. */
  141658. getTypeID(): number;
  141659. /**
  141660. * Specifies wether or not the shadowmap should be a cube texture.
  141661. * @returns true if the shadowmap needs to be a cube texture.
  141662. */
  141663. needCube(): boolean;
  141664. /**
  141665. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  141666. * @param faceIndex The index of the face we are computed the direction to generate shadow
  141667. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  141668. */
  141669. getShadowDirection(faceIndex?: number): Vector3;
  141670. /**
  141671. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  141672. * - fov = PI / 2
  141673. * - aspect ratio : 1.0
  141674. * - z-near and far equal to the active camera minZ and maxZ.
  141675. * Returns the PointLight.
  141676. */
  141677. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  141678. protected _buildUniformLayout(): void;
  141679. /**
  141680. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  141681. * @param effect The effect to update
  141682. * @param lightIndex The index of the light in the effect to update
  141683. * @returns The point light
  141684. */
  141685. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  141686. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  141687. /**
  141688. * Prepares the list of defines specific to the light type.
  141689. * @param defines the list of defines
  141690. * @param lightIndex defines the index of the light for the effect
  141691. */
  141692. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  141693. }
  141694. }
  141695. declare module BABYLON {
  141696. /**
  141697. * Header information of HDR texture files.
  141698. */
  141699. export interface HDRInfo {
  141700. /**
  141701. * The height of the texture in pixels.
  141702. */
  141703. height: number;
  141704. /**
  141705. * The width of the texture in pixels.
  141706. */
  141707. width: number;
  141708. /**
  141709. * The index of the beginning of the data in the binary file.
  141710. */
  141711. dataPosition: number;
  141712. }
  141713. /**
  141714. * This groups tools to convert HDR texture to native colors array.
  141715. */
  141716. export class HDRTools {
  141717. private static Ldexp;
  141718. private static Rgbe2float;
  141719. private static readStringLine;
  141720. /**
  141721. * Reads header information from an RGBE texture stored in a native array.
  141722. * More information on this format are available here:
  141723. * https://en.wikipedia.org/wiki/RGBE_image_format
  141724. *
  141725. * @param uint8array The binary file stored in native array.
  141726. * @return The header information.
  141727. */
  141728. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  141729. /**
  141730. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  141731. * This RGBE texture needs to store the information as a panorama.
  141732. *
  141733. * More information on this format are available here:
  141734. * https://en.wikipedia.org/wiki/RGBE_image_format
  141735. *
  141736. * @param buffer The binary file stored in an array buffer.
  141737. * @param size The expected size of the extracted cubemap.
  141738. * @return The Cube Map information.
  141739. */
  141740. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  141741. /**
  141742. * Returns the pixels data extracted from an RGBE texture.
  141743. * This pixels will be stored left to right up to down in the R G B order in one array.
  141744. *
  141745. * More information on this format are available here:
  141746. * https://en.wikipedia.org/wiki/RGBE_image_format
  141747. *
  141748. * @param uint8array The binary file stored in an array buffer.
  141749. * @param hdrInfo The header information of the file.
  141750. * @return The pixels data in RGB right to left up to down order.
  141751. */
  141752. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  141753. private static RGBE_ReadPixels_RLE;
  141754. private static RGBE_ReadPixels_NOT_RLE;
  141755. }
  141756. }
  141757. declare module BABYLON {
  141758. /**
  141759. * Effect Render Options
  141760. */
  141761. export interface IEffectRendererOptions {
  141762. /**
  141763. * Defines the vertices positions.
  141764. */
  141765. positions?: number[];
  141766. /**
  141767. * Defines the indices.
  141768. */
  141769. indices?: number[];
  141770. }
  141771. /**
  141772. * Helper class to render one or more effects.
  141773. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  141774. */
  141775. export class EffectRenderer {
  141776. private engine;
  141777. private static _DefaultOptions;
  141778. private _vertexBuffers;
  141779. private _indexBuffer;
  141780. private _fullscreenViewport;
  141781. /**
  141782. * Creates an effect renderer
  141783. * @param engine the engine to use for rendering
  141784. * @param options defines the options of the effect renderer
  141785. */
  141786. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  141787. /**
  141788. * Sets the current viewport in normalized coordinates 0-1
  141789. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  141790. */
  141791. setViewport(viewport?: Viewport): void;
  141792. /**
  141793. * Binds the embedded attributes buffer to the effect.
  141794. * @param effect Defines the effect to bind the attributes for
  141795. */
  141796. bindBuffers(effect: Effect): void;
  141797. /**
  141798. * Sets the current effect wrapper to use during draw.
  141799. * The effect needs to be ready before calling this api.
  141800. * This also sets the default full screen position attribute.
  141801. * @param effectWrapper Defines the effect to draw with
  141802. */
  141803. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  141804. /**
  141805. * Restores engine states
  141806. */
  141807. restoreStates(): void;
  141808. /**
  141809. * Draws a full screen quad.
  141810. */
  141811. draw(): void;
  141812. private isRenderTargetTexture;
  141813. /**
  141814. * renders one or more effects to a specified texture
  141815. * @param effectWrapper the effect to renderer
  141816. * @param outputTexture texture to draw to, if null it will render to the screen.
  141817. */
  141818. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  141819. /**
  141820. * Disposes of the effect renderer
  141821. */
  141822. dispose(): void;
  141823. }
  141824. /**
  141825. * Options to create an EffectWrapper
  141826. */
  141827. interface EffectWrapperCreationOptions {
  141828. /**
  141829. * Engine to use to create the effect
  141830. */
  141831. engine: ThinEngine;
  141832. /**
  141833. * Fragment shader for the effect
  141834. */
  141835. fragmentShader: string;
  141836. /**
  141837. * Use the shader store instead of direct source code
  141838. */
  141839. useShaderStore?: boolean;
  141840. /**
  141841. * Vertex shader for the effect
  141842. */
  141843. vertexShader?: string;
  141844. /**
  141845. * Attributes to use in the shader
  141846. */
  141847. attributeNames?: Array<string>;
  141848. /**
  141849. * Uniforms to use in the shader
  141850. */
  141851. uniformNames?: Array<string>;
  141852. /**
  141853. * Texture sampler names to use in the shader
  141854. */
  141855. samplerNames?: Array<string>;
  141856. /**
  141857. * Defines to use in the shader
  141858. */
  141859. defines?: Array<string>;
  141860. /**
  141861. * Callback when effect is compiled
  141862. */
  141863. onCompiled?: Nullable<(effect: Effect) => void>;
  141864. /**
  141865. * The friendly name of the effect displayed in Spector.
  141866. */
  141867. name?: string;
  141868. }
  141869. /**
  141870. * Wraps an effect to be used for rendering
  141871. */
  141872. export class EffectWrapper {
  141873. /**
  141874. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  141875. */
  141876. onApplyObservable: Observable<{}>;
  141877. /**
  141878. * The underlying effect
  141879. */
  141880. effect: Effect;
  141881. /**
  141882. * Creates an effect to be renderer
  141883. * @param creationOptions options to create the effect
  141884. */
  141885. constructor(creationOptions: EffectWrapperCreationOptions);
  141886. /**
  141887. * Disposes of the effect wrapper
  141888. */
  141889. dispose(): void;
  141890. }
  141891. }
  141892. declare module BABYLON {
  141893. /** @hidden */
  141894. export var hdrFilteringVertexShader: {
  141895. name: string;
  141896. shader: string;
  141897. };
  141898. }
  141899. declare module BABYLON {
  141900. /** @hidden */
  141901. export var hdrFilteringPixelShader: {
  141902. name: string;
  141903. shader: string;
  141904. };
  141905. }
  141906. declare module BABYLON {
  141907. /**
  141908. * Options for texture filtering
  141909. */
  141910. interface IHDRFilteringOptions {
  141911. /**
  141912. * Scales pixel intensity for the input HDR map.
  141913. */
  141914. hdrScale?: number;
  141915. /**
  141916. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  141917. */
  141918. quality?: number;
  141919. }
  141920. /**
  141921. * Filters HDR maps to get correct renderings of PBR reflections
  141922. */
  141923. export class HDRFiltering {
  141924. private _engine;
  141925. private _effectRenderer;
  141926. private _effectWrapper;
  141927. private _lodGenerationOffset;
  141928. private _lodGenerationScale;
  141929. /**
  141930. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  141931. * you care about baking speed.
  141932. */
  141933. quality: number;
  141934. /**
  141935. * Scales pixel intensity for the input HDR map.
  141936. */
  141937. hdrScale: number;
  141938. /**
  141939. * Instantiates HDR filter for reflection maps
  141940. *
  141941. * @param engine Thin engine
  141942. * @param options Options
  141943. */
  141944. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  141945. private _createRenderTarget;
  141946. private _prefilterInternal;
  141947. private _createEffect;
  141948. /**
  141949. * Get a value indicating if the filter is ready to be used
  141950. * @param texture Texture to filter
  141951. * @returns true if the filter is ready
  141952. */
  141953. isReady(texture: BaseTexture): boolean;
  141954. /**
  141955. * Prefilters a cube texture to have mipmap levels representing roughness values.
  141956. * Prefiltering will be invoked at the end of next rendering pass.
  141957. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  141958. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  141959. * @param texture Texture to filter
  141960. * @param onFinished Callback when filtering is done
  141961. * @return Promise called when prefiltering is done
  141962. */
  141963. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  141964. }
  141965. }
  141966. declare module BABYLON {
  141967. /**
  141968. * This represents a texture coming from an HDR input.
  141969. *
  141970. * The only supported format is currently panorama picture stored in RGBE format.
  141971. * Example of such files can be found on HDRLib: http://hdrlib.com/
  141972. */
  141973. export class HDRCubeTexture extends BaseTexture {
  141974. private static _facesMapping;
  141975. private _generateHarmonics;
  141976. private _noMipmap;
  141977. private _prefilterOnLoad;
  141978. private _textureMatrix;
  141979. private _size;
  141980. private _onLoad;
  141981. private _onError;
  141982. /**
  141983. * The texture URL.
  141984. */
  141985. url: string;
  141986. protected _isBlocking: boolean;
  141987. /**
  141988. * Sets wether or not the texture is blocking during loading.
  141989. */
  141990. set isBlocking(value: boolean);
  141991. /**
  141992. * Gets wether or not the texture is blocking during loading.
  141993. */
  141994. get isBlocking(): boolean;
  141995. protected _rotationY: number;
  141996. /**
  141997. * Sets texture matrix rotation angle around Y axis in radians.
  141998. */
  141999. set rotationY(value: number);
  142000. /**
  142001. * Gets texture matrix rotation angle around Y axis radians.
  142002. */
  142003. get rotationY(): number;
  142004. /**
  142005. * Gets or sets the center of the bounding box associated with the cube texture
  142006. * It must define where the camera used to render the texture was set
  142007. */
  142008. boundingBoxPosition: Vector3;
  142009. private _boundingBoxSize;
  142010. /**
  142011. * Gets or sets the size of the bounding box associated with the cube texture
  142012. * When defined, the cubemap will switch to local mode
  142013. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  142014. * @example https://www.babylonjs-playground.com/#RNASML
  142015. */
  142016. set boundingBoxSize(value: Vector3);
  142017. get boundingBoxSize(): Vector3;
  142018. /**
  142019. * Instantiates an HDRTexture from the following parameters.
  142020. *
  142021. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  142022. * @param sceneOrEngine The scene or engine the texture will be used in
  142023. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142024. * @param noMipmap Forces to not generate the mipmap if true
  142025. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  142026. * @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)
  142027. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  142028. */
  142029. 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>);
  142030. /**
  142031. * Get the current class name of the texture useful for serialization or dynamic coding.
  142032. * @returns "HDRCubeTexture"
  142033. */
  142034. getClassName(): string;
  142035. /**
  142036. * Occurs when the file is raw .hdr file.
  142037. */
  142038. private loadTexture;
  142039. clone(): HDRCubeTexture;
  142040. delayLoad(): void;
  142041. /**
  142042. * Get the texture reflection matrix used to rotate/transform the reflection.
  142043. * @returns the reflection matrix
  142044. */
  142045. getReflectionTextureMatrix(): Matrix;
  142046. /**
  142047. * Set the texture reflection matrix used to rotate/transform the reflection.
  142048. * @param value Define the reflection matrix to set
  142049. */
  142050. setReflectionTextureMatrix(value: Matrix): void;
  142051. /**
  142052. * Parses a JSON representation of an HDR Texture in order to create the texture
  142053. * @param parsedTexture Define the JSON representation
  142054. * @param scene Define the scene the texture should be created in
  142055. * @param rootUrl Define the root url in case we need to load relative dependencies
  142056. * @returns the newly created texture after parsing
  142057. */
  142058. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  142059. serialize(): any;
  142060. }
  142061. }
  142062. declare module BABYLON {
  142063. /**
  142064. * Class used to control physics engine
  142065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142066. */
  142067. export class PhysicsEngine implements IPhysicsEngine {
  142068. private _physicsPlugin;
  142069. /**
  142070. * Global value used to control the smallest number supported by the simulation
  142071. */
  142072. static Epsilon: number;
  142073. private _impostors;
  142074. private _joints;
  142075. private _subTimeStep;
  142076. /**
  142077. * Gets the gravity vector used by the simulation
  142078. */
  142079. gravity: Vector3;
  142080. /**
  142081. * Factory used to create the default physics plugin.
  142082. * @returns The default physics plugin
  142083. */
  142084. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  142085. /**
  142086. * Creates a new Physics Engine
  142087. * @param gravity defines the gravity vector used by the simulation
  142088. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  142089. */
  142090. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  142091. /**
  142092. * Sets the gravity vector used by the simulation
  142093. * @param gravity defines the gravity vector to use
  142094. */
  142095. setGravity(gravity: Vector3): void;
  142096. /**
  142097. * Set the time step of the physics engine.
  142098. * Default is 1/60.
  142099. * To slow it down, enter 1/600 for example.
  142100. * To speed it up, 1/30
  142101. * @param newTimeStep defines the new timestep to apply to this world.
  142102. */
  142103. setTimeStep(newTimeStep?: number): void;
  142104. /**
  142105. * Get the time step of the physics engine.
  142106. * @returns the current time step
  142107. */
  142108. getTimeStep(): number;
  142109. /**
  142110. * Set the sub time step of the physics engine.
  142111. * Default is 0 meaning there is no sub steps
  142112. * To increase physics resolution precision, set a small value (like 1 ms)
  142113. * @param subTimeStep defines the new sub timestep used for physics resolution.
  142114. */
  142115. setSubTimeStep(subTimeStep?: number): void;
  142116. /**
  142117. * Get the sub time step of the physics engine.
  142118. * @returns the current sub time step
  142119. */
  142120. getSubTimeStep(): number;
  142121. /**
  142122. * Release all resources
  142123. */
  142124. dispose(): void;
  142125. /**
  142126. * Gets the name of the current physics plugin
  142127. * @returns the name of the plugin
  142128. */
  142129. getPhysicsPluginName(): string;
  142130. /**
  142131. * Adding a new impostor for the impostor tracking.
  142132. * This will be done by the impostor itself.
  142133. * @param impostor the impostor to add
  142134. */
  142135. addImpostor(impostor: PhysicsImpostor): void;
  142136. /**
  142137. * Remove an impostor from the engine.
  142138. * This impostor and its mesh will not longer be updated by the physics engine.
  142139. * @param impostor the impostor to remove
  142140. */
  142141. removeImpostor(impostor: PhysicsImpostor): void;
  142142. /**
  142143. * Add a joint to the physics engine
  142144. * @param mainImpostor defines the main impostor to which the joint is added.
  142145. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  142146. * @param joint defines the joint that will connect both impostors.
  142147. */
  142148. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142149. /**
  142150. * Removes a joint from the simulation
  142151. * @param mainImpostor defines the impostor used with the joint
  142152. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  142153. * @param joint defines the joint to remove
  142154. */
  142155. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142156. /**
  142157. * Called by the scene. No need to call it.
  142158. * @param delta defines the timespam between frames
  142159. */
  142160. _step(delta: number): void;
  142161. /**
  142162. * Gets the current plugin used to run the simulation
  142163. * @returns current plugin
  142164. */
  142165. getPhysicsPlugin(): IPhysicsEnginePlugin;
  142166. /**
  142167. * Gets the list of physic impostors
  142168. * @returns an array of PhysicsImpostor
  142169. */
  142170. getImpostors(): Array<PhysicsImpostor>;
  142171. /**
  142172. * Gets the impostor for a physics enabled object
  142173. * @param object defines the object impersonated by the impostor
  142174. * @returns the PhysicsImpostor or null if not found
  142175. */
  142176. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  142177. /**
  142178. * Gets the impostor for a physics body object
  142179. * @param body defines physics body used by the impostor
  142180. * @returns the PhysicsImpostor or null if not found
  142181. */
  142182. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  142183. /**
  142184. * Does a raycast in the physics world
  142185. * @param from when should the ray start?
  142186. * @param to when should the ray end?
  142187. * @returns PhysicsRaycastResult
  142188. */
  142189. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142190. }
  142191. }
  142192. declare module BABYLON {
  142193. /** @hidden */
  142194. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  142195. private _useDeltaForWorldStep;
  142196. world: any;
  142197. name: string;
  142198. private _physicsMaterials;
  142199. private _fixedTimeStep;
  142200. private _cannonRaycastResult;
  142201. private _raycastResult;
  142202. private _physicsBodysToRemoveAfterStep;
  142203. private _firstFrame;
  142204. BJSCANNON: any;
  142205. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  142206. setGravity(gravity: Vector3): void;
  142207. setTimeStep(timeStep: number): void;
  142208. getTimeStep(): number;
  142209. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142210. private _removeMarkedPhysicsBodiesFromWorld;
  142211. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142212. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142213. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142214. private _processChildMeshes;
  142215. removePhysicsBody(impostor: PhysicsImpostor): void;
  142216. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142217. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142218. private _addMaterial;
  142219. private _checkWithEpsilon;
  142220. private _createShape;
  142221. private _createHeightmap;
  142222. private _minus90X;
  142223. private _plus90X;
  142224. private _tmpPosition;
  142225. private _tmpDeltaPosition;
  142226. private _tmpUnityRotation;
  142227. private _updatePhysicsBodyTransformation;
  142228. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142229. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142230. isSupported(): boolean;
  142231. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142232. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142233. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142234. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142235. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142236. getBodyMass(impostor: PhysicsImpostor): number;
  142237. getBodyFriction(impostor: PhysicsImpostor): number;
  142238. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142239. getBodyRestitution(impostor: PhysicsImpostor): number;
  142240. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142241. sleepBody(impostor: PhysicsImpostor): void;
  142242. wakeUpBody(impostor: PhysicsImpostor): void;
  142243. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  142244. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142245. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142246. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142247. getRadius(impostor: PhysicsImpostor): number;
  142248. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142249. dispose(): void;
  142250. private _extendNamespace;
  142251. /**
  142252. * Does a raycast in the physics world
  142253. * @param from when should the ray start?
  142254. * @param to when should the ray end?
  142255. * @returns PhysicsRaycastResult
  142256. */
  142257. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142258. }
  142259. }
  142260. declare module BABYLON {
  142261. /** @hidden */
  142262. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  142263. private _useDeltaForWorldStep;
  142264. world: any;
  142265. name: string;
  142266. BJSOIMO: any;
  142267. private _raycastResult;
  142268. private _fixedTimeStep;
  142269. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  142270. setGravity(gravity: Vector3): void;
  142271. setTimeStep(timeStep: number): void;
  142272. getTimeStep(): number;
  142273. private _tmpImpostorsArray;
  142274. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142275. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142276. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142277. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142278. private _tmpPositionVector;
  142279. removePhysicsBody(impostor: PhysicsImpostor): void;
  142280. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142281. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142282. isSupported(): boolean;
  142283. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142284. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142285. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142286. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142287. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142288. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142289. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142290. getBodyMass(impostor: PhysicsImpostor): number;
  142291. getBodyFriction(impostor: PhysicsImpostor): number;
  142292. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142293. getBodyRestitution(impostor: PhysicsImpostor): number;
  142294. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142295. sleepBody(impostor: PhysicsImpostor): void;
  142296. wakeUpBody(impostor: PhysicsImpostor): void;
  142297. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142298. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  142299. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  142300. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142301. getRadius(impostor: PhysicsImpostor): number;
  142302. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142303. dispose(): void;
  142304. /**
  142305. * Does a raycast in the physics world
  142306. * @param from when should the ray start?
  142307. * @param to when should the ray end?
  142308. * @returns PhysicsRaycastResult
  142309. */
  142310. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142311. }
  142312. }
  142313. declare module BABYLON {
  142314. /**
  142315. * AmmoJS Physics plugin
  142316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142317. * @see https://github.com/kripken/ammo.js/
  142318. */
  142319. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  142320. private _useDeltaForWorldStep;
  142321. /**
  142322. * Reference to the Ammo library
  142323. */
  142324. bjsAMMO: any;
  142325. /**
  142326. * Created ammoJS world which physics bodies are added to
  142327. */
  142328. world: any;
  142329. /**
  142330. * Name of the plugin
  142331. */
  142332. name: string;
  142333. private _timeStep;
  142334. private _fixedTimeStep;
  142335. private _maxSteps;
  142336. private _tmpQuaternion;
  142337. private _tmpAmmoTransform;
  142338. private _tmpAmmoQuaternion;
  142339. private _tmpAmmoConcreteContactResultCallback;
  142340. private _collisionConfiguration;
  142341. private _dispatcher;
  142342. private _overlappingPairCache;
  142343. private _solver;
  142344. private _softBodySolver;
  142345. private _tmpAmmoVectorA;
  142346. private _tmpAmmoVectorB;
  142347. private _tmpAmmoVectorC;
  142348. private _tmpAmmoVectorD;
  142349. private _tmpContactCallbackResult;
  142350. private _tmpAmmoVectorRCA;
  142351. private _tmpAmmoVectorRCB;
  142352. private _raycastResult;
  142353. private _tmpContactPoint;
  142354. private static readonly DISABLE_COLLISION_FLAG;
  142355. private static readonly KINEMATIC_FLAG;
  142356. private static readonly DISABLE_DEACTIVATION_FLAG;
  142357. /**
  142358. * Initializes the ammoJS plugin
  142359. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  142360. * @param ammoInjection can be used to inject your own ammo reference
  142361. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  142362. */
  142363. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  142364. /**
  142365. * Sets the gravity of the physics world (m/(s^2))
  142366. * @param gravity Gravity to set
  142367. */
  142368. setGravity(gravity: Vector3): void;
  142369. /**
  142370. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  142371. * @param timeStep timestep to use in seconds
  142372. */
  142373. setTimeStep(timeStep: number): void;
  142374. /**
  142375. * 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)
  142376. * @param fixedTimeStep fixedTimeStep to use in seconds
  142377. */
  142378. setFixedTimeStep(fixedTimeStep: number): void;
  142379. /**
  142380. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  142381. * @param maxSteps the maximum number of steps by the physics engine per frame
  142382. */
  142383. setMaxSteps(maxSteps: number): void;
  142384. /**
  142385. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  142386. * @returns the current timestep in seconds
  142387. */
  142388. getTimeStep(): number;
  142389. /**
  142390. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  142391. */
  142392. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  142393. private _isImpostorInContact;
  142394. private _isImpostorPairInContact;
  142395. private _stepSimulation;
  142396. /**
  142397. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  142398. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  142399. * After the step the babylon meshes are set to the position of the physics imposters
  142400. * @param delta amount of time to step forward
  142401. * @param impostors array of imposters to update before/after the step
  142402. */
  142403. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142404. /**
  142405. * Update babylon mesh to match physics world object
  142406. * @param impostor imposter to match
  142407. */
  142408. private _afterSoftStep;
  142409. /**
  142410. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142411. * @param impostor imposter to match
  142412. */
  142413. private _ropeStep;
  142414. /**
  142415. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142416. * @param impostor imposter to match
  142417. */
  142418. private _softbodyOrClothStep;
  142419. private _tmpMatrix;
  142420. /**
  142421. * Applies an impulse on the imposter
  142422. * @param impostor imposter to apply impulse to
  142423. * @param force amount of force to be applied to the imposter
  142424. * @param contactPoint the location to apply the impulse on the imposter
  142425. */
  142426. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142427. /**
  142428. * Applies a force on the imposter
  142429. * @param impostor imposter to apply force
  142430. * @param force amount of force to be applied to the imposter
  142431. * @param contactPoint the location to apply the force on the imposter
  142432. */
  142433. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142434. /**
  142435. * Creates a physics body using the plugin
  142436. * @param impostor the imposter to create the physics body on
  142437. */
  142438. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142439. /**
  142440. * Removes the physics body from the imposter and disposes of the body's memory
  142441. * @param impostor imposter to remove the physics body from
  142442. */
  142443. removePhysicsBody(impostor: PhysicsImpostor): void;
  142444. /**
  142445. * Generates a joint
  142446. * @param impostorJoint the imposter joint to create the joint with
  142447. */
  142448. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142449. /**
  142450. * Removes a joint
  142451. * @param impostorJoint the imposter joint to remove the joint from
  142452. */
  142453. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142454. private _addMeshVerts;
  142455. /**
  142456. * Initialise the soft body vertices to match its object's (mesh) vertices
  142457. * Softbody vertices (nodes) are in world space and to match this
  142458. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  142459. * @param impostor to create the softbody for
  142460. */
  142461. private _softVertexData;
  142462. /**
  142463. * Create an impostor's soft body
  142464. * @param impostor to create the softbody for
  142465. */
  142466. private _createSoftbody;
  142467. /**
  142468. * Create cloth for an impostor
  142469. * @param impostor to create the softbody for
  142470. */
  142471. private _createCloth;
  142472. /**
  142473. * Create rope for an impostor
  142474. * @param impostor to create the softbody for
  142475. */
  142476. private _createRope;
  142477. /**
  142478. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  142479. * @param impostor to create the custom physics shape for
  142480. */
  142481. private _createCustom;
  142482. private _addHullVerts;
  142483. private _createShape;
  142484. /**
  142485. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  142486. * @param impostor imposter containing the physics body and babylon object
  142487. */
  142488. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142489. /**
  142490. * Sets the babylon object's position/rotation from the physics body's position/rotation
  142491. * @param impostor imposter containing the physics body and babylon object
  142492. * @param newPosition new position
  142493. * @param newRotation new rotation
  142494. */
  142495. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142496. /**
  142497. * If this plugin is supported
  142498. * @returns true if its supported
  142499. */
  142500. isSupported(): boolean;
  142501. /**
  142502. * Sets the linear velocity of the physics body
  142503. * @param impostor imposter to set the velocity on
  142504. * @param velocity velocity to set
  142505. */
  142506. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142507. /**
  142508. * Sets the angular velocity of the physics body
  142509. * @param impostor imposter to set the velocity on
  142510. * @param velocity velocity to set
  142511. */
  142512. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142513. /**
  142514. * gets the linear velocity
  142515. * @param impostor imposter to get linear velocity from
  142516. * @returns linear velocity
  142517. */
  142518. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142519. /**
  142520. * gets the angular velocity
  142521. * @param impostor imposter to get angular velocity from
  142522. * @returns angular velocity
  142523. */
  142524. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142525. /**
  142526. * Sets the mass of physics body
  142527. * @param impostor imposter to set the mass on
  142528. * @param mass mass to set
  142529. */
  142530. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142531. /**
  142532. * Gets the mass of the physics body
  142533. * @param impostor imposter to get the mass from
  142534. * @returns mass
  142535. */
  142536. getBodyMass(impostor: PhysicsImpostor): number;
  142537. /**
  142538. * Gets friction of the impostor
  142539. * @param impostor impostor to get friction from
  142540. * @returns friction value
  142541. */
  142542. getBodyFriction(impostor: PhysicsImpostor): number;
  142543. /**
  142544. * Sets friction of the impostor
  142545. * @param impostor impostor to set friction on
  142546. * @param friction friction value
  142547. */
  142548. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142549. /**
  142550. * Gets restitution of the impostor
  142551. * @param impostor impostor to get restitution from
  142552. * @returns restitution value
  142553. */
  142554. getBodyRestitution(impostor: PhysicsImpostor): number;
  142555. /**
  142556. * Sets resitution of the impostor
  142557. * @param impostor impostor to set resitution on
  142558. * @param restitution resitution value
  142559. */
  142560. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142561. /**
  142562. * Gets pressure inside the impostor
  142563. * @param impostor impostor to get pressure from
  142564. * @returns pressure value
  142565. */
  142566. getBodyPressure(impostor: PhysicsImpostor): number;
  142567. /**
  142568. * Sets pressure inside a soft body impostor
  142569. * Cloth and rope must remain 0 pressure
  142570. * @param impostor impostor to set pressure on
  142571. * @param pressure pressure value
  142572. */
  142573. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  142574. /**
  142575. * Gets stiffness of the impostor
  142576. * @param impostor impostor to get stiffness from
  142577. * @returns pressure value
  142578. */
  142579. getBodyStiffness(impostor: PhysicsImpostor): number;
  142580. /**
  142581. * Sets stiffness of the impostor
  142582. * @param impostor impostor to set stiffness on
  142583. * @param stiffness stiffness value from 0 to 1
  142584. */
  142585. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  142586. /**
  142587. * Gets velocityIterations of the impostor
  142588. * @param impostor impostor to get velocity iterations from
  142589. * @returns velocityIterations value
  142590. */
  142591. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  142592. /**
  142593. * Sets velocityIterations of the impostor
  142594. * @param impostor impostor to set velocity iterations on
  142595. * @param velocityIterations velocityIterations value
  142596. */
  142597. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  142598. /**
  142599. * Gets positionIterations of the impostor
  142600. * @param impostor impostor to get position iterations from
  142601. * @returns positionIterations value
  142602. */
  142603. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  142604. /**
  142605. * Sets positionIterations of the impostor
  142606. * @param impostor impostor to set position on
  142607. * @param positionIterations positionIterations value
  142608. */
  142609. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  142610. /**
  142611. * Append an anchor to a cloth object
  142612. * @param impostor is the cloth impostor to add anchor to
  142613. * @param otherImpostor is the rigid impostor to anchor to
  142614. * @param width ratio across width from 0 to 1
  142615. * @param height ratio up height from 0 to 1
  142616. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  142617. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142618. */
  142619. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142620. /**
  142621. * Append an hook to a rope object
  142622. * @param impostor is the rope impostor to add hook to
  142623. * @param otherImpostor is the rigid impostor to hook to
  142624. * @param length ratio along the rope from 0 to 1
  142625. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  142626. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142627. */
  142628. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142629. /**
  142630. * Sleeps the physics body and stops it from being active
  142631. * @param impostor impostor to sleep
  142632. */
  142633. sleepBody(impostor: PhysicsImpostor): void;
  142634. /**
  142635. * Activates the physics body
  142636. * @param impostor impostor to activate
  142637. */
  142638. wakeUpBody(impostor: PhysicsImpostor): void;
  142639. /**
  142640. * Updates the distance parameters of the joint
  142641. * @param joint joint to update
  142642. * @param maxDistance maximum distance of the joint
  142643. * @param minDistance minimum distance of the joint
  142644. */
  142645. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142646. /**
  142647. * Sets a motor on the joint
  142648. * @param joint joint to set motor on
  142649. * @param speed speed of the motor
  142650. * @param maxForce maximum force of the motor
  142651. * @param motorIndex index of the motor
  142652. */
  142653. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142654. /**
  142655. * Sets the motors limit
  142656. * @param joint joint to set limit on
  142657. * @param upperLimit upper limit
  142658. * @param lowerLimit lower limit
  142659. */
  142660. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142661. /**
  142662. * Syncs the position and rotation of a mesh with the impostor
  142663. * @param mesh mesh to sync
  142664. * @param impostor impostor to update the mesh with
  142665. */
  142666. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142667. /**
  142668. * Gets the radius of the impostor
  142669. * @param impostor impostor to get radius from
  142670. * @returns the radius
  142671. */
  142672. getRadius(impostor: PhysicsImpostor): number;
  142673. /**
  142674. * Gets the box size of the impostor
  142675. * @param impostor impostor to get box size from
  142676. * @param result the resulting box size
  142677. */
  142678. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142679. /**
  142680. * Disposes of the impostor
  142681. */
  142682. dispose(): void;
  142683. /**
  142684. * Does a raycast in the physics world
  142685. * @param from when should the ray start?
  142686. * @param to when should the ray end?
  142687. * @returns PhysicsRaycastResult
  142688. */
  142689. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142690. }
  142691. }
  142692. declare module BABYLON {
  142693. interface AbstractScene {
  142694. /**
  142695. * The list of reflection probes added to the scene
  142696. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142697. */
  142698. reflectionProbes: Array<ReflectionProbe>;
  142699. /**
  142700. * Removes the given reflection probe from this scene.
  142701. * @param toRemove The reflection probe to remove
  142702. * @returns The index of the removed reflection probe
  142703. */
  142704. removeReflectionProbe(toRemove: ReflectionProbe): number;
  142705. /**
  142706. * Adds the given reflection probe to this scene.
  142707. * @param newReflectionProbe The reflection probe to add
  142708. */
  142709. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  142710. }
  142711. /**
  142712. * Class used to generate realtime reflection / refraction cube textures
  142713. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142714. */
  142715. export class ReflectionProbe {
  142716. /** defines the name of the probe */
  142717. name: string;
  142718. private _scene;
  142719. private _renderTargetTexture;
  142720. private _projectionMatrix;
  142721. private _viewMatrix;
  142722. private _target;
  142723. private _add;
  142724. private _attachedMesh;
  142725. private _invertYAxis;
  142726. /** Gets or sets probe position (center of the cube map) */
  142727. position: Vector3;
  142728. /**
  142729. * Creates a new reflection probe
  142730. * @param name defines the name of the probe
  142731. * @param size defines the texture resolution (for each face)
  142732. * @param scene defines the hosting scene
  142733. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  142734. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  142735. */
  142736. constructor(
  142737. /** defines the name of the probe */
  142738. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  142739. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  142740. get samples(): number;
  142741. set samples(value: number);
  142742. /** Gets or sets the refresh rate to use (on every frame by default) */
  142743. get refreshRate(): number;
  142744. set refreshRate(value: number);
  142745. /**
  142746. * Gets the hosting scene
  142747. * @returns a Scene
  142748. */
  142749. getScene(): Scene;
  142750. /** Gets the internal CubeTexture used to render to */
  142751. get cubeTexture(): RenderTargetTexture;
  142752. /** Gets the list of meshes to render */
  142753. get renderList(): Nullable<AbstractMesh[]>;
  142754. /**
  142755. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  142756. * @param mesh defines the mesh to attach to
  142757. */
  142758. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142759. /**
  142760. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  142761. * @param renderingGroupId The rendering group id corresponding to its index
  142762. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  142763. */
  142764. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  142765. /**
  142766. * Clean all associated resources
  142767. */
  142768. dispose(): void;
  142769. /**
  142770. * Converts the reflection probe information to a readable string for debug purpose.
  142771. * @param fullDetails Supports for multiple levels of logging within scene loading
  142772. * @returns the human readable reflection probe info
  142773. */
  142774. toString(fullDetails?: boolean): string;
  142775. /**
  142776. * Get the class name of the relfection probe.
  142777. * @returns "ReflectionProbe"
  142778. */
  142779. getClassName(): string;
  142780. /**
  142781. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  142782. * @returns The JSON representation of the texture
  142783. */
  142784. serialize(): any;
  142785. /**
  142786. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  142787. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  142788. * @param scene Define the scene the parsed reflection probe should be instantiated in
  142789. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  142790. * @returns The parsed reflection probe if successful
  142791. */
  142792. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  142793. }
  142794. }
  142795. declare module BABYLON {
  142796. /** @hidden */
  142797. export var _BabylonLoaderRegistered: boolean;
  142798. /**
  142799. * Helps setting up some configuration for the babylon file loader.
  142800. */
  142801. export class BabylonFileLoaderConfiguration {
  142802. /**
  142803. * The loader does not allow injecting custom physix engine into the plugins.
  142804. * Unfortunately in ES6, we need to manually inject them into the plugin.
  142805. * So you could set this variable to your engine import to make it work.
  142806. */
  142807. static LoaderInjectedPhysicsEngine: any;
  142808. }
  142809. }
  142810. declare module BABYLON {
  142811. /**
  142812. * The Physically based simple base material of BJS.
  142813. *
  142814. * This enables better naming and convention enforcements on top of the pbrMaterial.
  142815. * It is used as the base class for both the specGloss and metalRough conventions.
  142816. */
  142817. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  142818. /**
  142819. * Number of Simultaneous lights allowed on the material.
  142820. */
  142821. maxSimultaneousLights: number;
  142822. /**
  142823. * If sets to true, disables all the lights affecting the material.
  142824. */
  142825. disableLighting: boolean;
  142826. /**
  142827. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  142828. */
  142829. environmentTexture: BaseTexture;
  142830. /**
  142831. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  142832. */
  142833. invertNormalMapX: boolean;
  142834. /**
  142835. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  142836. */
  142837. invertNormalMapY: boolean;
  142838. /**
  142839. * Normal map used in the model.
  142840. */
  142841. normalTexture: BaseTexture;
  142842. /**
  142843. * Emissivie color used to self-illuminate the model.
  142844. */
  142845. emissiveColor: Color3;
  142846. /**
  142847. * Emissivie texture used to self-illuminate the model.
  142848. */
  142849. emissiveTexture: BaseTexture;
  142850. /**
  142851. * Occlusion Channel Strenght.
  142852. */
  142853. occlusionStrength: number;
  142854. /**
  142855. * Occlusion Texture of the material (adding extra occlusion effects).
  142856. */
  142857. occlusionTexture: BaseTexture;
  142858. /**
  142859. * Defines the alpha limits in alpha test mode.
  142860. */
  142861. alphaCutOff: number;
  142862. /**
  142863. * Gets the current double sided mode.
  142864. */
  142865. get doubleSided(): boolean;
  142866. /**
  142867. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  142868. */
  142869. set doubleSided(value: boolean);
  142870. /**
  142871. * Stores the pre-calculated light information of a mesh in a texture.
  142872. */
  142873. lightmapTexture: BaseTexture;
  142874. /**
  142875. * If true, the light map contains occlusion information instead of lighting info.
  142876. */
  142877. useLightmapAsShadowmap: boolean;
  142878. /**
  142879. * Instantiates a new PBRMaterial instance.
  142880. *
  142881. * @param name The material name
  142882. * @param scene The scene the material will be use in.
  142883. */
  142884. constructor(name: string, scene: Scene);
  142885. getClassName(): string;
  142886. }
  142887. }
  142888. declare module BABYLON {
  142889. /**
  142890. * The PBR material of BJS following the metal roughness convention.
  142891. *
  142892. * This fits to the PBR convention in the GLTF definition:
  142893. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  142894. */
  142895. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  142896. /**
  142897. * The base color has two different interpretations depending on the value of metalness.
  142898. * When the material is a metal, the base color is the specific measured reflectance value
  142899. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  142900. * of the material.
  142901. */
  142902. baseColor: Color3;
  142903. /**
  142904. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  142905. * well as opacity information in the alpha channel.
  142906. */
  142907. baseTexture: BaseTexture;
  142908. /**
  142909. * Specifies the metallic scalar value of the material.
  142910. * Can also be used to scale the metalness values of the metallic texture.
  142911. */
  142912. metallic: number;
  142913. /**
  142914. * Specifies the roughness scalar value of the material.
  142915. * Can also be used to scale the roughness values of the metallic texture.
  142916. */
  142917. roughness: number;
  142918. /**
  142919. * Texture containing both the metallic value in the B channel and the
  142920. * roughness value in the G channel to keep better precision.
  142921. */
  142922. metallicRoughnessTexture: BaseTexture;
  142923. /**
  142924. * Instantiates a new PBRMetalRoughnessMaterial instance.
  142925. *
  142926. * @param name The material name
  142927. * @param scene The scene the material will be use in.
  142928. */
  142929. constructor(name: string, scene: Scene);
  142930. /**
  142931. * Return the currrent class name of the material.
  142932. */
  142933. getClassName(): string;
  142934. /**
  142935. * Makes a duplicate of the current material.
  142936. * @param name - name to use for the new material.
  142937. */
  142938. clone(name: string): PBRMetallicRoughnessMaterial;
  142939. /**
  142940. * Serialize the material to a parsable JSON object.
  142941. */
  142942. serialize(): any;
  142943. /**
  142944. * Parses a JSON object correponding to the serialize function.
  142945. */
  142946. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  142947. }
  142948. }
  142949. declare module BABYLON {
  142950. /**
  142951. * The PBR material of BJS following the specular glossiness convention.
  142952. *
  142953. * This fits to the PBR convention in the GLTF definition:
  142954. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  142955. */
  142956. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  142957. /**
  142958. * Specifies the diffuse color of the material.
  142959. */
  142960. diffuseColor: Color3;
  142961. /**
  142962. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  142963. * channel.
  142964. */
  142965. diffuseTexture: BaseTexture;
  142966. /**
  142967. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  142968. */
  142969. specularColor: Color3;
  142970. /**
  142971. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  142972. */
  142973. glossiness: number;
  142974. /**
  142975. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  142976. */
  142977. specularGlossinessTexture: BaseTexture;
  142978. /**
  142979. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  142980. *
  142981. * @param name The material name
  142982. * @param scene The scene the material will be use in.
  142983. */
  142984. constructor(name: string, scene: Scene);
  142985. /**
  142986. * Return the currrent class name of the material.
  142987. */
  142988. getClassName(): string;
  142989. /**
  142990. * Makes a duplicate of the current material.
  142991. * @param name - name to use for the new material.
  142992. */
  142993. clone(name: string): PBRSpecularGlossinessMaterial;
  142994. /**
  142995. * Serialize the material to a parsable JSON object.
  142996. */
  142997. serialize(): any;
  142998. /**
  142999. * Parses a JSON object correponding to the serialize function.
  143000. */
  143001. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  143002. }
  143003. }
  143004. declare module BABYLON {
  143005. /**
  143006. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  143007. * It can help converting any input color in a desired output one. This can then be used to create effects
  143008. * from sepia, black and white to sixties or futuristic rendering...
  143009. *
  143010. * The only supported format is currently 3dl.
  143011. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  143012. */
  143013. export class ColorGradingTexture extends BaseTexture {
  143014. /**
  143015. * The texture URL.
  143016. */
  143017. url: string;
  143018. /**
  143019. * Empty line regex stored for GC.
  143020. */
  143021. private static _noneEmptyLineRegex;
  143022. private _textureMatrix;
  143023. private _onLoad;
  143024. /**
  143025. * Instantiates a ColorGradingTexture from the following parameters.
  143026. *
  143027. * @param url The location of the color gradind data (currently only supporting 3dl)
  143028. * @param sceneOrEngine The scene or engine the texture will be used in
  143029. * @param onLoad defines a callback triggered when the texture has been loaded
  143030. */
  143031. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  143032. /**
  143033. * Fires the onload event from the constructor if requested.
  143034. */
  143035. private _triggerOnLoad;
  143036. /**
  143037. * Returns the texture matrix used in most of the material.
  143038. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  143039. */
  143040. getTextureMatrix(): Matrix;
  143041. /**
  143042. * Occurs when the file being loaded is a .3dl LUT file.
  143043. */
  143044. private load3dlTexture;
  143045. /**
  143046. * Starts the loading process of the texture.
  143047. */
  143048. private loadTexture;
  143049. /**
  143050. * Clones the color gradind texture.
  143051. */
  143052. clone(): ColorGradingTexture;
  143053. /**
  143054. * Called during delayed load for textures.
  143055. */
  143056. delayLoad(): void;
  143057. /**
  143058. * Parses a color grading texture serialized by Babylon.
  143059. * @param parsedTexture The texture information being parsedTexture
  143060. * @param scene The scene to load the texture in
  143061. * @param rootUrl The root url of the data assets to load
  143062. * @return A color gradind texture
  143063. */
  143064. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  143065. /**
  143066. * Serializes the LUT texture to json format.
  143067. */
  143068. serialize(): any;
  143069. }
  143070. }
  143071. declare module BABYLON {
  143072. /**
  143073. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  143074. */
  143075. export class EquiRectangularCubeTexture extends BaseTexture {
  143076. /** The six faces of the cube. */
  143077. private static _FacesMapping;
  143078. private _noMipmap;
  143079. private _onLoad;
  143080. private _onError;
  143081. /** The size of the cubemap. */
  143082. private _size;
  143083. /** The buffer of the image. */
  143084. private _buffer;
  143085. /** The width of the input image. */
  143086. private _width;
  143087. /** The height of the input image. */
  143088. private _height;
  143089. /** The URL to the image. */
  143090. url: string;
  143091. /**
  143092. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  143093. * @param url The location of the image
  143094. * @param scene The scene the texture will be used in
  143095. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143096. * @param noMipmap Forces to not generate the mipmap if true
  143097. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  143098. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  143099. * @param onLoad — defines a callback called when texture is loaded
  143100. * @param onError — defines a callback called if there is an error
  143101. */
  143102. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  143103. /**
  143104. * Load the image data, by putting the image on a canvas and extracting its buffer.
  143105. */
  143106. private loadImage;
  143107. /**
  143108. * Convert the image buffer into a cubemap and create a CubeTexture.
  143109. */
  143110. private loadTexture;
  143111. /**
  143112. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  143113. * @param buffer The ArrayBuffer that should be converted.
  143114. * @returns The buffer as Float32Array.
  143115. */
  143116. private getFloat32ArrayFromArrayBuffer;
  143117. /**
  143118. * Get the current class name of the texture useful for serialization or dynamic coding.
  143119. * @returns "EquiRectangularCubeTexture"
  143120. */
  143121. getClassName(): string;
  143122. /**
  143123. * Create a clone of the current EquiRectangularCubeTexture and return it.
  143124. * @returns A clone of the current EquiRectangularCubeTexture.
  143125. */
  143126. clone(): EquiRectangularCubeTexture;
  143127. }
  143128. }
  143129. declare module BABYLON {
  143130. /**
  143131. * Defines the options related to the creation of an HtmlElementTexture
  143132. */
  143133. export interface IHtmlElementTextureOptions {
  143134. /**
  143135. * Defines wether mip maps should be created or not.
  143136. */
  143137. generateMipMaps?: boolean;
  143138. /**
  143139. * Defines the sampling mode of the texture.
  143140. */
  143141. samplingMode?: number;
  143142. /**
  143143. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  143144. */
  143145. engine: Nullable<ThinEngine>;
  143146. /**
  143147. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  143148. */
  143149. scene: Nullable<Scene>;
  143150. }
  143151. /**
  143152. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  143153. * To be as efficient as possible depending on your constraints nothing aside the first upload
  143154. * is automatically managed.
  143155. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  143156. * in your application.
  143157. *
  143158. * As the update is not automatic, you need to call them manually.
  143159. */
  143160. export class HtmlElementTexture extends BaseTexture {
  143161. /**
  143162. * The texture URL.
  143163. */
  143164. element: HTMLVideoElement | HTMLCanvasElement;
  143165. private static readonly DefaultOptions;
  143166. private _textureMatrix;
  143167. private _isVideo;
  143168. private _generateMipMaps;
  143169. private _samplingMode;
  143170. /**
  143171. * Instantiates a HtmlElementTexture from the following parameters.
  143172. *
  143173. * @param name Defines the name of the texture
  143174. * @param element Defines the video or canvas the texture is filled with
  143175. * @param options Defines the other none mandatory texture creation options
  143176. */
  143177. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  143178. private _createInternalTexture;
  143179. /**
  143180. * Returns the texture matrix used in most of the material.
  143181. */
  143182. getTextureMatrix(): Matrix;
  143183. /**
  143184. * Updates the content of the texture.
  143185. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  143186. */
  143187. update(invertY?: Nullable<boolean>): void;
  143188. }
  143189. }
  143190. declare module BABYLON {
  143191. /**
  143192. * Based on jsTGALoader - Javascript loader for TGA file
  143193. * By Vincent Thibault
  143194. * @see http://blog.robrowser.com/javascript-tga-loader.html
  143195. */
  143196. export class TGATools {
  143197. private static _TYPE_INDEXED;
  143198. private static _TYPE_RGB;
  143199. private static _TYPE_GREY;
  143200. private static _TYPE_RLE_INDEXED;
  143201. private static _TYPE_RLE_RGB;
  143202. private static _TYPE_RLE_GREY;
  143203. private static _ORIGIN_MASK;
  143204. private static _ORIGIN_SHIFT;
  143205. private static _ORIGIN_BL;
  143206. private static _ORIGIN_BR;
  143207. private static _ORIGIN_UL;
  143208. private static _ORIGIN_UR;
  143209. /**
  143210. * Gets the header of a TGA file
  143211. * @param data defines the TGA data
  143212. * @returns the header
  143213. */
  143214. static GetTGAHeader(data: Uint8Array): any;
  143215. /**
  143216. * Uploads TGA content to a Babylon Texture
  143217. * @hidden
  143218. */
  143219. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  143220. /** @hidden */
  143221. 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;
  143222. /** @hidden */
  143223. 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;
  143224. /** @hidden */
  143225. 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;
  143226. /** @hidden */
  143227. 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;
  143228. /** @hidden */
  143229. 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;
  143230. /** @hidden */
  143231. 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;
  143232. }
  143233. }
  143234. declare module BABYLON {
  143235. /**
  143236. * Implementation of the TGA Texture Loader.
  143237. * @hidden
  143238. */
  143239. export class _TGATextureLoader implements IInternalTextureLoader {
  143240. /**
  143241. * Defines wether the loader supports cascade loading the different faces.
  143242. */
  143243. readonly supportCascades: boolean;
  143244. /**
  143245. * This returns if the loader support the current file information.
  143246. * @param extension defines the file extension of the file being loaded
  143247. * @returns true if the loader can load the specified file
  143248. */
  143249. canLoad(extension: string): boolean;
  143250. /**
  143251. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143252. * @param data contains the texture data
  143253. * @param texture defines the BabylonJS internal texture
  143254. * @param createPolynomials will be true if polynomials have been requested
  143255. * @param onLoad defines the callback to trigger once the texture is ready
  143256. * @param onError defines the callback to trigger in case of error
  143257. */
  143258. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143259. /**
  143260. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143261. * @param data contains the texture data
  143262. * @param texture defines the BabylonJS internal texture
  143263. * @param callback defines the method to call once ready to upload
  143264. */
  143265. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143266. }
  143267. }
  143268. declare module BABYLON {
  143269. /**
  143270. * Info about the .basis files
  143271. */
  143272. class BasisFileInfo {
  143273. /**
  143274. * If the file has alpha
  143275. */
  143276. hasAlpha: boolean;
  143277. /**
  143278. * Info about each image of the basis file
  143279. */
  143280. images: Array<{
  143281. levels: Array<{
  143282. width: number;
  143283. height: number;
  143284. transcodedPixels: ArrayBufferView;
  143285. }>;
  143286. }>;
  143287. }
  143288. /**
  143289. * Result of transcoding a basis file
  143290. */
  143291. class TranscodeResult {
  143292. /**
  143293. * Info about the .basis file
  143294. */
  143295. fileInfo: BasisFileInfo;
  143296. /**
  143297. * Format to use when loading the file
  143298. */
  143299. format: number;
  143300. }
  143301. /**
  143302. * Configuration options for the Basis transcoder
  143303. */
  143304. export class BasisTranscodeConfiguration {
  143305. /**
  143306. * Supported compression formats used to determine the supported output format of the transcoder
  143307. */
  143308. supportedCompressionFormats?: {
  143309. /**
  143310. * etc1 compression format
  143311. */
  143312. etc1?: boolean;
  143313. /**
  143314. * s3tc compression format
  143315. */
  143316. s3tc?: boolean;
  143317. /**
  143318. * pvrtc compression format
  143319. */
  143320. pvrtc?: boolean;
  143321. /**
  143322. * etc2 compression format
  143323. */
  143324. etc2?: boolean;
  143325. };
  143326. /**
  143327. * If mipmap levels should be loaded for transcoded images (Default: true)
  143328. */
  143329. loadMipmapLevels?: boolean;
  143330. /**
  143331. * Index of a single image to load (Default: all images)
  143332. */
  143333. loadSingleImage?: number;
  143334. }
  143335. /**
  143336. * Used to load .Basis files
  143337. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  143338. */
  143339. export class BasisTools {
  143340. private static _IgnoreSupportedFormats;
  143341. /**
  143342. * URL to use when loading the basis transcoder
  143343. */
  143344. static JSModuleURL: string;
  143345. /**
  143346. * URL to use when loading the wasm module for the transcoder
  143347. */
  143348. static WasmModuleURL: string;
  143349. /**
  143350. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  143351. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  143352. * @returns internal format corresponding to the Basis format
  143353. */
  143354. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  143355. private static _WorkerPromise;
  143356. private static _Worker;
  143357. private static _actionId;
  143358. private static _CreateWorkerAsync;
  143359. /**
  143360. * Transcodes a loaded image file to compressed pixel data
  143361. * @param data image data to transcode
  143362. * @param config configuration options for the transcoding
  143363. * @returns a promise resulting in the transcoded image
  143364. */
  143365. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  143366. /**
  143367. * Loads a texture from the transcode result
  143368. * @param texture texture load to
  143369. * @param transcodeResult the result of transcoding the basis file to load from
  143370. */
  143371. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  143372. }
  143373. }
  143374. declare module BABYLON {
  143375. /**
  143376. * Loader for .basis file format
  143377. */
  143378. export class _BasisTextureLoader implements IInternalTextureLoader {
  143379. /**
  143380. * Defines whether the loader supports cascade loading the different faces.
  143381. */
  143382. readonly supportCascades: boolean;
  143383. /**
  143384. * This returns if the loader support the current file information.
  143385. * @param extension defines the file extension of the file being loaded
  143386. * @returns true if the loader can load the specified file
  143387. */
  143388. canLoad(extension: string): boolean;
  143389. /**
  143390. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143391. * @param data contains the texture data
  143392. * @param texture defines the BabylonJS internal texture
  143393. * @param createPolynomials will be true if polynomials have been requested
  143394. * @param onLoad defines the callback to trigger once the texture is ready
  143395. * @param onError defines the callback to trigger in case of error
  143396. */
  143397. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143398. /**
  143399. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143400. * @param data contains the texture data
  143401. * @param texture defines the BabylonJS internal texture
  143402. * @param callback defines the method to call once ready to upload
  143403. */
  143404. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143405. }
  143406. }
  143407. declare module BABYLON {
  143408. /**
  143409. * Defines the basic options interface of a TexturePacker Frame
  143410. */
  143411. export interface ITexturePackerFrame {
  143412. /**
  143413. * The frame ID
  143414. */
  143415. id: number;
  143416. /**
  143417. * The frames Scale
  143418. */
  143419. scale: Vector2;
  143420. /**
  143421. * The Frames offset
  143422. */
  143423. offset: Vector2;
  143424. }
  143425. /**
  143426. * This is a support class for frame Data on texture packer sets.
  143427. */
  143428. export class TexturePackerFrame implements ITexturePackerFrame {
  143429. /**
  143430. * The frame ID
  143431. */
  143432. id: number;
  143433. /**
  143434. * The frames Scale
  143435. */
  143436. scale: Vector2;
  143437. /**
  143438. * The Frames offset
  143439. */
  143440. offset: Vector2;
  143441. /**
  143442. * Initializes a texture package frame.
  143443. * @param id The numerical frame identifier
  143444. * @param scale Scalar Vector2 for UV frame
  143445. * @param offset Vector2 for the frame position in UV units.
  143446. * @returns TexturePackerFrame
  143447. */
  143448. constructor(id: number, scale: Vector2, offset: Vector2);
  143449. }
  143450. }
  143451. declare module BABYLON {
  143452. /**
  143453. * Defines the basic options interface of a TexturePacker
  143454. */
  143455. export interface ITexturePackerOptions {
  143456. /**
  143457. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  143458. */
  143459. map?: string[];
  143460. /**
  143461. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143462. */
  143463. uvsIn?: string;
  143464. /**
  143465. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143466. */
  143467. uvsOut?: string;
  143468. /**
  143469. * number representing the layout style. Defaults to LAYOUT_STRIP
  143470. */
  143471. layout?: number;
  143472. /**
  143473. * number of columns if using custom column count layout(2). This defaults to 4.
  143474. */
  143475. colnum?: number;
  143476. /**
  143477. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  143478. */
  143479. updateInputMeshes?: boolean;
  143480. /**
  143481. * boolean flag to dispose all the source textures. Defaults to true.
  143482. */
  143483. disposeSources?: boolean;
  143484. /**
  143485. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  143486. */
  143487. fillBlanks?: boolean;
  143488. /**
  143489. * string value representing the context fill style color. Defaults to 'black'.
  143490. */
  143491. customFillColor?: string;
  143492. /**
  143493. * Width and Height Value of each Frame in the TexturePacker Sets
  143494. */
  143495. frameSize?: number;
  143496. /**
  143497. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  143498. */
  143499. paddingRatio?: number;
  143500. /**
  143501. * Number that declares the fill method for the padding gutter.
  143502. */
  143503. paddingMode?: number;
  143504. /**
  143505. * If in SUBUV_COLOR padding mode what color to use.
  143506. */
  143507. paddingColor?: Color3 | Color4;
  143508. }
  143509. /**
  143510. * Defines the basic interface of a TexturePacker JSON File
  143511. */
  143512. export interface ITexturePackerJSON {
  143513. /**
  143514. * The frame ID
  143515. */
  143516. name: string;
  143517. /**
  143518. * The base64 channel data
  143519. */
  143520. sets: any;
  143521. /**
  143522. * The options of the Packer
  143523. */
  143524. options: ITexturePackerOptions;
  143525. /**
  143526. * The frame data of the Packer
  143527. */
  143528. frames: Array<number>;
  143529. }
  143530. /**
  143531. * This is a support class that generates a series of packed texture sets.
  143532. * @see https://doc.babylonjs.com/babylon101/materials
  143533. */
  143534. export class TexturePacker {
  143535. /** Packer Layout Constant 0 */
  143536. static readonly LAYOUT_STRIP: number;
  143537. /** Packer Layout Constant 1 */
  143538. static readonly LAYOUT_POWER2: number;
  143539. /** Packer Layout Constant 2 */
  143540. static readonly LAYOUT_COLNUM: number;
  143541. /** Packer Layout Constant 0 */
  143542. static readonly SUBUV_WRAP: number;
  143543. /** Packer Layout Constant 1 */
  143544. static readonly SUBUV_EXTEND: number;
  143545. /** Packer Layout Constant 2 */
  143546. static readonly SUBUV_COLOR: number;
  143547. /** The Name of the Texture Package */
  143548. name: string;
  143549. /** The scene scope of the TexturePacker */
  143550. scene: Scene;
  143551. /** The Meshes to target */
  143552. meshes: AbstractMesh[];
  143553. /** Arguments passed with the Constructor */
  143554. options: ITexturePackerOptions;
  143555. /** The promise that is started upon initialization */
  143556. promise: Nullable<Promise<TexturePacker | string>>;
  143557. /** The Container object for the channel sets that are generated */
  143558. sets: object;
  143559. /** The Container array for the frames that are generated */
  143560. frames: TexturePackerFrame[];
  143561. /** The expected number of textures the system is parsing. */
  143562. private _expecting;
  143563. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  143564. private _paddingValue;
  143565. /**
  143566. * Initializes a texture package series from an array of meshes or a single mesh.
  143567. * @param name The name of the package
  143568. * @param meshes The target meshes to compose the package from
  143569. * @param options The arguments that texture packer should follow while building.
  143570. * @param scene The scene which the textures are scoped to.
  143571. * @returns TexturePacker
  143572. */
  143573. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  143574. /**
  143575. * Starts the package process
  143576. * @param resolve The promises resolution function
  143577. * @returns TexturePacker
  143578. */
  143579. private _createFrames;
  143580. /**
  143581. * Calculates the Size of the Channel Sets
  143582. * @returns Vector2
  143583. */
  143584. private _calculateSize;
  143585. /**
  143586. * Calculates the UV data for the frames.
  143587. * @param baseSize the base frameSize
  143588. * @param padding the base frame padding
  143589. * @param dtSize size of the Dynamic Texture for that channel
  143590. * @param dtUnits is 1/dtSize
  143591. * @param update flag to update the input meshes
  143592. */
  143593. private _calculateMeshUVFrames;
  143594. /**
  143595. * Calculates the frames Offset.
  143596. * @param index of the frame
  143597. * @returns Vector2
  143598. */
  143599. private _getFrameOffset;
  143600. /**
  143601. * Updates a Mesh to the frame data
  143602. * @param mesh that is the target
  143603. * @param frameID or the frame index
  143604. */
  143605. private _updateMeshUV;
  143606. /**
  143607. * Updates a Meshes materials to use the texture packer channels
  143608. * @param m is the mesh to target
  143609. * @param force all channels on the packer to be set.
  143610. */
  143611. private _updateTextureReferences;
  143612. /**
  143613. * Public method to set a Mesh to a frame
  143614. * @param m that is the target
  143615. * @param frameID or the frame index
  143616. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  143617. */
  143618. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  143619. /**
  143620. * Starts the async promise to compile the texture packer.
  143621. * @returns Promise<void>
  143622. */
  143623. processAsync(): Promise<void>;
  143624. /**
  143625. * Disposes all textures associated with this packer
  143626. */
  143627. dispose(): void;
  143628. /**
  143629. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  143630. * @param imageType is the image type to use.
  143631. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  143632. */
  143633. download(imageType?: string, quality?: number): void;
  143634. /**
  143635. * Public method to load a texturePacker JSON file.
  143636. * @param data of the JSON file in string format.
  143637. */
  143638. updateFromJSON(data: string): void;
  143639. }
  143640. }
  143641. declare module BABYLON {
  143642. /**
  143643. * 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.
  143644. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143645. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143646. */
  143647. export class CustomProceduralTexture extends ProceduralTexture {
  143648. private _animate;
  143649. private _time;
  143650. private _config;
  143651. private _texturePath;
  143652. /**
  143653. * Instantiates a new Custom Procedural Texture.
  143654. * 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.
  143655. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143656. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143657. * @param name Define the name of the texture
  143658. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  143659. * @param size Define the size of the texture to create
  143660. * @param scene Define the scene the texture belongs to
  143661. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  143662. * @param generateMipMaps Define if the texture should creates mip maps or not
  143663. */
  143664. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143665. private _loadJson;
  143666. /**
  143667. * Is the texture ready to be used ? (rendered at least once)
  143668. * @returns true if ready, otherwise, false.
  143669. */
  143670. isReady(): boolean;
  143671. /**
  143672. * Render the texture to its associated render target.
  143673. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  143674. */
  143675. render(useCameraPostProcess?: boolean): void;
  143676. /**
  143677. * Update the list of dependant textures samplers in the shader.
  143678. */
  143679. updateTextures(): void;
  143680. /**
  143681. * Update the uniform values of the procedural texture in the shader.
  143682. */
  143683. updateShaderUniforms(): void;
  143684. /**
  143685. * Define if the texture animates or not.
  143686. */
  143687. get animate(): boolean;
  143688. set animate(value: boolean);
  143689. }
  143690. }
  143691. declare module BABYLON {
  143692. /** @hidden */
  143693. export var noisePixelShader: {
  143694. name: string;
  143695. shader: string;
  143696. };
  143697. }
  143698. declare module BABYLON {
  143699. /**
  143700. * Class used to generate noise procedural textures
  143701. */
  143702. export class NoiseProceduralTexture extends ProceduralTexture {
  143703. /** Gets or sets the start time (default is 0) */
  143704. time: number;
  143705. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  143706. brightness: number;
  143707. /** Defines the number of octaves to process */
  143708. octaves: number;
  143709. /** Defines the level of persistence (0.8 by default) */
  143710. persistence: number;
  143711. /** Gets or sets animation speed factor (default is 1) */
  143712. animationSpeedFactor: number;
  143713. /**
  143714. * Creates a new NoiseProceduralTexture
  143715. * @param name defines the name fo the texture
  143716. * @param size defines the size of the texture (default is 256)
  143717. * @param scene defines the hosting scene
  143718. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  143719. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  143720. */
  143721. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143722. private _updateShaderUniforms;
  143723. protected _getDefines(): string;
  143724. /** Generate the current state of the procedural texture */
  143725. render(useCameraPostProcess?: boolean): void;
  143726. /**
  143727. * Serializes this noise procedural texture
  143728. * @returns a serialized noise procedural texture object
  143729. */
  143730. serialize(): any;
  143731. /**
  143732. * Clone the texture.
  143733. * @returns the cloned texture
  143734. */
  143735. clone(): NoiseProceduralTexture;
  143736. /**
  143737. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  143738. * @param parsedTexture defines parsed texture data
  143739. * @param scene defines the current scene
  143740. * @param rootUrl defines the root URL containing noise procedural texture information
  143741. * @returns a parsed NoiseProceduralTexture
  143742. */
  143743. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  143744. }
  143745. }
  143746. declare module BABYLON {
  143747. /**
  143748. * Raw cube texture where the raw buffers are passed in
  143749. */
  143750. export class RawCubeTexture extends CubeTexture {
  143751. /**
  143752. * Creates a cube texture where the raw buffers are passed in.
  143753. * @param scene defines the scene the texture is attached to
  143754. * @param data defines the array of data to use to create each face
  143755. * @param size defines the size of the textures
  143756. * @param format defines the format of the data
  143757. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  143758. * @param generateMipMaps defines if the engine should generate the mip levels
  143759. * @param invertY defines if data must be stored with Y axis inverted
  143760. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  143761. * @param compression defines the compression used (null by default)
  143762. */
  143763. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  143764. /**
  143765. * Updates the raw cube texture.
  143766. * @param data defines the data to store
  143767. * @param format defines the data format
  143768. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143769. * @param invertY defines if data must be stored with Y axis inverted
  143770. * @param compression defines the compression used (null by default)
  143771. * @param level defines which level of the texture to update
  143772. */
  143773. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  143774. /**
  143775. * Updates a raw cube texture with RGBD encoded data.
  143776. * @param data defines the array of data [mipmap][face] to use to create each face
  143777. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  143778. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  143779. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  143780. * @returns a promsie that resolves when the operation is complete
  143781. */
  143782. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  143783. /**
  143784. * Clones the raw cube texture.
  143785. * @return a new cube texture
  143786. */
  143787. clone(): CubeTexture;
  143788. /** @hidden */
  143789. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  143790. }
  143791. }
  143792. declare module BABYLON {
  143793. /**
  143794. * Class used to store 2D array textures containing user data
  143795. */
  143796. export class RawTexture2DArray extends Texture {
  143797. /** Gets or sets the texture format to use */
  143798. format: number;
  143799. /**
  143800. * Create a new RawTexture2DArray
  143801. * @param data defines the data of the texture
  143802. * @param width defines the width of the texture
  143803. * @param height defines the height of the texture
  143804. * @param depth defines the number of layers of the texture
  143805. * @param format defines the texture format to use
  143806. * @param scene defines the hosting scene
  143807. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143808. * @param invertY defines if texture must be stored with Y axis inverted
  143809. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143810. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143811. */
  143812. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143813. /** Gets or sets the texture format to use */
  143814. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143815. /**
  143816. * Update the texture with new data
  143817. * @param data defines the data to store in the texture
  143818. */
  143819. update(data: ArrayBufferView): void;
  143820. }
  143821. }
  143822. declare module BABYLON {
  143823. /**
  143824. * Class used to store 3D textures containing user data
  143825. */
  143826. export class RawTexture3D extends Texture {
  143827. /** Gets or sets the texture format to use */
  143828. format: number;
  143829. /**
  143830. * Create a new RawTexture3D
  143831. * @param data defines the data of the texture
  143832. * @param width defines the width of the texture
  143833. * @param height defines the height of the texture
  143834. * @param depth defines the depth of the texture
  143835. * @param format defines the texture format to use
  143836. * @param scene defines the hosting scene
  143837. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143838. * @param invertY defines if texture must be stored with Y axis inverted
  143839. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143840. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143841. */
  143842. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143843. /** Gets or sets the texture format to use */
  143844. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143845. /**
  143846. * Update the texture with new data
  143847. * @param data defines the data to store in the texture
  143848. */
  143849. update(data: ArrayBufferView): void;
  143850. }
  143851. }
  143852. declare module BABYLON {
  143853. /**
  143854. * Creates a refraction texture used by refraction channel of the standard material.
  143855. * It is like a mirror but to see through a material.
  143856. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143857. */
  143858. export class RefractionTexture extends RenderTargetTexture {
  143859. /**
  143860. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  143861. * 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.
  143862. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143863. */
  143864. refractionPlane: Plane;
  143865. /**
  143866. * Define how deep under the surface we should see.
  143867. */
  143868. depth: number;
  143869. /**
  143870. * Creates a refraction texture used by refraction channel of the standard material.
  143871. * It is like a mirror but to see through a material.
  143872. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143873. * @param name Define the texture name
  143874. * @param size Define the size of the underlying texture
  143875. * @param scene Define the scene the refraction belongs to
  143876. * @param generateMipMaps Define if we need to generate mips level for the refraction
  143877. */
  143878. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  143879. /**
  143880. * Clone the refraction texture.
  143881. * @returns the cloned texture
  143882. */
  143883. clone(): RefractionTexture;
  143884. /**
  143885. * Serialize the texture to a JSON representation you could use in Parse later on
  143886. * @returns the serialized JSON representation
  143887. */
  143888. serialize(): any;
  143889. }
  143890. }
  143891. declare module BABYLON {
  143892. /**
  143893. * Block used to add support for vertex skinning (bones)
  143894. */
  143895. export class BonesBlock extends NodeMaterialBlock {
  143896. /**
  143897. * Creates a new BonesBlock
  143898. * @param name defines the block name
  143899. */
  143900. constructor(name: string);
  143901. /**
  143902. * Initialize the block and prepare the context for build
  143903. * @param state defines the state that will be used for the build
  143904. */
  143905. initialize(state: NodeMaterialBuildState): void;
  143906. /**
  143907. * Gets the current class name
  143908. * @returns the class name
  143909. */
  143910. getClassName(): string;
  143911. /**
  143912. * Gets the matrix indices input component
  143913. */
  143914. get matricesIndices(): NodeMaterialConnectionPoint;
  143915. /**
  143916. * Gets the matrix weights input component
  143917. */
  143918. get matricesWeights(): NodeMaterialConnectionPoint;
  143919. /**
  143920. * Gets the extra matrix indices input component
  143921. */
  143922. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  143923. /**
  143924. * Gets the extra matrix weights input component
  143925. */
  143926. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  143927. /**
  143928. * Gets the world input component
  143929. */
  143930. get world(): NodeMaterialConnectionPoint;
  143931. /**
  143932. * Gets the output component
  143933. */
  143934. get output(): NodeMaterialConnectionPoint;
  143935. autoConfigure(material: NodeMaterial): void;
  143936. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  143937. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143938. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143939. protected _buildBlock(state: NodeMaterialBuildState): this;
  143940. }
  143941. }
  143942. declare module BABYLON {
  143943. /**
  143944. * Block used to add support for instances
  143945. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  143946. */
  143947. export class InstancesBlock extends NodeMaterialBlock {
  143948. /**
  143949. * Creates a new InstancesBlock
  143950. * @param name defines the block name
  143951. */
  143952. constructor(name: string);
  143953. /**
  143954. * Gets the current class name
  143955. * @returns the class name
  143956. */
  143957. getClassName(): string;
  143958. /**
  143959. * Gets the first world row input component
  143960. */
  143961. get world0(): NodeMaterialConnectionPoint;
  143962. /**
  143963. * Gets the second world row input component
  143964. */
  143965. get world1(): NodeMaterialConnectionPoint;
  143966. /**
  143967. * Gets the third world row input component
  143968. */
  143969. get world2(): NodeMaterialConnectionPoint;
  143970. /**
  143971. * Gets the forth world row input component
  143972. */
  143973. get world3(): NodeMaterialConnectionPoint;
  143974. /**
  143975. * Gets the world input component
  143976. */
  143977. get world(): NodeMaterialConnectionPoint;
  143978. /**
  143979. * Gets the output component
  143980. */
  143981. get output(): NodeMaterialConnectionPoint;
  143982. /**
  143983. * Gets the isntanceID component
  143984. */
  143985. get instanceID(): NodeMaterialConnectionPoint;
  143986. autoConfigure(material: NodeMaterial): void;
  143987. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  143988. protected _buildBlock(state: NodeMaterialBuildState): this;
  143989. }
  143990. }
  143991. declare module BABYLON {
  143992. /**
  143993. * Block used to add morph targets support to vertex shader
  143994. */
  143995. export class MorphTargetsBlock extends NodeMaterialBlock {
  143996. private _repeatableContentAnchor;
  143997. /**
  143998. * Create a new MorphTargetsBlock
  143999. * @param name defines the block name
  144000. */
  144001. constructor(name: string);
  144002. /**
  144003. * Gets the current class name
  144004. * @returns the class name
  144005. */
  144006. getClassName(): string;
  144007. /**
  144008. * Gets the position input component
  144009. */
  144010. get position(): NodeMaterialConnectionPoint;
  144011. /**
  144012. * Gets the normal input component
  144013. */
  144014. get normal(): NodeMaterialConnectionPoint;
  144015. /**
  144016. * Gets the tangent input component
  144017. */
  144018. get tangent(): NodeMaterialConnectionPoint;
  144019. /**
  144020. * Gets the tangent input component
  144021. */
  144022. get uv(): NodeMaterialConnectionPoint;
  144023. /**
  144024. * Gets the position output component
  144025. */
  144026. get positionOutput(): NodeMaterialConnectionPoint;
  144027. /**
  144028. * Gets the normal output component
  144029. */
  144030. get normalOutput(): NodeMaterialConnectionPoint;
  144031. /**
  144032. * Gets the tangent output component
  144033. */
  144034. get tangentOutput(): NodeMaterialConnectionPoint;
  144035. /**
  144036. * Gets the tangent output component
  144037. */
  144038. get uvOutput(): NodeMaterialConnectionPoint;
  144039. initialize(state: NodeMaterialBuildState): void;
  144040. autoConfigure(material: NodeMaterial): void;
  144041. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144042. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144043. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  144044. protected _buildBlock(state: NodeMaterialBuildState): this;
  144045. }
  144046. }
  144047. declare module BABYLON {
  144048. /**
  144049. * Block used to get data information from a light
  144050. */
  144051. export class LightInformationBlock extends NodeMaterialBlock {
  144052. private _lightDataUniformName;
  144053. private _lightColorUniformName;
  144054. private _lightTypeDefineName;
  144055. /**
  144056. * Gets or sets the light associated with this block
  144057. */
  144058. light: Nullable<Light>;
  144059. /**
  144060. * Creates a new LightInformationBlock
  144061. * @param name defines the block name
  144062. */
  144063. constructor(name: string);
  144064. /**
  144065. * Gets the current class name
  144066. * @returns the class name
  144067. */
  144068. getClassName(): string;
  144069. /**
  144070. * Gets the world position input component
  144071. */
  144072. get worldPosition(): NodeMaterialConnectionPoint;
  144073. /**
  144074. * Gets the direction output component
  144075. */
  144076. get direction(): NodeMaterialConnectionPoint;
  144077. /**
  144078. * Gets the direction output component
  144079. */
  144080. get color(): NodeMaterialConnectionPoint;
  144081. /**
  144082. * Gets the direction output component
  144083. */
  144084. get intensity(): NodeMaterialConnectionPoint;
  144085. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144086. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144087. protected _buildBlock(state: NodeMaterialBuildState): this;
  144088. serialize(): any;
  144089. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144090. }
  144091. }
  144092. declare module BABYLON {
  144093. /**
  144094. * Block used to add image processing support to fragment shader
  144095. */
  144096. export class ImageProcessingBlock extends NodeMaterialBlock {
  144097. /**
  144098. * Create a new ImageProcessingBlock
  144099. * @param name defines the block name
  144100. */
  144101. constructor(name: string);
  144102. /**
  144103. * Gets the current class name
  144104. * @returns the class name
  144105. */
  144106. getClassName(): string;
  144107. /**
  144108. * Gets the color input component
  144109. */
  144110. get color(): NodeMaterialConnectionPoint;
  144111. /**
  144112. * Gets the output component
  144113. */
  144114. get output(): NodeMaterialConnectionPoint;
  144115. /**
  144116. * Initialize the block and prepare the context for build
  144117. * @param state defines the state that will be used for the build
  144118. */
  144119. initialize(state: NodeMaterialBuildState): void;
  144120. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  144121. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144122. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144123. protected _buildBlock(state: NodeMaterialBuildState): this;
  144124. }
  144125. }
  144126. declare module BABYLON {
  144127. /**
  144128. * Block used to pertub normals based on a normal map
  144129. */
  144130. export class PerturbNormalBlock extends NodeMaterialBlock {
  144131. private _tangentSpaceParameterName;
  144132. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144133. invertX: boolean;
  144134. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  144135. invertY: boolean;
  144136. /**
  144137. * Create a new PerturbNormalBlock
  144138. * @param name defines the block name
  144139. */
  144140. constructor(name: string);
  144141. /**
  144142. * Gets the current class name
  144143. * @returns the class name
  144144. */
  144145. getClassName(): string;
  144146. /**
  144147. * Gets the world position input component
  144148. */
  144149. get worldPosition(): NodeMaterialConnectionPoint;
  144150. /**
  144151. * Gets the world normal input component
  144152. */
  144153. get worldNormal(): NodeMaterialConnectionPoint;
  144154. /**
  144155. * Gets the world tangent input component
  144156. */
  144157. get worldTangent(): NodeMaterialConnectionPoint;
  144158. /**
  144159. * Gets the uv input component
  144160. */
  144161. get uv(): NodeMaterialConnectionPoint;
  144162. /**
  144163. * Gets the normal map color input component
  144164. */
  144165. get normalMapColor(): NodeMaterialConnectionPoint;
  144166. /**
  144167. * Gets the strength input component
  144168. */
  144169. get strength(): NodeMaterialConnectionPoint;
  144170. /**
  144171. * Gets the output component
  144172. */
  144173. get output(): NodeMaterialConnectionPoint;
  144174. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144175. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144176. autoConfigure(material: NodeMaterial): void;
  144177. protected _buildBlock(state: NodeMaterialBuildState): this;
  144178. protected _dumpPropertiesCode(): string;
  144179. serialize(): any;
  144180. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144181. }
  144182. }
  144183. declare module BABYLON {
  144184. /**
  144185. * Block used to discard a pixel if a value is smaller than a cutoff
  144186. */
  144187. export class DiscardBlock extends NodeMaterialBlock {
  144188. /**
  144189. * Create a new DiscardBlock
  144190. * @param name defines the block name
  144191. */
  144192. constructor(name: string);
  144193. /**
  144194. * Gets the current class name
  144195. * @returns the class name
  144196. */
  144197. getClassName(): string;
  144198. /**
  144199. * Gets the color input component
  144200. */
  144201. get value(): NodeMaterialConnectionPoint;
  144202. /**
  144203. * Gets the cutoff input component
  144204. */
  144205. get cutoff(): NodeMaterialConnectionPoint;
  144206. protected _buildBlock(state: NodeMaterialBuildState): this;
  144207. }
  144208. }
  144209. declare module BABYLON {
  144210. /**
  144211. * Block used to test if the fragment shader is front facing
  144212. */
  144213. export class FrontFacingBlock extends NodeMaterialBlock {
  144214. /**
  144215. * Creates a new FrontFacingBlock
  144216. * @param name defines the block name
  144217. */
  144218. constructor(name: string);
  144219. /**
  144220. * Gets the current class name
  144221. * @returns the class name
  144222. */
  144223. getClassName(): string;
  144224. /**
  144225. * Gets the output component
  144226. */
  144227. get output(): NodeMaterialConnectionPoint;
  144228. protected _buildBlock(state: NodeMaterialBuildState): this;
  144229. }
  144230. }
  144231. declare module BABYLON {
  144232. /**
  144233. * Block used to get the derivative value on x and y of a given input
  144234. */
  144235. export class DerivativeBlock extends NodeMaterialBlock {
  144236. /**
  144237. * Create a new DerivativeBlock
  144238. * @param name defines the block name
  144239. */
  144240. constructor(name: string);
  144241. /**
  144242. * Gets the current class name
  144243. * @returns the class name
  144244. */
  144245. getClassName(): string;
  144246. /**
  144247. * Gets the input component
  144248. */
  144249. get input(): NodeMaterialConnectionPoint;
  144250. /**
  144251. * Gets the derivative output on x
  144252. */
  144253. get dx(): NodeMaterialConnectionPoint;
  144254. /**
  144255. * Gets the derivative output on y
  144256. */
  144257. get dy(): NodeMaterialConnectionPoint;
  144258. protected _buildBlock(state: NodeMaterialBuildState): this;
  144259. }
  144260. }
  144261. declare module BABYLON {
  144262. /**
  144263. * Block used to make gl_FragCoord available
  144264. */
  144265. export class FragCoordBlock extends NodeMaterialBlock {
  144266. /**
  144267. * Creates a new FragCoordBlock
  144268. * @param name defines the block name
  144269. */
  144270. constructor(name: string);
  144271. /**
  144272. * Gets the current class name
  144273. * @returns the class name
  144274. */
  144275. getClassName(): string;
  144276. /**
  144277. * Gets the xy component
  144278. */
  144279. get xy(): NodeMaterialConnectionPoint;
  144280. /**
  144281. * Gets the xyz component
  144282. */
  144283. get xyz(): NodeMaterialConnectionPoint;
  144284. /**
  144285. * Gets the xyzw component
  144286. */
  144287. get xyzw(): NodeMaterialConnectionPoint;
  144288. /**
  144289. * Gets the x component
  144290. */
  144291. get x(): NodeMaterialConnectionPoint;
  144292. /**
  144293. * Gets the y component
  144294. */
  144295. get y(): NodeMaterialConnectionPoint;
  144296. /**
  144297. * Gets the z component
  144298. */
  144299. get z(): NodeMaterialConnectionPoint;
  144300. /**
  144301. * Gets the w component
  144302. */
  144303. get output(): NodeMaterialConnectionPoint;
  144304. protected writeOutputs(state: NodeMaterialBuildState): string;
  144305. protected _buildBlock(state: NodeMaterialBuildState): this;
  144306. }
  144307. }
  144308. declare module BABYLON {
  144309. /**
  144310. * Block used to get the screen sizes
  144311. */
  144312. export class ScreenSizeBlock extends NodeMaterialBlock {
  144313. private _varName;
  144314. private _scene;
  144315. /**
  144316. * Creates a new ScreenSizeBlock
  144317. * @param name defines the block name
  144318. */
  144319. constructor(name: string);
  144320. /**
  144321. * Gets the current class name
  144322. * @returns the class name
  144323. */
  144324. getClassName(): string;
  144325. /**
  144326. * Gets the xy component
  144327. */
  144328. get xy(): NodeMaterialConnectionPoint;
  144329. /**
  144330. * Gets the x component
  144331. */
  144332. get x(): NodeMaterialConnectionPoint;
  144333. /**
  144334. * Gets the y component
  144335. */
  144336. get y(): NodeMaterialConnectionPoint;
  144337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144338. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  144339. protected _buildBlock(state: NodeMaterialBuildState): this;
  144340. }
  144341. }
  144342. declare module BABYLON {
  144343. /**
  144344. * Block used to add support for scene fog
  144345. */
  144346. export class FogBlock extends NodeMaterialBlock {
  144347. private _fogDistanceName;
  144348. private _fogParameters;
  144349. /**
  144350. * Create a new FogBlock
  144351. * @param name defines the block name
  144352. */
  144353. constructor(name: string);
  144354. /**
  144355. * Gets the current class name
  144356. * @returns the class name
  144357. */
  144358. getClassName(): string;
  144359. /**
  144360. * Gets the world position input component
  144361. */
  144362. get worldPosition(): NodeMaterialConnectionPoint;
  144363. /**
  144364. * Gets the view input component
  144365. */
  144366. get view(): NodeMaterialConnectionPoint;
  144367. /**
  144368. * Gets the color input component
  144369. */
  144370. get input(): NodeMaterialConnectionPoint;
  144371. /**
  144372. * Gets the fog color input component
  144373. */
  144374. get fogColor(): NodeMaterialConnectionPoint;
  144375. /**
  144376. * Gets the output component
  144377. */
  144378. get output(): NodeMaterialConnectionPoint;
  144379. autoConfigure(material: NodeMaterial): void;
  144380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144381. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144382. protected _buildBlock(state: NodeMaterialBuildState): this;
  144383. }
  144384. }
  144385. declare module BABYLON {
  144386. /**
  144387. * Block used to add light in the fragment shader
  144388. */
  144389. export class LightBlock extends NodeMaterialBlock {
  144390. private _lightId;
  144391. /**
  144392. * Gets or sets the light associated with this block
  144393. */
  144394. light: Nullable<Light>;
  144395. /**
  144396. * Create a new LightBlock
  144397. * @param name defines the block name
  144398. */
  144399. constructor(name: string);
  144400. /**
  144401. * Gets the current class name
  144402. * @returns the class name
  144403. */
  144404. getClassName(): string;
  144405. /**
  144406. * Gets the world position input component
  144407. */
  144408. get worldPosition(): NodeMaterialConnectionPoint;
  144409. /**
  144410. * Gets the world normal input component
  144411. */
  144412. get worldNormal(): NodeMaterialConnectionPoint;
  144413. /**
  144414. * Gets the camera (or eye) position component
  144415. */
  144416. get cameraPosition(): NodeMaterialConnectionPoint;
  144417. /**
  144418. * Gets the glossiness component
  144419. */
  144420. get glossiness(): NodeMaterialConnectionPoint;
  144421. /**
  144422. * Gets the glossinness power component
  144423. */
  144424. get glossPower(): NodeMaterialConnectionPoint;
  144425. /**
  144426. * Gets the diffuse color component
  144427. */
  144428. get diffuseColor(): NodeMaterialConnectionPoint;
  144429. /**
  144430. * Gets the specular color component
  144431. */
  144432. get specularColor(): NodeMaterialConnectionPoint;
  144433. /**
  144434. * Gets the diffuse output component
  144435. */
  144436. get diffuseOutput(): NodeMaterialConnectionPoint;
  144437. /**
  144438. * Gets the specular output component
  144439. */
  144440. get specularOutput(): NodeMaterialConnectionPoint;
  144441. /**
  144442. * Gets the shadow output component
  144443. */
  144444. get shadow(): NodeMaterialConnectionPoint;
  144445. autoConfigure(material: NodeMaterial): void;
  144446. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144447. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144448. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144449. private _injectVertexCode;
  144450. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144451. serialize(): any;
  144452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144453. }
  144454. }
  144455. declare module BABYLON {
  144456. /**
  144457. * Block used to read a reflection texture from a sampler
  144458. */
  144459. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  144460. /**
  144461. * Create a new ReflectionTextureBlock
  144462. * @param name defines the block name
  144463. */
  144464. constructor(name: string);
  144465. /**
  144466. * Gets the current class name
  144467. * @returns the class name
  144468. */
  144469. getClassName(): string;
  144470. /**
  144471. * Gets the world position input component
  144472. */
  144473. get position(): NodeMaterialConnectionPoint;
  144474. /**
  144475. * Gets the world position input component
  144476. */
  144477. get worldPosition(): NodeMaterialConnectionPoint;
  144478. /**
  144479. * Gets the world normal input component
  144480. */
  144481. get worldNormal(): NodeMaterialConnectionPoint;
  144482. /**
  144483. * Gets the world input component
  144484. */
  144485. get world(): NodeMaterialConnectionPoint;
  144486. /**
  144487. * Gets the camera (or eye) position component
  144488. */
  144489. get cameraPosition(): NodeMaterialConnectionPoint;
  144490. /**
  144491. * Gets the view input component
  144492. */
  144493. get view(): NodeMaterialConnectionPoint;
  144494. /**
  144495. * Gets the rgb output component
  144496. */
  144497. get rgb(): NodeMaterialConnectionPoint;
  144498. /**
  144499. * Gets the rgba output component
  144500. */
  144501. get rgba(): NodeMaterialConnectionPoint;
  144502. /**
  144503. * Gets the r output component
  144504. */
  144505. get r(): NodeMaterialConnectionPoint;
  144506. /**
  144507. * Gets the g output component
  144508. */
  144509. get g(): NodeMaterialConnectionPoint;
  144510. /**
  144511. * Gets the b output component
  144512. */
  144513. get b(): NodeMaterialConnectionPoint;
  144514. /**
  144515. * Gets the a output component
  144516. */
  144517. get a(): NodeMaterialConnectionPoint;
  144518. autoConfigure(material: NodeMaterial): void;
  144519. protected _buildBlock(state: NodeMaterialBuildState): this;
  144520. }
  144521. }
  144522. declare module BABYLON {
  144523. /**
  144524. * Block used to add 2 vectors
  144525. */
  144526. export class AddBlock extends NodeMaterialBlock {
  144527. /**
  144528. * Creates a new AddBlock
  144529. * @param name defines the block name
  144530. */
  144531. constructor(name: string);
  144532. /**
  144533. * Gets the current class name
  144534. * @returns the class name
  144535. */
  144536. getClassName(): string;
  144537. /**
  144538. * Gets the left operand input component
  144539. */
  144540. get left(): NodeMaterialConnectionPoint;
  144541. /**
  144542. * Gets the right operand input component
  144543. */
  144544. get right(): NodeMaterialConnectionPoint;
  144545. /**
  144546. * Gets the output component
  144547. */
  144548. get output(): NodeMaterialConnectionPoint;
  144549. protected _buildBlock(state: NodeMaterialBuildState): this;
  144550. }
  144551. }
  144552. declare module BABYLON {
  144553. /**
  144554. * Block used to scale a vector by a float
  144555. */
  144556. export class ScaleBlock extends NodeMaterialBlock {
  144557. /**
  144558. * Creates a new ScaleBlock
  144559. * @param name defines the block name
  144560. */
  144561. constructor(name: string);
  144562. /**
  144563. * Gets the current class name
  144564. * @returns the class name
  144565. */
  144566. getClassName(): string;
  144567. /**
  144568. * Gets the input component
  144569. */
  144570. get input(): NodeMaterialConnectionPoint;
  144571. /**
  144572. * Gets the factor input component
  144573. */
  144574. get factor(): NodeMaterialConnectionPoint;
  144575. /**
  144576. * Gets the output component
  144577. */
  144578. get output(): NodeMaterialConnectionPoint;
  144579. protected _buildBlock(state: NodeMaterialBuildState): this;
  144580. }
  144581. }
  144582. declare module BABYLON {
  144583. /**
  144584. * Block used to clamp a float
  144585. */
  144586. export class ClampBlock extends NodeMaterialBlock {
  144587. /** Gets or sets the minimum range */
  144588. minimum: number;
  144589. /** Gets or sets the maximum range */
  144590. maximum: number;
  144591. /**
  144592. * Creates a new ClampBlock
  144593. * @param name defines the block name
  144594. */
  144595. constructor(name: string);
  144596. /**
  144597. * Gets the current class name
  144598. * @returns the class name
  144599. */
  144600. getClassName(): string;
  144601. /**
  144602. * Gets the value input component
  144603. */
  144604. get value(): NodeMaterialConnectionPoint;
  144605. /**
  144606. * Gets the output component
  144607. */
  144608. get output(): NodeMaterialConnectionPoint;
  144609. protected _buildBlock(state: NodeMaterialBuildState): this;
  144610. protected _dumpPropertiesCode(): string;
  144611. serialize(): any;
  144612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144613. }
  144614. }
  144615. declare module BABYLON {
  144616. /**
  144617. * Block used to apply a cross product between 2 vectors
  144618. */
  144619. export class CrossBlock extends NodeMaterialBlock {
  144620. /**
  144621. * Creates a new CrossBlock
  144622. * @param name defines the block name
  144623. */
  144624. constructor(name: string);
  144625. /**
  144626. * Gets the current class name
  144627. * @returns the class name
  144628. */
  144629. getClassName(): string;
  144630. /**
  144631. * Gets the left operand input component
  144632. */
  144633. get left(): NodeMaterialConnectionPoint;
  144634. /**
  144635. * Gets the right operand input component
  144636. */
  144637. get right(): NodeMaterialConnectionPoint;
  144638. /**
  144639. * Gets the output component
  144640. */
  144641. get output(): NodeMaterialConnectionPoint;
  144642. protected _buildBlock(state: NodeMaterialBuildState): this;
  144643. }
  144644. }
  144645. declare module BABYLON {
  144646. /**
  144647. * Block used to apply a dot product between 2 vectors
  144648. */
  144649. export class DotBlock extends NodeMaterialBlock {
  144650. /**
  144651. * Creates a new DotBlock
  144652. * @param name defines the block name
  144653. */
  144654. constructor(name: string);
  144655. /**
  144656. * Gets the current class name
  144657. * @returns the class name
  144658. */
  144659. getClassName(): string;
  144660. /**
  144661. * Gets the left operand input component
  144662. */
  144663. get left(): NodeMaterialConnectionPoint;
  144664. /**
  144665. * Gets the right operand input component
  144666. */
  144667. get right(): NodeMaterialConnectionPoint;
  144668. /**
  144669. * Gets the output component
  144670. */
  144671. get output(): NodeMaterialConnectionPoint;
  144672. protected _buildBlock(state: NodeMaterialBuildState): this;
  144673. }
  144674. }
  144675. declare module BABYLON {
  144676. /**
  144677. * Block used to normalize a vector
  144678. */
  144679. export class NormalizeBlock extends NodeMaterialBlock {
  144680. /**
  144681. * Creates a new NormalizeBlock
  144682. * @param name defines the block name
  144683. */
  144684. constructor(name: string);
  144685. /**
  144686. * Gets the current class name
  144687. * @returns the class name
  144688. */
  144689. getClassName(): string;
  144690. /**
  144691. * Gets the input component
  144692. */
  144693. get input(): NodeMaterialConnectionPoint;
  144694. /**
  144695. * Gets the output component
  144696. */
  144697. get output(): NodeMaterialConnectionPoint;
  144698. protected _buildBlock(state: NodeMaterialBuildState): this;
  144699. }
  144700. }
  144701. declare module BABYLON {
  144702. /**
  144703. * Block used to create a Color3/4 out of individual inputs (one for each component)
  144704. */
  144705. export class ColorMergerBlock extends NodeMaterialBlock {
  144706. /**
  144707. * Create a new ColorMergerBlock
  144708. * @param name defines the block name
  144709. */
  144710. constructor(name: string);
  144711. /**
  144712. * Gets the current class name
  144713. * @returns the class name
  144714. */
  144715. getClassName(): string;
  144716. /**
  144717. * Gets the rgb component (input)
  144718. */
  144719. get rgbIn(): NodeMaterialConnectionPoint;
  144720. /**
  144721. * Gets the r component (input)
  144722. */
  144723. get r(): NodeMaterialConnectionPoint;
  144724. /**
  144725. * Gets the g component (input)
  144726. */
  144727. get g(): NodeMaterialConnectionPoint;
  144728. /**
  144729. * Gets the b component (input)
  144730. */
  144731. get b(): NodeMaterialConnectionPoint;
  144732. /**
  144733. * Gets the a component (input)
  144734. */
  144735. get a(): NodeMaterialConnectionPoint;
  144736. /**
  144737. * Gets the rgba component (output)
  144738. */
  144739. get rgba(): NodeMaterialConnectionPoint;
  144740. /**
  144741. * Gets the rgb component (output)
  144742. */
  144743. get rgbOut(): NodeMaterialConnectionPoint;
  144744. /**
  144745. * Gets the rgb component (output)
  144746. * @deprecated Please use rgbOut instead.
  144747. */
  144748. get rgb(): NodeMaterialConnectionPoint;
  144749. protected _buildBlock(state: NodeMaterialBuildState): this;
  144750. }
  144751. }
  144752. declare module BABYLON {
  144753. /**
  144754. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  144755. */
  144756. export class VectorSplitterBlock extends NodeMaterialBlock {
  144757. /**
  144758. * Create a new VectorSplitterBlock
  144759. * @param name defines the block name
  144760. */
  144761. constructor(name: string);
  144762. /**
  144763. * Gets the current class name
  144764. * @returns the class name
  144765. */
  144766. getClassName(): string;
  144767. /**
  144768. * Gets the xyzw component (input)
  144769. */
  144770. get xyzw(): NodeMaterialConnectionPoint;
  144771. /**
  144772. * Gets the xyz component (input)
  144773. */
  144774. get xyzIn(): NodeMaterialConnectionPoint;
  144775. /**
  144776. * Gets the xy component (input)
  144777. */
  144778. get xyIn(): NodeMaterialConnectionPoint;
  144779. /**
  144780. * Gets the xyz component (output)
  144781. */
  144782. get xyzOut(): NodeMaterialConnectionPoint;
  144783. /**
  144784. * Gets the xy component (output)
  144785. */
  144786. get xyOut(): NodeMaterialConnectionPoint;
  144787. /**
  144788. * Gets the x component (output)
  144789. */
  144790. get x(): NodeMaterialConnectionPoint;
  144791. /**
  144792. * Gets the y component (output)
  144793. */
  144794. get y(): NodeMaterialConnectionPoint;
  144795. /**
  144796. * Gets the z component (output)
  144797. */
  144798. get z(): NodeMaterialConnectionPoint;
  144799. /**
  144800. * Gets the w component (output)
  144801. */
  144802. get w(): NodeMaterialConnectionPoint;
  144803. protected _inputRename(name: string): string;
  144804. protected _outputRename(name: string): string;
  144805. protected _buildBlock(state: NodeMaterialBuildState): this;
  144806. }
  144807. }
  144808. declare module BABYLON {
  144809. /**
  144810. * Block used to lerp between 2 values
  144811. */
  144812. export class LerpBlock extends NodeMaterialBlock {
  144813. /**
  144814. * Creates a new LerpBlock
  144815. * @param name defines the block name
  144816. */
  144817. constructor(name: string);
  144818. /**
  144819. * Gets the current class name
  144820. * @returns the class name
  144821. */
  144822. getClassName(): string;
  144823. /**
  144824. * Gets the left operand input component
  144825. */
  144826. get left(): NodeMaterialConnectionPoint;
  144827. /**
  144828. * Gets the right operand input component
  144829. */
  144830. get right(): NodeMaterialConnectionPoint;
  144831. /**
  144832. * Gets the gradient operand input component
  144833. */
  144834. get gradient(): NodeMaterialConnectionPoint;
  144835. /**
  144836. * Gets the output component
  144837. */
  144838. get output(): NodeMaterialConnectionPoint;
  144839. protected _buildBlock(state: NodeMaterialBuildState): this;
  144840. }
  144841. }
  144842. declare module BABYLON {
  144843. /**
  144844. * Block used to divide 2 vectors
  144845. */
  144846. export class DivideBlock extends NodeMaterialBlock {
  144847. /**
  144848. * Creates a new DivideBlock
  144849. * @param name defines the block name
  144850. */
  144851. constructor(name: string);
  144852. /**
  144853. * Gets the current class name
  144854. * @returns the class name
  144855. */
  144856. getClassName(): string;
  144857. /**
  144858. * Gets the left operand input component
  144859. */
  144860. get left(): NodeMaterialConnectionPoint;
  144861. /**
  144862. * Gets the right operand input component
  144863. */
  144864. get right(): NodeMaterialConnectionPoint;
  144865. /**
  144866. * Gets the output component
  144867. */
  144868. get output(): NodeMaterialConnectionPoint;
  144869. protected _buildBlock(state: NodeMaterialBuildState): this;
  144870. }
  144871. }
  144872. declare module BABYLON {
  144873. /**
  144874. * Block used to subtract 2 vectors
  144875. */
  144876. export class SubtractBlock extends NodeMaterialBlock {
  144877. /**
  144878. * Creates a new SubtractBlock
  144879. * @param name defines the block name
  144880. */
  144881. constructor(name: string);
  144882. /**
  144883. * Gets the current class name
  144884. * @returns the class name
  144885. */
  144886. getClassName(): string;
  144887. /**
  144888. * Gets the left operand input component
  144889. */
  144890. get left(): NodeMaterialConnectionPoint;
  144891. /**
  144892. * Gets the right operand input component
  144893. */
  144894. get right(): NodeMaterialConnectionPoint;
  144895. /**
  144896. * Gets the output component
  144897. */
  144898. get output(): NodeMaterialConnectionPoint;
  144899. protected _buildBlock(state: NodeMaterialBuildState): this;
  144900. }
  144901. }
  144902. declare module BABYLON {
  144903. /**
  144904. * Block used to step a value
  144905. */
  144906. export class StepBlock extends NodeMaterialBlock {
  144907. /**
  144908. * Creates a new StepBlock
  144909. * @param name defines the block name
  144910. */
  144911. constructor(name: string);
  144912. /**
  144913. * Gets the current class name
  144914. * @returns the class name
  144915. */
  144916. getClassName(): string;
  144917. /**
  144918. * Gets the value operand input component
  144919. */
  144920. get value(): NodeMaterialConnectionPoint;
  144921. /**
  144922. * Gets the edge operand input component
  144923. */
  144924. get edge(): NodeMaterialConnectionPoint;
  144925. /**
  144926. * Gets the output component
  144927. */
  144928. get output(): NodeMaterialConnectionPoint;
  144929. protected _buildBlock(state: NodeMaterialBuildState): this;
  144930. }
  144931. }
  144932. declare module BABYLON {
  144933. /**
  144934. * Block used to get the opposite (1 - x) of a value
  144935. */
  144936. export class OneMinusBlock extends NodeMaterialBlock {
  144937. /**
  144938. * Creates a new OneMinusBlock
  144939. * @param name defines the block name
  144940. */
  144941. constructor(name: string);
  144942. /**
  144943. * Gets the current class name
  144944. * @returns the class name
  144945. */
  144946. getClassName(): string;
  144947. /**
  144948. * Gets the input component
  144949. */
  144950. get input(): NodeMaterialConnectionPoint;
  144951. /**
  144952. * Gets the output component
  144953. */
  144954. get output(): NodeMaterialConnectionPoint;
  144955. protected _buildBlock(state: NodeMaterialBuildState): this;
  144956. }
  144957. }
  144958. declare module BABYLON {
  144959. /**
  144960. * Block used to get the view direction
  144961. */
  144962. export class ViewDirectionBlock extends NodeMaterialBlock {
  144963. /**
  144964. * Creates a new ViewDirectionBlock
  144965. * @param name defines the block name
  144966. */
  144967. constructor(name: string);
  144968. /**
  144969. * Gets the current class name
  144970. * @returns the class name
  144971. */
  144972. getClassName(): string;
  144973. /**
  144974. * Gets the world position component
  144975. */
  144976. get worldPosition(): NodeMaterialConnectionPoint;
  144977. /**
  144978. * Gets the camera position component
  144979. */
  144980. get cameraPosition(): NodeMaterialConnectionPoint;
  144981. /**
  144982. * Gets the output component
  144983. */
  144984. get output(): NodeMaterialConnectionPoint;
  144985. autoConfigure(material: NodeMaterial): void;
  144986. protected _buildBlock(state: NodeMaterialBuildState): this;
  144987. }
  144988. }
  144989. declare module BABYLON {
  144990. /**
  144991. * Block used to compute fresnel value
  144992. */
  144993. export class FresnelBlock extends NodeMaterialBlock {
  144994. /**
  144995. * Create a new FresnelBlock
  144996. * @param name defines the block name
  144997. */
  144998. constructor(name: string);
  144999. /**
  145000. * Gets the current class name
  145001. * @returns the class name
  145002. */
  145003. getClassName(): string;
  145004. /**
  145005. * Gets the world normal input component
  145006. */
  145007. get worldNormal(): NodeMaterialConnectionPoint;
  145008. /**
  145009. * Gets the view direction input component
  145010. */
  145011. get viewDirection(): NodeMaterialConnectionPoint;
  145012. /**
  145013. * Gets the bias input component
  145014. */
  145015. get bias(): NodeMaterialConnectionPoint;
  145016. /**
  145017. * Gets the camera (or eye) position component
  145018. */
  145019. get power(): NodeMaterialConnectionPoint;
  145020. /**
  145021. * Gets the fresnel output component
  145022. */
  145023. get fresnel(): NodeMaterialConnectionPoint;
  145024. autoConfigure(material: NodeMaterial): void;
  145025. protected _buildBlock(state: NodeMaterialBuildState): this;
  145026. }
  145027. }
  145028. declare module BABYLON {
  145029. /**
  145030. * Block used to get the max of 2 values
  145031. */
  145032. export class MaxBlock extends NodeMaterialBlock {
  145033. /**
  145034. * Creates a new MaxBlock
  145035. * @param name defines the block name
  145036. */
  145037. constructor(name: string);
  145038. /**
  145039. * Gets the current class name
  145040. * @returns the class name
  145041. */
  145042. getClassName(): string;
  145043. /**
  145044. * Gets the left operand input component
  145045. */
  145046. get left(): NodeMaterialConnectionPoint;
  145047. /**
  145048. * Gets the right operand input component
  145049. */
  145050. get right(): NodeMaterialConnectionPoint;
  145051. /**
  145052. * Gets the output component
  145053. */
  145054. get output(): NodeMaterialConnectionPoint;
  145055. protected _buildBlock(state: NodeMaterialBuildState): this;
  145056. }
  145057. }
  145058. declare module BABYLON {
  145059. /**
  145060. * Block used to get the min of 2 values
  145061. */
  145062. export class MinBlock extends NodeMaterialBlock {
  145063. /**
  145064. * Creates a new MinBlock
  145065. * @param name defines the block name
  145066. */
  145067. constructor(name: string);
  145068. /**
  145069. * Gets the current class name
  145070. * @returns the class name
  145071. */
  145072. getClassName(): string;
  145073. /**
  145074. * Gets the left operand input component
  145075. */
  145076. get left(): NodeMaterialConnectionPoint;
  145077. /**
  145078. * Gets the right operand input component
  145079. */
  145080. get right(): NodeMaterialConnectionPoint;
  145081. /**
  145082. * Gets the output component
  145083. */
  145084. get output(): NodeMaterialConnectionPoint;
  145085. protected _buildBlock(state: NodeMaterialBuildState): this;
  145086. }
  145087. }
  145088. declare module BABYLON {
  145089. /**
  145090. * Block used to get the distance between 2 values
  145091. */
  145092. export class DistanceBlock extends NodeMaterialBlock {
  145093. /**
  145094. * Creates a new DistanceBlock
  145095. * @param name defines the block name
  145096. */
  145097. constructor(name: string);
  145098. /**
  145099. * Gets the current class name
  145100. * @returns the class name
  145101. */
  145102. getClassName(): string;
  145103. /**
  145104. * Gets the left operand input component
  145105. */
  145106. get left(): NodeMaterialConnectionPoint;
  145107. /**
  145108. * Gets the right operand input component
  145109. */
  145110. get right(): NodeMaterialConnectionPoint;
  145111. /**
  145112. * Gets the output component
  145113. */
  145114. get output(): NodeMaterialConnectionPoint;
  145115. protected _buildBlock(state: NodeMaterialBuildState): this;
  145116. }
  145117. }
  145118. declare module BABYLON {
  145119. /**
  145120. * Block used to get the length of a vector
  145121. */
  145122. export class LengthBlock extends NodeMaterialBlock {
  145123. /**
  145124. * Creates a new LengthBlock
  145125. * @param name defines the block name
  145126. */
  145127. constructor(name: string);
  145128. /**
  145129. * Gets the current class name
  145130. * @returns the class name
  145131. */
  145132. getClassName(): string;
  145133. /**
  145134. * Gets the value input component
  145135. */
  145136. get value(): NodeMaterialConnectionPoint;
  145137. /**
  145138. * Gets the output component
  145139. */
  145140. get output(): NodeMaterialConnectionPoint;
  145141. protected _buildBlock(state: NodeMaterialBuildState): this;
  145142. }
  145143. }
  145144. declare module BABYLON {
  145145. /**
  145146. * Block used to get negative version of a value (i.e. x * -1)
  145147. */
  145148. export class NegateBlock extends NodeMaterialBlock {
  145149. /**
  145150. * Creates a new NegateBlock
  145151. * @param name defines the block name
  145152. */
  145153. constructor(name: string);
  145154. /**
  145155. * Gets the current class name
  145156. * @returns the class name
  145157. */
  145158. getClassName(): string;
  145159. /**
  145160. * Gets the value input component
  145161. */
  145162. get value(): NodeMaterialConnectionPoint;
  145163. /**
  145164. * Gets the output component
  145165. */
  145166. get output(): NodeMaterialConnectionPoint;
  145167. protected _buildBlock(state: NodeMaterialBuildState): this;
  145168. }
  145169. }
  145170. declare module BABYLON {
  145171. /**
  145172. * Block used to get the value of the first parameter raised to the power of the second
  145173. */
  145174. export class PowBlock extends NodeMaterialBlock {
  145175. /**
  145176. * Creates a new PowBlock
  145177. * @param name defines the block name
  145178. */
  145179. constructor(name: string);
  145180. /**
  145181. * Gets the current class name
  145182. * @returns the class name
  145183. */
  145184. getClassName(): string;
  145185. /**
  145186. * Gets the value operand input component
  145187. */
  145188. get value(): NodeMaterialConnectionPoint;
  145189. /**
  145190. * Gets the power operand input component
  145191. */
  145192. get power(): NodeMaterialConnectionPoint;
  145193. /**
  145194. * Gets the output component
  145195. */
  145196. get output(): NodeMaterialConnectionPoint;
  145197. protected _buildBlock(state: NodeMaterialBuildState): this;
  145198. }
  145199. }
  145200. declare module BABYLON {
  145201. /**
  145202. * Block used to get a random number
  145203. */
  145204. export class RandomNumberBlock extends NodeMaterialBlock {
  145205. /**
  145206. * Creates a new RandomNumberBlock
  145207. * @param name defines the block name
  145208. */
  145209. constructor(name: string);
  145210. /**
  145211. * Gets the current class name
  145212. * @returns the class name
  145213. */
  145214. getClassName(): string;
  145215. /**
  145216. * Gets the seed input component
  145217. */
  145218. get seed(): NodeMaterialConnectionPoint;
  145219. /**
  145220. * Gets the output component
  145221. */
  145222. get output(): NodeMaterialConnectionPoint;
  145223. protected _buildBlock(state: NodeMaterialBuildState): this;
  145224. }
  145225. }
  145226. declare module BABYLON {
  145227. /**
  145228. * Block used to compute arc tangent of 2 values
  145229. */
  145230. export class ArcTan2Block extends NodeMaterialBlock {
  145231. /**
  145232. * Creates a new ArcTan2Block
  145233. * @param name defines the block name
  145234. */
  145235. constructor(name: string);
  145236. /**
  145237. * Gets the current class name
  145238. * @returns the class name
  145239. */
  145240. getClassName(): string;
  145241. /**
  145242. * Gets the x operand input component
  145243. */
  145244. get x(): NodeMaterialConnectionPoint;
  145245. /**
  145246. * Gets the y operand input component
  145247. */
  145248. get y(): NodeMaterialConnectionPoint;
  145249. /**
  145250. * Gets the output component
  145251. */
  145252. get output(): NodeMaterialConnectionPoint;
  145253. protected _buildBlock(state: NodeMaterialBuildState): this;
  145254. }
  145255. }
  145256. declare module BABYLON {
  145257. /**
  145258. * Block used to smooth step a value
  145259. */
  145260. export class SmoothStepBlock extends NodeMaterialBlock {
  145261. /**
  145262. * Creates a new SmoothStepBlock
  145263. * @param name defines the block name
  145264. */
  145265. constructor(name: string);
  145266. /**
  145267. * Gets the current class name
  145268. * @returns the class name
  145269. */
  145270. getClassName(): string;
  145271. /**
  145272. * Gets the value operand input component
  145273. */
  145274. get value(): NodeMaterialConnectionPoint;
  145275. /**
  145276. * Gets the first edge operand input component
  145277. */
  145278. get edge0(): NodeMaterialConnectionPoint;
  145279. /**
  145280. * Gets the second edge operand input component
  145281. */
  145282. get edge1(): NodeMaterialConnectionPoint;
  145283. /**
  145284. * Gets the output component
  145285. */
  145286. get output(): NodeMaterialConnectionPoint;
  145287. protected _buildBlock(state: NodeMaterialBuildState): this;
  145288. }
  145289. }
  145290. declare module BABYLON {
  145291. /**
  145292. * Block used to get the reciprocal (1 / x) of a value
  145293. */
  145294. export class ReciprocalBlock extends NodeMaterialBlock {
  145295. /**
  145296. * Creates a new ReciprocalBlock
  145297. * @param name defines the block name
  145298. */
  145299. constructor(name: string);
  145300. /**
  145301. * Gets the current class name
  145302. * @returns the class name
  145303. */
  145304. getClassName(): string;
  145305. /**
  145306. * Gets the input component
  145307. */
  145308. get input(): NodeMaterialConnectionPoint;
  145309. /**
  145310. * Gets the output component
  145311. */
  145312. get output(): NodeMaterialConnectionPoint;
  145313. protected _buildBlock(state: NodeMaterialBuildState): this;
  145314. }
  145315. }
  145316. declare module BABYLON {
  145317. /**
  145318. * Block used to replace a color by another one
  145319. */
  145320. export class ReplaceColorBlock extends NodeMaterialBlock {
  145321. /**
  145322. * Creates a new ReplaceColorBlock
  145323. * @param name defines the block name
  145324. */
  145325. constructor(name: string);
  145326. /**
  145327. * Gets the current class name
  145328. * @returns the class name
  145329. */
  145330. getClassName(): string;
  145331. /**
  145332. * Gets the value input component
  145333. */
  145334. get value(): NodeMaterialConnectionPoint;
  145335. /**
  145336. * Gets the reference input component
  145337. */
  145338. get reference(): NodeMaterialConnectionPoint;
  145339. /**
  145340. * Gets the distance input component
  145341. */
  145342. get distance(): NodeMaterialConnectionPoint;
  145343. /**
  145344. * Gets the replacement input component
  145345. */
  145346. get replacement(): NodeMaterialConnectionPoint;
  145347. /**
  145348. * Gets the output component
  145349. */
  145350. get output(): NodeMaterialConnectionPoint;
  145351. protected _buildBlock(state: NodeMaterialBuildState): this;
  145352. }
  145353. }
  145354. declare module BABYLON {
  145355. /**
  145356. * Block used to posterize a value
  145357. * @see https://en.wikipedia.org/wiki/Posterization
  145358. */
  145359. export class PosterizeBlock extends NodeMaterialBlock {
  145360. /**
  145361. * Creates a new PosterizeBlock
  145362. * @param name defines the block name
  145363. */
  145364. constructor(name: string);
  145365. /**
  145366. * Gets the current class name
  145367. * @returns the class name
  145368. */
  145369. getClassName(): string;
  145370. /**
  145371. * Gets the value input component
  145372. */
  145373. get value(): NodeMaterialConnectionPoint;
  145374. /**
  145375. * Gets the steps input component
  145376. */
  145377. get steps(): NodeMaterialConnectionPoint;
  145378. /**
  145379. * Gets the output component
  145380. */
  145381. get output(): NodeMaterialConnectionPoint;
  145382. protected _buildBlock(state: NodeMaterialBuildState): this;
  145383. }
  145384. }
  145385. declare module BABYLON {
  145386. /**
  145387. * Operations supported by the Wave block
  145388. */
  145389. export enum WaveBlockKind {
  145390. /** SawTooth */
  145391. SawTooth = 0,
  145392. /** Square */
  145393. Square = 1,
  145394. /** Triangle */
  145395. Triangle = 2
  145396. }
  145397. /**
  145398. * Block used to apply wave operation to floats
  145399. */
  145400. export class WaveBlock extends NodeMaterialBlock {
  145401. /**
  145402. * Gets or sets the kibnd of wave to be applied by the block
  145403. */
  145404. kind: WaveBlockKind;
  145405. /**
  145406. * Creates a new WaveBlock
  145407. * @param name defines the block name
  145408. */
  145409. constructor(name: string);
  145410. /**
  145411. * Gets the current class name
  145412. * @returns the class name
  145413. */
  145414. getClassName(): string;
  145415. /**
  145416. * Gets the input component
  145417. */
  145418. get input(): NodeMaterialConnectionPoint;
  145419. /**
  145420. * Gets the output component
  145421. */
  145422. get output(): NodeMaterialConnectionPoint;
  145423. protected _buildBlock(state: NodeMaterialBuildState): this;
  145424. serialize(): any;
  145425. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145426. }
  145427. }
  145428. declare module BABYLON {
  145429. /**
  145430. * Class used to store a color step for the GradientBlock
  145431. */
  145432. export class GradientBlockColorStep {
  145433. private _step;
  145434. /**
  145435. * Gets value indicating which step this color is associated with (between 0 and 1)
  145436. */
  145437. get step(): number;
  145438. /**
  145439. * Sets a value indicating which step this color is associated with (between 0 and 1)
  145440. */
  145441. set step(val: number);
  145442. private _color;
  145443. /**
  145444. * Gets the color associated with this step
  145445. */
  145446. get color(): Color3;
  145447. /**
  145448. * Sets the color associated with this step
  145449. */
  145450. set color(val: Color3);
  145451. /**
  145452. * Creates a new GradientBlockColorStep
  145453. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  145454. * @param color defines the color associated with this step
  145455. */
  145456. constructor(step: number, color: Color3);
  145457. }
  145458. /**
  145459. * Block used to return a color from a gradient based on an input value between 0 and 1
  145460. */
  145461. export class GradientBlock extends NodeMaterialBlock {
  145462. /**
  145463. * Gets or sets the list of color steps
  145464. */
  145465. colorSteps: GradientBlockColorStep[];
  145466. /** Gets an observable raised when the value is changed */
  145467. onValueChangedObservable: Observable<GradientBlock>;
  145468. /** calls observable when the value is changed*/
  145469. colorStepsUpdated(): void;
  145470. /**
  145471. * Creates a new GradientBlock
  145472. * @param name defines the block name
  145473. */
  145474. constructor(name: string);
  145475. /**
  145476. * Gets the current class name
  145477. * @returns the class name
  145478. */
  145479. getClassName(): string;
  145480. /**
  145481. * Gets the gradient input component
  145482. */
  145483. get gradient(): NodeMaterialConnectionPoint;
  145484. /**
  145485. * Gets the output component
  145486. */
  145487. get output(): NodeMaterialConnectionPoint;
  145488. private _writeColorConstant;
  145489. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145490. serialize(): any;
  145491. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145492. protected _dumpPropertiesCode(): string;
  145493. }
  145494. }
  145495. declare module BABYLON {
  145496. /**
  145497. * Block used to normalize lerp between 2 values
  145498. */
  145499. export class NLerpBlock extends NodeMaterialBlock {
  145500. /**
  145501. * Creates a new NLerpBlock
  145502. * @param name defines the block name
  145503. */
  145504. constructor(name: string);
  145505. /**
  145506. * Gets the current class name
  145507. * @returns the class name
  145508. */
  145509. getClassName(): string;
  145510. /**
  145511. * Gets the left operand input component
  145512. */
  145513. get left(): NodeMaterialConnectionPoint;
  145514. /**
  145515. * Gets the right operand input component
  145516. */
  145517. get right(): NodeMaterialConnectionPoint;
  145518. /**
  145519. * Gets the gradient operand input component
  145520. */
  145521. get gradient(): NodeMaterialConnectionPoint;
  145522. /**
  145523. * Gets the output component
  145524. */
  145525. get output(): NodeMaterialConnectionPoint;
  145526. protected _buildBlock(state: NodeMaterialBuildState): this;
  145527. }
  145528. }
  145529. declare module BABYLON {
  145530. /**
  145531. * block used to Generate a Worley Noise 3D Noise Pattern
  145532. */
  145533. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  145534. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145535. manhattanDistance: boolean;
  145536. /**
  145537. * Creates a new WorleyNoise3DBlock
  145538. * @param name defines the block name
  145539. */
  145540. constructor(name: string);
  145541. /**
  145542. * Gets the current class name
  145543. * @returns the class name
  145544. */
  145545. getClassName(): string;
  145546. /**
  145547. * Gets the seed input component
  145548. */
  145549. get seed(): NodeMaterialConnectionPoint;
  145550. /**
  145551. * Gets the jitter input component
  145552. */
  145553. get jitter(): NodeMaterialConnectionPoint;
  145554. /**
  145555. * Gets the output component
  145556. */
  145557. get output(): NodeMaterialConnectionPoint;
  145558. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145559. /**
  145560. * Exposes the properties to the UI?
  145561. */
  145562. protected _dumpPropertiesCode(): string;
  145563. /**
  145564. * Exposes the properties to the Seralize?
  145565. */
  145566. serialize(): any;
  145567. /**
  145568. * Exposes the properties to the deseralize?
  145569. */
  145570. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145571. }
  145572. }
  145573. declare module BABYLON {
  145574. /**
  145575. * block used to Generate a Simplex Perlin 3d Noise Pattern
  145576. */
  145577. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  145578. /**
  145579. * Creates a new SimplexPerlin3DBlock
  145580. * @param name defines the block name
  145581. */
  145582. constructor(name: string);
  145583. /**
  145584. * Gets the current class name
  145585. * @returns the class name
  145586. */
  145587. getClassName(): string;
  145588. /**
  145589. * Gets the seed operand input component
  145590. */
  145591. get seed(): NodeMaterialConnectionPoint;
  145592. /**
  145593. * Gets the output component
  145594. */
  145595. get output(): NodeMaterialConnectionPoint;
  145596. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145597. }
  145598. }
  145599. declare module BABYLON {
  145600. /**
  145601. * Block used to blend normals
  145602. */
  145603. export class NormalBlendBlock extends NodeMaterialBlock {
  145604. /**
  145605. * Creates a new NormalBlendBlock
  145606. * @param name defines the block name
  145607. */
  145608. constructor(name: string);
  145609. /**
  145610. * Gets the current class name
  145611. * @returns the class name
  145612. */
  145613. getClassName(): string;
  145614. /**
  145615. * Gets the first input component
  145616. */
  145617. get normalMap0(): NodeMaterialConnectionPoint;
  145618. /**
  145619. * Gets the second input component
  145620. */
  145621. get normalMap1(): NodeMaterialConnectionPoint;
  145622. /**
  145623. * Gets the output component
  145624. */
  145625. get output(): NodeMaterialConnectionPoint;
  145626. protected _buildBlock(state: NodeMaterialBuildState): this;
  145627. }
  145628. }
  145629. declare module BABYLON {
  145630. /**
  145631. * Block used to rotate a 2d vector by a given angle
  145632. */
  145633. export class Rotate2dBlock extends NodeMaterialBlock {
  145634. /**
  145635. * Creates a new Rotate2dBlock
  145636. * @param name defines the block name
  145637. */
  145638. constructor(name: string);
  145639. /**
  145640. * Gets the current class name
  145641. * @returns the class name
  145642. */
  145643. getClassName(): string;
  145644. /**
  145645. * Gets the input vector
  145646. */
  145647. get input(): NodeMaterialConnectionPoint;
  145648. /**
  145649. * Gets the input angle
  145650. */
  145651. get angle(): NodeMaterialConnectionPoint;
  145652. /**
  145653. * Gets the output component
  145654. */
  145655. get output(): NodeMaterialConnectionPoint;
  145656. autoConfigure(material: NodeMaterial): void;
  145657. protected _buildBlock(state: NodeMaterialBuildState): this;
  145658. }
  145659. }
  145660. declare module BABYLON {
  145661. /**
  145662. * Block used to get the reflected vector from a direction and a normal
  145663. */
  145664. export class ReflectBlock extends NodeMaterialBlock {
  145665. /**
  145666. * Creates a new ReflectBlock
  145667. * @param name defines the block name
  145668. */
  145669. constructor(name: string);
  145670. /**
  145671. * Gets the current class name
  145672. * @returns the class name
  145673. */
  145674. getClassName(): string;
  145675. /**
  145676. * Gets the incident component
  145677. */
  145678. get incident(): NodeMaterialConnectionPoint;
  145679. /**
  145680. * Gets the normal component
  145681. */
  145682. get normal(): NodeMaterialConnectionPoint;
  145683. /**
  145684. * Gets the output component
  145685. */
  145686. get output(): NodeMaterialConnectionPoint;
  145687. protected _buildBlock(state: NodeMaterialBuildState): this;
  145688. }
  145689. }
  145690. declare module BABYLON {
  145691. /**
  145692. * Block used to get the refracted vector from a direction and a normal
  145693. */
  145694. export class RefractBlock extends NodeMaterialBlock {
  145695. /**
  145696. * Creates a new RefractBlock
  145697. * @param name defines the block name
  145698. */
  145699. constructor(name: string);
  145700. /**
  145701. * Gets the current class name
  145702. * @returns the class name
  145703. */
  145704. getClassName(): string;
  145705. /**
  145706. * Gets the incident component
  145707. */
  145708. get incident(): NodeMaterialConnectionPoint;
  145709. /**
  145710. * Gets the normal component
  145711. */
  145712. get normal(): NodeMaterialConnectionPoint;
  145713. /**
  145714. * Gets the index of refraction component
  145715. */
  145716. get ior(): NodeMaterialConnectionPoint;
  145717. /**
  145718. * Gets the output component
  145719. */
  145720. get output(): NodeMaterialConnectionPoint;
  145721. protected _buildBlock(state: NodeMaterialBuildState): this;
  145722. }
  145723. }
  145724. declare module BABYLON {
  145725. /**
  145726. * Block used to desaturate a color
  145727. */
  145728. export class DesaturateBlock extends NodeMaterialBlock {
  145729. /**
  145730. * Creates a new DesaturateBlock
  145731. * @param name defines the block name
  145732. */
  145733. constructor(name: string);
  145734. /**
  145735. * Gets the current class name
  145736. * @returns the class name
  145737. */
  145738. getClassName(): string;
  145739. /**
  145740. * Gets the color operand input component
  145741. */
  145742. get color(): NodeMaterialConnectionPoint;
  145743. /**
  145744. * Gets the level operand input component
  145745. */
  145746. get level(): NodeMaterialConnectionPoint;
  145747. /**
  145748. * Gets the output component
  145749. */
  145750. get output(): NodeMaterialConnectionPoint;
  145751. protected _buildBlock(state: NodeMaterialBuildState): this;
  145752. }
  145753. }
  145754. declare module BABYLON {
  145755. /**
  145756. * Block used to implement the ambient occlusion module of the PBR material
  145757. */
  145758. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  145759. /**
  145760. * Create a new AmbientOcclusionBlock
  145761. * @param name defines the block name
  145762. */
  145763. constructor(name: string);
  145764. /**
  145765. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  145766. */
  145767. useAmbientInGrayScale: boolean;
  145768. /**
  145769. * Initialize the block and prepare the context for build
  145770. * @param state defines the state that will be used for the build
  145771. */
  145772. initialize(state: NodeMaterialBuildState): void;
  145773. /**
  145774. * Gets the current class name
  145775. * @returns the class name
  145776. */
  145777. getClassName(): string;
  145778. /**
  145779. * Gets the texture input component
  145780. */
  145781. get texture(): NodeMaterialConnectionPoint;
  145782. /**
  145783. * Gets the texture intensity component
  145784. */
  145785. get intensity(): NodeMaterialConnectionPoint;
  145786. /**
  145787. * Gets the direct light intensity input component
  145788. */
  145789. get directLightIntensity(): NodeMaterialConnectionPoint;
  145790. /**
  145791. * Gets the ambient occlusion object output component
  145792. */
  145793. get ambientOcc(): NodeMaterialConnectionPoint;
  145794. /**
  145795. * Gets the main code of the block (fragment side)
  145796. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  145797. * @returns the shader code
  145798. */
  145799. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  145800. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145801. protected _buildBlock(state: NodeMaterialBuildState): this;
  145802. protected _dumpPropertiesCode(): string;
  145803. serialize(): any;
  145804. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145805. }
  145806. }
  145807. declare module BABYLON {
  145808. /**
  145809. * Block used to implement the reflection module of the PBR material
  145810. */
  145811. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  145812. /** @hidden */
  145813. _defineLODReflectionAlpha: string;
  145814. /** @hidden */
  145815. _defineLinearSpecularReflection: string;
  145816. private _vEnvironmentIrradianceName;
  145817. /** @hidden */
  145818. _vReflectionMicrosurfaceInfosName: string;
  145819. /** @hidden */
  145820. _vReflectionInfosName: string;
  145821. /** @hidden */
  145822. _vReflectionFilteringInfoName: string;
  145823. private _scene;
  145824. /**
  145825. * The three properties below are set by the main PBR block prior to calling methods of this class.
  145826. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145827. * It's less burden on the user side in the editor part.
  145828. */
  145829. /** @hidden */
  145830. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145831. /** @hidden */
  145832. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145833. /** @hidden */
  145834. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  145835. /**
  145836. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  145837. * diffuse part of the IBL.
  145838. */
  145839. useSphericalHarmonics: boolean;
  145840. /**
  145841. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  145842. */
  145843. forceIrradianceInFragment: boolean;
  145844. /**
  145845. * Create a new ReflectionBlock
  145846. * @param name defines the block name
  145847. */
  145848. constructor(name: string);
  145849. /**
  145850. * Gets the current class name
  145851. * @returns the class name
  145852. */
  145853. getClassName(): string;
  145854. /**
  145855. * Gets the position input component
  145856. */
  145857. get position(): NodeMaterialConnectionPoint;
  145858. /**
  145859. * Gets the world position input component
  145860. */
  145861. get worldPosition(): NodeMaterialConnectionPoint;
  145862. /**
  145863. * Gets the world normal input component
  145864. */
  145865. get worldNormal(): NodeMaterialConnectionPoint;
  145866. /**
  145867. * Gets the world input component
  145868. */
  145869. get world(): NodeMaterialConnectionPoint;
  145870. /**
  145871. * Gets the camera (or eye) position component
  145872. */
  145873. get cameraPosition(): NodeMaterialConnectionPoint;
  145874. /**
  145875. * Gets the view input component
  145876. */
  145877. get view(): NodeMaterialConnectionPoint;
  145878. /**
  145879. * Gets the color input component
  145880. */
  145881. get color(): NodeMaterialConnectionPoint;
  145882. /**
  145883. * Gets the reflection object output component
  145884. */
  145885. get reflection(): NodeMaterialConnectionPoint;
  145886. /**
  145887. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  145888. */
  145889. get hasTexture(): boolean;
  145890. /**
  145891. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  145892. */
  145893. get reflectionColor(): string;
  145894. protected _getTexture(): Nullable<BaseTexture>;
  145895. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145896. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145897. /**
  145898. * Gets the code to inject in the vertex shader
  145899. * @param state current state of the node material building
  145900. * @returns the shader code
  145901. */
  145902. handleVertexSide(state: NodeMaterialBuildState): string;
  145903. /**
  145904. * Gets the main code of the block (fragment side)
  145905. * @param state current state of the node material building
  145906. * @param normalVarName name of the existing variable corresponding to the normal
  145907. * @returns the shader code
  145908. */
  145909. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  145910. protected _buildBlock(state: NodeMaterialBuildState): this;
  145911. protected _dumpPropertiesCode(): string;
  145912. serialize(): any;
  145913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145914. }
  145915. }
  145916. declare module BABYLON {
  145917. /**
  145918. * Block used to implement the sheen module of the PBR material
  145919. */
  145920. export class SheenBlock extends NodeMaterialBlock {
  145921. /**
  145922. * Create a new SheenBlock
  145923. * @param name defines the block name
  145924. */
  145925. constructor(name: string);
  145926. /**
  145927. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  145928. * It allows the strength of the sheen effect to not depend on the base color of the material,
  145929. * making it easier to setup and tweak the effect
  145930. */
  145931. albedoScaling: boolean;
  145932. /**
  145933. * Defines if the sheen is linked to the sheen color.
  145934. */
  145935. linkSheenWithAlbedo: boolean;
  145936. /**
  145937. * Initialize the block and prepare the context for build
  145938. * @param state defines the state that will be used for the build
  145939. */
  145940. initialize(state: NodeMaterialBuildState): void;
  145941. /**
  145942. * Gets the current class name
  145943. * @returns the class name
  145944. */
  145945. getClassName(): string;
  145946. /**
  145947. * Gets the intensity input component
  145948. */
  145949. get intensity(): NodeMaterialConnectionPoint;
  145950. /**
  145951. * Gets the color input component
  145952. */
  145953. get color(): NodeMaterialConnectionPoint;
  145954. /**
  145955. * Gets the roughness input component
  145956. */
  145957. get roughness(): NodeMaterialConnectionPoint;
  145958. /**
  145959. * Gets the sheen object output component
  145960. */
  145961. get sheen(): NodeMaterialConnectionPoint;
  145962. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145963. /**
  145964. * Gets the main code of the block (fragment side)
  145965. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145966. * @returns the shader code
  145967. */
  145968. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  145969. protected _buildBlock(state: NodeMaterialBuildState): this;
  145970. protected _dumpPropertiesCode(): string;
  145971. serialize(): any;
  145972. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145973. }
  145974. }
  145975. declare module BABYLON {
  145976. /**
  145977. * Block used to implement the reflectivity module of the PBR material
  145978. */
  145979. export class ReflectivityBlock extends NodeMaterialBlock {
  145980. private _metallicReflectanceColor;
  145981. private _metallicF0Factor;
  145982. /** @hidden */
  145983. _vMetallicReflectanceFactorsName: string;
  145984. /**
  145985. * The property below is set by the main PBR block prior to calling methods of this class.
  145986. */
  145987. /** @hidden */
  145988. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  145989. /**
  145990. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  145991. */
  145992. useAmbientOcclusionFromMetallicTextureRed: boolean;
  145993. /**
  145994. * Specifies if the metallic texture contains the metallness information in its blue channel.
  145995. */
  145996. useMetallnessFromMetallicTextureBlue: boolean;
  145997. /**
  145998. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  145999. */
  146000. useRoughnessFromMetallicTextureAlpha: boolean;
  146001. /**
  146002. * Specifies if the metallic texture contains the roughness information in its green channel.
  146003. */
  146004. useRoughnessFromMetallicTextureGreen: boolean;
  146005. /**
  146006. * Create a new ReflectivityBlock
  146007. * @param name defines the block name
  146008. */
  146009. constructor(name: string);
  146010. /**
  146011. * Initialize the block and prepare the context for build
  146012. * @param state defines the state that will be used for the build
  146013. */
  146014. initialize(state: NodeMaterialBuildState): void;
  146015. /**
  146016. * Gets the current class name
  146017. * @returns the class name
  146018. */
  146019. getClassName(): string;
  146020. /**
  146021. * Gets the metallic input component
  146022. */
  146023. get metallic(): NodeMaterialConnectionPoint;
  146024. /**
  146025. * Gets the roughness input component
  146026. */
  146027. get roughness(): NodeMaterialConnectionPoint;
  146028. /**
  146029. * Gets the texture input component
  146030. */
  146031. get texture(): NodeMaterialConnectionPoint;
  146032. /**
  146033. * Gets the reflectivity object output component
  146034. */
  146035. get reflectivity(): NodeMaterialConnectionPoint;
  146036. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146037. /**
  146038. * Gets the main code of the block (fragment side)
  146039. * @param state current state of the node material building
  146040. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  146041. * @returns the shader code
  146042. */
  146043. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  146044. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146045. protected _buildBlock(state: NodeMaterialBuildState): this;
  146046. protected _dumpPropertiesCode(): string;
  146047. serialize(): any;
  146048. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146049. }
  146050. }
  146051. declare module BABYLON {
  146052. /**
  146053. * Block used to implement the anisotropy module of the PBR material
  146054. */
  146055. export class AnisotropyBlock extends NodeMaterialBlock {
  146056. /**
  146057. * The two properties below are set by the main PBR block prior to calling methods of this class.
  146058. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  146059. * It's less burden on the user side in the editor part.
  146060. */
  146061. /** @hidden */
  146062. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  146063. /** @hidden */
  146064. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  146065. /**
  146066. * Create a new AnisotropyBlock
  146067. * @param name defines the block name
  146068. */
  146069. constructor(name: string);
  146070. /**
  146071. * Initialize the block and prepare the context for build
  146072. * @param state defines the state that will be used for the build
  146073. */
  146074. initialize(state: NodeMaterialBuildState): void;
  146075. /**
  146076. * Gets the current class name
  146077. * @returns the class name
  146078. */
  146079. getClassName(): string;
  146080. /**
  146081. * Gets the intensity input component
  146082. */
  146083. get intensity(): NodeMaterialConnectionPoint;
  146084. /**
  146085. * Gets the direction input component
  146086. */
  146087. get direction(): NodeMaterialConnectionPoint;
  146088. /**
  146089. * Gets the texture input component
  146090. */
  146091. get texture(): NodeMaterialConnectionPoint;
  146092. /**
  146093. * Gets the uv input component
  146094. */
  146095. get uv(): NodeMaterialConnectionPoint;
  146096. /**
  146097. * Gets the worldTangent input component
  146098. */
  146099. get worldTangent(): NodeMaterialConnectionPoint;
  146100. /**
  146101. * Gets the anisotropy object output component
  146102. */
  146103. get anisotropy(): NodeMaterialConnectionPoint;
  146104. private _generateTBNSpace;
  146105. /**
  146106. * Gets the main code of the block (fragment side)
  146107. * @param state current state of the node material building
  146108. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146109. * @returns the shader code
  146110. */
  146111. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  146112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146113. protected _buildBlock(state: NodeMaterialBuildState): this;
  146114. }
  146115. }
  146116. declare module BABYLON {
  146117. /**
  146118. * Block used to implement the clear coat module of the PBR material
  146119. */
  146120. export class ClearCoatBlock extends NodeMaterialBlock {
  146121. private _scene;
  146122. /**
  146123. * Create a new ClearCoatBlock
  146124. * @param name defines the block name
  146125. */
  146126. constructor(name: string);
  146127. /**
  146128. * Initialize the block and prepare the context for build
  146129. * @param state defines the state that will be used for the build
  146130. */
  146131. initialize(state: NodeMaterialBuildState): void;
  146132. /**
  146133. * Gets the current class name
  146134. * @returns the class name
  146135. */
  146136. getClassName(): string;
  146137. /**
  146138. * Gets the intensity input component
  146139. */
  146140. get intensity(): NodeMaterialConnectionPoint;
  146141. /**
  146142. * Gets the roughness input component
  146143. */
  146144. get roughness(): NodeMaterialConnectionPoint;
  146145. /**
  146146. * Gets the ior input component
  146147. */
  146148. get ior(): NodeMaterialConnectionPoint;
  146149. /**
  146150. * Gets the texture input component
  146151. */
  146152. get texture(): NodeMaterialConnectionPoint;
  146153. /**
  146154. * Gets the bump texture input component
  146155. */
  146156. get bumpTexture(): NodeMaterialConnectionPoint;
  146157. /**
  146158. * Gets the uv input component
  146159. */
  146160. get uv(): NodeMaterialConnectionPoint;
  146161. /**
  146162. * Gets the tint color input component
  146163. */
  146164. get tintColor(): NodeMaterialConnectionPoint;
  146165. /**
  146166. * Gets the tint "at distance" input component
  146167. */
  146168. get tintAtDistance(): NodeMaterialConnectionPoint;
  146169. /**
  146170. * Gets the tint thickness input component
  146171. */
  146172. get tintThickness(): NodeMaterialConnectionPoint;
  146173. /**
  146174. * Gets the world tangent input component
  146175. */
  146176. get worldTangent(): NodeMaterialConnectionPoint;
  146177. /**
  146178. * Gets the clear coat object output component
  146179. */
  146180. get clearcoat(): NodeMaterialConnectionPoint;
  146181. autoConfigure(material: NodeMaterial): void;
  146182. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146183. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146184. private _generateTBNSpace;
  146185. /**
  146186. * Gets the main code of the block (fragment side)
  146187. * @param state current state of the node material building
  146188. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  146189. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146190. * @param worldPosVarName name of the variable holding the world position
  146191. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146192. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  146193. * @param worldNormalVarName name of the variable holding the world normal
  146194. * @returns the shader code
  146195. */
  146196. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  146197. protected _buildBlock(state: NodeMaterialBuildState): this;
  146198. }
  146199. }
  146200. declare module BABYLON {
  146201. /**
  146202. * Block used to implement the sub surface module of the PBR material
  146203. */
  146204. export class SubSurfaceBlock extends NodeMaterialBlock {
  146205. /**
  146206. * Create a new SubSurfaceBlock
  146207. * @param name defines the block name
  146208. */
  146209. constructor(name: string);
  146210. /**
  146211. * Stores the intensity of the different subsurface effects in the thickness texture.
  146212. * * the green channel is the translucency intensity.
  146213. * * the blue channel is the scattering intensity.
  146214. * * the alpha channel is the refraction intensity.
  146215. */
  146216. useMaskFromThicknessTexture: boolean;
  146217. /**
  146218. * Initialize the block and prepare the context for build
  146219. * @param state defines the state that will be used for the build
  146220. */
  146221. initialize(state: NodeMaterialBuildState): void;
  146222. /**
  146223. * Gets the current class name
  146224. * @returns the class name
  146225. */
  146226. getClassName(): string;
  146227. /**
  146228. * Gets the min thickness input component
  146229. */
  146230. get minThickness(): NodeMaterialConnectionPoint;
  146231. /**
  146232. * Gets the max thickness input component
  146233. */
  146234. get maxThickness(): NodeMaterialConnectionPoint;
  146235. /**
  146236. * Gets the thickness texture component
  146237. */
  146238. get thicknessTexture(): NodeMaterialConnectionPoint;
  146239. /**
  146240. * Gets the tint color input component
  146241. */
  146242. get tintColor(): NodeMaterialConnectionPoint;
  146243. /**
  146244. * Gets the translucency intensity input component
  146245. */
  146246. get translucencyIntensity(): NodeMaterialConnectionPoint;
  146247. /**
  146248. * Gets the translucency diffusion distance input component
  146249. */
  146250. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  146251. /**
  146252. * Gets the refraction object parameters
  146253. */
  146254. get refraction(): NodeMaterialConnectionPoint;
  146255. /**
  146256. * Gets the sub surface object output component
  146257. */
  146258. get subsurface(): NodeMaterialConnectionPoint;
  146259. autoConfigure(material: NodeMaterial): void;
  146260. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146261. /**
  146262. * Gets the main code of the block (fragment side)
  146263. * @param state current state of the node material building
  146264. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  146265. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146266. * @param worldPosVarName name of the variable holding the world position
  146267. * @returns the shader code
  146268. */
  146269. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  146270. protected _buildBlock(state: NodeMaterialBuildState): this;
  146271. }
  146272. }
  146273. declare module BABYLON {
  146274. /**
  146275. * Block used to implement the PBR metallic/roughness model
  146276. */
  146277. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  146278. /**
  146279. * Gets or sets the light associated with this block
  146280. */
  146281. light: Nullable<Light>;
  146282. private _lightId;
  146283. private _scene;
  146284. private _environmentBRDFTexture;
  146285. private _environmentBrdfSamplerName;
  146286. private _vNormalWName;
  146287. private _invertNormalName;
  146288. /**
  146289. * Create a new ReflectionBlock
  146290. * @param name defines the block name
  146291. */
  146292. constructor(name: string);
  146293. /**
  146294. * Intensity of the direct lights e.g. the four lights available in your scene.
  146295. * This impacts both the direct diffuse and specular highlights.
  146296. */
  146297. directIntensity: number;
  146298. /**
  146299. * Intensity of the environment e.g. how much the environment will light the object
  146300. * either through harmonics for rough material or through the refelction for shiny ones.
  146301. */
  146302. environmentIntensity: number;
  146303. /**
  146304. * This is a special control allowing the reduction of the specular highlights coming from the
  146305. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  146306. */
  146307. specularIntensity: number;
  146308. /**
  146309. * Defines the falloff type used in this material.
  146310. * It by default is Physical.
  146311. */
  146312. lightFalloff: number;
  146313. /**
  146314. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  146315. */
  146316. useAlphaFromAlbedoTexture: boolean;
  146317. /**
  146318. * Specifies that alpha test should be used
  146319. */
  146320. useAlphaTest: boolean;
  146321. /**
  146322. * Defines the alpha limits in alpha test mode.
  146323. */
  146324. alphaTestCutoff: number;
  146325. /**
  146326. * Specifies that alpha blending should be used
  146327. */
  146328. useAlphaBlending: boolean;
  146329. /**
  146330. * Defines if the alpha value should be determined via the rgb values.
  146331. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  146332. */
  146333. opacityRGB: boolean;
  146334. /**
  146335. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  146336. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  146337. */
  146338. useRadianceOverAlpha: boolean;
  146339. /**
  146340. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  146341. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  146342. */
  146343. useSpecularOverAlpha: boolean;
  146344. /**
  146345. * Enables specular anti aliasing in the PBR shader.
  146346. * It will both interacts on the Geometry for analytical and IBL lighting.
  146347. * It also prefilter the roughness map based on the bump values.
  146348. */
  146349. enableSpecularAntiAliasing: boolean;
  146350. /**
  146351. * Enables realtime filtering on the texture.
  146352. */
  146353. realTimeFiltering: boolean;
  146354. /**
  146355. * Quality switch for realtime filtering
  146356. */
  146357. realTimeFilteringQuality: number;
  146358. /**
  146359. * Defines if the material uses energy conservation.
  146360. */
  146361. useEnergyConservation: boolean;
  146362. /**
  146363. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  146364. * too much the area relying on ambient texture to define their ambient occlusion.
  146365. */
  146366. useRadianceOcclusion: boolean;
  146367. /**
  146368. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  146369. * makes the reflect vector face the model (under horizon).
  146370. */
  146371. useHorizonOcclusion: boolean;
  146372. /**
  146373. * If set to true, no lighting calculations will be applied.
  146374. */
  146375. unlit: boolean;
  146376. /**
  146377. * Force normal to face away from face.
  146378. */
  146379. forceNormalForward: boolean;
  146380. /**
  146381. * Defines the material debug mode.
  146382. * It helps seeing only some components of the material while troubleshooting.
  146383. */
  146384. debugMode: number;
  146385. /**
  146386. * Specify from where on screen the debug mode should start.
  146387. * The value goes from -1 (full screen) to 1 (not visible)
  146388. * It helps with side by side comparison against the final render
  146389. * This defaults to 0
  146390. */
  146391. debugLimit: number;
  146392. /**
  146393. * As the default viewing range might not be enough (if the ambient is really small for instance)
  146394. * You can use the factor to better multiply the final value.
  146395. */
  146396. debugFactor: number;
  146397. /**
  146398. * Initialize the block and prepare the context for build
  146399. * @param state defines the state that will be used for the build
  146400. */
  146401. initialize(state: NodeMaterialBuildState): void;
  146402. /**
  146403. * Gets the current class name
  146404. * @returns the class name
  146405. */
  146406. getClassName(): string;
  146407. /**
  146408. * Gets the world position input component
  146409. */
  146410. get worldPosition(): NodeMaterialConnectionPoint;
  146411. /**
  146412. * Gets the world normal input component
  146413. */
  146414. get worldNormal(): NodeMaterialConnectionPoint;
  146415. /**
  146416. * Gets the perturbed normal input component
  146417. */
  146418. get perturbedNormal(): NodeMaterialConnectionPoint;
  146419. /**
  146420. * Gets the camera position input component
  146421. */
  146422. get cameraPosition(): NodeMaterialConnectionPoint;
  146423. /**
  146424. * Gets the base color input component
  146425. */
  146426. get baseColor(): NodeMaterialConnectionPoint;
  146427. /**
  146428. * Gets the opacity texture input component
  146429. */
  146430. get opacityTexture(): NodeMaterialConnectionPoint;
  146431. /**
  146432. * Gets the ambient color input component
  146433. */
  146434. get ambientColor(): NodeMaterialConnectionPoint;
  146435. /**
  146436. * Gets the reflectivity object parameters
  146437. */
  146438. get reflectivity(): NodeMaterialConnectionPoint;
  146439. /**
  146440. * Gets the ambient occlusion object parameters
  146441. */
  146442. get ambientOcc(): NodeMaterialConnectionPoint;
  146443. /**
  146444. * Gets the reflection object parameters
  146445. */
  146446. get reflection(): NodeMaterialConnectionPoint;
  146447. /**
  146448. * Gets the sheen object parameters
  146449. */
  146450. get sheen(): NodeMaterialConnectionPoint;
  146451. /**
  146452. * Gets the clear coat object parameters
  146453. */
  146454. get clearcoat(): NodeMaterialConnectionPoint;
  146455. /**
  146456. * Gets the sub surface object parameters
  146457. */
  146458. get subsurface(): NodeMaterialConnectionPoint;
  146459. /**
  146460. * Gets the anisotropy object parameters
  146461. */
  146462. get anisotropy(): NodeMaterialConnectionPoint;
  146463. /**
  146464. * Gets the ambient output component
  146465. */
  146466. get ambient(): NodeMaterialConnectionPoint;
  146467. /**
  146468. * Gets the diffuse output component
  146469. */
  146470. get diffuse(): NodeMaterialConnectionPoint;
  146471. /**
  146472. * Gets the specular output component
  146473. */
  146474. get specular(): NodeMaterialConnectionPoint;
  146475. /**
  146476. * Gets the sheen output component
  146477. */
  146478. get sheenDir(): NodeMaterialConnectionPoint;
  146479. /**
  146480. * Gets the clear coat output component
  146481. */
  146482. get clearcoatDir(): NodeMaterialConnectionPoint;
  146483. /**
  146484. * Gets the indirect diffuse output component
  146485. */
  146486. get diffuseIndirect(): NodeMaterialConnectionPoint;
  146487. /**
  146488. * Gets the indirect specular output component
  146489. */
  146490. get specularIndirect(): NodeMaterialConnectionPoint;
  146491. /**
  146492. * Gets the indirect sheen output component
  146493. */
  146494. get sheenIndirect(): NodeMaterialConnectionPoint;
  146495. /**
  146496. * Gets the indirect clear coat output component
  146497. */
  146498. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  146499. /**
  146500. * Gets the refraction output component
  146501. */
  146502. get refraction(): NodeMaterialConnectionPoint;
  146503. /**
  146504. * Gets the global lighting output component
  146505. */
  146506. get lighting(): NodeMaterialConnectionPoint;
  146507. /**
  146508. * Gets the shadow output component
  146509. */
  146510. get shadow(): NodeMaterialConnectionPoint;
  146511. /**
  146512. * Gets the alpha output component
  146513. */
  146514. get alpha(): NodeMaterialConnectionPoint;
  146515. autoConfigure(material: NodeMaterial): void;
  146516. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146517. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  146518. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146519. private _injectVertexCode;
  146520. /**
  146521. * Gets the code corresponding to the albedo/opacity module
  146522. * @returns the shader code
  146523. */
  146524. getAlbedoOpacityCode(): string;
  146525. protected _buildBlock(state: NodeMaterialBuildState): this;
  146526. protected _dumpPropertiesCode(): string;
  146527. serialize(): any;
  146528. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146529. }
  146530. }
  146531. declare module BABYLON {
  146532. /**
  146533. * Block used to compute value of one parameter modulo another
  146534. */
  146535. export class ModBlock extends NodeMaterialBlock {
  146536. /**
  146537. * Creates a new ModBlock
  146538. * @param name defines the block name
  146539. */
  146540. constructor(name: string);
  146541. /**
  146542. * Gets the current class name
  146543. * @returns the class name
  146544. */
  146545. getClassName(): string;
  146546. /**
  146547. * Gets the left operand input component
  146548. */
  146549. get left(): NodeMaterialConnectionPoint;
  146550. /**
  146551. * Gets the right operand input component
  146552. */
  146553. get right(): NodeMaterialConnectionPoint;
  146554. /**
  146555. * Gets the output component
  146556. */
  146557. get output(): NodeMaterialConnectionPoint;
  146558. protected _buildBlock(state: NodeMaterialBuildState): this;
  146559. }
  146560. }
  146561. declare module BABYLON {
  146562. /**
  146563. * Configuration for Draco compression
  146564. */
  146565. export interface IDracoCompressionConfiguration {
  146566. /**
  146567. * Configuration for the decoder.
  146568. */
  146569. decoder: {
  146570. /**
  146571. * The url to the WebAssembly module.
  146572. */
  146573. wasmUrl?: string;
  146574. /**
  146575. * The url to the WebAssembly binary.
  146576. */
  146577. wasmBinaryUrl?: string;
  146578. /**
  146579. * The url to the fallback JavaScript module.
  146580. */
  146581. fallbackUrl?: string;
  146582. };
  146583. }
  146584. /**
  146585. * Draco compression (https://google.github.io/draco/)
  146586. *
  146587. * This class wraps the Draco module.
  146588. *
  146589. * **Encoder**
  146590. *
  146591. * The encoder is not currently implemented.
  146592. *
  146593. * **Decoder**
  146594. *
  146595. * 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.
  146596. *
  146597. * To update the configuration, use the following code:
  146598. * ```javascript
  146599. * DracoCompression.Configuration = {
  146600. * decoder: {
  146601. * wasmUrl: "<url to the WebAssembly library>",
  146602. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  146603. * fallbackUrl: "<url to the fallback JavaScript library>",
  146604. * }
  146605. * };
  146606. * ```
  146607. *
  146608. * 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.
  146609. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  146610. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  146611. *
  146612. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  146613. * ```javascript
  146614. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  146615. * ```
  146616. *
  146617. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  146618. */
  146619. export class DracoCompression implements IDisposable {
  146620. private _workerPoolPromise?;
  146621. private _decoderModulePromise?;
  146622. /**
  146623. * The configuration. Defaults to the following urls:
  146624. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  146625. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  146626. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  146627. */
  146628. static Configuration: IDracoCompressionConfiguration;
  146629. /**
  146630. * Returns true if the decoder configuration is available.
  146631. */
  146632. static get DecoderAvailable(): boolean;
  146633. /**
  146634. * Default number of workers to create when creating the draco compression object.
  146635. */
  146636. static DefaultNumWorkers: number;
  146637. private static GetDefaultNumWorkers;
  146638. private static _Default;
  146639. /**
  146640. * Default instance for the draco compression object.
  146641. */
  146642. static get Default(): DracoCompression;
  146643. /**
  146644. * Constructor
  146645. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  146646. */
  146647. constructor(numWorkers?: number);
  146648. /**
  146649. * Stop all async operations and release resources.
  146650. */
  146651. dispose(): void;
  146652. /**
  146653. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  146654. * @returns a promise that resolves when ready
  146655. */
  146656. whenReadyAsync(): Promise<void>;
  146657. /**
  146658. * Decode Draco compressed mesh data to vertex data.
  146659. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  146660. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  146661. * @returns A promise that resolves with the decoded vertex data
  146662. */
  146663. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  146664. [kind: string]: number;
  146665. }): Promise<VertexData>;
  146666. }
  146667. }
  146668. declare module BABYLON {
  146669. /**
  146670. * Class for building Constructive Solid Geometry
  146671. */
  146672. export class CSG {
  146673. private polygons;
  146674. /**
  146675. * The world matrix
  146676. */
  146677. matrix: Matrix;
  146678. /**
  146679. * Stores the position
  146680. */
  146681. position: Vector3;
  146682. /**
  146683. * Stores the rotation
  146684. */
  146685. rotation: Vector3;
  146686. /**
  146687. * Stores the rotation quaternion
  146688. */
  146689. rotationQuaternion: Nullable<Quaternion>;
  146690. /**
  146691. * Stores the scaling vector
  146692. */
  146693. scaling: Vector3;
  146694. /**
  146695. * Convert the Mesh to CSG
  146696. * @param mesh The Mesh to convert to CSG
  146697. * @returns A new CSG from the Mesh
  146698. */
  146699. static FromMesh(mesh: Mesh): CSG;
  146700. /**
  146701. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  146702. * @param polygons Polygons used to construct a CSG solid
  146703. */
  146704. private static FromPolygons;
  146705. /**
  146706. * Clones, or makes a deep copy, of the CSG
  146707. * @returns A new CSG
  146708. */
  146709. clone(): CSG;
  146710. /**
  146711. * Unions this CSG with another CSG
  146712. * @param csg The CSG to union against this CSG
  146713. * @returns The unioned CSG
  146714. */
  146715. union(csg: CSG): CSG;
  146716. /**
  146717. * Unions this CSG with another CSG in place
  146718. * @param csg The CSG to union against this CSG
  146719. */
  146720. unionInPlace(csg: CSG): void;
  146721. /**
  146722. * Subtracts this CSG with another CSG
  146723. * @param csg The CSG to subtract against this CSG
  146724. * @returns A new CSG
  146725. */
  146726. subtract(csg: CSG): CSG;
  146727. /**
  146728. * Subtracts this CSG with another CSG in place
  146729. * @param csg The CSG to subtact against this CSG
  146730. */
  146731. subtractInPlace(csg: CSG): void;
  146732. /**
  146733. * Intersect this CSG with another CSG
  146734. * @param csg The CSG to intersect against this CSG
  146735. * @returns A new CSG
  146736. */
  146737. intersect(csg: CSG): CSG;
  146738. /**
  146739. * Intersects this CSG with another CSG in place
  146740. * @param csg The CSG to intersect against this CSG
  146741. */
  146742. intersectInPlace(csg: CSG): void;
  146743. /**
  146744. * Return a new CSG solid with solid and empty space switched. This solid is
  146745. * not modified.
  146746. * @returns A new CSG solid with solid and empty space switched
  146747. */
  146748. inverse(): CSG;
  146749. /**
  146750. * Inverses the CSG in place
  146751. */
  146752. inverseInPlace(): void;
  146753. /**
  146754. * This is used to keep meshes transformations so they can be restored
  146755. * when we build back a Babylon Mesh
  146756. * NB : All CSG operations are performed in world coordinates
  146757. * @param csg The CSG to copy the transform attributes from
  146758. * @returns This CSG
  146759. */
  146760. copyTransformAttributes(csg: CSG): CSG;
  146761. /**
  146762. * Build Raw mesh from CSG
  146763. * Coordinates here are in world space
  146764. * @param name The name of the mesh geometry
  146765. * @param scene The Scene
  146766. * @param keepSubMeshes Specifies if the submeshes should be kept
  146767. * @returns A new Mesh
  146768. */
  146769. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146770. /**
  146771. * Build Mesh from CSG taking material and transforms into account
  146772. * @param name The name of the Mesh
  146773. * @param material The material of the Mesh
  146774. * @param scene The Scene
  146775. * @param keepSubMeshes Specifies if submeshes should be kept
  146776. * @returns The new Mesh
  146777. */
  146778. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146779. }
  146780. }
  146781. declare module BABYLON {
  146782. /**
  146783. * Class used to create a trail following a mesh
  146784. */
  146785. export class TrailMesh extends Mesh {
  146786. private _generator;
  146787. private _autoStart;
  146788. private _running;
  146789. private _diameter;
  146790. private _length;
  146791. private _sectionPolygonPointsCount;
  146792. private _sectionVectors;
  146793. private _sectionNormalVectors;
  146794. private _beforeRenderObserver;
  146795. /**
  146796. * @constructor
  146797. * @param name The value used by scene.getMeshByName() to do a lookup.
  146798. * @param generator The mesh or transform node to generate a trail.
  146799. * @param scene The scene to add this mesh to.
  146800. * @param diameter Diameter of trailing mesh. Default is 1.
  146801. * @param length Length of trailing mesh. Default is 60.
  146802. * @param autoStart Automatically start trailing mesh. Default true.
  146803. */
  146804. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  146805. /**
  146806. * "TrailMesh"
  146807. * @returns "TrailMesh"
  146808. */
  146809. getClassName(): string;
  146810. private _createMesh;
  146811. /**
  146812. * Start trailing mesh.
  146813. */
  146814. start(): void;
  146815. /**
  146816. * Stop trailing mesh.
  146817. */
  146818. stop(): void;
  146819. /**
  146820. * Update trailing mesh geometry.
  146821. */
  146822. update(): void;
  146823. /**
  146824. * Returns a new TrailMesh object.
  146825. * @param name is a string, the name given to the new mesh
  146826. * @param newGenerator use new generator object for cloned trail mesh
  146827. * @returns a new mesh
  146828. */
  146829. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  146830. /**
  146831. * Serializes this trail mesh
  146832. * @param serializationObject object to write serialization to
  146833. */
  146834. serialize(serializationObject: any): void;
  146835. /**
  146836. * Parses a serialized trail mesh
  146837. * @param parsedMesh the serialized mesh
  146838. * @param scene the scene to create the trail mesh in
  146839. * @returns the created trail mesh
  146840. */
  146841. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  146842. }
  146843. }
  146844. declare module BABYLON {
  146845. /**
  146846. * Class containing static functions to help procedurally build meshes
  146847. */
  146848. export class TiledBoxBuilder {
  146849. /**
  146850. * Creates a box mesh
  146851. * 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)
  146852. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146856. * @param name defines the name of the mesh
  146857. * @param options defines the options used to create the mesh
  146858. * @param scene defines the hosting scene
  146859. * @returns the box mesh
  146860. */
  146861. static CreateTiledBox(name: string, options: {
  146862. pattern?: number;
  146863. width?: number;
  146864. height?: number;
  146865. depth?: number;
  146866. tileSize?: number;
  146867. tileWidth?: number;
  146868. tileHeight?: number;
  146869. alignHorizontal?: number;
  146870. alignVertical?: number;
  146871. faceUV?: Vector4[];
  146872. faceColors?: Color4[];
  146873. sideOrientation?: number;
  146874. updatable?: boolean;
  146875. }, scene?: Nullable<Scene>): Mesh;
  146876. }
  146877. }
  146878. declare module BABYLON {
  146879. /**
  146880. * Class containing static functions to help procedurally build meshes
  146881. */
  146882. export class TorusKnotBuilder {
  146883. /**
  146884. * Creates a torus knot mesh
  146885. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146886. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146887. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146888. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146892. * @param name defines the name of the mesh
  146893. * @param options defines the options used to create the mesh
  146894. * @param scene defines the hosting scene
  146895. * @returns the torus knot mesh
  146896. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146897. */
  146898. static CreateTorusKnot(name: string, options: {
  146899. radius?: number;
  146900. tube?: number;
  146901. radialSegments?: number;
  146902. tubularSegments?: number;
  146903. p?: number;
  146904. q?: number;
  146905. updatable?: boolean;
  146906. sideOrientation?: number;
  146907. frontUVs?: Vector4;
  146908. backUVs?: Vector4;
  146909. }, scene: any): Mesh;
  146910. }
  146911. }
  146912. declare module BABYLON {
  146913. /**
  146914. * Polygon
  146915. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  146916. */
  146917. export class Polygon {
  146918. /**
  146919. * Creates a rectangle
  146920. * @param xmin bottom X coord
  146921. * @param ymin bottom Y coord
  146922. * @param xmax top X coord
  146923. * @param ymax top Y coord
  146924. * @returns points that make the resulting rectation
  146925. */
  146926. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  146927. /**
  146928. * Creates a circle
  146929. * @param radius radius of circle
  146930. * @param cx scale in x
  146931. * @param cy scale in y
  146932. * @param numberOfSides number of sides that make up the circle
  146933. * @returns points that make the resulting circle
  146934. */
  146935. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  146936. /**
  146937. * Creates a polygon from input string
  146938. * @param input Input polygon data
  146939. * @returns the parsed points
  146940. */
  146941. static Parse(input: string): Vector2[];
  146942. /**
  146943. * Starts building a polygon from x and y coordinates
  146944. * @param x x coordinate
  146945. * @param y y coordinate
  146946. * @returns the started path2
  146947. */
  146948. static StartingAt(x: number, y: number): Path2;
  146949. }
  146950. /**
  146951. * Builds a polygon
  146952. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  146953. */
  146954. export class PolygonMeshBuilder {
  146955. private _points;
  146956. private _outlinepoints;
  146957. private _holes;
  146958. private _name;
  146959. private _scene;
  146960. private _epoints;
  146961. private _eholes;
  146962. private _addToepoint;
  146963. /**
  146964. * Babylon reference to the earcut plugin.
  146965. */
  146966. bjsEarcut: any;
  146967. /**
  146968. * Creates a PolygonMeshBuilder
  146969. * @param name name of the builder
  146970. * @param contours Path of the polygon
  146971. * @param scene scene to add to when creating the mesh
  146972. * @param earcutInjection can be used to inject your own earcut reference
  146973. */
  146974. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  146975. /**
  146976. * Adds a whole within the polygon
  146977. * @param hole Array of points defining the hole
  146978. * @returns this
  146979. */
  146980. addHole(hole: Vector2[]): PolygonMeshBuilder;
  146981. /**
  146982. * Creates the polygon
  146983. * @param updatable If the mesh should be updatable
  146984. * @param depth The depth of the mesh created
  146985. * @returns the created mesh
  146986. */
  146987. build(updatable?: boolean, depth?: number): Mesh;
  146988. /**
  146989. * Creates the polygon
  146990. * @param depth The depth of the mesh created
  146991. * @returns the created VertexData
  146992. */
  146993. buildVertexData(depth?: number): VertexData;
  146994. /**
  146995. * Adds a side to the polygon
  146996. * @param positions points that make the polygon
  146997. * @param normals normals of the polygon
  146998. * @param uvs uvs of the polygon
  146999. * @param indices indices of the polygon
  147000. * @param bounds bounds of the polygon
  147001. * @param points points of the polygon
  147002. * @param depth depth of the polygon
  147003. * @param flip flip of the polygon
  147004. */
  147005. private addSide;
  147006. }
  147007. }
  147008. declare module BABYLON {
  147009. /**
  147010. * Class containing static functions to help procedurally build meshes
  147011. */
  147012. export class PolygonBuilder {
  147013. /**
  147014. * Creates a polygon mesh
  147015. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147016. * * 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
  147017. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147020. * * Remember you can only change the shape positions, not their number when updating a polygon
  147021. * @param name defines the name of the mesh
  147022. * @param options defines the options used to create the mesh
  147023. * @param scene defines the hosting scene
  147024. * @param earcutInjection can be used to inject your own earcut reference
  147025. * @returns the polygon mesh
  147026. */
  147027. static CreatePolygon(name: string, options: {
  147028. shape: Vector3[];
  147029. holes?: Vector3[][];
  147030. depth?: number;
  147031. faceUV?: Vector4[];
  147032. faceColors?: Color4[];
  147033. updatable?: boolean;
  147034. sideOrientation?: number;
  147035. frontUVs?: Vector4;
  147036. backUVs?: Vector4;
  147037. wrap?: boolean;
  147038. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147039. /**
  147040. * Creates an extruded polygon mesh, with depth in the Y direction.
  147041. * * 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)
  147042. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147043. * @param name defines the name of the mesh
  147044. * @param options defines the options used to create the mesh
  147045. * @param scene defines the hosting scene
  147046. * @param earcutInjection can be used to inject your own earcut reference
  147047. * @returns the polygon mesh
  147048. */
  147049. static ExtrudePolygon(name: string, options: {
  147050. shape: Vector3[];
  147051. holes?: Vector3[][];
  147052. depth?: number;
  147053. faceUV?: Vector4[];
  147054. faceColors?: Color4[];
  147055. updatable?: boolean;
  147056. sideOrientation?: number;
  147057. frontUVs?: Vector4;
  147058. backUVs?: Vector4;
  147059. wrap?: boolean;
  147060. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147061. }
  147062. }
  147063. declare module BABYLON {
  147064. /**
  147065. * Class containing static functions to help procedurally build meshes
  147066. */
  147067. export class LatheBuilder {
  147068. /**
  147069. * Creates lathe mesh.
  147070. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147071. * * 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
  147072. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147073. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147074. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147075. * * 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
  147076. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147077. * * 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
  147078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147082. * @param name defines the name of the mesh
  147083. * @param options defines the options used to create the mesh
  147084. * @param scene defines the hosting scene
  147085. * @returns the lathe mesh
  147086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147087. */
  147088. static CreateLathe(name: string, options: {
  147089. shape: Vector3[];
  147090. radius?: number;
  147091. tessellation?: number;
  147092. clip?: number;
  147093. arc?: number;
  147094. closed?: boolean;
  147095. updatable?: boolean;
  147096. sideOrientation?: number;
  147097. frontUVs?: Vector4;
  147098. backUVs?: Vector4;
  147099. cap?: number;
  147100. invertUV?: boolean;
  147101. }, scene?: Nullable<Scene>): Mesh;
  147102. }
  147103. }
  147104. declare module BABYLON {
  147105. /**
  147106. * Class containing static functions to help procedurally build meshes
  147107. */
  147108. export class TiledPlaneBuilder {
  147109. /**
  147110. * Creates a tiled plane mesh
  147111. * * The parameter `pattern` will, depending on value, do nothing or
  147112. * * * flip (reflect about central vertical) alternate tiles across and up
  147113. * * * flip every tile on alternate rows
  147114. * * * rotate (180 degs) alternate tiles across and up
  147115. * * * rotate every tile on alternate rows
  147116. * * * flip and rotate alternate tiles across and up
  147117. * * * flip and rotate every tile on alternate rows
  147118. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  147119. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  147120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147122. * * 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)
  147123. * * 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)
  147124. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147125. * @param name defines the name of the mesh
  147126. * @param options defines the options used to create the mesh
  147127. * @param scene defines the hosting scene
  147128. * @returns the box mesh
  147129. */
  147130. static CreateTiledPlane(name: string, options: {
  147131. pattern?: number;
  147132. tileSize?: number;
  147133. tileWidth?: number;
  147134. tileHeight?: number;
  147135. size?: number;
  147136. width?: number;
  147137. height?: number;
  147138. alignHorizontal?: number;
  147139. alignVertical?: number;
  147140. sideOrientation?: number;
  147141. frontUVs?: Vector4;
  147142. backUVs?: Vector4;
  147143. updatable?: boolean;
  147144. }, scene?: Nullable<Scene>): Mesh;
  147145. }
  147146. }
  147147. declare module BABYLON {
  147148. /**
  147149. * Class containing static functions to help procedurally build meshes
  147150. */
  147151. export class TubeBuilder {
  147152. /**
  147153. * Creates a tube mesh.
  147154. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147155. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147156. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147157. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147158. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147159. * * 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)
  147160. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147161. * * 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
  147162. * * 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
  147163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147165. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147167. * @param name defines the name of the mesh
  147168. * @param options defines the options used to create the mesh
  147169. * @param scene defines the hosting scene
  147170. * @returns the tube mesh
  147171. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147172. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147173. */
  147174. static CreateTube(name: string, options: {
  147175. path: Vector3[];
  147176. radius?: number;
  147177. tessellation?: number;
  147178. radiusFunction?: {
  147179. (i: number, distance: number): number;
  147180. };
  147181. cap?: number;
  147182. arc?: number;
  147183. updatable?: boolean;
  147184. sideOrientation?: number;
  147185. frontUVs?: Vector4;
  147186. backUVs?: Vector4;
  147187. instance?: Mesh;
  147188. invertUV?: boolean;
  147189. }, scene?: Nullable<Scene>): Mesh;
  147190. }
  147191. }
  147192. declare module BABYLON {
  147193. /**
  147194. * Class containing static functions to help procedurally build meshes
  147195. */
  147196. export class IcoSphereBuilder {
  147197. /**
  147198. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147199. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147200. * * 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`)
  147201. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147202. * * 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
  147203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147206. * @param name defines the name of the mesh
  147207. * @param options defines the options used to create the mesh
  147208. * @param scene defines the hosting scene
  147209. * @returns the icosahedron mesh
  147210. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147211. */
  147212. static CreateIcoSphere(name: string, options: {
  147213. radius?: number;
  147214. radiusX?: number;
  147215. radiusY?: number;
  147216. radiusZ?: number;
  147217. flat?: boolean;
  147218. subdivisions?: number;
  147219. sideOrientation?: number;
  147220. frontUVs?: Vector4;
  147221. backUVs?: Vector4;
  147222. updatable?: boolean;
  147223. }, scene?: Nullable<Scene>): Mesh;
  147224. }
  147225. }
  147226. declare module BABYLON {
  147227. /**
  147228. * Class containing static functions to help procedurally build meshes
  147229. */
  147230. export class DecalBuilder {
  147231. /**
  147232. * Creates a decal mesh.
  147233. * 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
  147234. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147235. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147236. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147237. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147238. * @param name defines the name of the mesh
  147239. * @param sourceMesh defines the mesh where the decal must be applied
  147240. * @param options defines the options used to create the mesh
  147241. * @param scene defines the hosting scene
  147242. * @returns the decal mesh
  147243. * @see https://doc.babylonjs.com/how_to/decals
  147244. */
  147245. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147246. position?: Vector3;
  147247. normal?: Vector3;
  147248. size?: Vector3;
  147249. angle?: number;
  147250. }): Mesh;
  147251. }
  147252. }
  147253. declare module BABYLON {
  147254. /**
  147255. * Class containing static functions to help procedurally build meshes
  147256. */
  147257. export class MeshBuilder {
  147258. /**
  147259. * Creates a box mesh
  147260. * * The parameter `size` sets the size (float) of each box side (default 1)
  147261. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  147262. * * 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)
  147263. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147265. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147267. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147268. * @param name defines the name of the mesh
  147269. * @param options defines the options used to create the mesh
  147270. * @param scene defines the hosting scene
  147271. * @returns the box mesh
  147272. */
  147273. static CreateBox(name: string, options: {
  147274. size?: number;
  147275. width?: number;
  147276. height?: number;
  147277. depth?: number;
  147278. faceUV?: Vector4[];
  147279. faceColors?: Color4[];
  147280. sideOrientation?: number;
  147281. frontUVs?: Vector4;
  147282. backUVs?: Vector4;
  147283. wrap?: boolean;
  147284. topBaseAt?: number;
  147285. bottomBaseAt?: number;
  147286. updatable?: boolean;
  147287. }, scene?: Nullable<Scene>): Mesh;
  147288. /**
  147289. * Creates a tiled box mesh
  147290. * * faceTiles sets the pattern, tile size and number of tiles for a face
  147291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147292. * @param name defines the name of the mesh
  147293. * @param options defines the options used to create the mesh
  147294. * @param scene defines the hosting scene
  147295. * @returns the tiled box mesh
  147296. */
  147297. static CreateTiledBox(name: string, options: {
  147298. pattern?: number;
  147299. size?: number;
  147300. width?: number;
  147301. height?: number;
  147302. depth: number;
  147303. tileSize?: number;
  147304. tileWidth?: number;
  147305. tileHeight?: number;
  147306. faceUV?: Vector4[];
  147307. faceColors?: Color4[];
  147308. alignHorizontal?: number;
  147309. alignVertical?: number;
  147310. sideOrientation?: number;
  147311. updatable?: boolean;
  147312. }, scene?: Nullable<Scene>): Mesh;
  147313. /**
  147314. * Creates a sphere mesh
  147315. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  147316. * * 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`)
  147317. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  147318. * * 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
  147319. * * 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)
  147320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147321. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147323. * @param name defines the name of the mesh
  147324. * @param options defines the options used to create the mesh
  147325. * @param scene defines the hosting scene
  147326. * @returns the sphere mesh
  147327. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  147328. */
  147329. static CreateSphere(name: string, options: {
  147330. segments?: number;
  147331. diameter?: number;
  147332. diameterX?: number;
  147333. diameterY?: number;
  147334. diameterZ?: number;
  147335. arc?: number;
  147336. slice?: number;
  147337. sideOrientation?: number;
  147338. frontUVs?: Vector4;
  147339. backUVs?: Vector4;
  147340. updatable?: boolean;
  147341. }, scene?: Nullable<Scene>): Mesh;
  147342. /**
  147343. * Creates a plane polygonal mesh. By default, this is a disc
  147344. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  147345. * * 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
  147346. * * 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
  147347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147350. * @param name defines the name of the mesh
  147351. * @param options defines the options used to create the mesh
  147352. * @param scene defines the hosting scene
  147353. * @returns the plane polygonal mesh
  147354. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  147355. */
  147356. static CreateDisc(name: string, options: {
  147357. radius?: number;
  147358. tessellation?: number;
  147359. arc?: number;
  147360. updatable?: boolean;
  147361. sideOrientation?: number;
  147362. frontUVs?: Vector4;
  147363. backUVs?: Vector4;
  147364. }, scene?: Nullable<Scene>): Mesh;
  147365. /**
  147366. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147367. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147368. * * 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`)
  147369. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147370. * * 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
  147371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147374. * @param name defines the name of the mesh
  147375. * @param options defines the options used to create the mesh
  147376. * @param scene defines the hosting scene
  147377. * @returns the icosahedron mesh
  147378. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147379. */
  147380. static CreateIcoSphere(name: string, options: {
  147381. radius?: number;
  147382. radiusX?: number;
  147383. radiusY?: number;
  147384. radiusZ?: number;
  147385. flat?: boolean;
  147386. subdivisions?: number;
  147387. sideOrientation?: number;
  147388. frontUVs?: Vector4;
  147389. backUVs?: Vector4;
  147390. updatable?: boolean;
  147391. }, scene?: Nullable<Scene>): Mesh;
  147392. /**
  147393. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147394. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  147395. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  147396. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  147397. * * 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
  147398. * * 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
  147399. * * 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
  147400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147402. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147403. * * 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
  147404. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  147405. * * 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
  147406. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  147407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147408. * @param name defines the name of the mesh
  147409. * @param options defines the options used to create the mesh
  147410. * @param scene defines the hosting scene
  147411. * @returns the ribbon mesh
  147412. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  147413. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147414. */
  147415. static CreateRibbon(name: string, options: {
  147416. pathArray: Vector3[][];
  147417. closeArray?: boolean;
  147418. closePath?: boolean;
  147419. offset?: number;
  147420. updatable?: boolean;
  147421. sideOrientation?: number;
  147422. frontUVs?: Vector4;
  147423. backUVs?: Vector4;
  147424. instance?: Mesh;
  147425. invertUV?: boolean;
  147426. uvs?: Vector2[];
  147427. colors?: Color4[];
  147428. }, scene?: Nullable<Scene>): Mesh;
  147429. /**
  147430. * Creates a cylinder or a cone mesh
  147431. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  147432. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  147433. * * 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.
  147434. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  147435. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  147436. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  147437. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  147438. * * 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).
  147439. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  147440. * * 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).
  147441. * * 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
  147442. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  147443. * * 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
  147444. * * 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.
  147445. * * If `enclose` is false, a ring surface is one element.
  147446. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  147447. * * 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
  147448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147451. * @param name defines the name of the mesh
  147452. * @param options defines the options used to create the mesh
  147453. * @param scene defines the hosting scene
  147454. * @returns the cylinder mesh
  147455. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  147456. */
  147457. static CreateCylinder(name: string, options: {
  147458. height?: number;
  147459. diameterTop?: number;
  147460. diameterBottom?: number;
  147461. diameter?: number;
  147462. tessellation?: number;
  147463. subdivisions?: number;
  147464. arc?: number;
  147465. faceColors?: Color4[];
  147466. faceUV?: Vector4[];
  147467. updatable?: boolean;
  147468. hasRings?: boolean;
  147469. enclose?: boolean;
  147470. cap?: number;
  147471. sideOrientation?: number;
  147472. frontUVs?: Vector4;
  147473. backUVs?: Vector4;
  147474. }, scene?: Nullable<Scene>): Mesh;
  147475. /**
  147476. * Creates a torus mesh
  147477. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  147478. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  147479. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  147480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147483. * @param name defines the name of the mesh
  147484. * @param options defines the options used to create the mesh
  147485. * @param scene defines the hosting scene
  147486. * @returns the torus mesh
  147487. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  147488. */
  147489. static CreateTorus(name: string, options: {
  147490. diameter?: number;
  147491. thickness?: number;
  147492. tessellation?: number;
  147493. updatable?: boolean;
  147494. sideOrientation?: number;
  147495. frontUVs?: Vector4;
  147496. backUVs?: Vector4;
  147497. }, scene?: Nullable<Scene>): Mesh;
  147498. /**
  147499. * Creates a torus knot mesh
  147500. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147501. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147502. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147503. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147507. * @param name defines the name of the mesh
  147508. * @param options defines the options used to create the mesh
  147509. * @param scene defines the hosting scene
  147510. * @returns the torus knot mesh
  147511. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147512. */
  147513. static CreateTorusKnot(name: string, options: {
  147514. radius?: number;
  147515. tube?: number;
  147516. radialSegments?: number;
  147517. tubularSegments?: number;
  147518. p?: number;
  147519. q?: number;
  147520. updatable?: boolean;
  147521. sideOrientation?: number;
  147522. frontUVs?: Vector4;
  147523. backUVs?: Vector4;
  147524. }, scene?: Nullable<Scene>): Mesh;
  147525. /**
  147526. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  147527. * * 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
  147528. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  147529. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  147530. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  147531. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  147532. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  147533. * * 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
  147534. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  147535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  147537. * @param name defines the name of the new line system
  147538. * @param options defines the options used to create the line system
  147539. * @param scene defines the hosting scene
  147540. * @returns a new line system mesh
  147541. */
  147542. static CreateLineSystem(name: string, options: {
  147543. lines: Vector3[][];
  147544. updatable?: boolean;
  147545. instance?: Nullable<LinesMesh>;
  147546. colors?: Nullable<Color4[][]>;
  147547. useVertexAlpha?: boolean;
  147548. }, scene: Nullable<Scene>): LinesMesh;
  147549. /**
  147550. * Creates a line mesh
  147551. * 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
  147552. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147553. * * The parameter `points` is an array successive Vector3
  147554. * * 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
  147555. * * The optional parameter `colors` is an array of successive Color4, one per line point
  147556. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  147557. * * When updating an instance, remember that only point positions can change, not the number of points
  147558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  147560. * @param name defines the name of the new line system
  147561. * @param options defines the options used to create the line system
  147562. * @param scene defines the hosting scene
  147563. * @returns a new line mesh
  147564. */
  147565. static CreateLines(name: string, options: {
  147566. points: Vector3[];
  147567. updatable?: boolean;
  147568. instance?: Nullable<LinesMesh>;
  147569. colors?: Color4[];
  147570. useVertexAlpha?: boolean;
  147571. }, scene?: Nullable<Scene>): LinesMesh;
  147572. /**
  147573. * Creates a dashed line mesh
  147574. * * 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
  147575. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147576. * * The parameter `points` is an array successive Vector3
  147577. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  147578. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  147579. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  147580. * * 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
  147581. * * When updating an instance, remember that only point positions can change, not the number of points
  147582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147583. * @param name defines the name of the mesh
  147584. * @param options defines the options used to create the mesh
  147585. * @param scene defines the hosting scene
  147586. * @returns the dashed line mesh
  147587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  147588. */
  147589. static CreateDashedLines(name: string, options: {
  147590. points: Vector3[];
  147591. dashSize?: number;
  147592. gapSize?: number;
  147593. dashNb?: number;
  147594. updatable?: boolean;
  147595. instance?: LinesMesh;
  147596. }, scene?: Nullable<Scene>): LinesMesh;
  147597. /**
  147598. * 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.
  147599. * * 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.
  147600. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147601. * * 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.
  147602. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  147603. * * 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
  147604. * * 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
  147605. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  147606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147608. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  147609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147610. * @param name defines the name of the mesh
  147611. * @param options defines the options used to create the mesh
  147612. * @param scene defines the hosting scene
  147613. * @returns the extruded shape mesh
  147614. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147616. */
  147617. static ExtrudeShape(name: string, options: {
  147618. shape: Vector3[];
  147619. path: Vector3[];
  147620. scale?: number;
  147621. rotation?: number;
  147622. cap?: number;
  147623. updatable?: boolean;
  147624. sideOrientation?: number;
  147625. frontUVs?: Vector4;
  147626. backUVs?: Vector4;
  147627. instance?: Mesh;
  147628. invertUV?: boolean;
  147629. }, scene?: Nullable<Scene>): Mesh;
  147630. /**
  147631. * Creates an custom extruded shape mesh.
  147632. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  147633. * * 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.
  147634. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147635. * * 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
  147636. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  147637. * * 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
  147638. * * It must returns a float value that will be the scale value applied to the shape on each path point
  147639. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  147640. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  147641. * * 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
  147642. * * 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
  147643. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  147644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147646. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147648. * @param name defines the name of the mesh
  147649. * @param options defines the options used to create the mesh
  147650. * @param scene defines the hosting scene
  147651. * @returns the custom extruded shape mesh
  147652. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  147653. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147655. */
  147656. static ExtrudeShapeCustom(name: string, options: {
  147657. shape: Vector3[];
  147658. path: Vector3[];
  147659. scaleFunction?: any;
  147660. rotationFunction?: any;
  147661. ribbonCloseArray?: boolean;
  147662. ribbonClosePath?: boolean;
  147663. cap?: number;
  147664. updatable?: boolean;
  147665. sideOrientation?: number;
  147666. frontUVs?: Vector4;
  147667. backUVs?: Vector4;
  147668. instance?: Mesh;
  147669. invertUV?: boolean;
  147670. }, scene?: Nullable<Scene>): Mesh;
  147671. /**
  147672. * Creates lathe mesh.
  147673. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147674. * * 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
  147675. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147676. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147677. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147678. * * 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
  147679. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147680. * * 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
  147681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147683. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147685. * @param name defines the name of the mesh
  147686. * @param options defines the options used to create the mesh
  147687. * @param scene defines the hosting scene
  147688. * @returns the lathe mesh
  147689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147690. */
  147691. static CreateLathe(name: string, options: {
  147692. shape: Vector3[];
  147693. radius?: number;
  147694. tessellation?: number;
  147695. clip?: number;
  147696. arc?: number;
  147697. closed?: boolean;
  147698. updatable?: boolean;
  147699. sideOrientation?: number;
  147700. frontUVs?: Vector4;
  147701. backUVs?: Vector4;
  147702. cap?: number;
  147703. invertUV?: boolean;
  147704. }, scene?: Nullable<Scene>): Mesh;
  147705. /**
  147706. * Creates a tiled plane mesh
  147707. * * You can set a limited pattern arrangement with the tiles
  147708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147711. * @param name defines the name of the mesh
  147712. * @param options defines the options used to create the mesh
  147713. * @param scene defines the hosting scene
  147714. * @returns the plane mesh
  147715. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147716. */
  147717. static CreateTiledPlane(name: string, options: {
  147718. pattern?: number;
  147719. tileSize?: number;
  147720. tileWidth?: number;
  147721. tileHeight?: number;
  147722. size?: number;
  147723. width?: number;
  147724. height?: number;
  147725. alignHorizontal?: number;
  147726. alignVertical?: number;
  147727. sideOrientation?: number;
  147728. frontUVs?: Vector4;
  147729. backUVs?: Vector4;
  147730. updatable?: boolean;
  147731. }, scene?: Nullable<Scene>): Mesh;
  147732. /**
  147733. * Creates a plane mesh
  147734. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  147735. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  147736. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  147737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147740. * @param name defines the name of the mesh
  147741. * @param options defines the options used to create the mesh
  147742. * @param scene defines the hosting scene
  147743. * @returns the plane mesh
  147744. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147745. */
  147746. static CreatePlane(name: string, options: {
  147747. size?: number;
  147748. width?: number;
  147749. height?: number;
  147750. sideOrientation?: number;
  147751. frontUVs?: Vector4;
  147752. backUVs?: Vector4;
  147753. updatable?: boolean;
  147754. sourcePlane?: Plane;
  147755. }, scene?: Nullable<Scene>): Mesh;
  147756. /**
  147757. * Creates a ground mesh
  147758. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  147759. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  147760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147761. * @param name defines the name of the mesh
  147762. * @param options defines the options used to create the mesh
  147763. * @param scene defines the hosting scene
  147764. * @returns the ground mesh
  147765. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  147766. */
  147767. static CreateGround(name: string, options: {
  147768. width?: number;
  147769. height?: number;
  147770. subdivisions?: number;
  147771. subdivisionsX?: number;
  147772. subdivisionsY?: number;
  147773. updatable?: boolean;
  147774. }, scene?: Nullable<Scene>): Mesh;
  147775. /**
  147776. * Creates a tiled ground mesh
  147777. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  147778. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  147779. * * 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
  147780. * * 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
  147781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147782. * @param name defines the name of the mesh
  147783. * @param options defines the options used to create the mesh
  147784. * @param scene defines the hosting scene
  147785. * @returns the tiled ground mesh
  147786. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  147787. */
  147788. static CreateTiledGround(name: string, options: {
  147789. xmin: number;
  147790. zmin: number;
  147791. xmax: number;
  147792. zmax: number;
  147793. subdivisions?: {
  147794. w: number;
  147795. h: number;
  147796. };
  147797. precision?: {
  147798. w: number;
  147799. h: number;
  147800. };
  147801. updatable?: boolean;
  147802. }, scene?: Nullable<Scene>): Mesh;
  147803. /**
  147804. * Creates a ground mesh from a height map
  147805. * * The parameter `url` sets the URL of the height map image resource.
  147806. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  147807. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  147808. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  147809. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  147810. * * 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.
  147811. * * 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).
  147812. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  147813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147814. * @param name defines the name of the mesh
  147815. * @param url defines the url to the height map
  147816. * @param options defines the options used to create the mesh
  147817. * @param scene defines the hosting scene
  147818. * @returns the ground mesh
  147819. * @see https://doc.babylonjs.com/babylon101/height_map
  147820. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  147821. */
  147822. static CreateGroundFromHeightMap(name: string, url: string, options: {
  147823. width?: number;
  147824. height?: number;
  147825. subdivisions?: number;
  147826. minHeight?: number;
  147827. maxHeight?: number;
  147828. colorFilter?: Color3;
  147829. alphaFilter?: number;
  147830. updatable?: boolean;
  147831. onReady?: (mesh: GroundMesh) => void;
  147832. }, scene?: Nullable<Scene>): GroundMesh;
  147833. /**
  147834. * Creates a polygon mesh
  147835. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147836. * * 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
  147837. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147840. * * Remember you can only change the shape positions, not their number when updating a polygon
  147841. * @param name defines the name of the mesh
  147842. * @param options defines the options used to create the mesh
  147843. * @param scene defines the hosting scene
  147844. * @param earcutInjection can be used to inject your own earcut reference
  147845. * @returns the polygon mesh
  147846. */
  147847. static CreatePolygon(name: string, options: {
  147848. shape: Vector3[];
  147849. holes?: Vector3[][];
  147850. depth?: number;
  147851. faceUV?: Vector4[];
  147852. faceColors?: Color4[];
  147853. updatable?: boolean;
  147854. sideOrientation?: number;
  147855. frontUVs?: Vector4;
  147856. backUVs?: Vector4;
  147857. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147858. /**
  147859. * Creates an extruded polygon mesh, with depth in the Y direction.
  147860. * * 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)
  147861. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147862. * @param name defines the name of the mesh
  147863. * @param options defines the options used to create the mesh
  147864. * @param scene defines the hosting scene
  147865. * @param earcutInjection can be used to inject your own earcut reference
  147866. * @returns the polygon mesh
  147867. */
  147868. static ExtrudePolygon(name: string, options: {
  147869. shape: Vector3[];
  147870. holes?: Vector3[][];
  147871. depth?: number;
  147872. faceUV?: Vector4[];
  147873. faceColors?: Color4[];
  147874. updatable?: boolean;
  147875. sideOrientation?: number;
  147876. frontUVs?: Vector4;
  147877. backUVs?: Vector4;
  147878. wrap?: boolean;
  147879. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147880. /**
  147881. * Creates a tube mesh.
  147882. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147883. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147884. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147885. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147886. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147887. * * 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)
  147888. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147889. * * 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
  147890. * * 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
  147891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147892. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147893. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147895. * @param name defines the name of the mesh
  147896. * @param options defines the options used to create the mesh
  147897. * @param scene defines the hosting scene
  147898. * @returns the tube mesh
  147899. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147900. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147901. */
  147902. static CreateTube(name: string, options: {
  147903. path: Vector3[];
  147904. radius?: number;
  147905. tessellation?: number;
  147906. radiusFunction?: {
  147907. (i: number, distance: number): number;
  147908. };
  147909. cap?: number;
  147910. arc?: number;
  147911. updatable?: boolean;
  147912. sideOrientation?: number;
  147913. frontUVs?: Vector4;
  147914. backUVs?: Vector4;
  147915. instance?: Mesh;
  147916. invertUV?: boolean;
  147917. }, scene?: Nullable<Scene>): Mesh;
  147918. /**
  147919. * Creates a polyhedron mesh
  147920. * * 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
  147921. * * The parameter `size` (positive float, default 1) sets the polygon size
  147922. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  147923. * * 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`
  147924. * * 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
  147925. * * 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)`)
  147926. * * 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
  147927. * * 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
  147928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147931. * @param name defines the name of the mesh
  147932. * @param options defines the options used to create the mesh
  147933. * @param scene defines the hosting scene
  147934. * @returns the polyhedron mesh
  147935. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  147936. */
  147937. static CreatePolyhedron(name: string, options: {
  147938. type?: number;
  147939. size?: number;
  147940. sizeX?: number;
  147941. sizeY?: number;
  147942. sizeZ?: number;
  147943. custom?: any;
  147944. faceUV?: Vector4[];
  147945. faceColors?: Color4[];
  147946. flat?: boolean;
  147947. updatable?: boolean;
  147948. sideOrientation?: number;
  147949. frontUVs?: Vector4;
  147950. backUVs?: Vector4;
  147951. }, scene?: Nullable<Scene>): Mesh;
  147952. /**
  147953. * Creates a decal mesh.
  147954. * 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
  147955. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147956. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147957. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147958. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147959. * @param name defines the name of the mesh
  147960. * @param sourceMesh defines the mesh where the decal must be applied
  147961. * @param options defines the options used to create the mesh
  147962. * @param scene defines the hosting scene
  147963. * @returns the decal mesh
  147964. * @see https://doc.babylonjs.com/how_to/decals
  147965. */
  147966. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147967. position?: Vector3;
  147968. normal?: Vector3;
  147969. size?: Vector3;
  147970. angle?: number;
  147971. }): Mesh;
  147972. /**
  147973. * Creates a Capsule Mesh
  147974. * @param name defines the name of the mesh.
  147975. * @param options the constructors options used to shape the mesh.
  147976. * @param scene defines the scene the mesh is scoped to.
  147977. * @returns the capsule mesh
  147978. * @see https://doc.babylonjs.com/how_to/capsule_shape
  147979. */
  147980. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  147981. }
  147982. }
  147983. declare module BABYLON {
  147984. /**
  147985. * A simplifier interface for future simplification implementations
  147986. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147987. */
  147988. export interface ISimplifier {
  147989. /**
  147990. * Simplification of a given mesh according to the given settings.
  147991. * Since this requires computation, it is assumed that the function runs async.
  147992. * @param settings The settings of the simplification, including quality and distance
  147993. * @param successCallback A callback that will be called after the mesh was simplified.
  147994. * @param errorCallback in case of an error, this callback will be called. optional.
  147995. */
  147996. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  147997. }
  147998. /**
  147999. * Expected simplification settings.
  148000. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  148001. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148002. */
  148003. export interface ISimplificationSettings {
  148004. /**
  148005. * Gets or sets the expected quality
  148006. */
  148007. quality: number;
  148008. /**
  148009. * Gets or sets the distance when this optimized version should be used
  148010. */
  148011. distance: number;
  148012. /**
  148013. * Gets an already optimized mesh
  148014. */
  148015. optimizeMesh?: boolean;
  148016. }
  148017. /**
  148018. * Class used to specify simplification options
  148019. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148020. */
  148021. export class SimplificationSettings implements ISimplificationSettings {
  148022. /** expected quality */
  148023. quality: number;
  148024. /** distance when this optimized version should be used */
  148025. distance: number;
  148026. /** already optimized mesh */
  148027. optimizeMesh?: boolean | undefined;
  148028. /**
  148029. * Creates a SimplificationSettings
  148030. * @param quality expected quality
  148031. * @param distance distance when this optimized version should be used
  148032. * @param optimizeMesh already optimized mesh
  148033. */
  148034. constructor(
  148035. /** expected quality */
  148036. quality: number,
  148037. /** distance when this optimized version should be used */
  148038. distance: number,
  148039. /** already optimized mesh */
  148040. optimizeMesh?: boolean | undefined);
  148041. }
  148042. /**
  148043. * Interface used to define a simplification task
  148044. */
  148045. export interface ISimplificationTask {
  148046. /**
  148047. * Array of settings
  148048. */
  148049. settings: Array<ISimplificationSettings>;
  148050. /**
  148051. * Simplification type
  148052. */
  148053. simplificationType: SimplificationType;
  148054. /**
  148055. * Mesh to simplify
  148056. */
  148057. mesh: Mesh;
  148058. /**
  148059. * Callback called on success
  148060. */
  148061. successCallback?: () => void;
  148062. /**
  148063. * Defines if parallel processing can be used
  148064. */
  148065. parallelProcessing: boolean;
  148066. }
  148067. /**
  148068. * Queue used to order the simplification tasks
  148069. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148070. */
  148071. export class SimplificationQueue {
  148072. private _simplificationArray;
  148073. /**
  148074. * Gets a boolean indicating that the process is still running
  148075. */
  148076. running: boolean;
  148077. /**
  148078. * Creates a new queue
  148079. */
  148080. constructor();
  148081. /**
  148082. * Adds a new simplification task
  148083. * @param task defines a task to add
  148084. */
  148085. addTask(task: ISimplificationTask): void;
  148086. /**
  148087. * Execute next task
  148088. */
  148089. executeNext(): void;
  148090. /**
  148091. * Execute a simplification task
  148092. * @param task defines the task to run
  148093. */
  148094. runSimplification(task: ISimplificationTask): void;
  148095. private getSimplifier;
  148096. }
  148097. /**
  148098. * The implemented types of simplification
  148099. * At the moment only Quadratic Error Decimation is implemented
  148100. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148101. */
  148102. export enum SimplificationType {
  148103. /** Quadratic error decimation */
  148104. QUADRATIC = 0
  148105. }
  148106. /**
  148107. * An implementation of the Quadratic Error simplification algorithm.
  148108. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  148109. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  148110. * @author RaananW
  148111. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148112. */
  148113. export class QuadraticErrorSimplification implements ISimplifier {
  148114. private _mesh;
  148115. private triangles;
  148116. private vertices;
  148117. private references;
  148118. private _reconstructedMesh;
  148119. /** Gets or sets the number pf sync interations */
  148120. syncIterations: number;
  148121. /** Gets or sets the aggressiveness of the simplifier */
  148122. aggressiveness: number;
  148123. /** Gets or sets the number of allowed iterations for decimation */
  148124. decimationIterations: number;
  148125. /** Gets or sets the espilon to use for bounding box computation */
  148126. boundingBoxEpsilon: number;
  148127. /**
  148128. * Creates a new QuadraticErrorSimplification
  148129. * @param _mesh defines the target mesh
  148130. */
  148131. constructor(_mesh: Mesh);
  148132. /**
  148133. * Simplification of a given mesh according to the given settings.
  148134. * Since this requires computation, it is assumed that the function runs async.
  148135. * @param settings The settings of the simplification, including quality and distance
  148136. * @param successCallback A callback that will be called after the mesh was simplified.
  148137. */
  148138. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  148139. private runDecimation;
  148140. private initWithMesh;
  148141. private init;
  148142. private reconstructMesh;
  148143. private initDecimatedMesh;
  148144. private isFlipped;
  148145. private updateTriangles;
  148146. private identifyBorder;
  148147. private updateMesh;
  148148. private vertexError;
  148149. private calculateError;
  148150. }
  148151. }
  148152. declare module BABYLON {
  148153. interface Scene {
  148154. /** @hidden (Backing field) */
  148155. _simplificationQueue: SimplificationQueue;
  148156. /**
  148157. * Gets or sets the simplification queue attached to the scene
  148158. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148159. */
  148160. simplificationQueue: SimplificationQueue;
  148161. }
  148162. interface Mesh {
  148163. /**
  148164. * Simplify the mesh according to the given array of settings.
  148165. * Function will return immediately and will simplify async
  148166. * @param settings a collection of simplification settings
  148167. * @param parallelProcessing should all levels calculate parallel or one after the other
  148168. * @param simplificationType the type of simplification to run
  148169. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  148170. * @returns the current mesh
  148171. */
  148172. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  148173. }
  148174. /**
  148175. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  148176. * created in a scene
  148177. */
  148178. export class SimplicationQueueSceneComponent implements ISceneComponent {
  148179. /**
  148180. * The component name helpfull to identify the component in the list of scene components.
  148181. */
  148182. readonly name: string;
  148183. /**
  148184. * The scene the component belongs to.
  148185. */
  148186. scene: Scene;
  148187. /**
  148188. * Creates a new instance of the component for the given scene
  148189. * @param scene Defines the scene to register the component in
  148190. */
  148191. constructor(scene: Scene);
  148192. /**
  148193. * Registers the component in a given scene
  148194. */
  148195. register(): void;
  148196. /**
  148197. * Rebuilds the elements related to this component in case of
  148198. * context lost for instance.
  148199. */
  148200. rebuild(): void;
  148201. /**
  148202. * Disposes the component and the associated ressources
  148203. */
  148204. dispose(): void;
  148205. private _beforeCameraUpdate;
  148206. }
  148207. }
  148208. declare module BABYLON {
  148209. interface Mesh {
  148210. /**
  148211. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  148212. */
  148213. thinInstanceEnablePicking: boolean;
  148214. /**
  148215. * Creates a new thin instance
  148216. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  148217. * @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
  148218. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  148219. */
  148220. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  148221. /**
  148222. * Adds the transformation (matrix) of the current mesh as a thin instance
  148223. * @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
  148224. * @returns the thin instance index number
  148225. */
  148226. thinInstanceAddSelf(refresh: boolean): number;
  148227. /**
  148228. * Registers a custom attribute to be used with thin instances
  148229. * @param kind name of the attribute
  148230. * @param stride size in floats of the attribute
  148231. */
  148232. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  148233. /**
  148234. * Sets the matrix of a thin instance
  148235. * @param index index of the thin instance
  148236. * @param matrix matrix to set
  148237. * @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
  148238. */
  148239. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  148240. /**
  148241. * Sets the value of a custom attribute for a thin instance
  148242. * @param kind name of the attribute
  148243. * @param index index of the thin instance
  148244. * @param value value to set
  148245. * @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
  148246. */
  148247. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  148248. /**
  148249. * 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.
  148250. */
  148251. thinInstanceCount: number;
  148252. /**
  148253. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  148254. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  148255. * @param buffer buffer to set
  148256. * @param stride size in floats of each value of the buffer
  148257. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  148258. */
  148259. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  148260. /**
  148261. * Gets the list of world matrices
  148262. * @return an array containing all the world matrices from the thin instances
  148263. */
  148264. thinInstanceGetWorldMatrices(): Matrix[];
  148265. /**
  148266. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  148267. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148268. */
  148269. thinInstanceBufferUpdated(kind: string): void;
  148270. /**
  148271. * Applies a partial update to a buffer directly on the GPU
  148272. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  148273. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148274. * @param data the data to set in the GPU buffer
  148275. * @param offset the offset in the GPU buffer where to update the data
  148276. */
  148277. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  148278. /**
  148279. * Refreshes the bounding info, taking into account all the thin instances defined
  148280. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  148281. */
  148282. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  148283. /** @hidden */
  148284. _thinInstanceInitializeUserStorage(): void;
  148285. /** @hidden */
  148286. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  148287. /** @hidden */
  148288. _userThinInstanceBuffersStorage: {
  148289. data: {
  148290. [key: string]: Float32Array;
  148291. };
  148292. sizes: {
  148293. [key: string]: number;
  148294. };
  148295. vertexBuffers: {
  148296. [key: string]: Nullable<VertexBuffer>;
  148297. };
  148298. strides: {
  148299. [key: string]: number;
  148300. };
  148301. };
  148302. }
  148303. }
  148304. declare module BABYLON {
  148305. /**
  148306. * Navigation plugin interface to add navigation constrained by a navigation mesh
  148307. */
  148308. export interface INavigationEnginePlugin {
  148309. /**
  148310. * plugin name
  148311. */
  148312. name: string;
  148313. /**
  148314. * Creates a navigation mesh
  148315. * @param meshes array of all the geometry used to compute the navigatio mesh
  148316. * @param parameters bunch of parameters used to filter geometry
  148317. */
  148318. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148319. /**
  148320. * Create a navigation mesh debug mesh
  148321. * @param scene is where the mesh will be added
  148322. * @returns debug display mesh
  148323. */
  148324. createDebugNavMesh(scene: Scene): Mesh;
  148325. /**
  148326. * Get a navigation mesh constrained position, closest to the parameter position
  148327. * @param position world position
  148328. * @returns the closest point to position constrained by the navigation mesh
  148329. */
  148330. getClosestPoint(position: Vector3): Vector3;
  148331. /**
  148332. * Get a navigation mesh constrained position, closest to the parameter position
  148333. * @param position world position
  148334. * @param result output the closest point to position constrained by the navigation mesh
  148335. */
  148336. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148337. /**
  148338. * Get a navigation mesh constrained position, within a particular radius
  148339. * @param position world position
  148340. * @param maxRadius the maximum distance to the constrained world position
  148341. * @returns the closest point to position constrained by the navigation mesh
  148342. */
  148343. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148344. /**
  148345. * Get a navigation mesh constrained position, within a particular radius
  148346. * @param position world position
  148347. * @param maxRadius the maximum distance to the constrained world position
  148348. * @param result output the closest point to position constrained by the navigation mesh
  148349. */
  148350. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148351. /**
  148352. * Compute the final position from a segment made of destination-position
  148353. * @param position world position
  148354. * @param destination world position
  148355. * @returns the resulting point along the navmesh
  148356. */
  148357. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148358. /**
  148359. * Compute the final position from a segment made of destination-position
  148360. * @param position world position
  148361. * @param destination world position
  148362. * @param result output the resulting point along the navmesh
  148363. */
  148364. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148365. /**
  148366. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148367. * @param start world position
  148368. * @param end world position
  148369. * @returns array containing world position composing the path
  148370. */
  148371. computePath(start: Vector3, end: Vector3): Vector3[];
  148372. /**
  148373. * If this plugin is supported
  148374. * @returns true if plugin is supported
  148375. */
  148376. isSupported(): boolean;
  148377. /**
  148378. * Create a new Crowd so you can add agents
  148379. * @param maxAgents the maximum agent count in the crowd
  148380. * @param maxAgentRadius the maximum radius an agent can have
  148381. * @param scene to attach the crowd to
  148382. * @returns the crowd you can add agents to
  148383. */
  148384. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148385. /**
  148386. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148387. * The queries will try to find a solution within those bounds
  148388. * default is (1,1,1)
  148389. * @param extent x,y,z value that define the extent around the queries point of reference
  148390. */
  148391. setDefaultQueryExtent(extent: Vector3): void;
  148392. /**
  148393. * Get the Bounding box extent specified by setDefaultQueryExtent
  148394. * @returns the box extent values
  148395. */
  148396. getDefaultQueryExtent(): Vector3;
  148397. /**
  148398. * build the navmesh from a previously saved state using getNavmeshData
  148399. * @param data the Uint8Array returned by getNavmeshData
  148400. */
  148401. buildFromNavmeshData(data: Uint8Array): void;
  148402. /**
  148403. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148404. * @returns data the Uint8Array that can be saved and reused
  148405. */
  148406. getNavmeshData(): Uint8Array;
  148407. /**
  148408. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148409. * @param result output the box extent values
  148410. */
  148411. getDefaultQueryExtentToRef(result: Vector3): void;
  148412. /**
  148413. * Release all resources
  148414. */
  148415. dispose(): void;
  148416. }
  148417. /**
  148418. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  148419. */
  148420. export interface ICrowd {
  148421. /**
  148422. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148423. * You can attach anything to that node. The node position is updated in the scene update tick.
  148424. * @param pos world position that will be constrained by the navigation mesh
  148425. * @param parameters agent parameters
  148426. * @param transform hooked to the agent that will be update by the scene
  148427. * @returns agent index
  148428. */
  148429. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148430. /**
  148431. * Returns the agent position in world space
  148432. * @param index agent index returned by addAgent
  148433. * @returns world space position
  148434. */
  148435. getAgentPosition(index: number): Vector3;
  148436. /**
  148437. * Gets the agent position result in world space
  148438. * @param index agent index returned by addAgent
  148439. * @param result output world space position
  148440. */
  148441. getAgentPositionToRef(index: number, result: Vector3): void;
  148442. /**
  148443. * Gets the agent velocity in world space
  148444. * @param index agent index returned by addAgent
  148445. * @returns world space velocity
  148446. */
  148447. getAgentVelocity(index: number): Vector3;
  148448. /**
  148449. * Gets the agent velocity result in world space
  148450. * @param index agent index returned by addAgent
  148451. * @param result output world space velocity
  148452. */
  148453. getAgentVelocityToRef(index: number, result: Vector3): void;
  148454. /**
  148455. * remove a particular agent previously created
  148456. * @param index agent index returned by addAgent
  148457. */
  148458. removeAgent(index: number): void;
  148459. /**
  148460. * get the list of all agents attached to this crowd
  148461. * @returns list of agent indices
  148462. */
  148463. getAgents(): number[];
  148464. /**
  148465. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148466. * @param deltaTime in seconds
  148467. */
  148468. update(deltaTime: number): void;
  148469. /**
  148470. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148471. * @param index agent index returned by addAgent
  148472. * @param destination targeted world position
  148473. */
  148474. agentGoto(index: number, destination: Vector3): void;
  148475. /**
  148476. * Teleport the agent to a new position
  148477. * @param index agent index returned by addAgent
  148478. * @param destination targeted world position
  148479. */
  148480. agentTeleport(index: number, destination: Vector3): void;
  148481. /**
  148482. * Update agent parameters
  148483. * @param index agent index returned by addAgent
  148484. * @param parameters agent parameters
  148485. */
  148486. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148487. /**
  148488. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148489. * The queries will try to find a solution within those bounds
  148490. * default is (1,1,1)
  148491. * @param extent x,y,z value that define the extent around the queries point of reference
  148492. */
  148493. setDefaultQueryExtent(extent: Vector3): void;
  148494. /**
  148495. * Get the Bounding box extent specified by setDefaultQueryExtent
  148496. * @returns the box extent values
  148497. */
  148498. getDefaultQueryExtent(): Vector3;
  148499. /**
  148500. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148501. * @param result output the box extent values
  148502. */
  148503. getDefaultQueryExtentToRef(result: Vector3): void;
  148504. /**
  148505. * Release all resources
  148506. */
  148507. dispose(): void;
  148508. }
  148509. /**
  148510. * Configures an agent
  148511. */
  148512. export interface IAgentParameters {
  148513. /**
  148514. * Agent radius. [Limit: >= 0]
  148515. */
  148516. radius: number;
  148517. /**
  148518. * Agent height. [Limit: > 0]
  148519. */
  148520. height: number;
  148521. /**
  148522. * Maximum allowed acceleration. [Limit: >= 0]
  148523. */
  148524. maxAcceleration: number;
  148525. /**
  148526. * Maximum allowed speed. [Limit: >= 0]
  148527. */
  148528. maxSpeed: number;
  148529. /**
  148530. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  148531. */
  148532. collisionQueryRange: number;
  148533. /**
  148534. * The path visibility optimization range. [Limit: > 0]
  148535. */
  148536. pathOptimizationRange: number;
  148537. /**
  148538. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  148539. */
  148540. separationWeight: number;
  148541. }
  148542. /**
  148543. * Configures the navigation mesh creation
  148544. */
  148545. export interface INavMeshParameters {
  148546. /**
  148547. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  148548. */
  148549. cs: number;
  148550. /**
  148551. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  148552. */
  148553. ch: number;
  148554. /**
  148555. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  148556. */
  148557. walkableSlopeAngle: number;
  148558. /**
  148559. * Minimum floor to 'ceiling' height that will still allow the floor area to
  148560. * be considered walkable. [Limit: >= 3] [Units: vx]
  148561. */
  148562. walkableHeight: number;
  148563. /**
  148564. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  148565. */
  148566. walkableClimb: number;
  148567. /**
  148568. * The distance to erode/shrink the walkable area of the heightfield away from
  148569. * obstructions. [Limit: >=0] [Units: vx]
  148570. */
  148571. walkableRadius: number;
  148572. /**
  148573. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  148574. */
  148575. maxEdgeLen: number;
  148576. /**
  148577. * The maximum distance a simplfied contour's border edges should deviate
  148578. * the original raw contour. [Limit: >=0] [Units: vx]
  148579. */
  148580. maxSimplificationError: number;
  148581. /**
  148582. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  148583. */
  148584. minRegionArea: number;
  148585. /**
  148586. * Any regions with a span count smaller than this value will, if possible,
  148587. * be merged with larger regions. [Limit: >=0] [Units: vx]
  148588. */
  148589. mergeRegionArea: number;
  148590. /**
  148591. * The maximum number of vertices allowed for polygons generated during the
  148592. * contour to polygon conversion process. [Limit: >= 3]
  148593. */
  148594. maxVertsPerPoly: number;
  148595. /**
  148596. * Sets the sampling distance to use when generating the detail mesh.
  148597. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  148598. */
  148599. detailSampleDist: number;
  148600. /**
  148601. * The maximum distance the detail mesh surface should deviate from heightfield
  148602. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  148603. */
  148604. detailSampleMaxError: number;
  148605. }
  148606. }
  148607. declare module BABYLON {
  148608. /**
  148609. * RecastJS navigation plugin
  148610. */
  148611. export class RecastJSPlugin implements INavigationEnginePlugin {
  148612. /**
  148613. * Reference to the Recast library
  148614. */
  148615. bjsRECAST: any;
  148616. /**
  148617. * plugin name
  148618. */
  148619. name: string;
  148620. /**
  148621. * the first navmesh created. We might extend this to support multiple navmeshes
  148622. */
  148623. navMesh: any;
  148624. /**
  148625. * Initializes the recastJS plugin
  148626. * @param recastInjection can be used to inject your own recast reference
  148627. */
  148628. constructor(recastInjection?: any);
  148629. /**
  148630. * Creates a navigation mesh
  148631. * @param meshes array of all the geometry used to compute the navigatio mesh
  148632. * @param parameters bunch of parameters used to filter geometry
  148633. */
  148634. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148635. /**
  148636. * Create a navigation mesh debug mesh
  148637. * @param scene is where the mesh will be added
  148638. * @returns debug display mesh
  148639. */
  148640. createDebugNavMesh(scene: Scene): Mesh;
  148641. /**
  148642. * Get a navigation mesh constrained position, closest to the parameter position
  148643. * @param position world position
  148644. * @returns the closest point to position constrained by the navigation mesh
  148645. */
  148646. getClosestPoint(position: Vector3): Vector3;
  148647. /**
  148648. * Get a navigation mesh constrained position, closest to the parameter position
  148649. * @param position world position
  148650. * @param result output the closest point to position constrained by the navigation mesh
  148651. */
  148652. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148653. /**
  148654. * Get a navigation mesh constrained position, within a particular radius
  148655. * @param position world position
  148656. * @param maxRadius the maximum distance to the constrained world position
  148657. * @returns the closest point to position constrained by the navigation mesh
  148658. */
  148659. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148660. /**
  148661. * Get a navigation mesh constrained position, within a particular radius
  148662. * @param position world position
  148663. * @param maxRadius the maximum distance to the constrained world position
  148664. * @param result output the closest point to position constrained by the navigation mesh
  148665. */
  148666. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148667. /**
  148668. * Compute the final position from a segment made of destination-position
  148669. * @param position world position
  148670. * @param destination world position
  148671. * @returns the resulting point along the navmesh
  148672. */
  148673. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148674. /**
  148675. * Compute the final position from a segment made of destination-position
  148676. * @param position world position
  148677. * @param destination world position
  148678. * @param result output the resulting point along the navmesh
  148679. */
  148680. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148681. /**
  148682. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148683. * @param start world position
  148684. * @param end world position
  148685. * @returns array containing world position composing the path
  148686. */
  148687. computePath(start: Vector3, end: Vector3): Vector3[];
  148688. /**
  148689. * Create a new Crowd so you can add agents
  148690. * @param maxAgents the maximum agent count in the crowd
  148691. * @param maxAgentRadius the maximum radius an agent can have
  148692. * @param scene to attach the crowd to
  148693. * @returns the crowd you can add agents to
  148694. */
  148695. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148696. /**
  148697. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148698. * The queries will try to find a solution within those bounds
  148699. * default is (1,1,1)
  148700. * @param extent x,y,z value that define the extent around the queries point of reference
  148701. */
  148702. setDefaultQueryExtent(extent: Vector3): void;
  148703. /**
  148704. * Get the Bounding box extent specified by setDefaultQueryExtent
  148705. * @returns the box extent values
  148706. */
  148707. getDefaultQueryExtent(): Vector3;
  148708. /**
  148709. * build the navmesh from a previously saved state using getNavmeshData
  148710. * @param data the Uint8Array returned by getNavmeshData
  148711. */
  148712. buildFromNavmeshData(data: Uint8Array): void;
  148713. /**
  148714. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148715. * @returns data the Uint8Array that can be saved and reused
  148716. */
  148717. getNavmeshData(): Uint8Array;
  148718. /**
  148719. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148720. * @param result output the box extent values
  148721. */
  148722. getDefaultQueryExtentToRef(result: Vector3): void;
  148723. /**
  148724. * Disposes
  148725. */
  148726. dispose(): void;
  148727. /**
  148728. * If this plugin is supported
  148729. * @returns true if plugin is supported
  148730. */
  148731. isSupported(): boolean;
  148732. }
  148733. /**
  148734. * Recast detour crowd implementation
  148735. */
  148736. export class RecastJSCrowd implements ICrowd {
  148737. /**
  148738. * Recast/detour plugin
  148739. */
  148740. bjsRECASTPlugin: RecastJSPlugin;
  148741. /**
  148742. * Link to the detour crowd
  148743. */
  148744. recastCrowd: any;
  148745. /**
  148746. * One transform per agent
  148747. */
  148748. transforms: TransformNode[];
  148749. /**
  148750. * All agents created
  148751. */
  148752. agents: number[];
  148753. /**
  148754. * Link to the scene is kept to unregister the crowd from the scene
  148755. */
  148756. private _scene;
  148757. /**
  148758. * Observer for crowd updates
  148759. */
  148760. private _onBeforeAnimationsObserver;
  148761. /**
  148762. * Constructor
  148763. * @param plugin recastJS plugin
  148764. * @param maxAgents the maximum agent count in the crowd
  148765. * @param maxAgentRadius the maximum radius an agent can have
  148766. * @param scene to attach the crowd to
  148767. * @returns the crowd you can add agents to
  148768. */
  148769. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  148770. /**
  148771. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148772. * You can attach anything to that node. The node position is updated in the scene update tick.
  148773. * @param pos world position that will be constrained by the navigation mesh
  148774. * @param parameters agent parameters
  148775. * @param transform hooked to the agent that will be update by the scene
  148776. * @returns agent index
  148777. */
  148778. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148779. /**
  148780. * Returns the agent position in world space
  148781. * @param index agent index returned by addAgent
  148782. * @returns world space position
  148783. */
  148784. getAgentPosition(index: number): Vector3;
  148785. /**
  148786. * Returns the agent position result in world space
  148787. * @param index agent index returned by addAgent
  148788. * @param result output world space position
  148789. */
  148790. getAgentPositionToRef(index: number, result: Vector3): void;
  148791. /**
  148792. * Returns the agent velocity in world space
  148793. * @param index agent index returned by addAgent
  148794. * @returns world space velocity
  148795. */
  148796. getAgentVelocity(index: number): Vector3;
  148797. /**
  148798. * Returns the agent velocity result in world space
  148799. * @param index agent index returned by addAgent
  148800. * @param result output world space velocity
  148801. */
  148802. getAgentVelocityToRef(index: number, result: Vector3): void;
  148803. /**
  148804. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148805. * @param index agent index returned by addAgent
  148806. * @param destination targeted world position
  148807. */
  148808. agentGoto(index: number, destination: Vector3): void;
  148809. /**
  148810. * Teleport the agent to a new position
  148811. * @param index agent index returned by addAgent
  148812. * @param destination targeted world position
  148813. */
  148814. agentTeleport(index: number, destination: Vector3): void;
  148815. /**
  148816. * Update agent parameters
  148817. * @param index agent index returned by addAgent
  148818. * @param parameters agent parameters
  148819. */
  148820. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148821. /**
  148822. * remove a particular agent previously created
  148823. * @param index agent index returned by addAgent
  148824. */
  148825. removeAgent(index: number): void;
  148826. /**
  148827. * get the list of all agents attached to this crowd
  148828. * @returns list of agent indices
  148829. */
  148830. getAgents(): number[];
  148831. /**
  148832. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148833. * @param deltaTime in seconds
  148834. */
  148835. update(deltaTime: number): void;
  148836. /**
  148837. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148838. * The queries will try to find a solution within those bounds
  148839. * default is (1,1,1)
  148840. * @param extent x,y,z value that define the extent around the queries point of reference
  148841. */
  148842. setDefaultQueryExtent(extent: Vector3): void;
  148843. /**
  148844. * Get the Bounding box extent specified by setDefaultQueryExtent
  148845. * @returns the box extent values
  148846. */
  148847. getDefaultQueryExtent(): Vector3;
  148848. /**
  148849. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148850. * @param result output the box extent values
  148851. */
  148852. getDefaultQueryExtentToRef(result: Vector3): void;
  148853. /**
  148854. * Release all resources
  148855. */
  148856. dispose(): void;
  148857. }
  148858. }
  148859. declare module BABYLON {
  148860. /**
  148861. * Class used to enable access to IndexedDB
  148862. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  148863. */
  148864. export class Database implements IOfflineProvider {
  148865. private _callbackManifestChecked;
  148866. private _currentSceneUrl;
  148867. private _db;
  148868. private _enableSceneOffline;
  148869. private _enableTexturesOffline;
  148870. private _manifestVersionFound;
  148871. private _mustUpdateRessources;
  148872. private _hasReachedQuota;
  148873. private _isSupported;
  148874. private _idbFactory;
  148875. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  148876. private static IsUASupportingBlobStorage;
  148877. /**
  148878. * Gets a boolean indicating if Database storate is enabled (off by default)
  148879. */
  148880. static IDBStorageEnabled: boolean;
  148881. /**
  148882. * Gets a boolean indicating if scene must be saved in the database
  148883. */
  148884. get enableSceneOffline(): boolean;
  148885. /**
  148886. * Gets a boolean indicating if textures must be saved in the database
  148887. */
  148888. get enableTexturesOffline(): boolean;
  148889. /**
  148890. * Creates a new Database
  148891. * @param urlToScene defines the url to load the scene
  148892. * @param callbackManifestChecked defines the callback to use when manifest is checked
  148893. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  148894. */
  148895. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  148896. private static _ParseURL;
  148897. private static _ReturnFullUrlLocation;
  148898. private _checkManifestFile;
  148899. /**
  148900. * Open the database and make it available
  148901. * @param successCallback defines the callback to call on success
  148902. * @param errorCallback defines the callback to call on error
  148903. */
  148904. open(successCallback: () => void, errorCallback: () => void): void;
  148905. /**
  148906. * Loads an image from the database
  148907. * @param url defines the url to load from
  148908. * @param image defines the target DOM image
  148909. */
  148910. loadImage(url: string, image: HTMLImageElement): void;
  148911. private _loadImageFromDBAsync;
  148912. private _saveImageIntoDBAsync;
  148913. private _checkVersionFromDB;
  148914. private _loadVersionFromDBAsync;
  148915. private _saveVersionIntoDBAsync;
  148916. /**
  148917. * Loads a file from database
  148918. * @param url defines the URL to load from
  148919. * @param sceneLoaded defines a callback to call on success
  148920. * @param progressCallBack defines a callback to call when progress changed
  148921. * @param errorCallback defines a callback to call on error
  148922. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  148923. */
  148924. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  148925. private _loadFileAsync;
  148926. private _saveFileAsync;
  148927. /**
  148928. * Validates if xhr data is correct
  148929. * @param xhr defines the request to validate
  148930. * @param dataType defines the expected data type
  148931. * @returns true if data is correct
  148932. */
  148933. private static _ValidateXHRData;
  148934. }
  148935. }
  148936. declare module BABYLON {
  148937. /** @hidden */
  148938. export var gpuUpdateParticlesPixelShader: {
  148939. name: string;
  148940. shader: string;
  148941. };
  148942. }
  148943. declare module BABYLON {
  148944. /** @hidden */
  148945. export var gpuUpdateParticlesVertexShader: {
  148946. name: string;
  148947. shader: string;
  148948. };
  148949. }
  148950. declare module BABYLON {
  148951. /** @hidden */
  148952. export var clipPlaneFragmentDeclaration2: {
  148953. name: string;
  148954. shader: string;
  148955. };
  148956. }
  148957. declare module BABYLON {
  148958. /** @hidden */
  148959. export var gpuRenderParticlesPixelShader: {
  148960. name: string;
  148961. shader: string;
  148962. };
  148963. }
  148964. declare module BABYLON {
  148965. /** @hidden */
  148966. export var clipPlaneVertexDeclaration2: {
  148967. name: string;
  148968. shader: string;
  148969. };
  148970. }
  148971. declare module BABYLON {
  148972. /** @hidden */
  148973. export var gpuRenderParticlesVertexShader: {
  148974. name: string;
  148975. shader: string;
  148976. };
  148977. }
  148978. declare module BABYLON {
  148979. /**
  148980. * This represents a GPU particle system in Babylon
  148981. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  148982. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  148983. */
  148984. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  148985. /**
  148986. * The layer mask we are rendering the particles through.
  148987. */
  148988. layerMask: number;
  148989. private _capacity;
  148990. private _activeCount;
  148991. private _currentActiveCount;
  148992. private _accumulatedCount;
  148993. private _renderEffect;
  148994. private _updateEffect;
  148995. private _buffer0;
  148996. private _buffer1;
  148997. private _spriteBuffer;
  148998. private _updateVAO;
  148999. private _renderVAO;
  149000. private _targetIndex;
  149001. private _sourceBuffer;
  149002. private _targetBuffer;
  149003. private _currentRenderId;
  149004. private _started;
  149005. private _stopped;
  149006. private _timeDelta;
  149007. private _randomTexture;
  149008. private _randomTexture2;
  149009. private _attributesStrideSize;
  149010. private _updateEffectOptions;
  149011. private _randomTextureSize;
  149012. private _actualFrame;
  149013. private _customEffect;
  149014. private readonly _rawTextureWidth;
  149015. /**
  149016. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  149017. */
  149018. static get IsSupported(): boolean;
  149019. /**
  149020. * An event triggered when the system is disposed.
  149021. */
  149022. onDisposeObservable: Observable<IParticleSystem>;
  149023. /**
  149024. * An event triggered when the system is stopped
  149025. */
  149026. onStoppedObservable: Observable<IParticleSystem>;
  149027. /**
  149028. * Gets the maximum number of particles active at the same time.
  149029. * @returns The max number of active particles.
  149030. */
  149031. getCapacity(): number;
  149032. /**
  149033. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  149034. * to override the particles.
  149035. */
  149036. forceDepthWrite: boolean;
  149037. /**
  149038. * Gets or set the number of active particles
  149039. */
  149040. get activeParticleCount(): number;
  149041. set activeParticleCount(value: number);
  149042. private _preWarmDone;
  149043. /**
  149044. * Specifies if the particles are updated in emitter local space or world space.
  149045. */
  149046. isLocal: boolean;
  149047. /** Gets or sets a matrix to use to compute projection */
  149048. defaultProjectionMatrix: Matrix;
  149049. /**
  149050. * Is this system ready to be used/rendered
  149051. * @return true if the system is ready
  149052. */
  149053. isReady(): boolean;
  149054. /**
  149055. * Gets if the system has been started. (Note: this will still be true after stop is called)
  149056. * @returns True if it has been started, otherwise false.
  149057. */
  149058. isStarted(): boolean;
  149059. /**
  149060. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  149061. * @returns True if it has been stopped, otherwise false.
  149062. */
  149063. isStopped(): boolean;
  149064. /**
  149065. * Gets a boolean indicating that the system is stopping
  149066. * @returns true if the system is currently stopping
  149067. */
  149068. isStopping(): boolean;
  149069. /**
  149070. * Gets the number of particles active at the same time.
  149071. * @returns The number of active particles.
  149072. */
  149073. getActiveCount(): number;
  149074. /**
  149075. * Starts the particle system and begins to emit
  149076. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  149077. */
  149078. start(delay?: number): void;
  149079. /**
  149080. * Stops the particle system.
  149081. */
  149082. stop(): void;
  149083. /**
  149084. * Remove all active particles
  149085. */
  149086. reset(): void;
  149087. /**
  149088. * Returns the string "GPUParticleSystem"
  149089. * @returns a string containing the class name
  149090. */
  149091. getClassName(): string;
  149092. /**
  149093. * Gets the custom effect used to render the particles
  149094. * @param blendMode Blend mode for which the effect should be retrieved
  149095. * @returns The effect
  149096. */
  149097. getCustomEffect(blendMode?: number): Nullable<Effect>;
  149098. /**
  149099. * Sets the custom effect used to render the particles
  149100. * @param effect The effect to set
  149101. * @param blendMode Blend mode for which the effect should be set
  149102. */
  149103. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  149104. /** @hidden */
  149105. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  149106. /**
  149107. * Observable that will be called just before the particles are drawn
  149108. */
  149109. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  149110. /**
  149111. * Gets the name of the particle vertex shader
  149112. */
  149113. get vertexShaderName(): string;
  149114. private _colorGradientsTexture;
  149115. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  149116. /**
  149117. * Adds a new color gradient
  149118. * @param gradient defines the gradient to use (between 0 and 1)
  149119. * @param color1 defines the color to affect to the specified gradient
  149120. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  149121. * @returns the current particle system
  149122. */
  149123. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  149124. private _refreshColorGradient;
  149125. /** Force the system to rebuild all gradients that need to be resync */
  149126. forceRefreshGradients(): void;
  149127. /**
  149128. * Remove a specific color gradient
  149129. * @param gradient defines the gradient to remove
  149130. * @returns the current particle system
  149131. */
  149132. removeColorGradient(gradient: number): GPUParticleSystem;
  149133. private _angularSpeedGradientsTexture;
  149134. private _sizeGradientsTexture;
  149135. private _velocityGradientsTexture;
  149136. private _limitVelocityGradientsTexture;
  149137. private _dragGradientsTexture;
  149138. private _addFactorGradient;
  149139. /**
  149140. * Adds a new size gradient
  149141. * @param gradient defines the gradient to use (between 0 and 1)
  149142. * @param factor defines the size factor to affect to the specified gradient
  149143. * @returns the current particle system
  149144. */
  149145. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  149146. /**
  149147. * Remove a specific size gradient
  149148. * @param gradient defines the gradient to remove
  149149. * @returns the current particle system
  149150. */
  149151. removeSizeGradient(gradient: number): GPUParticleSystem;
  149152. private _refreshFactorGradient;
  149153. /**
  149154. * Adds a new angular speed gradient
  149155. * @param gradient defines the gradient to use (between 0 and 1)
  149156. * @param factor defines the angular speed to affect to the specified gradient
  149157. * @returns the current particle system
  149158. */
  149159. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  149160. /**
  149161. * Remove a specific angular speed gradient
  149162. * @param gradient defines the gradient to remove
  149163. * @returns the current particle system
  149164. */
  149165. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  149166. /**
  149167. * Adds a new velocity gradient
  149168. * @param gradient defines the gradient to use (between 0 and 1)
  149169. * @param factor defines the velocity to affect to the specified gradient
  149170. * @returns the current particle system
  149171. */
  149172. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149173. /**
  149174. * Remove a specific velocity gradient
  149175. * @param gradient defines the gradient to remove
  149176. * @returns the current particle system
  149177. */
  149178. removeVelocityGradient(gradient: number): GPUParticleSystem;
  149179. /**
  149180. * Adds a new limit velocity gradient
  149181. * @param gradient defines the gradient to use (between 0 and 1)
  149182. * @param factor defines the limit velocity value to affect to the specified gradient
  149183. * @returns the current particle system
  149184. */
  149185. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149186. /**
  149187. * Remove a specific limit velocity gradient
  149188. * @param gradient defines the gradient to remove
  149189. * @returns the current particle system
  149190. */
  149191. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  149192. /**
  149193. * Adds a new drag gradient
  149194. * @param gradient defines the gradient to use (between 0 and 1)
  149195. * @param factor defines the drag value to affect to the specified gradient
  149196. * @returns the current particle system
  149197. */
  149198. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  149199. /**
  149200. * Remove a specific drag gradient
  149201. * @param gradient defines the gradient to remove
  149202. * @returns the current particle system
  149203. */
  149204. removeDragGradient(gradient: number): GPUParticleSystem;
  149205. /**
  149206. * Not supported by GPUParticleSystem
  149207. * @param gradient defines the gradient to use (between 0 and 1)
  149208. * @param factor defines the emit rate value to affect to the specified gradient
  149209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149210. * @returns the current particle system
  149211. */
  149212. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149213. /**
  149214. * Not supported by GPUParticleSystem
  149215. * @param gradient defines the gradient to remove
  149216. * @returns the current particle system
  149217. */
  149218. removeEmitRateGradient(gradient: number): IParticleSystem;
  149219. /**
  149220. * Not supported by GPUParticleSystem
  149221. * @param gradient defines the gradient to use (between 0 and 1)
  149222. * @param factor defines the start size value to affect to the specified gradient
  149223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149224. * @returns the current particle system
  149225. */
  149226. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149227. /**
  149228. * Not supported by GPUParticleSystem
  149229. * @param gradient defines the gradient to remove
  149230. * @returns the current particle system
  149231. */
  149232. removeStartSizeGradient(gradient: number): IParticleSystem;
  149233. /**
  149234. * Not supported by GPUParticleSystem
  149235. * @param gradient defines the gradient to use (between 0 and 1)
  149236. * @param min defines the color remap minimal range
  149237. * @param max defines the color remap maximal range
  149238. * @returns the current particle system
  149239. */
  149240. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149241. /**
  149242. * Not supported by GPUParticleSystem
  149243. * @param gradient defines the gradient to remove
  149244. * @returns the current particle system
  149245. */
  149246. removeColorRemapGradient(): IParticleSystem;
  149247. /**
  149248. * Not supported by GPUParticleSystem
  149249. * @param gradient defines the gradient to use (between 0 and 1)
  149250. * @param min defines the alpha remap minimal range
  149251. * @param max defines the alpha remap maximal range
  149252. * @returns the current particle system
  149253. */
  149254. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149255. /**
  149256. * Not supported by GPUParticleSystem
  149257. * @param gradient defines the gradient to remove
  149258. * @returns the current particle system
  149259. */
  149260. removeAlphaRemapGradient(): IParticleSystem;
  149261. /**
  149262. * Not supported by GPUParticleSystem
  149263. * @param gradient defines the gradient to use (between 0 and 1)
  149264. * @param color defines the color to affect to the specified gradient
  149265. * @returns the current particle system
  149266. */
  149267. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  149268. /**
  149269. * Not supported by GPUParticleSystem
  149270. * @param gradient defines the gradient to remove
  149271. * @returns the current particle system
  149272. */
  149273. removeRampGradient(): IParticleSystem;
  149274. /**
  149275. * Not supported by GPUParticleSystem
  149276. * @returns the list of ramp gradients
  149277. */
  149278. getRampGradients(): Nullable<Array<Color3Gradient>>;
  149279. /**
  149280. * Not supported by GPUParticleSystem
  149281. * Gets or sets a boolean indicating that ramp gradients must be used
  149282. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  149283. */
  149284. get useRampGradients(): boolean;
  149285. set useRampGradients(value: boolean);
  149286. /**
  149287. * Not supported by GPUParticleSystem
  149288. * @param gradient defines the gradient to use (between 0 and 1)
  149289. * @param factor defines the life time factor to affect to the specified gradient
  149290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149291. * @returns the current particle system
  149292. */
  149293. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149294. /**
  149295. * Not supported by GPUParticleSystem
  149296. * @param gradient defines the gradient to remove
  149297. * @returns the current particle system
  149298. */
  149299. removeLifeTimeGradient(gradient: number): IParticleSystem;
  149300. /**
  149301. * Instantiates a GPU particle system.
  149302. * 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.
  149303. * @param name The name of the particle system
  149304. * @param options The options used to create the system
  149305. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  149306. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  149307. * @param customEffect a custom effect used to change the way particles are rendered by default
  149308. */
  149309. constructor(name: string, options: Partial<{
  149310. capacity: number;
  149311. randomTextureSize: number;
  149312. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  149313. protected _reset(): void;
  149314. private _createUpdateVAO;
  149315. private _createRenderVAO;
  149316. private _initialize;
  149317. /** @hidden */
  149318. _recreateUpdateEffect(): void;
  149319. private _getEffect;
  149320. /**
  149321. * Fill the defines array according to the current settings of the particle system
  149322. * @param defines Array to be updated
  149323. * @param blendMode blend mode to take into account when updating the array
  149324. */
  149325. fillDefines(defines: Array<string>, blendMode?: number): void;
  149326. /**
  149327. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  149328. * @param uniforms Uniforms array to fill
  149329. * @param attributes Attributes array to fill
  149330. * @param samplers Samplers array to fill
  149331. */
  149332. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  149333. /** @hidden */
  149334. _recreateRenderEffect(): Effect;
  149335. /**
  149336. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  149337. * @param preWarm defines if we are in the pre-warmimg phase
  149338. */
  149339. animate(preWarm?: boolean): void;
  149340. private _createFactorGradientTexture;
  149341. private _createSizeGradientTexture;
  149342. private _createAngularSpeedGradientTexture;
  149343. private _createVelocityGradientTexture;
  149344. private _createLimitVelocityGradientTexture;
  149345. private _createDragGradientTexture;
  149346. private _createColorGradientTexture;
  149347. /**
  149348. * Renders the particle system in its current state
  149349. * @param preWarm defines if the system should only update the particles but not render them
  149350. * @returns the current number of particles
  149351. */
  149352. render(preWarm?: boolean): number;
  149353. /**
  149354. * Rebuilds the particle system
  149355. */
  149356. rebuild(): void;
  149357. private _releaseBuffers;
  149358. private _releaseVAOs;
  149359. /**
  149360. * Disposes the particle system and free the associated resources
  149361. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  149362. */
  149363. dispose(disposeTexture?: boolean): void;
  149364. /**
  149365. * Clones the particle system.
  149366. * @param name The name of the cloned object
  149367. * @param newEmitter The new emitter to use
  149368. * @returns the cloned particle system
  149369. */
  149370. clone(name: string, newEmitter: any): GPUParticleSystem;
  149371. /**
  149372. * Serializes the particle system to a JSON object
  149373. * @param serializeTexture defines if the texture must be serialized as well
  149374. * @returns the JSON object
  149375. */
  149376. serialize(serializeTexture?: boolean): any;
  149377. /**
  149378. * Parses a JSON object to create a GPU particle system.
  149379. * @param parsedParticleSystem The JSON object to parse
  149380. * @param sceneOrEngine The scene or the engine to create the particle system in
  149381. * @param rootUrl The root url to use to load external dependencies like texture
  149382. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  149383. * @returns the parsed GPU particle system
  149384. */
  149385. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  149386. }
  149387. }
  149388. declare module BABYLON {
  149389. /**
  149390. * Represents a set of particle systems working together to create a specific effect
  149391. */
  149392. export class ParticleSystemSet implements IDisposable {
  149393. /**
  149394. * Gets or sets base Assets URL
  149395. */
  149396. static BaseAssetsUrl: string;
  149397. private _emitterCreationOptions;
  149398. private _emitterNode;
  149399. /**
  149400. * Gets the particle system list
  149401. */
  149402. systems: IParticleSystem[];
  149403. /**
  149404. * Gets the emitter node used with this set
  149405. */
  149406. get emitterNode(): Nullable<TransformNode>;
  149407. /**
  149408. * Creates a new emitter mesh as a sphere
  149409. * @param options defines the options used to create the sphere
  149410. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  149411. * @param scene defines the hosting scene
  149412. */
  149413. setEmitterAsSphere(options: {
  149414. diameter: number;
  149415. segments: number;
  149416. color: Color3;
  149417. }, renderingGroupId: number, scene: Scene): void;
  149418. /**
  149419. * Starts all particle systems of the set
  149420. * @param emitter defines an optional mesh to use as emitter for the particle systems
  149421. */
  149422. start(emitter?: AbstractMesh): void;
  149423. /**
  149424. * Release all associated resources
  149425. */
  149426. dispose(): void;
  149427. /**
  149428. * Serialize the set into a JSON compatible object
  149429. * @param serializeTexture defines if the texture must be serialized as well
  149430. * @returns a JSON compatible representation of the set
  149431. */
  149432. serialize(serializeTexture?: boolean): any;
  149433. /**
  149434. * Parse a new ParticleSystemSet from a serialized source
  149435. * @param data defines a JSON compatible representation of the set
  149436. * @param scene defines the hosting scene
  149437. * @param gpu defines if we want GPU particles or CPU particles
  149438. * @returns a new ParticleSystemSet
  149439. */
  149440. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  149441. }
  149442. }
  149443. declare module BABYLON {
  149444. /**
  149445. * This class is made for on one-liner static method to help creating particle system set.
  149446. */
  149447. export class ParticleHelper {
  149448. /**
  149449. * Gets or sets base Assets URL
  149450. */
  149451. static BaseAssetsUrl: string;
  149452. /** Define the Url to load snippets */
  149453. static SnippetUrl: string;
  149454. /**
  149455. * Create a default particle system that you can tweak
  149456. * @param emitter defines the emitter to use
  149457. * @param capacity defines the system capacity (default is 500 particles)
  149458. * @param scene defines the hosting scene
  149459. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  149460. * @returns the new Particle system
  149461. */
  149462. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  149463. /**
  149464. * This is the main static method (one-liner) of this helper to create different particle systems
  149465. * @param type This string represents the type to the particle system to create
  149466. * @param scene The scene where the particle system should live
  149467. * @param gpu If the system will use gpu
  149468. * @returns the ParticleSystemSet created
  149469. */
  149470. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  149471. /**
  149472. * Static function used to export a particle system to a ParticleSystemSet variable.
  149473. * Please note that the emitter shape is not exported
  149474. * @param systems defines the particle systems to export
  149475. * @returns the created particle system set
  149476. */
  149477. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  149478. /**
  149479. * Creates a particle system from a snippet saved in a remote file
  149480. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  149481. * @param url defines the url to load from
  149482. * @param scene defines the hosting scene
  149483. * @param gpu If the system will use gpu
  149484. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149485. * @returns a promise that will resolve to the new particle system
  149486. */
  149487. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149488. /**
  149489. * Creates a particle system from a snippet saved by the particle system editor
  149490. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  149491. * @param scene defines the hosting scene
  149492. * @param gpu If the system will use gpu
  149493. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149494. * @returns a promise that will resolve to the new particle system
  149495. */
  149496. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149497. }
  149498. }
  149499. declare module BABYLON {
  149500. interface Engine {
  149501. /**
  149502. * Create an effect to use with particle systems.
  149503. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  149504. * the particle system for which you want to create a custom effect in the last parameter
  149505. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  149506. * @param uniformsNames defines a list of attribute names
  149507. * @param samplers defines an array of string used to represent textures
  149508. * @param defines defines the string containing the defines to use to compile the shaders
  149509. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  149510. * @param onCompiled defines a function to call when the effect creation is successful
  149511. * @param onError defines a function to call when the effect creation has failed
  149512. * @param particleSystem the particle system you want to create the effect for
  149513. * @returns the new Effect
  149514. */
  149515. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  149516. }
  149517. interface Mesh {
  149518. /**
  149519. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  149520. * @returns an array of IParticleSystem
  149521. */
  149522. getEmittedParticleSystems(): IParticleSystem[];
  149523. /**
  149524. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  149525. * @returns an array of IParticleSystem
  149526. */
  149527. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  149528. }
  149529. }
  149530. declare module BABYLON {
  149531. /** Defines the 4 color options */
  149532. export enum PointColor {
  149533. /** color value */
  149534. Color = 2,
  149535. /** uv value */
  149536. UV = 1,
  149537. /** random value */
  149538. Random = 0,
  149539. /** stated value */
  149540. Stated = 3
  149541. }
  149542. /**
  149543. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  149544. * 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.
  149545. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  149546. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  149547. *
  149548. * Full documentation here : TO BE ENTERED
  149549. */
  149550. export class PointsCloudSystem implements IDisposable {
  149551. /**
  149552. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  149553. * Example : var p = SPS.particles[i];
  149554. */
  149555. particles: CloudPoint[];
  149556. /**
  149557. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  149558. */
  149559. nbParticles: number;
  149560. /**
  149561. * This a counter for your own usage. It's not set by any SPS functions.
  149562. */
  149563. counter: number;
  149564. /**
  149565. * The PCS name. This name is also given to the underlying mesh.
  149566. */
  149567. name: string;
  149568. /**
  149569. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  149570. */
  149571. mesh: Mesh;
  149572. /**
  149573. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  149574. * Please read :
  149575. */
  149576. vars: any;
  149577. /**
  149578. * @hidden
  149579. */
  149580. _size: number;
  149581. private _scene;
  149582. private _promises;
  149583. private _positions;
  149584. private _indices;
  149585. private _normals;
  149586. private _colors;
  149587. private _uvs;
  149588. private _indices32;
  149589. private _positions32;
  149590. private _colors32;
  149591. private _uvs32;
  149592. private _updatable;
  149593. private _isVisibilityBoxLocked;
  149594. private _alwaysVisible;
  149595. private _groups;
  149596. private _groupCounter;
  149597. private _computeParticleColor;
  149598. private _computeParticleTexture;
  149599. private _computeParticleRotation;
  149600. private _computeBoundingBox;
  149601. private _isReady;
  149602. /**
  149603. * Creates a PCS (Points Cloud System) object
  149604. * @param name (String) is the PCS name, this will be the underlying mesh name
  149605. * @param pointSize (number) is the size for each point
  149606. * @param scene (Scene) is the scene in which the PCS is added
  149607. * @param options defines the options of the PCS e.g.
  149608. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  149609. */
  149610. constructor(name: string, pointSize: number, scene: Scene, options?: {
  149611. updatable?: boolean;
  149612. });
  149613. /**
  149614. * Builds the PCS underlying mesh. Returns a standard Mesh.
  149615. * If no points were added to the PCS, the returned mesh is just a single point.
  149616. * @returns a promise for the created mesh
  149617. */
  149618. buildMeshAsync(): Promise<Mesh>;
  149619. /**
  149620. * @hidden
  149621. */
  149622. private _buildMesh;
  149623. private _addParticle;
  149624. private _randomUnitVector;
  149625. private _getColorIndicesForCoord;
  149626. private _setPointsColorOrUV;
  149627. private _colorFromTexture;
  149628. private _calculateDensity;
  149629. /**
  149630. * Adds points to the PCS in random positions within a unit sphere
  149631. * @param nb (positive integer) the number of particles to be created from this model
  149632. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  149633. * @returns the number of groups in the system
  149634. */
  149635. addPoints(nb: number, pointFunction?: any): number;
  149636. /**
  149637. * Adds points to the PCS from the surface of the model shape
  149638. * @param mesh is any Mesh object that will be used as a surface model for the points
  149639. * @param nb (positive integer) the number of particles to be created from this model
  149640. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149641. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149642. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149643. * @returns the number of groups in the system
  149644. */
  149645. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149646. /**
  149647. * Adds points to the PCS inside the model shape
  149648. * @param mesh is any Mesh object that will be used as a surface model for the points
  149649. * @param nb (positive integer) the number of particles to be created from this model
  149650. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149651. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149652. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149653. * @returns the number of groups in the system
  149654. */
  149655. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149656. /**
  149657. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  149658. * This method calls `updateParticle()` for each particle of the SPS.
  149659. * For an animated SPS, it is usually called within the render loop.
  149660. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  149661. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  149662. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  149663. * @returns the PCS.
  149664. */
  149665. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  149666. /**
  149667. * Disposes the PCS.
  149668. */
  149669. dispose(): void;
  149670. /**
  149671. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  149672. * doc :
  149673. * @returns the PCS.
  149674. */
  149675. refreshVisibleSize(): PointsCloudSystem;
  149676. /**
  149677. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  149678. * @param size the size (float) of the visibility box
  149679. * note : this doesn't lock the PCS mesh bounding box.
  149680. * doc :
  149681. */
  149682. setVisibilityBox(size: number): void;
  149683. /**
  149684. * Gets whether the PCS is always visible or not
  149685. * doc :
  149686. */
  149687. get isAlwaysVisible(): boolean;
  149688. /**
  149689. * Sets the PCS as always visible or not
  149690. * doc :
  149691. */
  149692. set isAlwaysVisible(val: boolean);
  149693. /**
  149694. * Tells to `setParticles()` to compute the particle rotations or not
  149695. * Default value : false. The PCS is faster when it's set to false
  149696. * Note : particle rotations are only applied to parent particles
  149697. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  149698. */
  149699. set computeParticleRotation(val: boolean);
  149700. /**
  149701. * Tells to `setParticles()` to compute the particle colors or not.
  149702. * Default value : true. The PCS is faster when it's set to false.
  149703. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149704. */
  149705. set computeParticleColor(val: boolean);
  149706. set computeParticleTexture(val: boolean);
  149707. /**
  149708. * Gets if `setParticles()` computes the particle colors or not.
  149709. * Default value : false. The PCS is faster when it's set to false.
  149710. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149711. */
  149712. get computeParticleColor(): boolean;
  149713. /**
  149714. * Gets if `setParticles()` computes the particle textures or not.
  149715. * Default value : false. The PCS is faster when it's set to false.
  149716. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  149717. */
  149718. get computeParticleTexture(): boolean;
  149719. /**
  149720. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  149721. */
  149722. set computeBoundingBox(val: boolean);
  149723. /**
  149724. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  149725. */
  149726. get computeBoundingBox(): boolean;
  149727. /**
  149728. * This function does nothing. It may be overwritten to set all the particle first values.
  149729. * The PCS doesn't call this function, you may have to call it by your own.
  149730. * doc :
  149731. */
  149732. initParticles(): void;
  149733. /**
  149734. * This function does nothing. It may be overwritten to recycle a particle
  149735. * The PCS doesn't call this function, you can to call it
  149736. * doc :
  149737. * @param particle The particle to recycle
  149738. * @returns the recycled particle
  149739. */
  149740. recycleParticle(particle: CloudPoint): CloudPoint;
  149741. /**
  149742. * Updates a particle : this function should be overwritten by the user.
  149743. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  149744. * doc :
  149745. * @example : just set a particle position or velocity and recycle conditions
  149746. * @param particle The particle to update
  149747. * @returns the updated particle
  149748. */
  149749. updateParticle(particle: CloudPoint): CloudPoint;
  149750. /**
  149751. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  149752. * This does nothing and may be overwritten by the user.
  149753. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149754. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149755. * @param update the boolean update value actually passed to setParticles()
  149756. */
  149757. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149758. /**
  149759. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  149760. * This will be passed three parameters.
  149761. * This does nothing and may be overwritten by the user.
  149762. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149763. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149764. * @param update the boolean update value actually passed to setParticles()
  149765. */
  149766. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149767. }
  149768. }
  149769. declare module BABYLON {
  149770. /**
  149771. * Represents one particle of a points cloud system.
  149772. */
  149773. export class CloudPoint {
  149774. /**
  149775. * particle global index
  149776. */
  149777. idx: number;
  149778. /**
  149779. * The color of the particle
  149780. */
  149781. color: Nullable<Color4>;
  149782. /**
  149783. * The world space position of the particle.
  149784. */
  149785. position: Vector3;
  149786. /**
  149787. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  149788. */
  149789. rotation: Vector3;
  149790. /**
  149791. * The world space rotation quaternion of the particle.
  149792. */
  149793. rotationQuaternion: Nullable<Quaternion>;
  149794. /**
  149795. * The uv of the particle.
  149796. */
  149797. uv: Nullable<Vector2>;
  149798. /**
  149799. * The current speed of the particle.
  149800. */
  149801. velocity: Vector3;
  149802. /**
  149803. * The pivot point in the particle local space.
  149804. */
  149805. pivot: Vector3;
  149806. /**
  149807. * Must the particle be translated from its pivot point in its local space ?
  149808. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  149809. * Default : false
  149810. */
  149811. translateFromPivot: boolean;
  149812. /**
  149813. * Index of this particle in the global "positions" array (Internal use)
  149814. * @hidden
  149815. */
  149816. _pos: number;
  149817. /**
  149818. * @hidden Index of this particle in the global "indices" array (Internal use)
  149819. */
  149820. _ind: number;
  149821. /**
  149822. * Group this particle belongs to
  149823. */
  149824. _group: PointsGroup;
  149825. /**
  149826. * Group id of this particle
  149827. */
  149828. groupId: number;
  149829. /**
  149830. * Index of the particle in its group id (Internal use)
  149831. */
  149832. idxInGroup: number;
  149833. /**
  149834. * @hidden Particle BoundingInfo object (Internal use)
  149835. */
  149836. _boundingInfo: BoundingInfo;
  149837. /**
  149838. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  149839. */
  149840. _pcs: PointsCloudSystem;
  149841. /**
  149842. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  149843. */
  149844. _stillInvisible: boolean;
  149845. /**
  149846. * @hidden Last computed particle rotation matrix
  149847. */
  149848. _rotationMatrix: number[];
  149849. /**
  149850. * Parent particle Id, if any.
  149851. * Default null.
  149852. */
  149853. parentId: Nullable<number>;
  149854. /**
  149855. * @hidden Internal global position in the PCS.
  149856. */
  149857. _globalPosition: Vector3;
  149858. /**
  149859. * Creates a Point Cloud object.
  149860. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  149861. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  149862. * @param group (PointsGroup) is the group the particle belongs to
  149863. * @param groupId (integer) is the group identifier in the PCS.
  149864. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  149865. * @param pcs defines the PCS it is associated to
  149866. */
  149867. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  149868. /**
  149869. * get point size
  149870. */
  149871. get size(): Vector3;
  149872. /**
  149873. * Set point size
  149874. */
  149875. set size(scale: Vector3);
  149876. /**
  149877. * Legacy support, changed quaternion to rotationQuaternion
  149878. */
  149879. get quaternion(): Nullable<Quaternion>;
  149880. /**
  149881. * Legacy support, changed quaternion to rotationQuaternion
  149882. */
  149883. set quaternion(q: Nullable<Quaternion>);
  149884. /**
  149885. * Returns a boolean. True if the particle intersects a mesh, else false
  149886. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  149887. * @param target is the object (point or mesh) what the intersection is computed against
  149888. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  149889. * @returns true if it intersects
  149890. */
  149891. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  149892. /**
  149893. * get the rotation matrix of the particle
  149894. * @hidden
  149895. */
  149896. getRotationMatrix(m: Matrix): void;
  149897. }
  149898. /**
  149899. * Represents a group of points in a points cloud system
  149900. * * PCS internal tool, don't use it manually.
  149901. */
  149902. export class PointsGroup {
  149903. /**
  149904. * The group id
  149905. * @hidden
  149906. */
  149907. groupID: number;
  149908. /**
  149909. * image data for group (internal use)
  149910. * @hidden
  149911. */
  149912. _groupImageData: Nullable<ArrayBufferView>;
  149913. /**
  149914. * Image Width (internal use)
  149915. * @hidden
  149916. */
  149917. _groupImgWidth: number;
  149918. /**
  149919. * Image Height (internal use)
  149920. * @hidden
  149921. */
  149922. _groupImgHeight: number;
  149923. /**
  149924. * Custom position function (internal use)
  149925. * @hidden
  149926. */
  149927. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  149928. /**
  149929. * density per facet for surface points
  149930. * @hidden
  149931. */
  149932. _groupDensity: number[];
  149933. /**
  149934. * Only when points are colored by texture carries pointer to texture list array
  149935. * @hidden
  149936. */
  149937. _textureNb: number;
  149938. /**
  149939. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  149940. * PCS internal tool, don't use it manually.
  149941. * @hidden
  149942. */
  149943. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  149944. }
  149945. }
  149946. declare module BABYLON {
  149947. interface Scene {
  149948. /** @hidden (Backing field) */
  149949. _physicsEngine: Nullable<IPhysicsEngine>;
  149950. /** @hidden */
  149951. _physicsTimeAccumulator: number;
  149952. /**
  149953. * Gets the current physics engine
  149954. * @returns a IPhysicsEngine or null if none attached
  149955. */
  149956. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  149957. /**
  149958. * Enables physics to the current scene
  149959. * @param gravity defines the scene's gravity for the physics engine
  149960. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  149961. * @return a boolean indicating if the physics engine was initialized
  149962. */
  149963. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  149964. /**
  149965. * Disables and disposes the physics engine associated with the scene
  149966. */
  149967. disablePhysicsEngine(): void;
  149968. /**
  149969. * Gets a boolean indicating if there is an active physics engine
  149970. * @returns a boolean indicating if there is an active physics engine
  149971. */
  149972. isPhysicsEnabled(): boolean;
  149973. /**
  149974. * Deletes a physics compound impostor
  149975. * @param compound defines the compound to delete
  149976. */
  149977. deleteCompoundImpostor(compound: any): void;
  149978. /**
  149979. * An event triggered when physic simulation is about to be run
  149980. */
  149981. onBeforePhysicsObservable: Observable<Scene>;
  149982. /**
  149983. * An event triggered when physic simulation has been done
  149984. */
  149985. onAfterPhysicsObservable: Observable<Scene>;
  149986. }
  149987. interface AbstractMesh {
  149988. /** @hidden */
  149989. _physicsImpostor: Nullable<PhysicsImpostor>;
  149990. /**
  149991. * Gets or sets impostor used for physic simulation
  149992. * @see https://doc.babylonjs.com/features/physics_engine
  149993. */
  149994. physicsImpostor: Nullable<PhysicsImpostor>;
  149995. /**
  149996. * Gets the current physics impostor
  149997. * @see https://doc.babylonjs.com/features/physics_engine
  149998. * @returns a physics impostor or null
  149999. */
  150000. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  150001. /** Apply a physic impulse to the mesh
  150002. * @param force defines the force to apply
  150003. * @param contactPoint defines where to apply the force
  150004. * @returns the current mesh
  150005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  150006. */
  150007. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  150008. /**
  150009. * Creates a physic joint between two meshes
  150010. * @param otherMesh defines the other mesh to use
  150011. * @param pivot1 defines the pivot to use on this mesh
  150012. * @param pivot2 defines the pivot to use on the other mesh
  150013. * @param options defines additional options (can be plugin dependent)
  150014. * @returns the current mesh
  150015. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  150016. */
  150017. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  150018. /** @hidden */
  150019. _disposePhysicsObserver: Nullable<Observer<Node>>;
  150020. }
  150021. /**
  150022. * Defines the physics engine scene component responsible to manage a physics engine
  150023. */
  150024. export class PhysicsEngineSceneComponent implements ISceneComponent {
  150025. /**
  150026. * The component name helpful to identify the component in the list of scene components.
  150027. */
  150028. readonly name: string;
  150029. /**
  150030. * The scene the component belongs to.
  150031. */
  150032. scene: Scene;
  150033. /**
  150034. * Creates a new instance of the component for the given scene
  150035. * @param scene Defines the scene to register the component in
  150036. */
  150037. constructor(scene: Scene);
  150038. /**
  150039. * Registers the component in a given scene
  150040. */
  150041. register(): void;
  150042. /**
  150043. * Rebuilds the elements related to this component in case of
  150044. * context lost for instance.
  150045. */
  150046. rebuild(): void;
  150047. /**
  150048. * Disposes the component and the associated ressources
  150049. */
  150050. dispose(): void;
  150051. }
  150052. }
  150053. declare module BABYLON {
  150054. /**
  150055. * A helper for physics simulations
  150056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150057. */
  150058. export class PhysicsHelper {
  150059. private _scene;
  150060. private _physicsEngine;
  150061. /**
  150062. * Initializes the Physics helper
  150063. * @param scene Babylon.js scene
  150064. */
  150065. constructor(scene: Scene);
  150066. /**
  150067. * Applies a radial explosion impulse
  150068. * @param origin the origin of the explosion
  150069. * @param radiusOrEventOptions the radius or the options of radial explosion
  150070. * @param strength the explosion strength
  150071. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150072. * @returns A physics radial explosion event, or null
  150073. */
  150074. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150075. /**
  150076. * Applies a radial explosion force
  150077. * @param origin the origin of the explosion
  150078. * @param radiusOrEventOptions the radius or the options of radial explosion
  150079. * @param strength the explosion strength
  150080. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150081. * @returns A physics radial explosion event, or null
  150082. */
  150083. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150084. /**
  150085. * Creates a gravitational field
  150086. * @param origin the origin of the explosion
  150087. * @param radiusOrEventOptions the radius or the options of radial explosion
  150088. * @param strength the explosion strength
  150089. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150090. * @returns A physics gravitational field event, or null
  150091. */
  150092. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  150093. /**
  150094. * Creates a physics updraft event
  150095. * @param origin the origin of the updraft
  150096. * @param radiusOrEventOptions the radius or the options of the updraft
  150097. * @param strength the strength of the updraft
  150098. * @param height the height of the updraft
  150099. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  150100. * @returns A physics updraft event, or null
  150101. */
  150102. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  150103. /**
  150104. * Creates a physics vortex event
  150105. * @param origin the of the vortex
  150106. * @param radiusOrEventOptions the radius or the options of the vortex
  150107. * @param strength the strength of the vortex
  150108. * @param height the height of the vortex
  150109. * @returns a Physics vortex event, or null
  150110. * A physics vortex event or null
  150111. */
  150112. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  150113. }
  150114. /**
  150115. * Represents a physics radial explosion event
  150116. */
  150117. class PhysicsRadialExplosionEvent {
  150118. private _scene;
  150119. private _options;
  150120. private _sphere;
  150121. private _dataFetched;
  150122. /**
  150123. * Initializes a radial explosioin event
  150124. * @param _scene BabylonJS scene
  150125. * @param _options The options for the vortex event
  150126. */
  150127. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  150128. /**
  150129. * Returns the data related to the radial explosion event (sphere).
  150130. * @returns The radial explosion event data
  150131. */
  150132. getData(): PhysicsRadialExplosionEventData;
  150133. /**
  150134. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  150135. * @param impostor A physics imposter
  150136. * @param origin the origin of the explosion
  150137. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  150138. */
  150139. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  150140. /**
  150141. * Triggers affecterd impostors callbacks
  150142. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  150143. */
  150144. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  150145. /**
  150146. * Disposes the sphere.
  150147. * @param force Specifies if the sphere should be disposed by force
  150148. */
  150149. dispose(force?: boolean): void;
  150150. /*** Helpers ***/
  150151. private _prepareSphere;
  150152. private _intersectsWithSphere;
  150153. }
  150154. /**
  150155. * Represents a gravitational field event
  150156. */
  150157. class PhysicsGravitationalFieldEvent {
  150158. private _physicsHelper;
  150159. private _scene;
  150160. private _origin;
  150161. private _options;
  150162. private _tickCallback;
  150163. private _sphere;
  150164. private _dataFetched;
  150165. /**
  150166. * Initializes the physics gravitational field event
  150167. * @param _physicsHelper A physics helper
  150168. * @param _scene BabylonJS scene
  150169. * @param _origin The origin position of the gravitational field event
  150170. * @param _options The options for the vortex event
  150171. */
  150172. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  150173. /**
  150174. * Returns the data related to the gravitational field event (sphere).
  150175. * @returns A gravitational field event
  150176. */
  150177. getData(): PhysicsGravitationalFieldEventData;
  150178. /**
  150179. * Enables the gravitational field.
  150180. */
  150181. enable(): void;
  150182. /**
  150183. * Disables the gravitational field.
  150184. */
  150185. disable(): void;
  150186. /**
  150187. * Disposes the sphere.
  150188. * @param force The force to dispose from the gravitational field event
  150189. */
  150190. dispose(force?: boolean): void;
  150191. private _tick;
  150192. }
  150193. /**
  150194. * Represents a physics updraft event
  150195. */
  150196. class PhysicsUpdraftEvent {
  150197. private _scene;
  150198. private _origin;
  150199. private _options;
  150200. private _physicsEngine;
  150201. private _originTop;
  150202. private _originDirection;
  150203. private _tickCallback;
  150204. private _cylinder;
  150205. private _cylinderPosition;
  150206. private _dataFetched;
  150207. /**
  150208. * Initializes the physics updraft event
  150209. * @param _scene BabylonJS scene
  150210. * @param _origin The origin position of the updraft
  150211. * @param _options The options for the updraft event
  150212. */
  150213. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  150214. /**
  150215. * Returns the data related to the updraft event (cylinder).
  150216. * @returns A physics updraft event
  150217. */
  150218. getData(): PhysicsUpdraftEventData;
  150219. /**
  150220. * Enables the updraft.
  150221. */
  150222. enable(): void;
  150223. /**
  150224. * Disables the updraft.
  150225. */
  150226. disable(): void;
  150227. /**
  150228. * Disposes the cylinder.
  150229. * @param force Specifies if the updraft should be disposed by force
  150230. */
  150231. dispose(force?: boolean): void;
  150232. private getImpostorHitData;
  150233. private _tick;
  150234. /*** Helpers ***/
  150235. private _prepareCylinder;
  150236. private _intersectsWithCylinder;
  150237. }
  150238. /**
  150239. * Represents a physics vortex event
  150240. */
  150241. class PhysicsVortexEvent {
  150242. private _scene;
  150243. private _origin;
  150244. private _options;
  150245. private _physicsEngine;
  150246. private _originTop;
  150247. private _tickCallback;
  150248. private _cylinder;
  150249. private _cylinderPosition;
  150250. private _dataFetched;
  150251. /**
  150252. * Initializes the physics vortex event
  150253. * @param _scene The BabylonJS scene
  150254. * @param _origin The origin position of the vortex
  150255. * @param _options The options for the vortex event
  150256. */
  150257. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  150258. /**
  150259. * Returns the data related to the vortex event (cylinder).
  150260. * @returns The physics vortex event data
  150261. */
  150262. getData(): PhysicsVortexEventData;
  150263. /**
  150264. * Enables the vortex.
  150265. */
  150266. enable(): void;
  150267. /**
  150268. * Disables the cortex.
  150269. */
  150270. disable(): void;
  150271. /**
  150272. * Disposes the sphere.
  150273. * @param force
  150274. */
  150275. dispose(force?: boolean): void;
  150276. private getImpostorHitData;
  150277. private _tick;
  150278. /*** Helpers ***/
  150279. private _prepareCylinder;
  150280. private _intersectsWithCylinder;
  150281. }
  150282. /**
  150283. * Options fot the radial explosion event
  150284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150285. */
  150286. export class PhysicsRadialExplosionEventOptions {
  150287. /**
  150288. * The radius of the sphere for the radial explosion.
  150289. */
  150290. radius: number;
  150291. /**
  150292. * The strenth of the explosion.
  150293. */
  150294. strength: number;
  150295. /**
  150296. * The strenght of the force in correspondence to the distance of the affected object
  150297. */
  150298. falloff: PhysicsRadialImpulseFalloff;
  150299. /**
  150300. * Sphere options for the radial explosion.
  150301. */
  150302. sphere: {
  150303. segments: number;
  150304. diameter: number;
  150305. };
  150306. /**
  150307. * Sphere options for the radial explosion.
  150308. */
  150309. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  150310. }
  150311. /**
  150312. * Options fot the updraft event
  150313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150314. */
  150315. export class PhysicsUpdraftEventOptions {
  150316. /**
  150317. * The radius of the cylinder for the vortex
  150318. */
  150319. radius: number;
  150320. /**
  150321. * The strenth of the updraft.
  150322. */
  150323. strength: number;
  150324. /**
  150325. * The height of the cylinder for the updraft.
  150326. */
  150327. height: number;
  150328. /**
  150329. * The mode for the the updraft.
  150330. */
  150331. updraftMode: PhysicsUpdraftMode;
  150332. }
  150333. /**
  150334. * Options fot the vortex event
  150335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150336. */
  150337. export class PhysicsVortexEventOptions {
  150338. /**
  150339. * The radius of the cylinder for the vortex
  150340. */
  150341. radius: number;
  150342. /**
  150343. * The strenth of the vortex.
  150344. */
  150345. strength: number;
  150346. /**
  150347. * The height of the cylinder for the vortex.
  150348. */
  150349. height: number;
  150350. /**
  150351. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  150352. */
  150353. centripetalForceThreshold: number;
  150354. /**
  150355. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  150356. */
  150357. centripetalForceMultiplier: number;
  150358. /**
  150359. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  150360. */
  150361. centrifugalForceMultiplier: number;
  150362. /**
  150363. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  150364. */
  150365. updraftForceMultiplier: number;
  150366. }
  150367. /**
  150368. * The strenght of the force in correspondence to the distance of the affected object
  150369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150370. */
  150371. export enum PhysicsRadialImpulseFalloff {
  150372. /** Defines that impulse is constant in strength across it's whole radius */
  150373. Constant = 0,
  150374. /** Defines that impulse gets weaker if it's further from the origin */
  150375. Linear = 1
  150376. }
  150377. /**
  150378. * The strength of the force in correspondence to the distance of the affected object
  150379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150380. */
  150381. export enum PhysicsUpdraftMode {
  150382. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  150383. Center = 0,
  150384. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  150385. Perpendicular = 1
  150386. }
  150387. /**
  150388. * Interface for a physics hit data
  150389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150390. */
  150391. export interface PhysicsHitData {
  150392. /**
  150393. * The force applied at the contact point
  150394. */
  150395. force: Vector3;
  150396. /**
  150397. * The contact point
  150398. */
  150399. contactPoint: Vector3;
  150400. /**
  150401. * The distance from the origin to the contact point
  150402. */
  150403. distanceFromOrigin: number;
  150404. }
  150405. /**
  150406. * Interface for radial explosion event data
  150407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150408. */
  150409. export interface PhysicsRadialExplosionEventData {
  150410. /**
  150411. * A sphere used for the radial explosion event
  150412. */
  150413. sphere: Mesh;
  150414. }
  150415. /**
  150416. * Interface for gravitational field event data
  150417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150418. */
  150419. export interface PhysicsGravitationalFieldEventData {
  150420. /**
  150421. * A sphere mesh used for the gravitational field event
  150422. */
  150423. sphere: Mesh;
  150424. }
  150425. /**
  150426. * Interface for updraft event data
  150427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150428. */
  150429. export interface PhysicsUpdraftEventData {
  150430. /**
  150431. * A cylinder used for the updraft event
  150432. */
  150433. cylinder: Mesh;
  150434. }
  150435. /**
  150436. * Interface for vortex event data
  150437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150438. */
  150439. export interface PhysicsVortexEventData {
  150440. /**
  150441. * A cylinder used for the vortex event
  150442. */
  150443. cylinder: Mesh;
  150444. }
  150445. /**
  150446. * Interface for an affected physics impostor
  150447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150448. */
  150449. export interface PhysicsAffectedImpostorWithData {
  150450. /**
  150451. * The impostor affected by the effect
  150452. */
  150453. impostor: PhysicsImpostor;
  150454. /**
  150455. * The data about the hit/horce from the explosion
  150456. */
  150457. hitData: PhysicsHitData;
  150458. }
  150459. }
  150460. declare module BABYLON {
  150461. /** @hidden */
  150462. export var blackAndWhitePixelShader: {
  150463. name: string;
  150464. shader: string;
  150465. };
  150466. }
  150467. declare module BABYLON {
  150468. /**
  150469. * Post process used to render in black and white
  150470. */
  150471. export class BlackAndWhitePostProcess extends PostProcess {
  150472. /**
  150473. * Linear about to convert he result to black and white (default: 1)
  150474. */
  150475. degree: number;
  150476. /**
  150477. * Gets a string identifying the name of the class
  150478. * @returns "BlackAndWhitePostProcess" string
  150479. */
  150480. getClassName(): string;
  150481. /**
  150482. * Creates a black and white post process
  150483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  150484. * @param name The name of the effect.
  150485. * @param options The required width/height ratio to downsize to before computing the render pass.
  150486. * @param camera The camera to apply the render pass to.
  150487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150488. * @param engine The engine which the post process will be applied. (default: current engine)
  150489. * @param reusable If the post process can be reused on the same frame. (default: false)
  150490. */
  150491. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150492. /** @hidden */
  150493. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  150494. }
  150495. }
  150496. declare module BABYLON {
  150497. /**
  150498. * This represents a set of one or more post processes in Babylon.
  150499. * A post process can be used to apply a shader to a texture after it is rendered.
  150500. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150501. */
  150502. export class PostProcessRenderEffect {
  150503. private _postProcesses;
  150504. private _getPostProcesses;
  150505. private _singleInstance;
  150506. private _cameras;
  150507. private _indicesForCamera;
  150508. /**
  150509. * Name of the effect
  150510. * @hidden
  150511. */
  150512. _name: string;
  150513. /**
  150514. * Instantiates a post process render effect.
  150515. * A post process can be used to apply a shader to a texture after it is rendered.
  150516. * @param engine The engine the effect is tied to
  150517. * @param name The name of the effect
  150518. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  150519. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  150520. */
  150521. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  150522. /**
  150523. * Checks if all the post processes in the effect are supported.
  150524. */
  150525. get isSupported(): boolean;
  150526. /**
  150527. * Updates the current state of the effect
  150528. * @hidden
  150529. */
  150530. _update(): void;
  150531. /**
  150532. * Attaches the effect on cameras
  150533. * @param cameras The camera to attach to.
  150534. * @hidden
  150535. */
  150536. _attachCameras(cameras: Camera): void;
  150537. /**
  150538. * Attaches the effect on cameras
  150539. * @param cameras The camera to attach to.
  150540. * @hidden
  150541. */
  150542. _attachCameras(cameras: Camera[]): void;
  150543. /**
  150544. * Detaches the effect on cameras
  150545. * @param cameras The camera to detatch from.
  150546. * @hidden
  150547. */
  150548. _detachCameras(cameras: Camera): void;
  150549. /**
  150550. * Detatches the effect on cameras
  150551. * @param cameras The camera to detatch from.
  150552. * @hidden
  150553. */
  150554. _detachCameras(cameras: Camera[]): void;
  150555. /**
  150556. * Enables the effect on given cameras
  150557. * @param cameras The camera to enable.
  150558. * @hidden
  150559. */
  150560. _enable(cameras: Camera): void;
  150561. /**
  150562. * Enables the effect on given cameras
  150563. * @param cameras The camera to enable.
  150564. * @hidden
  150565. */
  150566. _enable(cameras: Nullable<Camera[]>): void;
  150567. /**
  150568. * Disables the effect on the given cameras
  150569. * @param cameras The camera to disable.
  150570. * @hidden
  150571. */
  150572. _disable(cameras: Camera): void;
  150573. /**
  150574. * Disables the effect on the given cameras
  150575. * @param cameras The camera to disable.
  150576. * @hidden
  150577. */
  150578. _disable(cameras: Nullable<Camera[]>): void;
  150579. /**
  150580. * Gets a list of the post processes contained in the effect.
  150581. * @param camera The camera to get the post processes on.
  150582. * @returns The list of the post processes in the effect.
  150583. */
  150584. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  150585. }
  150586. }
  150587. declare module BABYLON {
  150588. /** @hidden */
  150589. export var extractHighlightsPixelShader: {
  150590. name: string;
  150591. shader: string;
  150592. };
  150593. }
  150594. declare module BABYLON {
  150595. /**
  150596. * 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.
  150597. */
  150598. export class ExtractHighlightsPostProcess extends PostProcess {
  150599. /**
  150600. * The luminance threshold, pixels below this value will be set to black.
  150601. */
  150602. threshold: number;
  150603. /** @hidden */
  150604. _exposure: number;
  150605. /**
  150606. * Post process which has the input texture to be used when performing highlight extraction
  150607. * @hidden
  150608. */
  150609. _inputPostProcess: Nullable<PostProcess>;
  150610. /**
  150611. * Gets a string identifying the name of the class
  150612. * @returns "ExtractHighlightsPostProcess" string
  150613. */
  150614. getClassName(): string;
  150615. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150616. }
  150617. }
  150618. declare module BABYLON {
  150619. /** @hidden */
  150620. export var bloomMergePixelShader: {
  150621. name: string;
  150622. shader: string;
  150623. };
  150624. }
  150625. declare module BABYLON {
  150626. /**
  150627. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150628. */
  150629. export class BloomMergePostProcess extends PostProcess {
  150630. /** Weight of the bloom to be added to the original input. */
  150631. weight: number;
  150632. /**
  150633. * Gets a string identifying the name of the class
  150634. * @returns "BloomMergePostProcess" string
  150635. */
  150636. getClassName(): string;
  150637. /**
  150638. * Creates a new instance of @see BloomMergePostProcess
  150639. * @param name The name of the effect.
  150640. * @param originalFromInput Post process which's input will be used for the merge.
  150641. * @param blurred Blurred highlights post process which's output will be used.
  150642. * @param weight Weight of the bloom to be added to the original input.
  150643. * @param options The required width/height ratio to downsize to before computing the render pass.
  150644. * @param camera The camera to apply the render pass to.
  150645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150646. * @param engine The engine which the post process will be applied. (default: current engine)
  150647. * @param reusable If the post process can be reused on the same frame. (default: false)
  150648. * @param textureType Type of textures used when performing the post process. (default: 0)
  150649. * @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)
  150650. */
  150651. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  150652. /** Weight of the bloom to be added to the original input. */
  150653. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150654. }
  150655. }
  150656. declare module BABYLON {
  150657. /**
  150658. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  150659. */
  150660. export class BloomEffect extends PostProcessRenderEffect {
  150661. private bloomScale;
  150662. /**
  150663. * @hidden Internal
  150664. */
  150665. _effects: Array<PostProcess>;
  150666. /**
  150667. * @hidden Internal
  150668. */
  150669. _downscale: ExtractHighlightsPostProcess;
  150670. private _blurX;
  150671. private _blurY;
  150672. private _merge;
  150673. /**
  150674. * The luminance threshold to find bright areas of the image to bloom.
  150675. */
  150676. get threshold(): number;
  150677. set threshold(value: number);
  150678. /**
  150679. * The strength of the bloom.
  150680. */
  150681. get weight(): number;
  150682. set weight(value: number);
  150683. /**
  150684. * Specifies the size of the bloom blur kernel, relative to the final output size
  150685. */
  150686. get kernel(): number;
  150687. set kernel(value: number);
  150688. /**
  150689. * Creates a new instance of @see BloomEffect
  150690. * @param scene The scene the effect belongs to.
  150691. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  150692. * @param bloomKernel The size of the kernel to be used when applying the blur.
  150693. * @param bloomWeight The the strength of bloom.
  150694. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150695. * @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)
  150696. */
  150697. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  150698. /**
  150699. * Disposes each of the internal effects for a given camera.
  150700. * @param camera The camera to dispose the effect on.
  150701. */
  150702. disposeEffects(camera: Camera): void;
  150703. /**
  150704. * @hidden Internal
  150705. */
  150706. _updateEffects(): void;
  150707. /**
  150708. * Internal
  150709. * @returns if all the contained post processes are ready.
  150710. * @hidden
  150711. */
  150712. _isReady(): boolean;
  150713. }
  150714. }
  150715. declare module BABYLON {
  150716. /** @hidden */
  150717. export var chromaticAberrationPixelShader: {
  150718. name: string;
  150719. shader: string;
  150720. };
  150721. }
  150722. declare module BABYLON {
  150723. /**
  150724. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  150725. */
  150726. export class ChromaticAberrationPostProcess extends PostProcess {
  150727. /**
  150728. * The amount of seperation of rgb channels (default: 30)
  150729. */
  150730. aberrationAmount: number;
  150731. /**
  150732. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  150733. */
  150734. radialIntensity: number;
  150735. /**
  150736. * 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))
  150737. */
  150738. direction: Vector2;
  150739. /**
  150740. * 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))
  150741. */
  150742. centerPosition: Vector2;
  150743. /** The width of the screen to apply the effect on */
  150744. screenWidth: number;
  150745. /** The height of the screen to apply the effect on */
  150746. screenHeight: number;
  150747. /**
  150748. * Gets a string identifying the name of the class
  150749. * @returns "ChromaticAberrationPostProcess" string
  150750. */
  150751. getClassName(): string;
  150752. /**
  150753. * Creates a new instance ChromaticAberrationPostProcess
  150754. * @param name The name of the effect.
  150755. * @param screenWidth The width of the screen to apply the effect on.
  150756. * @param screenHeight The height of the screen to apply the effect on.
  150757. * @param options The required width/height ratio to downsize to before computing the render pass.
  150758. * @param camera The camera to apply the render pass to.
  150759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150760. * @param engine The engine which the post process will be applied. (default: current engine)
  150761. * @param reusable If the post process can be reused on the same frame. (default: false)
  150762. * @param textureType Type of textures used when performing the post process. (default: 0)
  150763. * @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)
  150764. */
  150765. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150766. /** @hidden */
  150767. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  150768. }
  150769. }
  150770. declare module BABYLON {
  150771. /** @hidden */
  150772. export var circleOfConfusionPixelShader: {
  150773. name: string;
  150774. shader: string;
  150775. };
  150776. }
  150777. declare module BABYLON {
  150778. /**
  150779. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  150780. */
  150781. export class CircleOfConfusionPostProcess extends PostProcess {
  150782. /**
  150783. * 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.
  150784. */
  150785. lensSize: number;
  150786. /**
  150787. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150788. */
  150789. fStop: number;
  150790. /**
  150791. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150792. */
  150793. focusDistance: number;
  150794. /**
  150795. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  150796. */
  150797. focalLength: number;
  150798. /**
  150799. * Gets a string identifying the name of the class
  150800. * @returns "CircleOfConfusionPostProcess" string
  150801. */
  150802. getClassName(): string;
  150803. private _depthTexture;
  150804. /**
  150805. * Creates a new instance CircleOfConfusionPostProcess
  150806. * @param name The name of the effect.
  150807. * @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.
  150808. * @param options The required width/height ratio to downsize to before computing the render pass.
  150809. * @param camera The camera to apply the render pass to.
  150810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150811. * @param engine The engine which the post process will be applied. (default: current engine)
  150812. * @param reusable If the post process can be reused on the same frame. (default: false)
  150813. * @param textureType Type of textures used when performing the post process. (default: 0)
  150814. * @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)
  150815. */
  150816. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150817. /**
  150818. * 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.
  150819. */
  150820. set depthTexture(value: RenderTargetTexture);
  150821. }
  150822. }
  150823. declare module BABYLON {
  150824. /** @hidden */
  150825. export var colorCorrectionPixelShader: {
  150826. name: string;
  150827. shader: string;
  150828. };
  150829. }
  150830. declare module BABYLON {
  150831. /**
  150832. *
  150833. * This post-process allows the modification of rendered colors by using
  150834. * a 'look-up table' (LUT). This effect is also called Color Grading.
  150835. *
  150836. * The object needs to be provided an url to a texture containing the color
  150837. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  150838. * Use an image editing software to tweak the LUT to match your needs.
  150839. *
  150840. * For an example of a color LUT, see here:
  150841. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  150842. * For explanations on color grading, see here:
  150843. * @see http://udn.epicgames.com/Three/ColorGrading.html
  150844. *
  150845. */
  150846. export class ColorCorrectionPostProcess extends PostProcess {
  150847. private _colorTableTexture;
  150848. /**
  150849. * Gets the color table url used to create the LUT texture
  150850. */
  150851. colorTableUrl: string;
  150852. /**
  150853. * Gets a string identifying the name of the class
  150854. * @returns "ColorCorrectionPostProcess" string
  150855. */
  150856. getClassName(): string;
  150857. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150858. /** @hidden */
  150859. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  150860. }
  150861. }
  150862. declare module BABYLON {
  150863. /** @hidden */
  150864. export var convolutionPixelShader: {
  150865. name: string;
  150866. shader: string;
  150867. };
  150868. }
  150869. declare module BABYLON {
  150870. /**
  150871. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  150872. * input texture to perform effects such as edge detection or sharpening
  150873. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150874. */
  150875. export class ConvolutionPostProcess extends PostProcess {
  150876. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  150877. kernel: number[];
  150878. /**
  150879. * Gets a string identifying the name of the class
  150880. * @returns "ConvolutionPostProcess" string
  150881. */
  150882. getClassName(): string;
  150883. /**
  150884. * Creates a new instance ConvolutionPostProcess
  150885. * @param name The name of the effect.
  150886. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  150887. * @param options The required width/height ratio to downsize to before computing the render pass.
  150888. * @param camera The camera to apply the render pass to.
  150889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150890. * @param engine The engine which the post process will be applied. (default: current engine)
  150891. * @param reusable If the post process can be reused on the same frame. (default: false)
  150892. * @param textureType Type of textures used when performing the post process. (default: 0)
  150893. */
  150894. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150895. /** @hidden */
  150896. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  150897. /**
  150898. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150899. */
  150900. static EdgeDetect0Kernel: number[];
  150901. /**
  150902. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150903. */
  150904. static EdgeDetect1Kernel: number[];
  150905. /**
  150906. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150907. */
  150908. static EdgeDetect2Kernel: number[];
  150909. /**
  150910. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150911. */
  150912. static SharpenKernel: number[];
  150913. /**
  150914. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150915. */
  150916. static EmbossKernel: number[];
  150917. /**
  150918. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150919. */
  150920. static GaussianKernel: number[];
  150921. }
  150922. }
  150923. declare module BABYLON {
  150924. /**
  150925. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  150926. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  150927. * based on samples that have a large difference in distance than the center pixel.
  150928. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  150929. */
  150930. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  150931. /**
  150932. * The direction the blur should be applied
  150933. */
  150934. direction: Vector2;
  150935. /**
  150936. * Gets a string identifying the name of the class
  150937. * @returns "DepthOfFieldBlurPostProcess" string
  150938. */
  150939. getClassName(): string;
  150940. /**
  150941. * Creates a new instance CircleOfConfusionPostProcess
  150942. * @param name The name of the effect.
  150943. * @param scene The scene the effect belongs to.
  150944. * @param direction The direction the blur should be applied.
  150945. * @param kernel The size of the kernel used to blur.
  150946. * @param options The required width/height ratio to downsize to before computing the render pass.
  150947. * @param camera The camera to apply the render pass to.
  150948. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  150949. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  150950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150951. * @param engine The engine which the post process will be applied. (default: current engine)
  150952. * @param reusable If the post process can be reused on the same frame. (default: false)
  150953. * @param textureType Type of textures used when performing the post process. (default: 0)
  150954. * @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)
  150955. */
  150956. 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);
  150957. }
  150958. }
  150959. declare module BABYLON {
  150960. /** @hidden */
  150961. export var depthOfFieldMergePixelShader: {
  150962. name: string;
  150963. shader: string;
  150964. };
  150965. }
  150966. declare module BABYLON {
  150967. /**
  150968. * Options to be set when merging outputs from the default pipeline.
  150969. */
  150970. export class DepthOfFieldMergePostProcessOptions {
  150971. /**
  150972. * The original image to merge on top of
  150973. */
  150974. originalFromInput: PostProcess;
  150975. /**
  150976. * Parameters to perform the merge of the depth of field effect
  150977. */
  150978. depthOfField?: {
  150979. circleOfConfusion: PostProcess;
  150980. blurSteps: Array<PostProcess>;
  150981. };
  150982. /**
  150983. * Parameters to perform the merge of bloom effect
  150984. */
  150985. bloom?: {
  150986. blurred: PostProcess;
  150987. weight: number;
  150988. };
  150989. }
  150990. /**
  150991. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150992. */
  150993. export class DepthOfFieldMergePostProcess extends PostProcess {
  150994. private blurSteps;
  150995. /**
  150996. * Gets a string identifying the name of the class
  150997. * @returns "DepthOfFieldMergePostProcess" string
  150998. */
  150999. getClassName(): string;
  151000. /**
  151001. * Creates a new instance of DepthOfFieldMergePostProcess
  151002. * @param name The name of the effect.
  151003. * @param originalFromInput Post process which's input will be used for the merge.
  151004. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  151005. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  151006. * @param options The required width/height ratio to downsize to before computing the render pass.
  151007. * @param camera The camera to apply the render pass to.
  151008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151009. * @param engine The engine which the post process will be applied. (default: current engine)
  151010. * @param reusable If the post process can be reused on the same frame. (default: false)
  151011. * @param textureType Type of textures used when performing the post process. (default: 0)
  151012. * @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)
  151013. */
  151014. 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);
  151015. /**
  151016. * Updates the effect with the current post process compile time values and recompiles the shader.
  151017. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  151018. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  151019. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  151020. * @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
  151021. * @param onCompiled Called when the shader has been compiled.
  151022. * @param onError Called if there is an error when compiling a shader.
  151023. */
  151024. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  151025. }
  151026. }
  151027. declare module BABYLON {
  151028. /**
  151029. * Specifies the level of max blur that should be applied when using the depth of field effect
  151030. */
  151031. export enum DepthOfFieldEffectBlurLevel {
  151032. /**
  151033. * Subtle blur
  151034. */
  151035. Low = 0,
  151036. /**
  151037. * Medium blur
  151038. */
  151039. Medium = 1,
  151040. /**
  151041. * Large blur
  151042. */
  151043. High = 2
  151044. }
  151045. /**
  151046. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  151047. */
  151048. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  151049. private _circleOfConfusion;
  151050. /**
  151051. * @hidden Internal, blurs from high to low
  151052. */
  151053. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  151054. private _depthOfFieldBlurY;
  151055. private _dofMerge;
  151056. /**
  151057. * @hidden Internal post processes in depth of field effect
  151058. */
  151059. _effects: Array<PostProcess>;
  151060. /**
  151061. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  151062. */
  151063. set focalLength(value: number);
  151064. get focalLength(): number;
  151065. /**
  151066. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  151067. */
  151068. set fStop(value: number);
  151069. get fStop(): number;
  151070. /**
  151071. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  151072. */
  151073. set focusDistance(value: number);
  151074. get focusDistance(): number;
  151075. /**
  151076. * 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.
  151077. */
  151078. set lensSize(value: number);
  151079. get lensSize(): number;
  151080. /**
  151081. * Creates a new instance DepthOfFieldEffect
  151082. * @param scene The scene the effect belongs to.
  151083. * @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.
  151084. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151085. * @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)
  151086. */
  151087. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  151088. /**
  151089. * Get the current class name of the current effet
  151090. * @returns "DepthOfFieldEffect"
  151091. */
  151092. getClassName(): string;
  151093. /**
  151094. * 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.
  151095. */
  151096. set depthTexture(value: RenderTargetTexture);
  151097. /**
  151098. * Disposes each of the internal effects for a given camera.
  151099. * @param camera The camera to dispose the effect on.
  151100. */
  151101. disposeEffects(camera: Camera): void;
  151102. /**
  151103. * @hidden Internal
  151104. */
  151105. _updateEffects(): void;
  151106. /**
  151107. * Internal
  151108. * @returns if all the contained post processes are ready.
  151109. * @hidden
  151110. */
  151111. _isReady(): boolean;
  151112. }
  151113. }
  151114. declare module BABYLON {
  151115. /** @hidden */
  151116. export var displayPassPixelShader: {
  151117. name: string;
  151118. shader: string;
  151119. };
  151120. }
  151121. declare module BABYLON {
  151122. /**
  151123. * DisplayPassPostProcess which produces an output the same as it's input
  151124. */
  151125. export class DisplayPassPostProcess extends PostProcess {
  151126. /**
  151127. * Gets a string identifying the name of the class
  151128. * @returns "DisplayPassPostProcess" string
  151129. */
  151130. getClassName(): string;
  151131. /**
  151132. * Creates the DisplayPassPostProcess
  151133. * @param name The name of the effect.
  151134. * @param options The required width/height ratio to downsize to before computing the render pass.
  151135. * @param camera The camera to apply the render pass to.
  151136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151137. * @param engine The engine which the post process will be applied. (default: current engine)
  151138. * @param reusable If the post process can be reused on the same frame. (default: false)
  151139. */
  151140. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151141. /** @hidden */
  151142. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  151143. }
  151144. }
  151145. declare module BABYLON {
  151146. /** @hidden */
  151147. export var filterPixelShader: {
  151148. name: string;
  151149. shader: string;
  151150. };
  151151. }
  151152. declare module BABYLON {
  151153. /**
  151154. * Applies a kernel filter to the image
  151155. */
  151156. export class FilterPostProcess extends PostProcess {
  151157. /** The matrix to be applied to the image */
  151158. kernelMatrix: Matrix;
  151159. /**
  151160. * Gets a string identifying the name of the class
  151161. * @returns "FilterPostProcess" string
  151162. */
  151163. getClassName(): string;
  151164. /**
  151165. *
  151166. * @param name The name of the effect.
  151167. * @param kernelMatrix The matrix to be applied to the image
  151168. * @param options The required width/height ratio to downsize to before computing the render pass.
  151169. * @param camera The camera to apply the render pass to.
  151170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151171. * @param engine The engine which the post process will be applied. (default: current engine)
  151172. * @param reusable If the post process can be reused on the same frame. (default: false)
  151173. */
  151174. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151175. /** @hidden */
  151176. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  151177. }
  151178. }
  151179. declare module BABYLON {
  151180. /** @hidden */
  151181. export var fxaaPixelShader: {
  151182. name: string;
  151183. shader: string;
  151184. };
  151185. }
  151186. declare module BABYLON {
  151187. /** @hidden */
  151188. export var fxaaVertexShader: {
  151189. name: string;
  151190. shader: string;
  151191. };
  151192. }
  151193. declare module BABYLON {
  151194. /**
  151195. * Fxaa post process
  151196. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  151197. */
  151198. export class FxaaPostProcess extends PostProcess {
  151199. /**
  151200. * Gets a string identifying the name of the class
  151201. * @returns "FxaaPostProcess" string
  151202. */
  151203. getClassName(): string;
  151204. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151205. private _getDefines;
  151206. /** @hidden */
  151207. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  151208. }
  151209. }
  151210. declare module BABYLON {
  151211. /** @hidden */
  151212. export var grainPixelShader: {
  151213. name: string;
  151214. shader: string;
  151215. };
  151216. }
  151217. declare module BABYLON {
  151218. /**
  151219. * The GrainPostProcess adds noise to the image at mid luminance levels
  151220. */
  151221. export class GrainPostProcess extends PostProcess {
  151222. /**
  151223. * The intensity of the grain added (default: 30)
  151224. */
  151225. intensity: number;
  151226. /**
  151227. * If the grain should be randomized on every frame
  151228. */
  151229. animated: boolean;
  151230. /**
  151231. * Gets a string identifying the name of the class
  151232. * @returns "GrainPostProcess" string
  151233. */
  151234. getClassName(): string;
  151235. /**
  151236. * Creates a new instance of @see GrainPostProcess
  151237. * @param name The name of the effect.
  151238. * @param options The required width/height ratio to downsize to before computing the render pass.
  151239. * @param camera The camera to apply the render pass to.
  151240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151241. * @param engine The engine which the post process will be applied. (default: current engine)
  151242. * @param reusable If the post process can be reused on the same frame. (default: false)
  151243. * @param textureType Type of textures used when performing the post process. (default: 0)
  151244. * @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)
  151245. */
  151246. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151247. /** @hidden */
  151248. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  151249. }
  151250. }
  151251. declare module BABYLON {
  151252. /** @hidden */
  151253. export var highlightsPixelShader: {
  151254. name: string;
  151255. shader: string;
  151256. };
  151257. }
  151258. declare module BABYLON {
  151259. /**
  151260. * Extracts highlights from the image
  151261. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151262. */
  151263. export class HighlightsPostProcess extends PostProcess {
  151264. /**
  151265. * Gets a string identifying the name of the class
  151266. * @returns "HighlightsPostProcess" string
  151267. */
  151268. getClassName(): string;
  151269. /**
  151270. * Extracts highlights from the image
  151271. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151272. * @param name The name of the effect.
  151273. * @param options The required width/height ratio to downsize to before computing the render pass.
  151274. * @param camera The camera to apply the render pass to.
  151275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151276. * @param engine The engine which the post process will be applied. (default: current engine)
  151277. * @param reusable If the post process can be reused on the same frame. (default: false)
  151278. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  151279. */
  151280. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151281. }
  151282. }
  151283. declare module BABYLON {
  151284. /**
  151285. * Contains all parameters needed for the prepass to perform
  151286. * motion blur
  151287. */
  151288. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  151289. /**
  151290. * Is motion blur enabled
  151291. */
  151292. enabled: boolean;
  151293. /**
  151294. * Name of the configuration
  151295. */
  151296. name: string;
  151297. /**
  151298. * Textures that should be present in the MRT for this effect to work
  151299. */
  151300. readonly texturesRequired: number[];
  151301. }
  151302. }
  151303. declare module BABYLON {
  151304. interface Scene {
  151305. /** @hidden (Backing field) */
  151306. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151307. /**
  151308. * Gets or Sets the current geometry buffer associated to the scene.
  151309. */
  151310. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151311. /**
  151312. * Enables a GeometryBufferRender and associates it with the scene
  151313. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  151314. * @returns the GeometryBufferRenderer
  151315. */
  151316. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  151317. /**
  151318. * Disables the GeometryBufferRender associated with the scene
  151319. */
  151320. disableGeometryBufferRenderer(): void;
  151321. }
  151322. /**
  151323. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151324. * in several rendering techniques.
  151325. */
  151326. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  151327. /**
  151328. * The component name helpful to identify the component in the list of scene components.
  151329. */
  151330. readonly name: string;
  151331. /**
  151332. * The scene the component belongs to.
  151333. */
  151334. scene: Scene;
  151335. /**
  151336. * Creates a new instance of the component for the given scene
  151337. * @param scene Defines the scene to register the component in
  151338. */
  151339. constructor(scene: Scene);
  151340. /**
  151341. * Registers the component in a given scene
  151342. */
  151343. register(): void;
  151344. /**
  151345. * Rebuilds the elements related to this component in case of
  151346. * context lost for instance.
  151347. */
  151348. rebuild(): void;
  151349. /**
  151350. * Disposes the component and the associated ressources
  151351. */
  151352. dispose(): void;
  151353. private _gatherRenderTargets;
  151354. }
  151355. }
  151356. declare module BABYLON {
  151357. /** @hidden */
  151358. export var motionBlurPixelShader: {
  151359. name: string;
  151360. shader: string;
  151361. };
  151362. }
  151363. declare module BABYLON {
  151364. /**
  151365. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  151366. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  151367. * As an example, all you have to do is to create the post-process:
  151368. * var mb = new BABYLON.MotionBlurPostProcess(
  151369. * 'mb', // The name of the effect.
  151370. * scene, // The scene containing the objects to blur according to their velocity.
  151371. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  151372. * camera // The camera to apply the render pass to.
  151373. * );
  151374. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  151375. */
  151376. export class MotionBlurPostProcess extends PostProcess {
  151377. /**
  151378. * Defines how much the image is blurred by the movement. Default value is equal to 1
  151379. */
  151380. motionStrength: number;
  151381. /**
  151382. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  151383. */
  151384. get motionBlurSamples(): number;
  151385. /**
  151386. * Sets the number of iterations to be used for motion blur quality
  151387. */
  151388. set motionBlurSamples(samples: number);
  151389. private _motionBlurSamples;
  151390. private _forceGeometryBuffer;
  151391. private _geometryBufferRenderer;
  151392. private _prePassRenderer;
  151393. /**
  151394. * Gets a string identifying the name of the class
  151395. * @returns "MotionBlurPostProcess" string
  151396. */
  151397. getClassName(): string;
  151398. /**
  151399. * Creates a new instance MotionBlurPostProcess
  151400. * @param name The name of the effect.
  151401. * @param scene The scene containing the objects to blur according to their velocity.
  151402. * @param options The required width/height ratio to downsize to before computing the render pass.
  151403. * @param camera The camera to apply the render pass to.
  151404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151405. * @param engine The engine which the post process will be applied. (default: current engine)
  151406. * @param reusable If the post process can be reused on the same frame. (default: false)
  151407. * @param textureType Type of textures used when performing the post process. (default: 0)
  151408. * @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)
  151409. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  151410. */
  151411. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  151412. /**
  151413. * Excludes the given skinned mesh from computing bones velocities.
  151414. * 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.
  151415. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  151416. */
  151417. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151418. /**
  151419. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  151420. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  151421. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  151422. */
  151423. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151424. /**
  151425. * Disposes the post process.
  151426. * @param camera The camera to dispose the post process on.
  151427. */
  151428. dispose(camera?: Camera): void;
  151429. /** @hidden */
  151430. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  151431. }
  151432. }
  151433. declare module BABYLON {
  151434. /** @hidden */
  151435. export var refractionPixelShader: {
  151436. name: string;
  151437. shader: string;
  151438. };
  151439. }
  151440. declare module BABYLON {
  151441. /**
  151442. * Post process which applies a refractin texture
  151443. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151444. */
  151445. export class RefractionPostProcess extends PostProcess {
  151446. private _refTexture;
  151447. private _ownRefractionTexture;
  151448. /** the base color of the refraction (used to taint the rendering) */
  151449. color: Color3;
  151450. /** simulated refraction depth */
  151451. depth: number;
  151452. /** the coefficient of the base color (0 to remove base color tainting) */
  151453. colorLevel: number;
  151454. /** Gets the url used to load the refraction texture */
  151455. refractionTextureUrl: string;
  151456. /**
  151457. * Gets or sets the refraction texture
  151458. * Please note that you are responsible for disposing the texture if you set it manually
  151459. */
  151460. get refractionTexture(): Texture;
  151461. set refractionTexture(value: Texture);
  151462. /**
  151463. * Gets a string identifying the name of the class
  151464. * @returns "RefractionPostProcess" string
  151465. */
  151466. getClassName(): string;
  151467. /**
  151468. * Initializes the RefractionPostProcess
  151469. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151470. * @param name The name of the effect.
  151471. * @param refractionTextureUrl Url of the refraction texture to use
  151472. * @param color the base color of the refraction (used to taint the rendering)
  151473. * @param depth simulated refraction depth
  151474. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  151475. * @param camera The camera to apply the render pass to.
  151476. * @param options The required width/height ratio to downsize to before computing the render pass.
  151477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151478. * @param engine The engine which the post process will be applied. (default: current engine)
  151479. * @param reusable If the post process can be reused on the same frame. (default: false)
  151480. */
  151481. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151482. /**
  151483. * Disposes of the post process
  151484. * @param camera Camera to dispose post process on
  151485. */
  151486. dispose(camera: Camera): void;
  151487. /** @hidden */
  151488. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  151489. }
  151490. }
  151491. declare module BABYLON {
  151492. /** @hidden */
  151493. export var sharpenPixelShader: {
  151494. name: string;
  151495. shader: string;
  151496. };
  151497. }
  151498. declare module BABYLON {
  151499. /**
  151500. * The SharpenPostProcess applies a sharpen kernel to every pixel
  151501. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151502. */
  151503. export class SharpenPostProcess extends PostProcess {
  151504. /**
  151505. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  151506. */
  151507. colorAmount: number;
  151508. /**
  151509. * How much sharpness should be applied (default: 0.3)
  151510. */
  151511. edgeAmount: number;
  151512. /**
  151513. * Gets a string identifying the name of the class
  151514. * @returns "SharpenPostProcess" string
  151515. */
  151516. getClassName(): string;
  151517. /**
  151518. * Creates a new instance ConvolutionPostProcess
  151519. * @param name The name of the effect.
  151520. * @param options The required width/height ratio to downsize to before computing the render pass.
  151521. * @param camera The camera to apply the render pass to.
  151522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151523. * @param engine The engine which the post process will be applied. (default: current engine)
  151524. * @param reusable If the post process can be reused on the same frame. (default: false)
  151525. * @param textureType Type of textures used when performing the post process. (default: 0)
  151526. * @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)
  151527. */
  151528. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151529. /** @hidden */
  151530. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  151531. }
  151532. }
  151533. declare module BABYLON {
  151534. /**
  151535. * PostProcessRenderPipeline
  151536. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151537. */
  151538. export class PostProcessRenderPipeline {
  151539. private engine;
  151540. private _renderEffects;
  151541. private _renderEffectsForIsolatedPass;
  151542. /**
  151543. * List of inspectable custom properties (used by the Inspector)
  151544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  151545. */
  151546. inspectableCustomProperties: IInspectable[];
  151547. /**
  151548. * @hidden
  151549. */
  151550. protected _cameras: Camera[];
  151551. /** @hidden */
  151552. _name: string;
  151553. /**
  151554. * Gets pipeline name
  151555. */
  151556. get name(): string;
  151557. /** Gets the list of attached cameras */
  151558. get cameras(): Camera[];
  151559. /**
  151560. * Initializes a PostProcessRenderPipeline
  151561. * @param engine engine to add the pipeline to
  151562. * @param name name of the pipeline
  151563. */
  151564. constructor(engine: Engine, name: string);
  151565. /**
  151566. * Gets the class name
  151567. * @returns "PostProcessRenderPipeline"
  151568. */
  151569. getClassName(): string;
  151570. /**
  151571. * If all the render effects in the pipeline are supported
  151572. */
  151573. get isSupported(): boolean;
  151574. /**
  151575. * Adds an effect to the pipeline
  151576. * @param renderEffect the effect to add
  151577. */
  151578. addEffect(renderEffect: PostProcessRenderEffect): void;
  151579. /** @hidden */
  151580. _rebuild(): void;
  151581. /** @hidden */
  151582. _enableEffect(renderEffectName: string, cameras: Camera): void;
  151583. /** @hidden */
  151584. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  151585. /** @hidden */
  151586. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151587. /** @hidden */
  151588. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151589. /** @hidden */
  151590. _attachCameras(cameras: Camera, unique: boolean): void;
  151591. /** @hidden */
  151592. _attachCameras(cameras: Camera[], unique: boolean): void;
  151593. /** @hidden */
  151594. _detachCameras(cameras: Camera): void;
  151595. /** @hidden */
  151596. _detachCameras(cameras: Nullable<Camera[]>): void;
  151597. /** @hidden */
  151598. _update(): void;
  151599. /** @hidden */
  151600. _reset(): void;
  151601. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  151602. /**
  151603. * Sets the required values to the prepass renderer.
  151604. * @param prePassRenderer defines the prepass renderer to setup.
  151605. * @returns true if the pre pass is needed.
  151606. */
  151607. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151608. /**
  151609. * Disposes of the pipeline
  151610. */
  151611. dispose(): void;
  151612. }
  151613. }
  151614. declare module BABYLON {
  151615. /**
  151616. * PostProcessRenderPipelineManager class
  151617. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151618. */
  151619. export class PostProcessRenderPipelineManager {
  151620. private _renderPipelines;
  151621. /**
  151622. * Initializes a PostProcessRenderPipelineManager
  151623. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151624. */
  151625. constructor();
  151626. /**
  151627. * Gets the list of supported render pipelines
  151628. */
  151629. get supportedPipelines(): PostProcessRenderPipeline[];
  151630. /**
  151631. * Adds a pipeline to the manager
  151632. * @param renderPipeline The pipeline to add
  151633. */
  151634. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  151635. /**
  151636. * Attaches a camera to the pipeline
  151637. * @param renderPipelineName The name of the pipeline to attach to
  151638. * @param cameras the camera to attach
  151639. * @param unique if the camera can be attached multiple times to the pipeline
  151640. */
  151641. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  151642. /**
  151643. * Detaches a camera from the pipeline
  151644. * @param renderPipelineName The name of the pipeline to detach from
  151645. * @param cameras the camera to detach
  151646. */
  151647. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  151648. /**
  151649. * Enables an effect by name on a pipeline
  151650. * @param renderPipelineName the name of the pipeline to enable the effect in
  151651. * @param renderEffectName the name of the effect to enable
  151652. * @param cameras the cameras that the effect should be enabled on
  151653. */
  151654. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151655. /**
  151656. * Disables an effect by name on a pipeline
  151657. * @param renderPipelineName the name of the pipeline to disable the effect in
  151658. * @param renderEffectName the name of the effect to disable
  151659. * @param cameras the cameras that the effect should be disabled on
  151660. */
  151661. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151662. /**
  151663. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  151664. */
  151665. update(): void;
  151666. /** @hidden */
  151667. _rebuild(): void;
  151668. /**
  151669. * Disposes of the manager and pipelines
  151670. */
  151671. dispose(): void;
  151672. }
  151673. }
  151674. declare module BABYLON {
  151675. interface Scene {
  151676. /** @hidden (Backing field) */
  151677. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151678. /**
  151679. * Gets the postprocess render pipeline manager
  151680. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151681. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151682. */
  151683. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151684. }
  151685. /**
  151686. * Defines the Render Pipeline scene component responsible to rendering pipelines
  151687. */
  151688. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  151689. /**
  151690. * The component name helpfull to identify the component in the list of scene components.
  151691. */
  151692. readonly name: string;
  151693. /**
  151694. * The scene the component belongs to.
  151695. */
  151696. scene: Scene;
  151697. /**
  151698. * Creates a new instance of the component for the given scene
  151699. * @param scene Defines the scene to register the component in
  151700. */
  151701. constructor(scene: Scene);
  151702. /**
  151703. * Registers the component in a given scene
  151704. */
  151705. register(): void;
  151706. /**
  151707. * Rebuilds the elements related to this component in case of
  151708. * context lost for instance.
  151709. */
  151710. rebuild(): void;
  151711. /**
  151712. * Disposes the component and the associated ressources
  151713. */
  151714. dispose(): void;
  151715. private _gatherRenderTargets;
  151716. }
  151717. }
  151718. declare module BABYLON {
  151719. /**
  151720. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  151721. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151722. */
  151723. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151724. private _scene;
  151725. private _camerasToBeAttached;
  151726. /**
  151727. * ID of the sharpen post process,
  151728. */
  151729. private readonly SharpenPostProcessId;
  151730. /**
  151731. * @ignore
  151732. * ID of the image processing post process;
  151733. */
  151734. readonly ImageProcessingPostProcessId: string;
  151735. /**
  151736. * @ignore
  151737. * ID of the Fast Approximate Anti-Aliasing post process;
  151738. */
  151739. readonly FxaaPostProcessId: string;
  151740. /**
  151741. * ID of the chromatic aberration post process,
  151742. */
  151743. private readonly ChromaticAberrationPostProcessId;
  151744. /**
  151745. * ID of the grain post process
  151746. */
  151747. private readonly GrainPostProcessId;
  151748. /**
  151749. * Sharpen post process which will apply a sharpen convolution to enhance edges
  151750. */
  151751. sharpen: SharpenPostProcess;
  151752. private _sharpenEffect;
  151753. private bloom;
  151754. /**
  151755. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  151756. */
  151757. depthOfField: DepthOfFieldEffect;
  151758. /**
  151759. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151760. */
  151761. fxaa: FxaaPostProcess;
  151762. /**
  151763. * Image post processing pass used to perform operations such as tone mapping or color grading.
  151764. */
  151765. imageProcessing: ImageProcessingPostProcess;
  151766. /**
  151767. * Chromatic aberration post process which will shift rgb colors in the image
  151768. */
  151769. chromaticAberration: ChromaticAberrationPostProcess;
  151770. private _chromaticAberrationEffect;
  151771. /**
  151772. * Grain post process which add noise to the image
  151773. */
  151774. grain: GrainPostProcess;
  151775. private _grainEffect;
  151776. /**
  151777. * Glow post process which adds a glow to emissive areas of the image
  151778. */
  151779. private _glowLayer;
  151780. /**
  151781. * Animations which can be used to tweak settings over a period of time
  151782. */
  151783. animations: Animation[];
  151784. private _imageProcessingConfigurationObserver;
  151785. private _sharpenEnabled;
  151786. private _bloomEnabled;
  151787. private _depthOfFieldEnabled;
  151788. private _depthOfFieldBlurLevel;
  151789. private _fxaaEnabled;
  151790. private _imageProcessingEnabled;
  151791. private _defaultPipelineTextureType;
  151792. private _bloomScale;
  151793. private _chromaticAberrationEnabled;
  151794. private _grainEnabled;
  151795. private _buildAllowed;
  151796. /**
  151797. * Gets active scene
  151798. */
  151799. get scene(): Scene;
  151800. /**
  151801. * Enable or disable the sharpen process from the pipeline
  151802. */
  151803. set sharpenEnabled(enabled: boolean);
  151804. get sharpenEnabled(): boolean;
  151805. private _resizeObserver;
  151806. private _hardwareScaleLevel;
  151807. private _bloomKernel;
  151808. /**
  151809. * Specifies the size of the bloom blur kernel, relative to the final output size
  151810. */
  151811. get bloomKernel(): number;
  151812. set bloomKernel(value: number);
  151813. /**
  151814. * Specifies the weight of the bloom in the final rendering
  151815. */
  151816. private _bloomWeight;
  151817. /**
  151818. * Specifies the luma threshold for the area that will be blurred by the bloom
  151819. */
  151820. private _bloomThreshold;
  151821. private _hdr;
  151822. /**
  151823. * The strength of the bloom.
  151824. */
  151825. set bloomWeight(value: number);
  151826. get bloomWeight(): number;
  151827. /**
  151828. * The strength of the bloom.
  151829. */
  151830. set bloomThreshold(value: number);
  151831. get bloomThreshold(): number;
  151832. /**
  151833. * The scale of the bloom, lower value will provide better performance.
  151834. */
  151835. set bloomScale(value: number);
  151836. get bloomScale(): number;
  151837. /**
  151838. * Enable or disable the bloom from the pipeline
  151839. */
  151840. set bloomEnabled(enabled: boolean);
  151841. get bloomEnabled(): boolean;
  151842. private _rebuildBloom;
  151843. /**
  151844. * If the depth of field is enabled.
  151845. */
  151846. get depthOfFieldEnabled(): boolean;
  151847. set depthOfFieldEnabled(enabled: boolean);
  151848. /**
  151849. * Blur level of the depth of field effect. (Higher blur will effect performance)
  151850. */
  151851. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  151852. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  151853. /**
  151854. * If the anti aliasing is enabled.
  151855. */
  151856. set fxaaEnabled(enabled: boolean);
  151857. get fxaaEnabled(): boolean;
  151858. private _samples;
  151859. /**
  151860. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151861. */
  151862. set samples(sampleCount: number);
  151863. get samples(): number;
  151864. /**
  151865. * If image processing is enabled.
  151866. */
  151867. set imageProcessingEnabled(enabled: boolean);
  151868. get imageProcessingEnabled(): boolean;
  151869. /**
  151870. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  151871. */
  151872. set glowLayerEnabled(enabled: boolean);
  151873. get glowLayerEnabled(): boolean;
  151874. /**
  151875. * Gets the glow layer (or null if not defined)
  151876. */
  151877. get glowLayer(): Nullable<GlowLayer>;
  151878. /**
  151879. * Enable or disable the chromaticAberration process from the pipeline
  151880. */
  151881. set chromaticAberrationEnabled(enabled: boolean);
  151882. get chromaticAberrationEnabled(): boolean;
  151883. /**
  151884. * Enable or disable the grain process from the pipeline
  151885. */
  151886. set grainEnabled(enabled: boolean);
  151887. get grainEnabled(): boolean;
  151888. /**
  151889. * @constructor
  151890. * @param name - The rendering pipeline name (default: "")
  151891. * @param hdr - If high dynamic range textures should be used (default: true)
  151892. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151893. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151894. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151895. */
  151896. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151897. /**
  151898. * Get the class name
  151899. * @returns "DefaultRenderingPipeline"
  151900. */
  151901. getClassName(): string;
  151902. /**
  151903. * Force the compilation of the entire pipeline.
  151904. */
  151905. prepare(): void;
  151906. private _hasCleared;
  151907. private _prevPostProcess;
  151908. private _prevPrevPostProcess;
  151909. private _setAutoClearAndTextureSharing;
  151910. private _depthOfFieldSceneObserver;
  151911. private _buildPipeline;
  151912. private _disposePostProcesses;
  151913. /**
  151914. * Adds a camera to the pipeline
  151915. * @param camera the camera to be added
  151916. */
  151917. addCamera(camera: Camera): void;
  151918. /**
  151919. * Removes a camera from the pipeline
  151920. * @param camera the camera to remove
  151921. */
  151922. removeCamera(camera: Camera): void;
  151923. /**
  151924. * Dispose of the pipeline and stop all post processes
  151925. */
  151926. dispose(): void;
  151927. /**
  151928. * Serialize the rendering pipeline (Used when exporting)
  151929. * @returns the serialized object
  151930. */
  151931. serialize(): any;
  151932. /**
  151933. * Parse the serialized pipeline
  151934. * @param source Source pipeline.
  151935. * @param scene The scene to load the pipeline to.
  151936. * @param rootUrl The URL of the serialized pipeline.
  151937. * @returns An instantiated pipeline from the serialized object.
  151938. */
  151939. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  151940. }
  151941. }
  151942. declare module BABYLON {
  151943. /** @hidden */
  151944. export var lensHighlightsPixelShader: {
  151945. name: string;
  151946. shader: string;
  151947. };
  151948. }
  151949. declare module BABYLON {
  151950. /** @hidden */
  151951. export var depthOfFieldPixelShader: {
  151952. name: string;
  151953. shader: string;
  151954. };
  151955. }
  151956. declare module BABYLON {
  151957. /**
  151958. * BABYLON.JS Chromatic Aberration GLSL Shader
  151959. * Author: Olivier Guyot
  151960. * Separates very slightly R, G and B colors on the edges of the screen
  151961. * Inspired by Francois Tarlier & Martins Upitis
  151962. */
  151963. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151964. /**
  151965. * @ignore
  151966. * The chromatic aberration PostProcess id in the pipeline
  151967. */
  151968. LensChromaticAberrationEffect: string;
  151969. /**
  151970. * @ignore
  151971. * The highlights enhancing PostProcess id in the pipeline
  151972. */
  151973. HighlightsEnhancingEffect: string;
  151974. /**
  151975. * @ignore
  151976. * The depth-of-field PostProcess id in the pipeline
  151977. */
  151978. LensDepthOfFieldEffect: string;
  151979. private _scene;
  151980. private _depthTexture;
  151981. private _grainTexture;
  151982. private _chromaticAberrationPostProcess;
  151983. private _highlightsPostProcess;
  151984. private _depthOfFieldPostProcess;
  151985. private _edgeBlur;
  151986. private _grainAmount;
  151987. private _chromaticAberration;
  151988. private _distortion;
  151989. private _highlightsGain;
  151990. private _highlightsThreshold;
  151991. private _dofDistance;
  151992. private _dofAperture;
  151993. private _dofDarken;
  151994. private _dofPentagon;
  151995. private _blurNoise;
  151996. /**
  151997. * @constructor
  151998. *
  151999. * Effect parameters are as follow:
  152000. * {
  152001. * chromatic_aberration: number; // from 0 to x (1 for realism)
  152002. * edge_blur: number; // from 0 to x (1 for realism)
  152003. * distortion: number; // from 0 to x (1 for realism)
  152004. * grain_amount: number; // from 0 to 1
  152005. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  152006. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  152007. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  152008. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  152009. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  152010. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  152011. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  152012. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  152013. * }
  152014. * Note: if an effect parameter is unset, effect is disabled
  152015. *
  152016. * @param name The rendering pipeline name
  152017. * @param parameters - An object containing all parameters (see above)
  152018. * @param scene The scene linked to this pipeline
  152019. * @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)
  152020. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152021. */
  152022. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  152023. /**
  152024. * Get the class name
  152025. * @returns "LensRenderingPipeline"
  152026. */
  152027. getClassName(): string;
  152028. /**
  152029. * Gets associated scene
  152030. */
  152031. get scene(): Scene;
  152032. /**
  152033. * Gets or sets the edge blur
  152034. */
  152035. get edgeBlur(): number;
  152036. set edgeBlur(value: number);
  152037. /**
  152038. * Gets or sets the grain amount
  152039. */
  152040. get grainAmount(): number;
  152041. set grainAmount(value: number);
  152042. /**
  152043. * Gets or sets the chromatic aberration amount
  152044. */
  152045. get chromaticAberration(): number;
  152046. set chromaticAberration(value: number);
  152047. /**
  152048. * Gets or sets the depth of field aperture
  152049. */
  152050. get dofAperture(): number;
  152051. set dofAperture(value: number);
  152052. /**
  152053. * Gets or sets the edge distortion
  152054. */
  152055. get edgeDistortion(): number;
  152056. set edgeDistortion(value: number);
  152057. /**
  152058. * Gets or sets the depth of field distortion
  152059. */
  152060. get dofDistortion(): number;
  152061. set dofDistortion(value: number);
  152062. /**
  152063. * Gets or sets the darken out of focus amount
  152064. */
  152065. get darkenOutOfFocus(): number;
  152066. set darkenOutOfFocus(value: number);
  152067. /**
  152068. * Gets or sets a boolean indicating if blur noise is enabled
  152069. */
  152070. get blurNoise(): boolean;
  152071. set blurNoise(value: boolean);
  152072. /**
  152073. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  152074. */
  152075. get pentagonBokeh(): boolean;
  152076. set pentagonBokeh(value: boolean);
  152077. /**
  152078. * Gets or sets the highlight grain amount
  152079. */
  152080. get highlightsGain(): number;
  152081. set highlightsGain(value: number);
  152082. /**
  152083. * Gets or sets the highlight threshold
  152084. */
  152085. get highlightsThreshold(): number;
  152086. set highlightsThreshold(value: number);
  152087. /**
  152088. * Sets the amount of blur at the edges
  152089. * @param amount blur amount
  152090. */
  152091. setEdgeBlur(amount: number): void;
  152092. /**
  152093. * Sets edge blur to 0
  152094. */
  152095. disableEdgeBlur(): void;
  152096. /**
  152097. * Sets the amout of grain
  152098. * @param amount Amount of grain
  152099. */
  152100. setGrainAmount(amount: number): void;
  152101. /**
  152102. * Set grain amount to 0
  152103. */
  152104. disableGrain(): void;
  152105. /**
  152106. * Sets the chromatic aberration amount
  152107. * @param amount amount of chromatic aberration
  152108. */
  152109. setChromaticAberration(amount: number): void;
  152110. /**
  152111. * Sets chromatic aberration amount to 0
  152112. */
  152113. disableChromaticAberration(): void;
  152114. /**
  152115. * Sets the EdgeDistortion amount
  152116. * @param amount amount of EdgeDistortion
  152117. */
  152118. setEdgeDistortion(amount: number): void;
  152119. /**
  152120. * Sets edge distortion to 0
  152121. */
  152122. disableEdgeDistortion(): void;
  152123. /**
  152124. * Sets the FocusDistance amount
  152125. * @param amount amount of FocusDistance
  152126. */
  152127. setFocusDistance(amount: number): void;
  152128. /**
  152129. * Disables depth of field
  152130. */
  152131. disableDepthOfField(): void;
  152132. /**
  152133. * Sets the Aperture amount
  152134. * @param amount amount of Aperture
  152135. */
  152136. setAperture(amount: number): void;
  152137. /**
  152138. * Sets the DarkenOutOfFocus amount
  152139. * @param amount amount of DarkenOutOfFocus
  152140. */
  152141. setDarkenOutOfFocus(amount: number): void;
  152142. private _pentagonBokehIsEnabled;
  152143. /**
  152144. * Creates a pentagon bokeh effect
  152145. */
  152146. enablePentagonBokeh(): void;
  152147. /**
  152148. * Disables the pentagon bokeh effect
  152149. */
  152150. disablePentagonBokeh(): void;
  152151. /**
  152152. * Enables noise blur
  152153. */
  152154. enableNoiseBlur(): void;
  152155. /**
  152156. * Disables noise blur
  152157. */
  152158. disableNoiseBlur(): void;
  152159. /**
  152160. * Sets the HighlightsGain amount
  152161. * @param amount amount of HighlightsGain
  152162. */
  152163. setHighlightsGain(amount: number): void;
  152164. /**
  152165. * Sets the HighlightsThreshold amount
  152166. * @param amount amount of HighlightsThreshold
  152167. */
  152168. setHighlightsThreshold(amount: number): void;
  152169. /**
  152170. * Disables highlights
  152171. */
  152172. disableHighlights(): void;
  152173. /**
  152174. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  152175. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  152176. */
  152177. dispose(disableDepthRender?: boolean): void;
  152178. private _createChromaticAberrationPostProcess;
  152179. private _createHighlightsPostProcess;
  152180. private _createDepthOfFieldPostProcess;
  152181. private _createGrainTexture;
  152182. }
  152183. }
  152184. declare module BABYLON {
  152185. /**
  152186. * Contains all parameters needed for the prepass to perform
  152187. * screen space subsurface scattering
  152188. */
  152189. export class SSAO2Configuration implements PrePassEffectConfiguration {
  152190. /**
  152191. * Is subsurface enabled
  152192. */
  152193. enabled: boolean;
  152194. /**
  152195. * Name of the configuration
  152196. */
  152197. name: string;
  152198. /**
  152199. * Textures that should be present in the MRT for this effect to work
  152200. */
  152201. readonly texturesRequired: number[];
  152202. }
  152203. }
  152204. declare module BABYLON {
  152205. /** @hidden */
  152206. export var ssao2PixelShader: {
  152207. name: string;
  152208. shader: string;
  152209. };
  152210. }
  152211. declare module BABYLON {
  152212. /** @hidden */
  152213. export var ssaoCombinePixelShader: {
  152214. name: string;
  152215. shader: string;
  152216. };
  152217. }
  152218. declare module BABYLON {
  152219. /**
  152220. * Render pipeline to produce ssao effect
  152221. */
  152222. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  152223. /**
  152224. * @ignore
  152225. * The PassPostProcess id in the pipeline that contains the original scene color
  152226. */
  152227. SSAOOriginalSceneColorEffect: string;
  152228. /**
  152229. * @ignore
  152230. * The SSAO PostProcess id in the pipeline
  152231. */
  152232. SSAORenderEffect: string;
  152233. /**
  152234. * @ignore
  152235. * The horizontal blur PostProcess id in the pipeline
  152236. */
  152237. SSAOBlurHRenderEffect: string;
  152238. /**
  152239. * @ignore
  152240. * The vertical blur PostProcess id in the pipeline
  152241. */
  152242. SSAOBlurVRenderEffect: string;
  152243. /**
  152244. * @ignore
  152245. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152246. */
  152247. SSAOCombineRenderEffect: string;
  152248. /**
  152249. * The output strength of the SSAO post-process. Default value is 1.0.
  152250. */
  152251. totalStrength: number;
  152252. /**
  152253. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  152254. */
  152255. maxZ: number;
  152256. /**
  152257. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  152258. */
  152259. minZAspect: number;
  152260. private _samples;
  152261. /**
  152262. * Number of samples used for the SSAO calculations. Default value is 8
  152263. */
  152264. set samples(n: number);
  152265. get samples(): number;
  152266. private _textureSamples;
  152267. /**
  152268. * Number of samples to use for antialiasing
  152269. */
  152270. set textureSamples(n: number);
  152271. get textureSamples(): number;
  152272. /**
  152273. * Force rendering the geometry through geometry buffer
  152274. */
  152275. private _forceGeometryBuffer;
  152276. /**
  152277. * Ratio object used for SSAO ratio and blur ratio
  152278. */
  152279. private _ratio;
  152280. /**
  152281. * Dynamically generated sphere sampler.
  152282. */
  152283. private _sampleSphere;
  152284. /**
  152285. * Blur filter offsets
  152286. */
  152287. private _samplerOffsets;
  152288. private _expensiveBlur;
  152289. /**
  152290. * If bilateral blur should be used
  152291. */
  152292. set expensiveBlur(b: boolean);
  152293. get expensiveBlur(): boolean;
  152294. /**
  152295. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  152296. */
  152297. radius: number;
  152298. /**
  152299. * The base color of the SSAO post-process
  152300. * The final result is "base + ssao" between [0, 1]
  152301. */
  152302. base: number;
  152303. /**
  152304. * Support test.
  152305. */
  152306. static get IsSupported(): boolean;
  152307. private _scene;
  152308. private _randomTexture;
  152309. private _originalColorPostProcess;
  152310. private _ssaoPostProcess;
  152311. private _blurHPostProcess;
  152312. private _blurVPostProcess;
  152313. private _ssaoCombinePostProcess;
  152314. private _prePassRenderer;
  152315. /**
  152316. * Gets active scene
  152317. */
  152318. get scene(): Scene;
  152319. /**
  152320. * @constructor
  152321. * @param name The rendering pipeline name
  152322. * @param scene The scene linked to this pipeline
  152323. * @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 }
  152324. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152325. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  152326. */
  152327. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  152328. /**
  152329. * Get the class name
  152330. * @returns "SSAO2RenderingPipeline"
  152331. */
  152332. getClassName(): string;
  152333. /**
  152334. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152335. */
  152336. dispose(disableGeometryBufferRenderer?: boolean): void;
  152337. private _createBlurPostProcess;
  152338. /** @hidden */
  152339. _rebuild(): void;
  152340. private _bits;
  152341. private _radicalInverse_VdC;
  152342. private _hammersley;
  152343. private _hemisphereSample_uniform;
  152344. private _generateHemisphere;
  152345. private _getDefinesForSSAO;
  152346. private _createSSAOPostProcess;
  152347. private _createSSAOCombinePostProcess;
  152348. private _createRandomTexture;
  152349. /**
  152350. * Serialize the rendering pipeline (Used when exporting)
  152351. * @returns the serialized object
  152352. */
  152353. serialize(): any;
  152354. /**
  152355. * Parse the serialized pipeline
  152356. * @param source Source pipeline.
  152357. * @param scene The scene to load the pipeline to.
  152358. * @param rootUrl The URL of the serialized pipeline.
  152359. * @returns An instantiated pipeline from the serialized object.
  152360. */
  152361. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  152362. }
  152363. }
  152364. declare module BABYLON {
  152365. /** @hidden */
  152366. export var ssaoPixelShader: {
  152367. name: string;
  152368. shader: string;
  152369. };
  152370. }
  152371. declare module BABYLON {
  152372. /**
  152373. * Render pipeline to produce ssao effect
  152374. */
  152375. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  152376. /**
  152377. * @ignore
  152378. * The PassPostProcess id in the pipeline that contains the original scene color
  152379. */
  152380. SSAOOriginalSceneColorEffect: string;
  152381. /**
  152382. * @ignore
  152383. * The SSAO PostProcess id in the pipeline
  152384. */
  152385. SSAORenderEffect: string;
  152386. /**
  152387. * @ignore
  152388. * The horizontal blur PostProcess id in the pipeline
  152389. */
  152390. SSAOBlurHRenderEffect: string;
  152391. /**
  152392. * @ignore
  152393. * The vertical blur PostProcess id in the pipeline
  152394. */
  152395. SSAOBlurVRenderEffect: string;
  152396. /**
  152397. * @ignore
  152398. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152399. */
  152400. SSAOCombineRenderEffect: string;
  152401. /**
  152402. * The output strength of the SSAO post-process. Default value is 1.0.
  152403. */
  152404. totalStrength: number;
  152405. /**
  152406. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  152407. */
  152408. radius: number;
  152409. /**
  152410. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  152411. * Must not be equal to fallOff and superior to fallOff.
  152412. * Default value is 0.0075
  152413. */
  152414. area: number;
  152415. /**
  152416. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  152417. * Must not be equal to area and inferior to area.
  152418. * Default value is 0.000001
  152419. */
  152420. fallOff: number;
  152421. /**
  152422. * The base color of the SSAO post-process
  152423. * The final result is "base + ssao" between [0, 1]
  152424. */
  152425. base: number;
  152426. private _scene;
  152427. private _depthTexture;
  152428. private _randomTexture;
  152429. private _originalColorPostProcess;
  152430. private _ssaoPostProcess;
  152431. private _blurHPostProcess;
  152432. private _blurVPostProcess;
  152433. private _ssaoCombinePostProcess;
  152434. private _firstUpdate;
  152435. /**
  152436. * Gets active scene
  152437. */
  152438. get scene(): Scene;
  152439. /**
  152440. * @constructor
  152441. * @param name - The rendering pipeline name
  152442. * @param scene - The scene linked to this pipeline
  152443. * @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 }
  152444. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  152445. */
  152446. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  152447. /**
  152448. * Get the class name
  152449. * @returns "SSAORenderingPipeline"
  152450. */
  152451. getClassName(): string;
  152452. /**
  152453. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152454. */
  152455. dispose(disableDepthRender?: boolean): void;
  152456. private _createBlurPostProcess;
  152457. /** @hidden */
  152458. _rebuild(): void;
  152459. private _createSSAOPostProcess;
  152460. private _createSSAOCombinePostProcess;
  152461. private _createRandomTexture;
  152462. }
  152463. }
  152464. declare module BABYLON {
  152465. /**
  152466. * Contains all parameters needed for the prepass to perform
  152467. * screen space reflections
  152468. */
  152469. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  152470. /**
  152471. * Is ssr enabled
  152472. */
  152473. enabled: boolean;
  152474. /**
  152475. * Name of the configuration
  152476. */
  152477. name: string;
  152478. /**
  152479. * Textures that should be present in the MRT for this effect to work
  152480. */
  152481. readonly texturesRequired: number[];
  152482. }
  152483. }
  152484. declare module BABYLON {
  152485. /** @hidden */
  152486. export var screenSpaceReflectionPixelShader: {
  152487. name: string;
  152488. shader: string;
  152489. };
  152490. }
  152491. declare module BABYLON {
  152492. /**
  152493. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  152494. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  152495. */
  152496. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  152497. /**
  152498. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  152499. */
  152500. threshold: number;
  152501. /**
  152502. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  152503. */
  152504. strength: number;
  152505. /**
  152506. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  152507. */
  152508. reflectionSpecularFalloffExponent: number;
  152509. /**
  152510. * 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]
  152511. */
  152512. step: number;
  152513. /**
  152514. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  152515. */
  152516. roughnessFactor: number;
  152517. private _forceGeometryBuffer;
  152518. private _geometryBufferRenderer;
  152519. private _prePassRenderer;
  152520. private _enableSmoothReflections;
  152521. private _reflectionSamples;
  152522. private _smoothSteps;
  152523. /**
  152524. * Gets a string identifying the name of the class
  152525. * @returns "ScreenSpaceReflectionPostProcess" string
  152526. */
  152527. getClassName(): string;
  152528. /**
  152529. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  152530. * @param name The name of the effect.
  152531. * @param scene The scene containing the objects to calculate reflections.
  152532. * @param options The required width/height ratio to downsize to before computing the render pass.
  152533. * @param camera The camera to apply the render pass to.
  152534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152535. * @param engine The engine which the post process will be applied. (default: current engine)
  152536. * @param reusable If the post process can be reused on the same frame. (default: false)
  152537. * @param textureType Type of textures used when performing the post process. (default: 0)
  152538. * @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)
  152539. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152540. */
  152541. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152542. /**
  152543. * Gets wether or not smoothing reflections is enabled.
  152544. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152545. */
  152546. get enableSmoothReflections(): boolean;
  152547. /**
  152548. * Sets wether or not smoothing reflections is enabled.
  152549. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152550. */
  152551. set enableSmoothReflections(enabled: boolean);
  152552. /**
  152553. * Gets the number of samples taken while computing reflections. More samples count is high,
  152554. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152555. */
  152556. get reflectionSamples(): number;
  152557. /**
  152558. * Sets the number of samples taken while computing reflections. More samples count is high,
  152559. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152560. */
  152561. set reflectionSamples(samples: number);
  152562. /**
  152563. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  152564. * more the post-process will require GPU power and can generate a drop in FPS.
  152565. * Default value (5.0) work pretty well in all cases but can be adjusted.
  152566. */
  152567. get smoothSteps(): number;
  152568. set smoothSteps(steps: number);
  152569. private _updateEffectDefines;
  152570. /** @hidden */
  152571. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  152572. }
  152573. }
  152574. declare module BABYLON {
  152575. /** @hidden */
  152576. export var standardPixelShader: {
  152577. name: string;
  152578. shader: string;
  152579. };
  152580. }
  152581. declare module BABYLON {
  152582. /**
  152583. * Standard rendering pipeline
  152584. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152585. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  152586. */
  152587. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152588. /**
  152589. * Public members
  152590. */
  152591. /**
  152592. * Post-process which contains the original scene color before the pipeline applies all the effects
  152593. */
  152594. originalPostProcess: Nullable<PostProcess>;
  152595. /**
  152596. * Post-process used to down scale an image x4
  152597. */
  152598. downSampleX4PostProcess: Nullable<PostProcess>;
  152599. /**
  152600. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  152601. */
  152602. brightPassPostProcess: Nullable<PostProcess>;
  152603. /**
  152604. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  152605. */
  152606. blurHPostProcesses: PostProcess[];
  152607. /**
  152608. * Post-process array storing all the vertical blur post-processes used by the pipeline
  152609. */
  152610. blurVPostProcesses: PostProcess[];
  152611. /**
  152612. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  152613. */
  152614. textureAdderPostProcess: Nullable<PostProcess>;
  152615. /**
  152616. * Post-process used to create volumetric lighting effect
  152617. */
  152618. volumetricLightPostProcess: Nullable<PostProcess>;
  152619. /**
  152620. * Post-process used to smooth the previous volumetric light post-process on the X axis
  152621. */
  152622. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  152623. /**
  152624. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  152625. */
  152626. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  152627. /**
  152628. * Post-process used to merge the volumetric light effect and the real scene color
  152629. */
  152630. volumetricLightMergePostProces: Nullable<PostProcess>;
  152631. /**
  152632. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  152633. */
  152634. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  152635. /**
  152636. * Base post-process used to calculate the average luminance of the final image for HDR
  152637. */
  152638. luminancePostProcess: Nullable<PostProcess>;
  152639. /**
  152640. * Post-processes used to create down sample post-processes in order to get
  152641. * the average luminance of the final image for HDR
  152642. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  152643. */
  152644. luminanceDownSamplePostProcesses: PostProcess[];
  152645. /**
  152646. * Post-process used to create a HDR effect (light adaptation)
  152647. */
  152648. hdrPostProcess: Nullable<PostProcess>;
  152649. /**
  152650. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  152651. */
  152652. textureAdderFinalPostProcess: Nullable<PostProcess>;
  152653. /**
  152654. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  152655. */
  152656. lensFlareFinalPostProcess: Nullable<PostProcess>;
  152657. /**
  152658. * Post-process used to merge the final HDR post-process and the real scene color
  152659. */
  152660. hdrFinalPostProcess: Nullable<PostProcess>;
  152661. /**
  152662. * Post-process used to create a lens flare effect
  152663. */
  152664. lensFlarePostProcess: Nullable<PostProcess>;
  152665. /**
  152666. * Post-process that merges the result of the lens flare post-process and the real scene color
  152667. */
  152668. lensFlareComposePostProcess: Nullable<PostProcess>;
  152669. /**
  152670. * Post-process used to create a motion blur effect
  152671. */
  152672. motionBlurPostProcess: Nullable<PostProcess>;
  152673. /**
  152674. * Post-process used to create a depth of field effect
  152675. */
  152676. depthOfFieldPostProcess: Nullable<PostProcess>;
  152677. /**
  152678. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152679. */
  152680. fxaaPostProcess: Nullable<FxaaPostProcess>;
  152681. /**
  152682. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  152683. */
  152684. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  152685. /**
  152686. * Represents the brightness threshold in order to configure the illuminated surfaces
  152687. */
  152688. brightThreshold: number;
  152689. /**
  152690. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  152691. */
  152692. blurWidth: number;
  152693. /**
  152694. * Sets if the blur for highlighted surfaces must be only horizontal
  152695. */
  152696. horizontalBlur: boolean;
  152697. /**
  152698. * Gets the overall exposure used by the pipeline
  152699. */
  152700. get exposure(): number;
  152701. /**
  152702. * Sets the overall exposure used by the pipeline
  152703. */
  152704. set exposure(value: number);
  152705. /**
  152706. * Texture used typically to simulate "dirty" on camera lens
  152707. */
  152708. lensTexture: Nullable<Texture>;
  152709. /**
  152710. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  152711. */
  152712. volumetricLightCoefficient: number;
  152713. /**
  152714. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  152715. */
  152716. volumetricLightPower: number;
  152717. /**
  152718. * Used the set the blur intensity to smooth the volumetric lights
  152719. */
  152720. volumetricLightBlurScale: number;
  152721. /**
  152722. * Light (spot or directional) used to generate the volumetric lights rays
  152723. * The source light must have a shadow generate so the pipeline can get its
  152724. * depth map
  152725. */
  152726. sourceLight: Nullable<SpotLight | DirectionalLight>;
  152727. /**
  152728. * For eye adaptation, represents the minimum luminance the eye can see
  152729. */
  152730. hdrMinimumLuminance: number;
  152731. /**
  152732. * For eye adaptation, represents the decrease luminance speed
  152733. */
  152734. hdrDecreaseRate: number;
  152735. /**
  152736. * For eye adaptation, represents the increase luminance speed
  152737. */
  152738. hdrIncreaseRate: number;
  152739. /**
  152740. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152741. */
  152742. get hdrAutoExposure(): boolean;
  152743. /**
  152744. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152745. */
  152746. set hdrAutoExposure(value: boolean);
  152747. /**
  152748. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  152749. */
  152750. lensColorTexture: Nullable<Texture>;
  152751. /**
  152752. * The overall strengh for the lens flare effect
  152753. */
  152754. lensFlareStrength: number;
  152755. /**
  152756. * Dispersion coefficient for lens flare ghosts
  152757. */
  152758. lensFlareGhostDispersal: number;
  152759. /**
  152760. * Main lens flare halo width
  152761. */
  152762. lensFlareHaloWidth: number;
  152763. /**
  152764. * Based on the lens distortion effect, defines how much the lens flare result
  152765. * is distorted
  152766. */
  152767. lensFlareDistortionStrength: number;
  152768. /**
  152769. * Configures the blur intensity used for for lens flare (halo)
  152770. */
  152771. lensFlareBlurWidth: number;
  152772. /**
  152773. * Lens star texture must be used to simulate rays on the flares and is available
  152774. * in the documentation
  152775. */
  152776. lensStarTexture: Nullable<Texture>;
  152777. /**
  152778. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  152779. * flare effect by taking account of the dirt texture
  152780. */
  152781. lensFlareDirtTexture: Nullable<Texture>;
  152782. /**
  152783. * Represents the focal length for the depth of field effect
  152784. */
  152785. depthOfFieldDistance: number;
  152786. /**
  152787. * Represents the blur intensity for the blurred part of the depth of field effect
  152788. */
  152789. depthOfFieldBlurWidth: number;
  152790. /**
  152791. * Gets how much the image is blurred by the movement while using the motion blur post-process
  152792. */
  152793. get motionStrength(): number;
  152794. /**
  152795. * Sets how much the image is blurred by the movement while using the motion blur post-process
  152796. */
  152797. set motionStrength(strength: number);
  152798. /**
  152799. * Gets wether or not the motion blur post-process is object based or screen based.
  152800. */
  152801. get objectBasedMotionBlur(): boolean;
  152802. /**
  152803. * Sets wether or not the motion blur post-process should be object based or screen based
  152804. */
  152805. set objectBasedMotionBlur(value: boolean);
  152806. /**
  152807. * List of animations for the pipeline (IAnimatable implementation)
  152808. */
  152809. animations: Animation[];
  152810. /**
  152811. * Private members
  152812. */
  152813. private _scene;
  152814. private _currentDepthOfFieldSource;
  152815. private _basePostProcess;
  152816. private _fixedExposure;
  152817. private _currentExposure;
  152818. private _hdrAutoExposure;
  152819. private _hdrCurrentLuminance;
  152820. private _motionStrength;
  152821. private _isObjectBasedMotionBlur;
  152822. private _floatTextureType;
  152823. private _camerasToBeAttached;
  152824. private _ratio;
  152825. private _bloomEnabled;
  152826. private _depthOfFieldEnabled;
  152827. private _vlsEnabled;
  152828. private _lensFlareEnabled;
  152829. private _hdrEnabled;
  152830. private _motionBlurEnabled;
  152831. private _fxaaEnabled;
  152832. private _screenSpaceReflectionsEnabled;
  152833. private _motionBlurSamples;
  152834. private _volumetricLightStepsCount;
  152835. private _samples;
  152836. /**
  152837. * @ignore
  152838. * Specifies if the bloom pipeline is enabled
  152839. */
  152840. get BloomEnabled(): boolean;
  152841. set BloomEnabled(enabled: boolean);
  152842. /**
  152843. * @ignore
  152844. * Specifies if the depth of field pipeline is enabed
  152845. */
  152846. get DepthOfFieldEnabled(): boolean;
  152847. set DepthOfFieldEnabled(enabled: boolean);
  152848. /**
  152849. * @ignore
  152850. * Specifies if the lens flare pipeline is enabed
  152851. */
  152852. get LensFlareEnabled(): boolean;
  152853. set LensFlareEnabled(enabled: boolean);
  152854. /**
  152855. * @ignore
  152856. * Specifies if the HDR pipeline is enabled
  152857. */
  152858. get HDREnabled(): boolean;
  152859. set HDREnabled(enabled: boolean);
  152860. /**
  152861. * @ignore
  152862. * Specifies if the volumetric lights scattering effect is enabled
  152863. */
  152864. get VLSEnabled(): boolean;
  152865. set VLSEnabled(enabled: boolean);
  152866. /**
  152867. * @ignore
  152868. * Specifies if the motion blur effect is enabled
  152869. */
  152870. get MotionBlurEnabled(): boolean;
  152871. set MotionBlurEnabled(enabled: boolean);
  152872. /**
  152873. * Specifies if anti-aliasing is enabled
  152874. */
  152875. get fxaaEnabled(): boolean;
  152876. set fxaaEnabled(enabled: boolean);
  152877. /**
  152878. * Specifies if screen space reflections are enabled.
  152879. */
  152880. get screenSpaceReflectionsEnabled(): boolean;
  152881. set screenSpaceReflectionsEnabled(enabled: boolean);
  152882. /**
  152883. * Specifies the number of steps used to calculate the volumetric lights
  152884. * Typically in interval [50, 200]
  152885. */
  152886. get volumetricLightStepsCount(): number;
  152887. set volumetricLightStepsCount(count: number);
  152888. /**
  152889. * Specifies the number of samples used for the motion blur effect
  152890. * Typically in interval [16, 64]
  152891. */
  152892. get motionBlurSamples(): number;
  152893. set motionBlurSamples(samples: number);
  152894. /**
  152895. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152896. */
  152897. get samples(): number;
  152898. set samples(sampleCount: number);
  152899. /**
  152900. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152901. * @constructor
  152902. * @param name The rendering pipeline name
  152903. * @param scene The scene linked to this pipeline
  152904. * @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)
  152905. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  152906. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152907. */
  152908. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  152909. private _buildPipeline;
  152910. private _createDownSampleX4PostProcess;
  152911. private _createBrightPassPostProcess;
  152912. private _createBlurPostProcesses;
  152913. private _createTextureAdderPostProcess;
  152914. private _createVolumetricLightPostProcess;
  152915. private _createLuminancePostProcesses;
  152916. private _createHdrPostProcess;
  152917. private _createLensFlarePostProcess;
  152918. private _createDepthOfFieldPostProcess;
  152919. private _createMotionBlurPostProcess;
  152920. private _getDepthTexture;
  152921. private _disposePostProcesses;
  152922. /**
  152923. * Dispose of the pipeline and stop all post processes
  152924. */
  152925. dispose(): void;
  152926. /**
  152927. * Serialize the rendering pipeline (Used when exporting)
  152928. * @returns the serialized object
  152929. */
  152930. serialize(): any;
  152931. /**
  152932. * Parse the serialized pipeline
  152933. * @param source Source pipeline.
  152934. * @param scene The scene to load the pipeline to.
  152935. * @param rootUrl The URL of the serialized pipeline.
  152936. * @returns An instantiated pipeline from the serialized object.
  152937. */
  152938. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  152939. /**
  152940. * Luminance steps
  152941. */
  152942. static LuminanceSteps: number;
  152943. }
  152944. }
  152945. declare module BABYLON {
  152946. /** @hidden */
  152947. export var stereoscopicInterlacePixelShader: {
  152948. name: string;
  152949. shader: string;
  152950. };
  152951. }
  152952. declare module BABYLON {
  152953. /**
  152954. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  152955. */
  152956. export class StereoscopicInterlacePostProcessI extends PostProcess {
  152957. private _stepSize;
  152958. private _passedProcess;
  152959. /**
  152960. * Gets a string identifying the name of the class
  152961. * @returns "StereoscopicInterlacePostProcessI" string
  152962. */
  152963. getClassName(): string;
  152964. /**
  152965. * Initializes a StereoscopicInterlacePostProcessI
  152966. * @param name The name of the effect.
  152967. * @param rigCameras The rig cameras to be appled to the post process
  152968. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152969. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152971. * @param engine The engine which the post process will be applied. (default: current engine)
  152972. * @param reusable If the post process can be reused on the same frame. (default: false)
  152973. */
  152974. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152975. }
  152976. /**
  152977. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152978. */
  152979. export class StereoscopicInterlacePostProcess extends PostProcess {
  152980. private _stepSize;
  152981. private _passedProcess;
  152982. /**
  152983. * Gets a string identifying the name of the class
  152984. * @returns "StereoscopicInterlacePostProcess" string
  152985. */
  152986. getClassName(): string;
  152987. /**
  152988. * Initializes a StereoscopicInterlacePostProcess
  152989. * @param name The name of the effect.
  152990. * @param rigCameras The rig cameras to be appled to the post process
  152991. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152993. * @param engine The engine which the post process will be applied. (default: current engine)
  152994. * @param reusable If the post process can be reused on the same frame. (default: false)
  152995. */
  152996. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152997. }
  152998. }
  152999. declare module BABYLON {
  153000. /** @hidden */
  153001. export var tonemapPixelShader: {
  153002. name: string;
  153003. shader: string;
  153004. };
  153005. }
  153006. declare module BABYLON {
  153007. /** Defines operator used for tonemapping */
  153008. export enum TonemappingOperator {
  153009. /** Hable */
  153010. Hable = 0,
  153011. /** Reinhard */
  153012. Reinhard = 1,
  153013. /** HejiDawson */
  153014. HejiDawson = 2,
  153015. /** Photographic */
  153016. Photographic = 3
  153017. }
  153018. /**
  153019. * Defines a post process to apply tone mapping
  153020. */
  153021. export class TonemapPostProcess extends PostProcess {
  153022. private _operator;
  153023. /** Defines the required exposure adjustement */
  153024. exposureAdjustment: number;
  153025. /**
  153026. * Gets a string identifying the name of the class
  153027. * @returns "TonemapPostProcess" string
  153028. */
  153029. getClassName(): string;
  153030. /**
  153031. * Creates a new TonemapPostProcess
  153032. * @param name defines the name of the postprocess
  153033. * @param _operator defines the operator to use
  153034. * @param exposureAdjustment defines the required exposure adjustement
  153035. * @param camera defines the camera to use (can be null)
  153036. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  153037. * @param engine defines the hosting engine (can be ignore if camera is set)
  153038. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  153039. */
  153040. constructor(name: string, _operator: TonemappingOperator,
  153041. /** Defines the required exposure adjustement */
  153042. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  153043. }
  153044. }
  153045. declare module BABYLON {
  153046. /** @hidden */
  153047. export var volumetricLightScatteringPixelShader: {
  153048. name: string;
  153049. shader: string;
  153050. };
  153051. }
  153052. declare module BABYLON {
  153053. /** @hidden */
  153054. export var volumetricLightScatteringPassVertexShader: {
  153055. name: string;
  153056. shader: string;
  153057. };
  153058. }
  153059. declare module BABYLON {
  153060. /** @hidden */
  153061. export var volumetricLightScatteringPassPixelShader: {
  153062. name: string;
  153063. shader: string;
  153064. };
  153065. }
  153066. declare module BABYLON {
  153067. /**
  153068. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  153069. */
  153070. export class VolumetricLightScatteringPostProcess extends PostProcess {
  153071. private _volumetricLightScatteringPass;
  153072. private _volumetricLightScatteringRTT;
  153073. private _viewPort;
  153074. private _screenCoordinates;
  153075. private _cachedDefines;
  153076. /**
  153077. * If not undefined, the mesh position is computed from the attached node position
  153078. */
  153079. attachedNode: {
  153080. position: Vector3;
  153081. };
  153082. /**
  153083. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  153084. */
  153085. customMeshPosition: Vector3;
  153086. /**
  153087. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  153088. */
  153089. useCustomMeshPosition: boolean;
  153090. /**
  153091. * If the post-process should inverse the light scattering direction
  153092. */
  153093. invert: boolean;
  153094. /**
  153095. * The internal mesh used by the post-process
  153096. */
  153097. mesh: Mesh;
  153098. /**
  153099. * @hidden
  153100. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  153101. */
  153102. get useDiffuseColor(): boolean;
  153103. set useDiffuseColor(useDiffuseColor: boolean);
  153104. /**
  153105. * Array containing the excluded meshes not rendered in the internal pass
  153106. */
  153107. excludedMeshes: AbstractMesh[];
  153108. /**
  153109. * Controls the overall intensity of the post-process
  153110. */
  153111. exposure: number;
  153112. /**
  153113. * Dissipates each sample's contribution in range [0, 1]
  153114. */
  153115. decay: number;
  153116. /**
  153117. * Controls the overall intensity of each sample
  153118. */
  153119. weight: number;
  153120. /**
  153121. * Controls the density of each sample
  153122. */
  153123. density: number;
  153124. /**
  153125. * @constructor
  153126. * @param name The post-process name
  153127. * @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)
  153128. * @param camera The camera that the post-process will be attached to
  153129. * @param mesh The mesh used to create the light scattering
  153130. * @param samples The post-process quality, default 100
  153131. * @param samplingModeThe post-process filtering mode
  153132. * @param engine The babylon engine
  153133. * @param reusable If the post-process is reusable
  153134. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  153135. */
  153136. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  153137. /**
  153138. * Returns the string "VolumetricLightScatteringPostProcess"
  153139. * @returns "VolumetricLightScatteringPostProcess"
  153140. */
  153141. getClassName(): string;
  153142. private _isReady;
  153143. /**
  153144. * Sets the new light position for light scattering effect
  153145. * @param position The new custom light position
  153146. */
  153147. setCustomMeshPosition(position: Vector3): void;
  153148. /**
  153149. * Returns the light position for light scattering effect
  153150. * @return Vector3 The custom light position
  153151. */
  153152. getCustomMeshPosition(): Vector3;
  153153. /**
  153154. * Disposes the internal assets and detaches the post-process from the camera
  153155. */
  153156. dispose(camera: Camera): void;
  153157. /**
  153158. * Returns the render target texture used by the post-process
  153159. * @return the render target texture used by the post-process
  153160. */
  153161. getPass(): RenderTargetTexture;
  153162. private _meshExcluded;
  153163. private _createPass;
  153164. private _updateMeshScreenCoordinates;
  153165. /**
  153166. * Creates a default mesh for the Volumeric Light Scattering post-process
  153167. * @param name The mesh name
  153168. * @param scene The scene where to create the mesh
  153169. * @return the default mesh
  153170. */
  153171. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  153172. }
  153173. }
  153174. declare module BABYLON {
  153175. /** @hidden */
  153176. export var screenSpaceCurvaturePixelShader: {
  153177. name: string;
  153178. shader: string;
  153179. };
  153180. }
  153181. declare module BABYLON {
  153182. /**
  153183. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  153184. */
  153185. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  153186. /**
  153187. * Defines how much ridge the curvature effect displays.
  153188. */
  153189. ridge: number;
  153190. /**
  153191. * Defines how much valley the curvature effect displays.
  153192. */
  153193. valley: number;
  153194. private _geometryBufferRenderer;
  153195. /**
  153196. * Gets a string identifying the name of the class
  153197. * @returns "ScreenSpaceCurvaturePostProcess" string
  153198. */
  153199. getClassName(): string;
  153200. /**
  153201. * Creates a new instance ScreenSpaceCurvaturePostProcess
  153202. * @param name The name of the effect.
  153203. * @param scene The scene containing the objects to blur according to their velocity.
  153204. * @param options The required width/height ratio to downsize to before computing the render pass.
  153205. * @param camera The camera to apply the render pass to.
  153206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153207. * @param engine The engine which the post process will be applied. (default: current engine)
  153208. * @param reusable If the post process can be reused on the same frame. (default: false)
  153209. * @param textureType Type of textures used when performing the post process. (default: 0)
  153210. * @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)
  153211. */
  153212. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  153213. /**
  153214. * Support test.
  153215. */
  153216. static get IsSupported(): boolean;
  153217. /** @hidden */
  153218. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  153219. }
  153220. }
  153221. declare module BABYLON {
  153222. interface Scene {
  153223. /** @hidden (Backing field) */
  153224. _boundingBoxRenderer: BoundingBoxRenderer;
  153225. /** @hidden (Backing field) */
  153226. _forceShowBoundingBoxes: boolean;
  153227. /**
  153228. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  153229. */
  153230. forceShowBoundingBoxes: boolean;
  153231. /**
  153232. * Gets the bounding box renderer associated with the scene
  153233. * @returns a BoundingBoxRenderer
  153234. */
  153235. getBoundingBoxRenderer(): BoundingBoxRenderer;
  153236. }
  153237. interface AbstractMesh {
  153238. /** @hidden (Backing field) */
  153239. _showBoundingBox: boolean;
  153240. /**
  153241. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  153242. */
  153243. showBoundingBox: boolean;
  153244. }
  153245. /**
  153246. * Component responsible of rendering the bounding box of the meshes in a scene.
  153247. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  153248. */
  153249. export class BoundingBoxRenderer implements ISceneComponent {
  153250. /**
  153251. * The component name helpfull to identify the component in the list of scene components.
  153252. */
  153253. readonly name: string;
  153254. /**
  153255. * The scene the component belongs to.
  153256. */
  153257. scene: Scene;
  153258. /**
  153259. * Color of the bounding box lines placed in front of an object
  153260. */
  153261. frontColor: Color3;
  153262. /**
  153263. * Color of the bounding box lines placed behind an object
  153264. */
  153265. backColor: Color3;
  153266. /**
  153267. * Defines if the renderer should show the back lines or not
  153268. */
  153269. showBackLines: boolean;
  153270. /**
  153271. * Observable raised before rendering a bounding box
  153272. */
  153273. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  153274. /**
  153275. * Observable raised after rendering a bounding box
  153276. */
  153277. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  153278. /**
  153279. * @hidden
  153280. */
  153281. renderList: SmartArray<BoundingBox>;
  153282. private _colorShader;
  153283. private _vertexBuffers;
  153284. private _indexBuffer;
  153285. private _fillIndexBuffer;
  153286. private _fillIndexData;
  153287. /**
  153288. * Instantiates a new bounding box renderer in a scene.
  153289. * @param scene the scene the renderer renders in
  153290. */
  153291. constructor(scene: Scene);
  153292. /**
  153293. * Registers the component in a given scene
  153294. */
  153295. register(): void;
  153296. private _evaluateSubMesh;
  153297. private _activeMesh;
  153298. private _prepareRessources;
  153299. private _createIndexBuffer;
  153300. /**
  153301. * Rebuilds the elements related to this component in case of
  153302. * context lost for instance.
  153303. */
  153304. rebuild(): void;
  153305. /**
  153306. * @hidden
  153307. */
  153308. reset(): void;
  153309. /**
  153310. * Render the bounding boxes of a specific rendering group
  153311. * @param renderingGroupId defines the rendering group to render
  153312. */
  153313. render(renderingGroupId: number): void;
  153314. /**
  153315. * In case of occlusion queries, we can render the occlusion bounding box through this method
  153316. * @param mesh Define the mesh to render the occlusion bounding box for
  153317. */
  153318. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  153319. /**
  153320. * Dispose and release the resources attached to this renderer.
  153321. */
  153322. dispose(): void;
  153323. }
  153324. }
  153325. declare module BABYLON {
  153326. interface Scene {
  153327. /** @hidden (Backing field) */
  153328. _depthRenderer: {
  153329. [id: string]: DepthRenderer;
  153330. };
  153331. /**
  153332. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  153333. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  153334. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  153335. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  153336. * @returns the created depth renderer
  153337. */
  153338. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  153339. /**
  153340. * Disables a depth renderer for a given camera
  153341. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  153342. */
  153343. disableDepthRenderer(camera?: Nullable<Camera>): void;
  153344. }
  153345. /**
  153346. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  153347. * in several rendering techniques.
  153348. */
  153349. export class DepthRendererSceneComponent implements ISceneComponent {
  153350. /**
  153351. * The component name helpfull to identify the component in the list of scene components.
  153352. */
  153353. readonly name: string;
  153354. /**
  153355. * The scene the component belongs to.
  153356. */
  153357. scene: Scene;
  153358. /**
  153359. * Creates a new instance of the component for the given scene
  153360. * @param scene Defines the scene to register the component in
  153361. */
  153362. constructor(scene: Scene);
  153363. /**
  153364. * Registers the component in a given scene
  153365. */
  153366. register(): void;
  153367. /**
  153368. * Rebuilds the elements related to this component in case of
  153369. * context lost for instance.
  153370. */
  153371. rebuild(): void;
  153372. /**
  153373. * Disposes the component and the associated ressources
  153374. */
  153375. dispose(): void;
  153376. private _gatherRenderTargets;
  153377. private _gatherActiveCameraRenderTargets;
  153378. }
  153379. }
  153380. declare module BABYLON {
  153381. interface AbstractScene {
  153382. /** @hidden (Backing field) */
  153383. _prePassRenderer: Nullable<PrePassRenderer>;
  153384. /**
  153385. * Gets or Sets the current prepass renderer associated to the scene.
  153386. */
  153387. prePassRenderer: Nullable<PrePassRenderer>;
  153388. /**
  153389. * Enables the prepass and associates it with the scene
  153390. * @returns the PrePassRenderer
  153391. */
  153392. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  153393. /**
  153394. * Disables the prepass associated with the scene
  153395. */
  153396. disablePrePassRenderer(): void;
  153397. }
  153398. /**
  153399. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153400. * in several rendering techniques.
  153401. */
  153402. export class PrePassRendererSceneComponent implements ISceneComponent {
  153403. /**
  153404. * The component name helpful to identify the component in the list of scene components.
  153405. */
  153406. readonly name: string;
  153407. /**
  153408. * The scene the component belongs to.
  153409. */
  153410. scene: Scene;
  153411. /**
  153412. * Creates a new instance of the component for the given scene
  153413. * @param scene Defines the scene to register the component in
  153414. */
  153415. constructor(scene: Scene);
  153416. /**
  153417. * Registers the component in a given scene
  153418. */
  153419. register(): void;
  153420. private _beforeCameraDraw;
  153421. private _afterCameraDraw;
  153422. private _beforeClearStage;
  153423. /**
  153424. * Rebuilds the elements related to this component in case of
  153425. * context lost for instance.
  153426. */
  153427. rebuild(): void;
  153428. /**
  153429. * Disposes the component and the associated ressources
  153430. */
  153431. dispose(): void;
  153432. }
  153433. }
  153434. declare module BABYLON {
  153435. /** @hidden */
  153436. export var fibonacci: {
  153437. name: string;
  153438. shader: string;
  153439. };
  153440. }
  153441. declare module BABYLON {
  153442. /** @hidden */
  153443. export var diffusionProfile: {
  153444. name: string;
  153445. shader: string;
  153446. };
  153447. }
  153448. declare module BABYLON {
  153449. /** @hidden */
  153450. export var subSurfaceScatteringPixelShader: {
  153451. name: string;
  153452. shader: string;
  153453. };
  153454. }
  153455. declare module BABYLON {
  153456. /**
  153457. * Sub surface scattering post process
  153458. */
  153459. export class SubSurfaceScatteringPostProcess extends PostProcess {
  153460. /**
  153461. * Gets a string identifying the name of the class
  153462. * @returns "SubSurfaceScatteringPostProcess" string
  153463. */
  153464. getClassName(): string;
  153465. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  153466. }
  153467. }
  153468. declare module BABYLON {
  153469. /**
  153470. * Contains all parameters needed for the prepass to perform
  153471. * screen space subsurface scattering
  153472. */
  153473. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  153474. /** @hidden */
  153475. static _SceneComponentInitialization: (scene: Scene) => void;
  153476. private _ssDiffusionS;
  153477. private _ssFilterRadii;
  153478. private _ssDiffusionD;
  153479. /**
  153480. * Post process to attach for screen space subsurface scattering
  153481. */
  153482. postProcess: SubSurfaceScatteringPostProcess;
  153483. /**
  153484. * Diffusion profile color for subsurface scattering
  153485. */
  153486. get ssDiffusionS(): number[];
  153487. /**
  153488. * Diffusion profile max color channel value for subsurface scattering
  153489. */
  153490. get ssDiffusionD(): number[];
  153491. /**
  153492. * Diffusion profile filter radius for subsurface scattering
  153493. */
  153494. get ssFilterRadii(): number[];
  153495. /**
  153496. * Is subsurface enabled
  153497. */
  153498. enabled: boolean;
  153499. /**
  153500. * Name of the configuration
  153501. */
  153502. name: string;
  153503. /**
  153504. * Diffusion profile colors for subsurface scattering
  153505. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  153506. * See ...
  153507. * Note that you can only store up to 5 of them
  153508. */
  153509. ssDiffusionProfileColors: Color3[];
  153510. /**
  153511. * Defines the ratio real world => scene units.
  153512. * Used for subsurface scattering
  153513. */
  153514. metersPerUnit: number;
  153515. /**
  153516. * Textures that should be present in the MRT for this effect to work
  153517. */
  153518. readonly texturesRequired: number[];
  153519. private _scene;
  153520. /**
  153521. * Builds a subsurface configuration object
  153522. * @param scene The scene
  153523. */
  153524. constructor(scene: Scene);
  153525. /**
  153526. * Adds a new diffusion profile.
  153527. * Useful for more realistic subsurface scattering on diverse materials.
  153528. * @param color The color of the diffusion profile. Should be the average color of the material.
  153529. * @return The index of the diffusion profile for the material subsurface configuration
  153530. */
  153531. addDiffusionProfile(color: Color3): number;
  153532. /**
  153533. * Creates the sss post process
  153534. * @return The created post process
  153535. */
  153536. createPostProcess(): SubSurfaceScatteringPostProcess;
  153537. /**
  153538. * Deletes all diffusion profiles.
  153539. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  153540. */
  153541. clearAllDiffusionProfiles(): void;
  153542. /**
  153543. * Disposes this object
  153544. */
  153545. dispose(): void;
  153546. /**
  153547. * @hidden
  153548. * https://zero-radiance.github.io/post/sampling-diffusion/
  153549. *
  153550. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  153551. * ------------------------------------------------------------------------------------
  153552. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  153553. * PDF[r, phi, s] = r * R[r, phi, s]
  153554. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  153555. * ------------------------------------------------------------------------------------
  153556. * We importance sample the color channel with the widest scattering distance.
  153557. */
  153558. getDiffusionProfileParameters(color: Color3): number;
  153559. /**
  153560. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  153561. * 'u' is the random number (the value of the CDF): [0, 1).
  153562. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  153563. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  153564. */
  153565. private _sampleBurleyDiffusionProfile;
  153566. }
  153567. }
  153568. declare module BABYLON {
  153569. interface AbstractScene {
  153570. /** @hidden (Backing field) */
  153571. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153572. /**
  153573. * Gets or Sets the current prepass renderer associated to the scene.
  153574. */
  153575. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153576. /**
  153577. * Enables the subsurface effect for prepass
  153578. * @returns the SubSurfaceConfiguration
  153579. */
  153580. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  153581. /**
  153582. * Disables the subsurface effect for prepass
  153583. */
  153584. disableSubSurfaceForPrePass(): void;
  153585. }
  153586. /**
  153587. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153588. * in several rendering techniques.
  153589. */
  153590. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  153591. /**
  153592. * The component name helpful to identify the component in the list of scene components.
  153593. */
  153594. readonly name: string;
  153595. /**
  153596. * The scene the component belongs to.
  153597. */
  153598. scene: Scene;
  153599. /**
  153600. * Creates a new instance of the component for the given scene
  153601. * @param scene Defines the scene to register the component in
  153602. */
  153603. constructor(scene: Scene);
  153604. /**
  153605. * Registers the component in a given scene
  153606. */
  153607. register(): void;
  153608. /**
  153609. * Serializes the component data to the specified json object
  153610. * @param serializationObject The object to serialize to
  153611. */
  153612. serialize(serializationObject: any): void;
  153613. /**
  153614. * Adds all the elements from the container to the scene
  153615. * @param container the container holding the elements
  153616. */
  153617. addFromContainer(container: AbstractScene): void;
  153618. /**
  153619. * Removes all the elements in the container from the scene
  153620. * @param container contains the elements to remove
  153621. * @param dispose if the removed element should be disposed (default: false)
  153622. */
  153623. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  153624. /**
  153625. * Rebuilds the elements related to this component in case of
  153626. * context lost for instance.
  153627. */
  153628. rebuild(): void;
  153629. /**
  153630. * Disposes the component and the associated ressources
  153631. */
  153632. dispose(): void;
  153633. }
  153634. }
  153635. declare module BABYLON {
  153636. /** @hidden */
  153637. export var outlinePixelShader: {
  153638. name: string;
  153639. shader: string;
  153640. };
  153641. }
  153642. declare module BABYLON {
  153643. /** @hidden */
  153644. export var outlineVertexShader: {
  153645. name: string;
  153646. shader: string;
  153647. };
  153648. }
  153649. declare module BABYLON {
  153650. interface Scene {
  153651. /** @hidden */
  153652. _outlineRenderer: OutlineRenderer;
  153653. /**
  153654. * Gets the outline renderer associated with the scene
  153655. * @returns a OutlineRenderer
  153656. */
  153657. getOutlineRenderer(): OutlineRenderer;
  153658. }
  153659. interface AbstractMesh {
  153660. /** @hidden (Backing field) */
  153661. _renderOutline: boolean;
  153662. /**
  153663. * Gets or sets a boolean indicating if the outline must be rendered as well
  153664. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  153665. */
  153666. renderOutline: boolean;
  153667. /** @hidden (Backing field) */
  153668. _renderOverlay: boolean;
  153669. /**
  153670. * Gets or sets a boolean indicating if the overlay must be rendered as well
  153671. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  153672. */
  153673. renderOverlay: boolean;
  153674. }
  153675. /**
  153676. * This class is responsible to draw bothe outline/overlay of meshes.
  153677. * It should not be used directly but through the available method on mesh.
  153678. */
  153679. export class OutlineRenderer implements ISceneComponent {
  153680. /**
  153681. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  153682. */
  153683. private static _StencilReference;
  153684. /**
  153685. * The name of the component. Each component must have a unique name.
  153686. */
  153687. name: string;
  153688. /**
  153689. * The scene the component belongs to.
  153690. */
  153691. scene: Scene;
  153692. /**
  153693. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  153694. */
  153695. zOffset: number;
  153696. private _engine;
  153697. private _effect;
  153698. private _cachedDefines;
  153699. private _savedDepthWrite;
  153700. /**
  153701. * Instantiates a new outline renderer. (There could be only one per scene).
  153702. * @param scene Defines the scene it belongs to
  153703. */
  153704. constructor(scene: Scene);
  153705. /**
  153706. * Register the component to one instance of a scene.
  153707. */
  153708. register(): void;
  153709. /**
  153710. * Rebuilds the elements related to this component in case of
  153711. * context lost for instance.
  153712. */
  153713. rebuild(): void;
  153714. /**
  153715. * Disposes the component and the associated ressources.
  153716. */
  153717. dispose(): void;
  153718. /**
  153719. * Renders the outline in the canvas.
  153720. * @param subMesh Defines the sumesh to render
  153721. * @param batch Defines the batch of meshes in case of instances
  153722. * @param useOverlay Defines if the rendering is for the overlay or the outline
  153723. */
  153724. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  153725. /**
  153726. * Returns whether or not the outline renderer is ready for a given submesh.
  153727. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  153728. * @param subMesh Defines the submesh to check readyness for
  153729. * @param useInstances Defines wheter wee are trying to render instances or not
  153730. * @returns true if ready otherwise false
  153731. */
  153732. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  153733. private _beforeRenderingMesh;
  153734. private _afterRenderingMesh;
  153735. }
  153736. }
  153737. declare module BABYLON {
  153738. /**
  153739. * Defines the basic options interface of a Sprite Frame Source Size.
  153740. */
  153741. export interface ISpriteJSONSpriteSourceSize {
  153742. /**
  153743. * number of the original width of the Frame
  153744. */
  153745. w: number;
  153746. /**
  153747. * number of the original height of the Frame
  153748. */
  153749. h: number;
  153750. }
  153751. /**
  153752. * Defines the basic options interface of a Sprite Frame Data.
  153753. */
  153754. export interface ISpriteJSONSpriteFrameData {
  153755. /**
  153756. * number of the x offset of the Frame
  153757. */
  153758. x: number;
  153759. /**
  153760. * number of the y offset of the Frame
  153761. */
  153762. y: number;
  153763. /**
  153764. * number of the width of the Frame
  153765. */
  153766. w: number;
  153767. /**
  153768. * number of the height of the Frame
  153769. */
  153770. h: number;
  153771. }
  153772. /**
  153773. * Defines the basic options interface of a JSON Sprite.
  153774. */
  153775. export interface ISpriteJSONSprite {
  153776. /**
  153777. * string name of the Frame
  153778. */
  153779. filename: string;
  153780. /**
  153781. * ISpriteJSONSpriteFrame basic object of the frame data
  153782. */
  153783. frame: ISpriteJSONSpriteFrameData;
  153784. /**
  153785. * boolean to flag is the frame was rotated.
  153786. */
  153787. rotated: boolean;
  153788. /**
  153789. * boolean to flag is the frame was trimmed.
  153790. */
  153791. trimmed: boolean;
  153792. /**
  153793. * ISpriteJSONSpriteFrame basic object of the source data
  153794. */
  153795. spriteSourceSize: ISpriteJSONSpriteFrameData;
  153796. /**
  153797. * ISpriteJSONSpriteFrame basic object of the source data
  153798. */
  153799. sourceSize: ISpriteJSONSpriteSourceSize;
  153800. }
  153801. /**
  153802. * Defines the basic options interface of a JSON atlas.
  153803. */
  153804. export interface ISpriteJSONAtlas {
  153805. /**
  153806. * Array of objects that contain the frame data.
  153807. */
  153808. frames: Array<ISpriteJSONSprite>;
  153809. /**
  153810. * object basic object containing the sprite meta data.
  153811. */
  153812. meta?: object;
  153813. }
  153814. }
  153815. declare module BABYLON {
  153816. /** @hidden */
  153817. export var spriteMapPixelShader: {
  153818. name: string;
  153819. shader: string;
  153820. };
  153821. }
  153822. declare module BABYLON {
  153823. /** @hidden */
  153824. export var spriteMapVertexShader: {
  153825. name: string;
  153826. shader: string;
  153827. };
  153828. }
  153829. declare module BABYLON {
  153830. /**
  153831. * Defines the basic options interface of a SpriteMap
  153832. */
  153833. export interface ISpriteMapOptions {
  153834. /**
  153835. * Vector2 of the number of cells in the grid.
  153836. */
  153837. stageSize?: Vector2;
  153838. /**
  153839. * Vector2 of the size of the output plane in World Units.
  153840. */
  153841. outputSize?: Vector2;
  153842. /**
  153843. * Vector3 of the position of the output plane in World Units.
  153844. */
  153845. outputPosition?: Vector3;
  153846. /**
  153847. * Vector3 of the rotation of the output plane.
  153848. */
  153849. outputRotation?: Vector3;
  153850. /**
  153851. * number of layers that the system will reserve in resources.
  153852. */
  153853. layerCount?: number;
  153854. /**
  153855. * number of max animation frames a single cell will reserve in resources.
  153856. */
  153857. maxAnimationFrames?: number;
  153858. /**
  153859. * number cell index of the base tile when the system compiles.
  153860. */
  153861. baseTile?: number;
  153862. /**
  153863. * boolean flip the sprite after its been repositioned by the framing data.
  153864. */
  153865. flipU?: boolean;
  153866. /**
  153867. * Vector3 scalar of the global RGB values of the SpriteMap.
  153868. */
  153869. colorMultiply?: Vector3;
  153870. }
  153871. /**
  153872. * Defines the IDisposable interface in order to be cleanable from resources.
  153873. */
  153874. export interface ISpriteMap extends IDisposable {
  153875. /**
  153876. * String name of the SpriteMap.
  153877. */
  153878. name: string;
  153879. /**
  153880. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153881. */
  153882. atlasJSON: ISpriteJSONAtlas;
  153883. /**
  153884. * Texture of the SpriteMap.
  153885. */
  153886. spriteSheet: Texture;
  153887. /**
  153888. * The parameters to initialize the SpriteMap with.
  153889. */
  153890. options: ISpriteMapOptions;
  153891. }
  153892. /**
  153893. * Class used to manage a grid restricted sprite deployment on an Output plane.
  153894. */
  153895. export class SpriteMap implements ISpriteMap {
  153896. /** The Name of the spriteMap */
  153897. name: string;
  153898. /** The JSON file with the frame and meta data */
  153899. atlasJSON: ISpriteJSONAtlas;
  153900. /** The systems Sprite Sheet Texture */
  153901. spriteSheet: Texture;
  153902. /** Arguments passed with the Constructor */
  153903. options: ISpriteMapOptions;
  153904. /** Public Sprite Storage array, parsed from atlasJSON */
  153905. sprites: Array<ISpriteJSONSprite>;
  153906. /** Returns the Number of Sprites in the System */
  153907. get spriteCount(): number;
  153908. /** Returns the Position of Output Plane*/
  153909. get position(): Vector3;
  153910. /** Returns the Position of Output Plane*/
  153911. set position(v: Vector3);
  153912. /** Returns the Rotation of Output Plane*/
  153913. get rotation(): Vector3;
  153914. /** Returns the Rotation of Output Plane*/
  153915. set rotation(v: Vector3);
  153916. /** Sets the AnimationMap*/
  153917. get animationMap(): RawTexture;
  153918. /** Sets the AnimationMap*/
  153919. set animationMap(v: RawTexture);
  153920. /** Scene that the SpriteMap was created in */
  153921. private _scene;
  153922. /** Texture Buffer of Float32 that holds tile frame data*/
  153923. private _frameMap;
  153924. /** Texture Buffers of Float32 that holds tileMap data*/
  153925. private _tileMaps;
  153926. /** Texture Buffer of Float32 that holds Animation Data*/
  153927. private _animationMap;
  153928. /** Custom ShaderMaterial Central to the System*/
  153929. private _material;
  153930. /** Custom ShaderMaterial Central to the System*/
  153931. private _output;
  153932. /** Systems Time Ticker*/
  153933. private _time;
  153934. /**
  153935. * Creates a new SpriteMap
  153936. * @param name defines the SpriteMaps Name
  153937. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  153938. * @param spriteSheet is the Texture that the Sprites are on.
  153939. * @param options a basic deployment configuration
  153940. * @param scene The Scene that the map is deployed on
  153941. */
  153942. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  153943. /**
  153944. * Returns tileID location
  153945. * @returns Vector2 the cell position ID
  153946. */
  153947. getTileID(): Vector2;
  153948. /**
  153949. * Gets the UV location of the mouse over the SpriteMap.
  153950. * @returns Vector2 the UV position of the mouse interaction
  153951. */
  153952. getMousePosition(): Vector2;
  153953. /**
  153954. * Creates the "frame" texture Buffer
  153955. * -------------------------------------
  153956. * Structure of frames
  153957. * "filename": "Falling-Water-2.png",
  153958. * "frame": {"x":69,"y":103,"w":24,"h":32},
  153959. * "rotated": true,
  153960. * "trimmed": true,
  153961. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  153962. * "sourceSize": {"w":32,"h":32}
  153963. * @returns RawTexture of the frameMap
  153964. */
  153965. private _createFrameBuffer;
  153966. /**
  153967. * Creates the tileMap texture Buffer
  153968. * @param buffer normally and array of numbers, or a false to generate from scratch
  153969. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153970. * @returns RawTexture of the tileMap
  153971. */
  153972. private _createTileBuffer;
  153973. /**
  153974. * Modifies the data of the tileMaps
  153975. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153976. * @param pos is the iVector2 Coordinates of the Tile
  153977. * @param tile The SpriteIndex of the new Tile
  153978. */
  153979. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153980. /**
  153981. * Creates the animationMap texture Buffer
  153982. * @param buffer normally and array of numbers, or a false to generate from scratch
  153983. * @returns RawTexture of the animationMap
  153984. */
  153985. private _createTileAnimationBuffer;
  153986. /**
  153987. * Modifies the data of the animationMap
  153988. * @param cellID is the Index of the Sprite
  153989. * @param _frame is the target Animation frame
  153990. * @param toCell is the Target Index of the next frame of the animation
  153991. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153992. * @param speed is a global scalar of the time variable on the map.
  153993. */
  153994. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153995. /**
  153996. * Exports the .tilemaps file
  153997. */
  153998. saveTileMaps(): void;
  153999. /**
  154000. * Imports the .tilemaps file
  154001. * @param url of the .tilemaps file
  154002. */
  154003. loadTileMaps(url: string): void;
  154004. /**
  154005. * Release associated resources
  154006. */
  154007. dispose(): void;
  154008. }
  154009. }
  154010. declare module BABYLON {
  154011. /**
  154012. * Class used to manage multiple sprites of different sizes on the same spritesheet
  154013. * @see https://doc.babylonjs.com/babylon101/sprites
  154014. */
  154015. export class SpritePackedManager extends SpriteManager {
  154016. /** defines the packed manager's name */
  154017. name: string;
  154018. /**
  154019. * Creates a new sprite manager from a packed sprite sheet
  154020. * @param name defines the manager's name
  154021. * @param imgUrl defines the sprite sheet url
  154022. * @param capacity defines the maximum allowed number of sprites
  154023. * @param scene defines the hosting scene
  154024. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  154025. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  154026. * @param samplingMode defines the smapling mode to use with spritesheet
  154027. * @param fromPacked set to true; do not alter
  154028. */
  154029. constructor(
  154030. /** defines the packed manager's name */
  154031. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  154032. }
  154033. }
  154034. declare module BABYLON {
  154035. /**
  154036. * Defines the list of states available for a task inside a AssetsManager
  154037. */
  154038. export enum AssetTaskState {
  154039. /**
  154040. * Initialization
  154041. */
  154042. INIT = 0,
  154043. /**
  154044. * Running
  154045. */
  154046. RUNNING = 1,
  154047. /**
  154048. * Done
  154049. */
  154050. DONE = 2,
  154051. /**
  154052. * Error
  154053. */
  154054. ERROR = 3
  154055. }
  154056. /**
  154057. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  154058. */
  154059. export abstract class AbstractAssetTask {
  154060. /**
  154061. * Task name
  154062. */ name: string;
  154063. /**
  154064. * Callback called when the task is successful
  154065. */
  154066. onSuccess: (task: any) => void;
  154067. /**
  154068. * Callback called when the task is not successful
  154069. */
  154070. onError: (task: any, message?: string, exception?: any) => void;
  154071. /**
  154072. * Creates a new AssetsManager
  154073. * @param name defines the name of the task
  154074. */
  154075. constructor(
  154076. /**
  154077. * Task name
  154078. */ name: string);
  154079. private _isCompleted;
  154080. private _taskState;
  154081. private _errorObject;
  154082. /**
  154083. * Get if the task is completed
  154084. */
  154085. get isCompleted(): boolean;
  154086. /**
  154087. * Gets the current state of the task
  154088. */
  154089. get taskState(): AssetTaskState;
  154090. /**
  154091. * Gets the current error object (if task is in error)
  154092. */
  154093. get errorObject(): {
  154094. message?: string;
  154095. exception?: any;
  154096. };
  154097. /**
  154098. * Internal only
  154099. * @hidden
  154100. */
  154101. _setErrorObject(message?: string, exception?: any): void;
  154102. /**
  154103. * Execute the current task
  154104. * @param scene defines the scene where you want your assets to be loaded
  154105. * @param onSuccess is a callback called when the task is successfully executed
  154106. * @param onError is a callback called if an error occurs
  154107. */
  154108. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154109. /**
  154110. * Execute the current task
  154111. * @param scene defines the scene where you want your assets to be loaded
  154112. * @param onSuccess is a callback called when the task is successfully executed
  154113. * @param onError is a callback called if an error occurs
  154114. */
  154115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154116. /**
  154117. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  154118. * This can be used with failed tasks that have the reason for failure fixed.
  154119. */
  154120. reset(): void;
  154121. private onErrorCallback;
  154122. private onDoneCallback;
  154123. }
  154124. /**
  154125. * Define the interface used by progress events raised during assets loading
  154126. */
  154127. export interface IAssetsProgressEvent {
  154128. /**
  154129. * Defines the number of remaining tasks to process
  154130. */
  154131. remainingCount: number;
  154132. /**
  154133. * Defines the total number of tasks
  154134. */
  154135. totalCount: number;
  154136. /**
  154137. * Defines the task that was just processed
  154138. */
  154139. task: AbstractAssetTask;
  154140. }
  154141. /**
  154142. * Class used to share progress information about assets loading
  154143. */
  154144. export class AssetsProgressEvent implements IAssetsProgressEvent {
  154145. /**
  154146. * Defines the number of remaining tasks to process
  154147. */
  154148. remainingCount: number;
  154149. /**
  154150. * Defines the total number of tasks
  154151. */
  154152. totalCount: number;
  154153. /**
  154154. * Defines the task that was just processed
  154155. */
  154156. task: AbstractAssetTask;
  154157. /**
  154158. * Creates a AssetsProgressEvent
  154159. * @param remainingCount defines the number of remaining tasks to process
  154160. * @param totalCount defines the total number of tasks
  154161. * @param task defines the task that was just processed
  154162. */
  154163. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  154164. }
  154165. /**
  154166. * Define a task used by AssetsManager to load assets into a container
  154167. */
  154168. export class ContainerAssetTask extends AbstractAssetTask {
  154169. /**
  154170. * Defines the name of the task
  154171. */
  154172. name: string;
  154173. /**
  154174. * Defines the list of mesh's names you want to load
  154175. */
  154176. meshesNames: any;
  154177. /**
  154178. * Defines the root url to use as a base to load your meshes and associated resources
  154179. */
  154180. rootUrl: string;
  154181. /**
  154182. * Defines the filename or File of the scene to load from
  154183. */
  154184. sceneFilename: string | File;
  154185. /**
  154186. * Get the loaded asset container
  154187. */
  154188. loadedContainer: AssetContainer;
  154189. /**
  154190. * Gets the list of loaded meshes
  154191. */
  154192. loadedMeshes: Array<AbstractMesh>;
  154193. /**
  154194. * Gets the list of loaded particle systems
  154195. */
  154196. loadedParticleSystems: Array<IParticleSystem>;
  154197. /**
  154198. * Gets the list of loaded skeletons
  154199. */
  154200. loadedSkeletons: Array<Skeleton>;
  154201. /**
  154202. * Gets the list of loaded animation groups
  154203. */
  154204. loadedAnimationGroups: Array<AnimationGroup>;
  154205. /**
  154206. * Callback called when the task is successful
  154207. */
  154208. onSuccess: (task: ContainerAssetTask) => void;
  154209. /**
  154210. * Callback called when the task is successful
  154211. */
  154212. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  154213. /**
  154214. * Creates a new ContainerAssetTask
  154215. * @param name defines the name of the task
  154216. * @param meshesNames defines the list of mesh's names you want to load
  154217. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154218. * @param sceneFilename defines the filename or File of the scene to load from
  154219. */
  154220. constructor(
  154221. /**
  154222. * Defines the name of the task
  154223. */
  154224. name: string,
  154225. /**
  154226. * Defines the list of mesh's names you want to load
  154227. */
  154228. meshesNames: any,
  154229. /**
  154230. * Defines the root url to use as a base to load your meshes and associated resources
  154231. */
  154232. rootUrl: string,
  154233. /**
  154234. * Defines the filename or File of the scene to load from
  154235. */
  154236. sceneFilename: string | File);
  154237. /**
  154238. * Execute the current task
  154239. * @param scene defines the scene where you want your assets to be loaded
  154240. * @param onSuccess is a callback called when the task is successfully executed
  154241. * @param onError is a callback called if an error occurs
  154242. */
  154243. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154244. }
  154245. /**
  154246. * Define a task used by AssetsManager to load meshes
  154247. */
  154248. export class MeshAssetTask extends AbstractAssetTask {
  154249. /**
  154250. * Defines the name of the task
  154251. */
  154252. name: string;
  154253. /**
  154254. * Defines the list of mesh's names you want to load
  154255. */
  154256. meshesNames: any;
  154257. /**
  154258. * Defines the root url to use as a base to load your meshes and associated resources
  154259. */
  154260. rootUrl: string;
  154261. /**
  154262. * Defines the filename or File of the scene to load from
  154263. */
  154264. sceneFilename: string | File;
  154265. /**
  154266. * Gets the list of loaded meshes
  154267. */
  154268. loadedMeshes: Array<AbstractMesh>;
  154269. /**
  154270. * Gets the list of loaded particle systems
  154271. */
  154272. loadedParticleSystems: Array<IParticleSystem>;
  154273. /**
  154274. * Gets the list of loaded skeletons
  154275. */
  154276. loadedSkeletons: Array<Skeleton>;
  154277. /**
  154278. * Gets the list of loaded animation groups
  154279. */
  154280. loadedAnimationGroups: Array<AnimationGroup>;
  154281. /**
  154282. * Callback called when the task is successful
  154283. */
  154284. onSuccess: (task: MeshAssetTask) => void;
  154285. /**
  154286. * Callback called when the task is successful
  154287. */
  154288. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  154289. /**
  154290. * Creates a new MeshAssetTask
  154291. * @param name defines the name of the task
  154292. * @param meshesNames defines the list of mesh's names you want to load
  154293. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154294. * @param sceneFilename defines the filename or File of the scene to load from
  154295. */
  154296. constructor(
  154297. /**
  154298. * Defines the name of the task
  154299. */
  154300. name: string,
  154301. /**
  154302. * Defines the list of mesh's names you want to load
  154303. */
  154304. meshesNames: any,
  154305. /**
  154306. * Defines the root url to use as a base to load your meshes and associated resources
  154307. */
  154308. rootUrl: string,
  154309. /**
  154310. * Defines the filename or File of the scene to load from
  154311. */
  154312. sceneFilename: string | File);
  154313. /**
  154314. * Execute the current task
  154315. * @param scene defines the scene where you want your assets to be loaded
  154316. * @param onSuccess is a callback called when the task is successfully executed
  154317. * @param onError is a callback called if an error occurs
  154318. */
  154319. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154320. }
  154321. /**
  154322. * Define a task used by AssetsManager to load text content
  154323. */
  154324. export class TextFileAssetTask extends AbstractAssetTask {
  154325. /**
  154326. * Defines the name of the task
  154327. */
  154328. name: string;
  154329. /**
  154330. * Defines the location of the file to load
  154331. */
  154332. url: string;
  154333. /**
  154334. * Gets the loaded text string
  154335. */
  154336. text: string;
  154337. /**
  154338. * Callback called when the task is successful
  154339. */
  154340. onSuccess: (task: TextFileAssetTask) => void;
  154341. /**
  154342. * Callback called when the task is successful
  154343. */
  154344. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  154345. /**
  154346. * Creates a new TextFileAssetTask object
  154347. * @param name defines the name of the task
  154348. * @param url defines the location of the file to load
  154349. */
  154350. constructor(
  154351. /**
  154352. * Defines the name of the task
  154353. */
  154354. name: string,
  154355. /**
  154356. * Defines the location of the file to load
  154357. */
  154358. url: string);
  154359. /**
  154360. * Execute the current task
  154361. * @param scene defines the scene where you want your assets to be loaded
  154362. * @param onSuccess is a callback called when the task is successfully executed
  154363. * @param onError is a callback called if an error occurs
  154364. */
  154365. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154366. }
  154367. /**
  154368. * Define a task used by AssetsManager to load binary data
  154369. */
  154370. export class BinaryFileAssetTask extends AbstractAssetTask {
  154371. /**
  154372. * Defines the name of the task
  154373. */
  154374. name: string;
  154375. /**
  154376. * Defines the location of the file to load
  154377. */
  154378. url: string;
  154379. /**
  154380. * Gets the lodaded data (as an array buffer)
  154381. */
  154382. data: ArrayBuffer;
  154383. /**
  154384. * Callback called when the task is successful
  154385. */
  154386. onSuccess: (task: BinaryFileAssetTask) => void;
  154387. /**
  154388. * Callback called when the task is successful
  154389. */
  154390. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  154391. /**
  154392. * Creates a new BinaryFileAssetTask object
  154393. * @param name defines the name of the new task
  154394. * @param url defines the location of the file to load
  154395. */
  154396. constructor(
  154397. /**
  154398. * Defines the name of the task
  154399. */
  154400. name: string,
  154401. /**
  154402. * Defines the location of the file to load
  154403. */
  154404. url: string);
  154405. /**
  154406. * Execute the current task
  154407. * @param scene defines the scene where you want your assets to be loaded
  154408. * @param onSuccess is a callback called when the task is successfully executed
  154409. * @param onError is a callback called if an error occurs
  154410. */
  154411. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154412. }
  154413. /**
  154414. * Define a task used by AssetsManager to load images
  154415. */
  154416. export class ImageAssetTask extends AbstractAssetTask {
  154417. /**
  154418. * Defines the name of the task
  154419. */
  154420. name: string;
  154421. /**
  154422. * Defines the location of the image to load
  154423. */
  154424. url: string;
  154425. /**
  154426. * Gets the loaded images
  154427. */
  154428. image: HTMLImageElement;
  154429. /**
  154430. * Callback called when the task is successful
  154431. */
  154432. onSuccess: (task: ImageAssetTask) => void;
  154433. /**
  154434. * Callback called when the task is successful
  154435. */
  154436. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  154437. /**
  154438. * Creates a new ImageAssetTask
  154439. * @param name defines the name of the task
  154440. * @param url defines the location of the image to load
  154441. */
  154442. constructor(
  154443. /**
  154444. * Defines the name of the task
  154445. */
  154446. name: string,
  154447. /**
  154448. * Defines the location of the image to load
  154449. */
  154450. url: string);
  154451. /**
  154452. * Execute the current task
  154453. * @param scene defines the scene where you want your assets to be loaded
  154454. * @param onSuccess is a callback called when the task is successfully executed
  154455. * @param onError is a callback called if an error occurs
  154456. */
  154457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154458. }
  154459. /**
  154460. * Defines the interface used by texture loading tasks
  154461. */
  154462. export interface ITextureAssetTask<TEX extends BaseTexture> {
  154463. /**
  154464. * Gets the loaded texture
  154465. */
  154466. texture: TEX;
  154467. }
  154468. /**
  154469. * Define a task used by AssetsManager to load 2D textures
  154470. */
  154471. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  154472. /**
  154473. * Defines the name of the task
  154474. */
  154475. name: string;
  154476. /**
  154477. * Defines the location of the file to load
  154478. */
  154479. url: string;
  154480. /**
  154481. * Defines if mipmap should not be generated (default is false)
  154482. */
  154483. noMipmap?: boolean | undefined;
  154484. /**
  154485. * Defines if texture must be inverted on Y axis (default is true)
  154486. */
  154487. invertY: boolean;
  154488. /**
  154489. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154490. */
  154491. samplingMode: number;
  154492. /**
  154493. * Gets the loaded texture
  154494. */
  154495. texture: Texture;
  154496. /**
  154497. * Callback called when the task is successful
  154498. */
  154499. onSuccess: (task: TextureAssetTask) => void;
  154500. /**
  154501. * Callback called when the task is successful
  154502. */
  154503. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  154504. /**
  154505. * Creates a new TextureAssetTask object
  154506. * @param name defines the name of the task
  154507. * @param url defines the location of the file to load
  154508. * @param noMipmap defines if mipmap should not be generated (default is false)
  154509. * @param invertY defines if texture must be inverted on Y axis (default is true)
  154510. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154511. */
  154512. constructor(
  154513. /**
  154514. * Defines the name of the task
  154515. */
  154516. name: string,
  154517. /**
  154518. * Defines the location of the file to load
  154519. */
  154520. url: string,
  154521. /**
  154522. * Defines if mipmap should not be generated (default is false)
  154523. */
  154524. noMipmap?: boolean | undefined,
  154525. /**
  154526. * Defines if texture must be inverted on Y axis (default is true)
  154527. */
  154528. invertY?: boolean,
  154529. /**
  154530. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154531. */
  154532. samplingMode?: number);
  154533. /**
  154534. * Execute the current task
  154535. * @param scene defines the scene where you want your assets to be loaded
  154536. * @param onSuccess is a callback called when the task is successfully executed
  154537. * @param onError is a callback called if an error occurs
  154538. */
  154539. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154540. }
  154541. /**
  154542. * Define a task used by AssetsManager to load cube textures
  154543. */
  154544. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  154545. /**
  154546. * Defines the name of the task
  154547. */
  154548. name: string;
  154549. /**
  154550. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154551. */
  154552. url: string;
  154553. /**
  154554. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154555. */
  154556. extensions?: string[] | undefined;
  154557. /**
  154558. * Defines if mipmaps should not be generated (default is false)
  154559. */
  154560. noMipmap?: boolean | undefined;
  154561. /**
  154562. * Defines the explicit list of files (undefined by default)
  154563. */
  154564. files?: string[] | undefined;
  154565. /**
  154566. * Gets the loaded texture
  154567. */
  154568. texture: CubeTexture;
  154569. /**
  154570. * Callback called when the task is successful
  154571. */
  154572. onSuccess: (task: CubeTextureAssetTask) => void;
  154573. /**
  154574. * Callback called when the task is successful
  154575. */
  154576. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  154577. /**
  154578. * Creates a new CubeTextureAssetTask
  154579. * @param name defines the name of the task
  154580. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154581. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154582. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154583. * @param files defines the explicit list of files (undefined by default)
  154584. */
  154585. constructor(
  154586. /**
  154587. * Defines the name of the task
  154588. */
  154589. name: string,
  154590. /**
  154591. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154592. */
  154593. url: string,
  154594. /**
  154595. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154596. */
  154597. extensions?: string[] | undefined,
  154598. /**
  154599. * Defines if mipmaps should not be generated (default is false)
  154600. */
  154601. noMipmap?: boolean | undefined,
  154602. /**
  154603. * Defines the explicit list of files (undefined by default)
  154604. */
  154605. files?: string[] | undefined);
  154606. /**
  154607. * Execute the current task
  154608. * @param scene defines the scene where you want your assets to be loaded
  154609. * @param onSuccess is a callback called when the task is successfully executed
  154610. * @param onError is a callback called if an error occurs
  154611. */
  154612. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154613. }
  154614. /**
  154615. * Define a task used by AssetsManager to load HDR cube textures
  154616. */
  154617. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  154618. /**
  154619. * Defines the name of the task
  154620. */
  154621. name: string;
  154622. /**
  154623. * Defines the location of the file to load
  154624. */
  154625. url: string;
  154626. /**
  154627. * Defines the desired size (the more it increases the longer the generation will be)
  154628. */
  154629. size: number;
  154630. /**
  154631. * Defines if mipmaps should not be generated (default is false)
  154632. */
  154633. noMipmap: boolean;
  154634. /**
  154635. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154636. */
  154637. generateHarmonics: boolean;
  154638. /**
  154639. * 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)
  154640. */
  154641. gammaSpace: boolean;
  154642. /**
  154643. * Internal Use Only
  154644. */
  154645. reserved: boolean;
  154646. /**
  154647. * Gets the loaded texture
  154648. */
  154649. texture: HDRCubeTexture;
  154650. /**
  154651. * Callback called when the task is successful
  154652. */
  154653. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  154654. /**
  154655. * Callback called when the task is successful
  154656. */
  154657. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  154658. /**
  154659. * Creates a new HDRCubeTextureAssetTask object
  154660. * @param name defines the name of the task
  154661. * @param url defines the location of the file to load
  154662. * @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.
  154663. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154664. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154665. * @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)
  154666. * @param reserved Internal use only
  154667. */
  154668. constructor(
  154669. /**
  154670. * Defines the name of the task
  154671. */
  154672. name: string,
  154673. /**
  154674. * Defines the location of the file to load
  154675. */
  154676. url: string,
  154677. /**
  154678. * Defines the desired size (the more it increases the longer the generation will be)
  154679. */
  154680. size: number,
  154681. /**
  154682. * Defines if mipmaps should not be generated (default is false)
  154683. */
  154684. noMipmap?: boolean,
  154685. /**
  154686. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154687. */
  154688. generateHarmonics?: boolean,
  154689. /**
  154690. * 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)
  154691. */
  154692. gammaSpace?: boolean,
  154693. /**
  154694. * Internal Use Only
  154695. */
  154696. reserved?: boolean);
  154697. /**
  154698. * Execute the current task
  154699. * @param scene defines the scene where you want your assets to be loaded
  154700. * @param onSuccess is a callback called when the task is successfully executed
  154701. * @param onError is a callback called if an error occurs
  154702. */
  154703. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154704. }
  154705. /**
  154706. * Define a task used by AssetsManager to load Equirectangular cube textures
  154707. */
  154708. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  154709. /**
  154710. * Defines the name of the task
  154711. */
  154712. name: string;
  154713. /**
  154714. * Defines the location of the file to load
  154715. */
  154716. url: string;
  154717. /**
  154718. * Defines the desired size (the more it increases the longer the generation will be)
  154719. */
  154720. size: number;
  154721. /**
  154722. * Defines if mipmaps should not be generated (default is false)
  154723. */
  154724. noMipmap: boolean;
  154725. /**
  154726. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154727. * but the standard material would require them in Gamma space) (default is true)
  154728. */
  154729. gammaSpace: boolean;
  154730. /**
  154731. * Gets the loaded texture
  154732. */
  154733. texture: EquiRectangularCubeTexture;
  154734. /**
  154735. * Callback called when the task is successful
  154736. */
  154737. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  154738. /**
  154739. * Callback called when the task is successful
  154740. */
  154741. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  154742. /**
  154743. * Creates a new EquiRectangularCubeTextureAssetTask object
  154744. * @param name defines the name of the task
  154745. * @param url defines the location of the file to load
  154746. * @param size defines the desired size (the more it increases the longer the generation will be)
  154747. * If the size is omitted this implies you are using a preprocessed cubemap.
  154748. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154749. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  154750. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  154751. * (default is true)
  154752. */
  154753. constructor(
  154754. /**
  154755. * Defines the name of the task
  154756. */
  154757. name: string,
  154758. /**
  154759. * Defines the location of the file to load
  154760. */
  154761. url: string,
  154762. /**
  154763. * Defines the desired size (the more it increases the longer the generation will be)
  154764. */
  154765. size: number,
  154766. /**
  154767. * Defines if mipmaps should not be generated (default is false)
  154768. */
  154769. noMipmap?: boolean,
  154770. /**
  154771. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154772. * but the standard material would require them in Gamma space) (default is true)
  154773. */
  154774. gammaSpace?: boolean);
  154775. /**
  154776. * Execute the current task
  154777. * @param scene defines the scene where you want your assets to be loaded
  154778. * @param onSuccess is a callback called when the task is successfully executed
  154779. * @param onError is a callback called if an error occurs
  154780. */
  154781. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154782. }
  154783. /**
  154784. * This class can be used to easily import assets into a scene
  154785. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  154786. */
  154787. export class AssetsManager {
  154788. private _scene;
  154789. private _isLoading;
  154790. protected _tasks: AbstractAssetTask[];
  154791. protected _waitingTasksCount: number;
  154792. protected _totalTasksCount: number;
  154793. /**
  154794. * Callback called when all tasks are processed
  154795. */
  154796. onFinish: (tasks: AbstractAssetTask[]) => void;
  154797. /**
  154798. * Callback called when a task is successful
  154799. */
  154800. onTaskSuccess: (task: AbstractAssetTask) => void;
  154801. /**
  154802. * Callback called when a task had an error
  154803. */
  154804. onTaskError: (task: AbstractAssetTask) => void;
  154805. /**
  154806. * Callback called when a task is done (whatever the result is)
  154807. */
  154808. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  154809. /**
  154810. * Observable called when all tasks are processed
  154811. */
  154812. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  154813. /**
  154814. * Observable called when a task had an error
  154815. */
  154816. onTaskErrorObservable: Observable<AbstractAssetTask>;
  154817. /**
  154818. * Observable called when all tasks were executed
  154819. */
  154820. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  154821. /**
  154822. * Observable called when a task is done (whatever the result is)
  154823. */
  154824. onProgressObservable: Observable<IAssetsProgressEvent>;
  154825. /**
  154826. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  154827. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  154828. */
  154829. useDefaultLoadingScreen: boolean;
  154830. /**
  154831. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  154832. * when all assets have been downloaded.
  154833. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  154834. */
  154835. autoHideLoadingUI: boolean;
  154836. /**
  154837. * Creates a new AssetsManager
  154838. * @param scene defines the scene to work on
  154839. */
  154840. constructor(scene: Scene);
  154841. /**
  154842. * Add a ContainerAssetTask to the list of active tasks
  154843. * @param taskName defines the name of the new task
  154844. * @param meshesNames defines the name of meshes to load
  154845. * @param rootUrl defines the root url to use to locate files
  154846. * @param sceneFilename defines the filename of the scene file
  154847. * @returns a new ContainerAssetTask object
  154848. */
  154849. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  154850. /**
  154851. * Add a MeshAssetTask to the list of active tasks
  154852. * @param taskName defines the name of the new task
  154853. * @param meshesNames defines the name of meshes to load
  154854. * @param rootUrl defines the root url to use to locate files
  154855. * @param sceneFilename defines the filename of the scene file
  154856. * @returns a new MeshAssetTask object
  154857. */
  154858. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  154859. /**
  154860. * Add a TextFileAssetTask to the list of active tasks
  154861. * @param taskName defines the name of the new task
  154862. * @param url defines the url of the file to load
  154863. * @returns a new TextFileAssetTask object
  154864. */
  154865. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  154866. /**
  154867. * Add a BinaryFileAssetTask to the list of active tasks
  154868. * @param taskName defines the name of the new task
  154869. * @param url defines the url of the file to load
  154870. * @returns a new BinaryFileAssetTask object
  154871. */
  154872. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  154873. /**
  154874. * Add a ImageAssetTask to the list of active tasks
  154875. * @param taskName defines the name of the new task
  154876. * @param url defines the url of the file to load
  154877. * @returns a new ImageAssetTask object
  154878. */
  154879. addImageTask(taskName: string, url: string): ImageAssetTask;
  154880. /**
  154881. * Add a TextureAssetTask to the list of active tasks
  154882. * @param taskName defines the name of the new task
  154883. * @param url defines the url of the file to load
  154884. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154885. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154886. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154887. * @returns a new TextureAssetTask object
  154888. */
  154889. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154890. /**
  154891. * Add a CubeTextureAssetTask to the list of active tasks
  154892. * @param taskName defines the name of the new task
  154893. * @param url defines the url of the file to load
  154894. * @param extensions defines the extension to use to load the cube map (can be null)
  154895. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154896. * @param files defines the list of files to load (can be null)
  154897. * @returns a new CubeTextureAssetTask object
  154898. */
  154899. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  154900. /**
  154901. *
  154902. * Add a HDRCubeTextureAssetTask to the list of active tasks
  154903. * @param taskName defines the name of the new task
  154904. * @param url defines the url of the file to load
  154905. * @param size defines the size you want for the cubemap (can be null)
  154906. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154907. * @param generateHarmonics defines if you want to automatically generate (true by default)
  154908. * @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)
  154909. * @param reserved Internal use only
  154910. * @returns a new HDRCubeTextureAssetTask object
  154911. */
  154912. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  154913. /**
  154914. *
  154915. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  154916. * @param taskName defines the name of the new task
  154917. * @param url defines the url of the file to load
  154918. * @param size defines the size you want for the cubemap (can be null)
  154919. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154920. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  154921. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  154922. * @returns a new EquiRectangularCubeTextureAssetTask object
  154923. */
  154924. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  154925. /**
  154926. * Remove a task from the assets manager.
  154927. * @param task the task to remove
  154928. */
  154929. removeTask(task: AbstractAssetTask): void;
  154930. private _decreaseWaitingTasksCount;
  154931. private _runTask;
  154932. /**
  154933. * Reset the AssetsManager and remove all tasks
  154934. * @return the current instance of the AssetsManager
  154935. */
  154936. reset(): AssetsManager;
  154937. /**
  154938. * Start the loading process
  154939. * @return the current instance of the AssetsManager
  154940. */
  154941. load(): AssetsManager;
  154942. /**
  154943. * Start the loading process as an async operation
  154944. * @return a promise returning the list of failed tasks
  154945. */
  154946. loadAsync(): Promise<void>;
  154947. }
  154948. }
  154949. declare module BABYLON {
  154950. /**
  154951. * Wrapper class for promise with external resolve and reject.
  154952. */
  154953. export class Deferred<T> {
  154954. /**
  154955. * The promise associated with this deferred object.
  154956. */
  154957. readonly promise: Promise<T>;
  154958. private _resolve;
  154959. private _reject;
  154960. /**
  154961. * The resolve method of the promise associated with this deferred object.
  154962. */
  154963. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  154964. /**
  154965. * The reject method of the promise associated with this deferred object.
  154966. */
  154967. get reject(): (reason?: any) => void;
  154968. /**
  154969. * Constructor for this deferred object.
  154970. */
  154971. constructor();
  154972. }
  154973. }
  154974. declare module BABYLON {
  154975. /**
  154976. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154977. */
  154978. export class MeshExploder {
  154979. private _centerMesh;
  154980. private _meshes;
  154981. private _meshesOrigins;
  154982. private _toCenterVectors;
  154983. private _scaledDirection;
  154984. private _newPosition;
  154985. private _centerPosition;
  154986. /**
  154987. * Explodes meshes from a center mesh.
  154988. * @param meshes The meshes to explode.
  154989. * @param centerMesh The mesh to be center of explosion.
  154990. */
  154991. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154992. private _setCenterMesh;
  154993. /**
  154994. * Get class name
  154995. * @returns "MeshExploder"
  154996. */
  154997. getClassName(): string;
  154998. /**
  154999. * "Exploded meshes"
  155000. * @returns Array of meshes with the centerMesh at index 0.
  155001. */
  155002. getMeshes(): Array<Mesh>;
  155003. /**
  155004. * Explodes meshes giving a specific direction
  155005. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  155006. */
  155007. explode(direction?: number): void;
  155008. }
  155009. }
  155010. declare module BABYLON {
  155011. /**
  155012. * Class used to help managing file picking and drag'n'drop
  155013. */
  155014. export class FilesInput {
  155015. /**
  155016. * List of files ready to be loaded
  155017. */
  155018. static get FilesToLoad(): {
  155019. [key: string]: File;
  155020. };
  155021. /**
  155022. * Callback called when a file is processed
  155023. */
  155024. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  155025. private _engine;
  155026. private _currentScene;
  155027. private _sceneLoadedCallback;
  155028. private _progressCallback;
  155029. private _additionalRenderLoopLogicCallback;
  155030. private _textureLoadingCallback;
  155031. private _startingProcessingFilesCallback;
  155032. private _onReloadCallback;
  155033. private _errorCallback;
  155034. private _elementToMonitor;
  155035. private _sceneFileToLoad;
  155036. private _filesToLoad;
  155037. /**
  155038. * Creates a new FilesInput
  155039. * @param engine defines the rendering engine
  155040. * @param scene defines the hosting scene
  155041. * @param sceneLoadedCallback callback called when scene is loaded
  155042. * @param progressCallback callback called to track progress
  155043. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  155044. * @param textureLoadingCallback callback called when a texture is loading
  155045. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  155046. * @param onReloadCallback callback called when a reload is requested
  155047. * @param errorCallback callback call if an error occurs
  155048. */
  155049. 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>);
  155050. private _dragEnterHandler;
  155051. private _dragOverHandler;
  155052. private _dropHandler;
  155053. /**
  155054. * Calls this function to listen to drag'n'drop events on a specific DOM element
  155055. * @param elementToMonitor defines the DOM element to track
  155056. */
  155057. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  155058. /** Gets the current list of files to load */
  155059. get filesToLoad(): File[];
  155060. /**
  155061. * Release all associated resources
  155062. */
  155063. dispose(): void;
  155064. private renderFunction;
  155065. private drag;
  155066. private drop;
  155067. private _traverseFolder;
  155068. private _processFiles;
  155069. /**
  155070. * Load files from a drop event
  155071. * @param event defines the drop event to use as source
  155072. */
  155073. loadFiles(event: any): void;
  155074. private _processReload;
  155075. /**
  155076. * Reload the current scene from the loaded files
  155077. */
  155078. reload(): void;
  155079. }
  155080. }
  155081. declare module BABYLON {
  155082. /**
  155083. * Defines the root class used to create scene optimization to use with SceneOptimizer
  155084. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155085. */
  155086. export class SceneOptimization {
  155087. /**
  155088. * Defines the priority of this optimization (0 by default which means first in the list)
  155089. */
  155090. priority: number;
  155091. /**
  155092. * Gets a string describing the action executed by the current optimization
  155093. * @returns description string
  155094. */
  155095. getDescription(): string;
  155096. /**
  155097. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155098. * @param scene defines the current scene where to apply this optimization
  155099. * @param optimizer defines the current optimizer
  155100. * @returns true if everything that can be done was applied
  155101. */
  155102. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155103. /**
  155104. * Creates the SceneOptimization object
  155105. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155106. * @param desc defines the description associated with the optimization
  155107. */
  155108. constructor(
  155109. /**
  155110. * Defines the priority of this optimization (0 by default which means first in the list)
  155111. */
  155112. priority?: number);
  155113. }
  155114. /**
  155115. * Defines an optimization used to reduce the size of render target textures
  155116. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155117. */
  155118. export class TextureOptimization extends SceneOptimization {
  155119. /**
  155120. * Defines the priority of this optimization (0 by default which means first in the list)
  155121. */
  155122. priority: number;
  155123. /**
  155124. * 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
  155125. */
  155126. maximumSize: number;
  155127. /**
  155128. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155129. */
  155130. step: number;
  155131. /**
  155132. * Gets a string describing the action executed by the current optimization
  155133. * @returns description string
  155134. */
  155135. getDescription(): string;
  155136. /**
  155137. * Creates the TextureOptimization object
  155138. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155139. * @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
  155140. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155141. */
  155142. constructor(
  155143. /**
  155144. * Defines the priority of this optimization (0 by default which means first in the list)
  155145. */
  155146. priority?: number,
  155147. /**
  155148. * 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
  155149. */
  155150. maximumSize?: number,
  155151. /**
  155152. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155153. */
  155154. step?: number);
  155155. /**
  155156. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155157. * @param scene defines the current scene where to apply this optimization
  155158. * @param optimizer defines the current optimizer
  155159. * @returns true if everything that can be done was applied
  155160. */
  155161. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155162. }
  155163. /**
  155164. * Defines an optimization used to increase or decrease the rendering resolution
  155165. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155166. */
  155167. export class HardwareScalingOptimization extends SceneOptimization {
  155168. /**
  155169. * Defines the priority of this optimization (0 by default which means first in the list)
  155170. */
  155171. priority: number;
  155172. /**
  155173. * Defines the maximum scale to use (2 by default)
  155174. */
  155175. maximumScale: number;
  155176. /**
  155177. * Defines the step to use between two passes (0.5 by default)
  155178. */
  155179. step: number;
  155180. private _currentScale;
  155181. private _directionOffset;
  155182. /**
  155183. * Gets a string describing the action executed by the current optimization
  155184. * @return description string
  155185. */
  155186. getDescription(): string;
  155187. /**
  155188. * Creates the HardwareScalingOptimization object
  155189. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155190. * @param maximumScale defines the maximum scale to use (2 by default)
  155191. * @param step defines the step to use between two passes (0.5 by default)
  155192. */
  155193. constructor(
  155194. /**
  155195. * Defines the priority of this optimization (0 by default which means first in the list)
  155196. */
  155197. priority?: number,
  155198. /**
  155199. * Defines the maximum scale to use (2 by default)
  155200. */
  155201. maximumScale?: number,
  155202. /**
  155203. * Defines the step to use between two passes (0.5 by default)
  155204. */
  155205. step?: number);
  155206. /**
  155207. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155208. * @param scene defines the current scene where to apply this optimization
  155209. * @param optimizer defines the current optimizer
  155210. * @returns true if everything that can be done was applied
  155211. */
  155212. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155213. }
  155214. /**
  155215. * Defines an optimization used to remove shadows
  155216. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155217. */
  155218. export class ShadowsOptimization extends SceneOptimization {
  155219. /**
  155220. * Gets a string describing the action executed by the current optimization
  155221. * @return description string
  155222. */
  155223. getDescription(): string;
  155224. /**
  155225. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155226. * @param scene defines the current scene where to apply this optimization
  155227. * @param optimizer defines the current optimizer
  155228. * @returns true if everything that can be done was applied
  155229. */
  155230. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155231. }
  155232. /**
  155233. * Defines an optimization used to turn post-processes off
  155234. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155235. */
  155236. export class PostProcessesOptimization extends SceneOptimization {
  155237. /**
  155238. * Gets a string describing the action executed by the current optimization
  155239. * @return description string
  155240. */
  155241. getDescription(): string;
  155242. /**
  155243. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155244. * @param scene defines the current scene where to apply this optimization
  155245. * @param optimizer defines the current optimizer
  155246. * @returns true if everything that can be done was applied
  155247. */
  155248. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155249. }
  155250. /**
  155251. * Defines an optimization used to turn lens flares off
  155252. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155253. */
  155254. export class LensFlaresOptimization extends SceneOptimization {
  155255. /**
  155256. * Gets a string describing the action executed by the current optimization
  155257. * @return description string
  155258. */
  155259. getDescription(): string;
  155260. /**
  155261. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155262. * @param scene defines the current scene where to apply this optimization
  155263. * @param optimizer defines the current optimizer
  155264. * @returns true if everything that can be done was applied
  155265. */
  155266. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155267. }
  155268. /**
  155269. * Defines an optimization based on user defined callback.
  155270. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155271. */
  155272. export class CustomOptimization extends SceneOptimization {
  155273. /**
  155274. * Callback called to apply the custom optimization.
  155275. */
  155276. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  155277. /**
  155278. * Callback called to get custom description
  155279. */
  155280. onGetDescription: () => string;
  155281. /**
  155282. * Gets a string describing the action executed by the current optimization
  155283. * @returns description string
  155284. */
  155285. getDescription(): string;
  155286. /**
  155287. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155288. * @param scene defines the current scene where to apply this optimization
  155289. * @param optimizer defines the current optimizer
  155290. * @returns true if everything that can be done was applied
  155291. */
  155292. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155293. }
  155294. /**
  155295. * Defines an optimization used to turn particles off
  155296. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155297. */
  155298. export class ParticlesOptimization extends SceneOptimization {
  155299. /**
  155300. * Gets a string describing the action executed by the current optimization
  155301. * @return description string
  155302. */
  155303. getDescription(): string;
  155304. /**
  155305. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155306. * @param scene defines the current scene where to apply this optimization
  155307. * @param optimizer defines the current optimizer
  155308. * @returns true if everything that can be done was applied
  155309. */
  155310. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155311. }
  155312. /**
  155313. * Defines an optimization used to turn render targets off
  155314. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155315. */
  155316. export class RenderTargetsOptimization extends SceneOptimization {
  155317. /**
  155318. * Gets a string describing the action executed by the current optimization
  155319. * @return description string
  155320. */
  155321. getDescription(): string;
  155322. /**
  155323. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155324. * @param scene defines the current scene where to apply this optimization
  155325. * @param optimizer defines the current optimizer
  155326. * @returns true if everything that can be done was applied
  155327. */
  155328. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155329. }
  155330. /**
  155331. * Defines an optimization used to merge meshes with compatible materials
  155332. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155333. */
  155334. export class MergeMeshesOptimization extends SceneOptimization {
  155335. private static _UpdateSelectionTree;
  155336. /**
  155337. * Gets or sets a boolean which defines if optimization octree has to be updated
  155338. */
  155339. static get UpdateSelectionTree(): boolean;
  155340. /**
  155341. * Gets or sets a boolean which defines if optimization octree has to be updated
  155342. */
  155343. static set UpdateSelectionTree(value: boolean);
  155344. /**
  155345. * Gets a string describing the action executed by the current optimization
  155346. * @return description string
  155347. */
  155348. getDescription(): string;
  155349. private _canBeMerged;
  155350. /**
  155351. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155352. * @param scene defines the current scene where to apply this optimization
  155353. * @param optimizer defines the current optimizer
  155354. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  155355. * @returns true if everything that can be done was applied
  155356. */
  155357. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  155358. }
  155359. /**
  155360. * Defines a list of options used by SceneOptimizer
  155361. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155362. */
  155363. export class SceneOptimizerOptions {
  155364. /**
  155365. * Defines the target frame rate to reach (60 by default)
  155366. */
  155367. targetFrameRate: number;
  155368. /**
  155369. * Defines the interval between two checkes (2000ms by default)
  155370. */
  155371. trackerDuration: number;
  155372. /**
  155373. * Gets the list of optimizations to apply
  155374. */
  155375. optimizations: SceneOptimization[];
  155376. /**
  155377. * Creates a new list of options used by SceneOptimizer
  155378. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  155379. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  155380. */
  155381. constructor(
  155382. /**
  155383. * Defines the target frame rate to reach (60 by default)
  155384. */
  155385. targetFrameRate?: number,
  155386. /**
  155387. * Defines the interval between two checkes (2000ms by default)
  155388. */
  155389. trackerDuration?: number);
  155390. /**
  155391. * Add a new optimization
  155392. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  155393. * @returns the current SceneOptimizerOptions
  155394. */
  155395. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  155396. /**
  155397. * Add a new custom optimization
  155398. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  155399. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  155400. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155401. * @returns the current SceneOptimizerOptions
  155402. */
  155403. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  155404. /**
  155405. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  155406. * @param targetFrameRate defines the target frame rate (60 by default)
  155407. * @returns a SceneOptimizerOptions object
  155408. */
  155409. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155410. /**
  155411. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  155412. * @param targetFrameRate defines the target frame rate (60 by default)
  155413. * @returns a SceneOptimizerOptions object
  155414. */
  155415. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155416. /**
  155417. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  155418. * @param targetFrameRate defines the target frame rate (60 by default)
  155419. * @returns a SceneOptimizerOptions object
  155420. */
  155421. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155422. }
  155423. /**
  155424. * Class used to run optimizations in order to reach a target frame rate
  155425. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155426. */
  155427. export class SceneOptimizer implements IDisposable {
  155428. private _isRunning;
  155429. private _options;
  155430. private _scene;
  155431. private _currentPriorityLevel;
  155432. private _targetFrameRate;
  155433. private _trackerDuration;
  155434. private _currentFrameRate;
  155435. private _sceneDisposeObserver;
  155436. private _improvementMode;
  155437. /**
  155438. * Defines an observable called when the optimizer reaches the target frame rate
  155439. */
  155440. onSuccessObservable: Observable<SceneOptimizer>;
  155441. /**
  155442. * Defines an observable called when the optimizer enables an optimization
  155443. */
  155444. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  155445. /**
  155446. * Defines an observable called when the optimizer is not able to reach the target frame rate
  155447. */
  155448. onFailureObservable: Observable<SceneOptimizer>;
  155449. /**
  155450. * Gets a boolean indicating if the optimizer is in improvement mode
  155451. */
  155452. get isInImprovementMode(): boolean;
  155453. /**
  155454. * Gets the current priority level (0 at start)
  155455. */
  155456. get currentPriorityLevel(): number;
  155457. /**
  155458. * Gets the current frame rate checked by the SceneOptimizer
  155459. */
  155460. get currentFrameRate(): number;
  155461. /**
  155462. * Gets or sets the current target frame rate (60 by default)
  155463. */
  155464. get targetFrameRate(): number;
  155465. /**
  155466. * Gets or sets the current target frame rate (60 by default)
  155467. */
  155468. set targetFrameRate(value: number);
  155469. /**
  155470. * Gets or sets the current interval between two checks (every 2000ms by default)
  155471. */
  155472. get trackerDuration(): number;
  155473. /**
  155474. * Gets or sets the current interval between two checks (every 2000ms by default)
  155475. */
  155476. set trackerDuration(value: number);
  155477. /**
  155478. * Gets the list of active optimizations
  155479. */
  155480. get optimizations(): SceneOptimization[];
  155481. /**
  155482. * Creates a new SceneOptimizer
  155483. * @param scene defines the scene to work on
  155484. * @param options defines the options to use with the SceneOptimizer
  155485. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  155486. * @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)
  155487. */
  155488. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  155489. /**
  155490. * Stops the current optimizer
  155491. */
  155492. stop(): void;
  155493. /**
  155494. * Reset the optimizer to initial step (current priority level = 0)
  155495. */
  155496. reset(): void;
  155497. /**
  155498. * Start the optimizer. By default it will try to reach a specific framerate
  155499. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  155500. */
  155501. start(): void;
  155502. private _checkCurrentState;
  155503. /**
  155504. * Release all resources
  155505. */
  155506. dispose(): void;
  155507. /**
  155508. * Helper function to create a SceneOptimizer with one single line of code
  155509. * @param scene defines the scene to work on
  155510. * @param options defines the options to use with the SceneOptimizer
  155511. * @param onSuccess defines a callback to call on success
  155512. * @param onFailure defines a callback to call on failure
  155513. * @returns the new SceneOptimizer object
  155514. */
  155515. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  155516. }
  155517. }
  155518. declare module BABYLON {
  155519. /**
  155520. * Class used to serialize a scene into a string
  155521. */
  155522. export class SceneSerializer {
  155523. /**
  155524. * Clear cache used by a previous serialization
  155525. */
  155526. static ClearCache(): void;
  155527. /**
  155528. * Serialize a scene into a JSON compatible object
  155529. * @param scene defines the scene to serialize
  155530. * @returns a JSON compatible object
  155531. */
  155532. static Serialize(scene: Scene): any;
  155533. /**
  155534. * Serialize a mesh into a JSON compatible object
  155535. * @param toSerialize defines the mesh to serialize
  155536. * @param withParents defines if parents must be serialized as well
  155537. * @param withChildren defines if children must be serialized as well
  155538. * @returns a JSON compatible object
  155539. */
  155540. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  155541. }
  155542. }
  155543. declare module BABYLON {
  155544. /**
  155545. * Class used to host texture specific utilities
  155546. */
  155547. export class TextureTools {
  155548. /**
  155549. * Uses the GPU to create a copy texture rescaled at a given size
  155550. * @param texture Texture to copy from
  155551. * @param width defines the desired width
  155552. * @param height defines the desired height
  155553. * @param useBilinearMode defines if bilinear mode has to be used
  155554. * @return the generated texture
  155555. */
  155556. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  155557. }
  155558. }
  155559. declare module BABYLON {
  155560. /**
  155561. * This represents the different options available for the video capture.
  155562. */
  155563. export interface VideoRecorderOptions {
  155564. /** Defines the mime type of the video. */
  155565. mimeType: string;
  155566. /** Defines the FPS the video should be recorded at. */
  155567. fps: number;
  155568. /** Defines the chunk size for the recording data. */
  155569. recordChunckSize: number;
  155570. /** The audio tracks to attach to the recording. */
  155571. audioTracks?: MediaStreamTrack[];
  155572. }
  155573. /**
  155574. * This can help with recording videos from BabylonJS.
  155575. * This is based on the available WebRTC functionalities of the browser.
  155576. *
  155577. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  155578. */
  155579. export class VideoRecorder {
  155580. private static readonly _defaultOptions;
  155581. /**
  155582. * Returns whether or not the VideoRecorder is available in your browser.
  155583. * @param engine Defines the Babylon Engine.
  155584. * @returns true if supported otherwise false.
  155585. */
  155586. static IsSupported(engine: Engine): boolean;
  155587. private readonly _options;
  155588. private _canvas;
  155589. private _mediaRecorder;
  155590. private _recordedChunks;
  155591. private _fileName;
  155592. private _resolve;
  155593. private _reject;
  155594. /**
  155595. * True when a recording is already in progress.
  155596. */
  155597. get isRecording(): boolean;
  155598. /**
  155599. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  155600. * @param engine Defines the BabylonJS Engine you wish to record.
  155601. * @param options Defines options that can be used to customize the capture.
  155602. */
  155603. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  155604. /**
  155605. * Stops the current recording before the default capture timeout passed in the startRecording function.
  155606. */
  155607. stopRecording(): void;
  155608. /**
  155609. * Starts recording the canvas for a max duration specified in parameters.
  155610. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  155611. * If null no automatic download will start and you can rely on the promise to get the data back.
  155612. * @param maxDuration Defines the maximum recording time in seconds.
  155613. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  155614. * @return A promise callback at the end of the recording with the video data in Blob.
  155615. */
  155616. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  155617. /**
  155618. * Releases internal resources used during the recording.
  155619. */
  155620. dispose(): void;
  155621. private _handleDataAvailable;
  155622. private _handleError;
  155623. private _handleStop;
  155624. }
  155625. }
  155626. declare module BABYLON {
  155627. /**
  155628. * Class containing a set of static utilities functions for screenshots
  155629. */
  155630. export class ScreenshotTools {
  155631. /**
  155632. * Captures a screenshot of the current rendering
  155633. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155634. * @param engine defines the rendering engine
  155635. * @param camera defines the source camera
  155636. * @param size This parameter can be set to a single number or to an object with the
  155637. * following (optional) properties: precision, width, height. If a single number is passed,
  155638. * it will be used for both width and height. If an object is passed, the screenshot size
  155639. * will be derived from the parameters. The precision property is a multiplier allowing
  155640. * rendering at a higher or lower resolution
  155641. * @param successCallback defines the callback receives a single parameter which contains the
  155642. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155643. * src parameter of an <img> to display it
  155644. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155645. * Check your browser for supported MIME types
  155646. */
  155647. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  155648. /**
  155649. * Captures a screenshot of the current rendering
  155650. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155651. * @param engine defines the rendering engine
  155652. * @param camera defines the source camera
  155653. * @param size This parameter can be set to a single number or to an object with the
  155654. * following (optional) properties: precision, width, height. If a single number is passed,
  155655. * it will be used for both width and height. If an object is passed, the screenshot size
  155656. * will be derived from the parameters. The precision property is a multiplier allowing
  155657. * rendering at a higher or lower resolution
  155658. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155659. * Check your browser for supported MIME types
  155660. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155661. * to the src parameter of an <img> to display it
  155662. */
  155663. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  155664. /**
  155665. * Generates an image screenshot from the specified camera.
  155666. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155667. * @param engine The engine to use for rendering
  155668. * @param camera The camera to use for rendering
  155669. * @param size This parameter can be set to a single number or to an object with the
  155670. * following (optional) properties: precision, width, height. If a single number is passed,
  155671. * it will be used for both width and height. If an object is passed, the screenshot size
  155672. * will be derived from the parameters. The precision property is a multiplier allowing
  155673. * rendering at a higher or lower resolution
  155674. * @param successCallback The callback receives a single parameter which contains the
  155675. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155676. * src parameter of an <img> to display it
  155677. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155678. * Check your browser for supported MIME types
  155679. * @param samples Texture samples (default: 1)
  155680. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155681. * @param fileName A name for for the downloaded file.
  155682. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155683. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  155684. */
  155685. 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;
  155686. /**
  155687. * Generates an image screenshot from the specified camera.
  155688. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155689. * @param engine The engine to use for rendering
  155690. * @param camera The camera to use for rendering
  155691. * @param size This parameter can be set to a single number or to an object with the
  155692. * following (optional) properties: precision, width, height. If a single number is passed,
  155693. * it will be used for both width and height. If an object is passed, the screenshot size
  155694. * will be derived from the parameters. The precision property is a multiplier allowing
  155695. * rendering at a higher or lower resolution
  155696. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155697. * Check your browser for supported MIME types
  155698. * @param samples Texture samples (default: 1)
  155699. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155700. * @param fileName A name for for the downloaded file.
  155701. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155702. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155703. * to the src parameter of an <img> to display it
  155704. */
  155705. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  155706. /**
  155707. * Gets height and width for screenshot size
  155708. * @private
  155709. */
  155710. private static _getScreenshotSize;
  155711. }
  155712. }
  155713. declare module BABYLON {
  155714. /**
  155715. * Interface for a data buffer
  155716. */
  155717. export interface IDataBuffer {
  155718. /**
  155719. * Reads bytes from the data buffer.
  155720. * @param byteOffset The byte offset to read
  155721. * @param byteLength The byte length to read
  155722. * @returns A promise that resolves when the bytes are read
  155723. */
  155724. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  155725. /**
  155726. * The byte length of the buffer.
  155727. */
  155728. readonly byteLength: number;
  155729. }
  155730. /**
  155731. * Utility class for reading from a data buffer
  155732. */
  155733. export class DataReader {
  155734. /**
  155735. * The data buffer associated with this data reader.
  155736. */
  155737. readonly buffer: IDataBuffer;
  155738. /**
  155739. * The current byte offset from the beginning of the data buffer.
  155740. */
  155741. byteOffset: number;
  155742. private _dataView;
  155743. private _dataByteOffset;
  155744. /**
  155745. * Constructor
  155746. * @param buffer The buffer to read
  155747. */
  155748. constructor(buffer: IDataBuffer);
  155749. /**
  155750. * Loads the given byte length.
  155751. * @param byteLength The byte length to load
  155752. * @returns A promise that resolves when the load is complete
  155753. */
  155754. loadAsync(byteLength: number): Promise<void>;
  155755. /**
  155756. * Read a unsigned 32-bit integer from the currently loaded data range.
  155757. * @returns The 32-bit integer read
  155758. */
  155759. readUint32(): number;
  155760. /**
  155761. * Read a byte array from the currently loaded data range.
  155762. * @param byteLength The byte length to read
  155763. * @returns The byte array read
  155764. */
  155765. readUint8Array(byteLength: number): Uint8Array;
  155766. /**
  155767. * Read a string from the currently loaded data range.
  155768. * @param byteLength The byte length to read
  155769. * @returns The string read
  155770. */
  155771. readString(byteLength: number): string;
  155772. /**
  155773. * Skips the given byte length the currently loaded data range.
  155774. * @param byteLength The byte length to skip
  155775. */
  155776. skipBytes(byteLength: number): void;
  155777. }
  155778. }
  155779. declare module BABYLON {
  155780. /**
  155781. * Class for storing data to local storage if available or in-memory storage otherwise
  155782. */
  155783. export class DataStorage {
  155784. private static _Storage;
  155785. private static _GetStorage;
  155786. /**
  155787. * Reads a string from the data storage
  155788. * @param key The key to read
  155789. * @param defaultValue The value if the key doesn't exist
  155790. * @returns The string value
  155791. */
  155792. static ReadString(key: string, defaultValue: string): string;
  155793. /**
  155794. * Writes a string to the data storage
  155795. * @param key The key to write
  155796. * @param value The value to write
  155797. */
  155798. static WriteString(key: string, value: string): void;
  155799. /**
  155800. * Reads a boolean from the data storage
  155801. * @param key The key to read
  155802. * @param defaultValue The value if the key doesn't exist
  155803. * @returns The boolean value
  155804. */
  155805. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  155806. /**
  155807. * Writes a boolean to the data storage
  155808. * @param key The key to write
  155809. * @param value The value to write
  155810. */
  155811. static WriteBoolean(key: string, value: boolean): void;
  155812. /**
  155813. * Reads a number from the data storage
  155814. * @param key The key to read
  155815. * @param defaultValue The value if the key doesn't exist
  155816. * @returns The number value
  155817. */
  155818. static ReadNumber(key: string, defaultValue: number): number;
  155819. /**
  155820. * Writes a number to the data storage
  155821. * @param key The key to write
  155822. * @param value The value to write
  155823. */
  155824. static WriteNumber(key: string, value: number): void;
  155825. }
  155826. }
  155827. declare module BABYLON {
  155828. /**
  155829. * Class used to record delta files between 2 scene states
  155830. */
  155831. export class SceneRecorder {
  155832. private _trackedScene;
  155833. private _savedJSON;
  155834. /**
  155835. * Track a given scene. This means the current scene state will be considered the original state
  155836. * @param scene defines the scene to track
  155837. */
  155838. track(scene: Scene): void;
  155839. /**
  155840. * Get the delta between current state and original state
  155841. * @returns a string containing the delta
  155842. */
  155843. getDelta(): any;
  155844. private _compareArray;
  155845. private _compareObjects;
  155846. private _compareCollections;
  155847. private static GetShadowGeneratorById;
  155848. /**
  155849. * Apply a given delta to a given scene
  155850. * @param deltaJSON defines the JSON containing the delta
  155851. * @param scene defines the scene to apply the delta to
  155852. */
  155853. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  155854. private static _ApplyPropertiesToEntity;
  155855. private static _ApplyDeltaForEntity;
  155856. }
  155857. }
  155858. declare module BABYLON {
  155859. /**
  155860. * A 3D trajectory consisting of an order list of vectors describing a
  155861. * path of motion through 3D space.
  155862. */
  155863. export class Trajectory {
  155864. private _points;
  155865. private readonly _segmentLength;
  155866. /**
  155867. * Serialize to JSON.
  155868. * @returns serialized JSON string
  155869. */
  155870. serialize(): string;
  155871. /**
  155872. * Deserialize from JSON.
  155873. * @param json serialized JSON string
  155874. * @returns deserialized Trajectory
  155875. */
  155876. static Deserialize(json: string): Trajectory;
  155877. /**
  155878. * Create a new empty Trajectory.
  155879. * @param segmentLength radius of discretization for Trajectory points
  155880. */
  155881. constructor(segmentLength?: number);
  155882. /**
  155883. * Get the length of the Trajectory.
  155884. * @returns length of the Trajectory
  155885. */
  155886. getLength(): number;
  155887. /**
  155888. * Append a new point to the Trajectory.
  155889. * NOTE: This implementation has many allocations.
  155890. * @param point point to append to the Trajectory
  155891. */
  155892. add(point: DeepImmutable<Vector3>): void;
  155893. /**
  155894. * Create a new Trajectory with a segment length chosen to make it
  155895. * probable that the new Trajectory will have a specified number of
  155896. * segments. This operation is imprecise.
  155897. * @param targetResolution number of segments desired
  155898. * @returns new Trajectory with approximately the requested number of segments
  155899. */
  155900. resampleAtTargetResolution(targetResolution: number): Trajectory;
  155901. /**
  155902. * Convert Trajectory segments into tokenized representation. This
  155903. * representation is an array of numbers where each nth number is the
  155904. * index of the token which is most similar to the nth segment of the
  155905. * Trajectory.
  155906. * @param tokens list of vectors which serve as discrete tokens
  155907. * @returns list of indices of most similar token per segment
  155908. */
  155909. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  155910. private static _forwardDir;
  155911. private static _inverseFromVec;
  155912. private static _upDir;
  155913. private static _fromToVec;
  155914. private static _lookMatrix;
  155915. /**
  155916. * Transform the rotation (i.e., direction) of a segment to isolate
  155917. * the relative transformation represented by the segment. This operation
  155918. * may or may not succeed due to singularities in the equations that define
  155919. * motion relativity in this context.
  155920. * @param priorVec the origin of the prior segment
  155921. * @param fromVec the origin of the current segment
  155922. * @param toVec the destination of the current segment
  155923. * @param result reference to output variable
  155924. * @returns whether or not transformation was successful
  155925. */
  155926. private static _transformSegmentDirToRef;
  155927. private static _bestMatch;
  155928. private static _score;
  155929. private static _bestScore;
  155930. /**
  155931. * Determine which token vector is most similar to the
  155932. * segment vector.
  155933. * @param segment segment vector
  155934. * @param tokens token vector list
  155935. * @returns index of the most similar token to the segment
  155936. */
  155937. private static _tokenizeSegment;
  155938. }
  155939. /**
  155940. * Class representing a set of known, named trajectories to which Trajectories can be
  155941. * added and using which Trajectories can be recognized.
  155942. */
  155943. export class TrajectoryClassifier {
  155944. private _maximumAllowableMatchCost;
  155945. private _vector3Alphabet;
  155946. private _levenshteinAlphabet;
  155947. private _nameToDescribedTrajectory;
  155948. /**
  155949. * Serialize to JSON.
  155950. * @returns JSON serialization
  155951. */
  155952. serialize(): string;
  155953. /**
  155954. * Deserialize from JSON.
  155955. * @param json JSON serialization
  155956. * @returns deserialized TrajectorySet
  155957. */
  155958. static Deserialize(json: string): TrajectoryClassifier;
  155959. /**
  155960. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  155961. * VERY naive, need to be generating these things from known
  155962. * sets. Better version later, probably eliminating this one.
  155963. * @returns auto-generated TrajectorySet
  155964. */
  155965. static Generate(): TrajectoryClassifier;
  155966. private constructor();
  155967. /**
  155968. * Add a new Trajectory to the set with a given name.
  155969. * @param trajectory new Trajectory to be added
  155970. * @param classification name to which to add the Trajectory
  155971. */
  155972. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155973. /**
  155974. * Remove a known named trajectory and all Trajectories associated with it.
  155975. * @param classification name to remove
  155976. * @returns whether anything was removed
  155977. */
  155978. deleteClassification(classification: string): boolean;
  155979. /**
  155980. * Attempt to recognize a Trajectory from among all the classifications
  155981. * already known to the classifier.
  155982. * @param trajectory Trajectory to be recognized
  155983. * @returns classification of Trajectory if recognized, null otherwise
  155984. */
  155985. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155986. }
  155987. }
  155988. declare module BABYLON {
  155989. /**
  155990. * An interface for all Hit test features
  155991. */
  155992. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155993. /**
  155994. * Triggered when new babylon (transformed) hit test results are available
  155995. */
  155996. onHitTestResultObservable: Observable<T[]>;
  155997. }
  155998. /**
  155999. * Options used for hit testing
  156000. */
  156001. export interface IWebXRLegacyHitTestOptions {
  156002. /**
  156003. * Only test when user interacted with the scene. Default - hit test every frame
  156004. */
  156005. testOnPointerDownOnly?: boolean;
  156006. /**
  156007. * The node to use to transform the local results to world coordinates
  156008. */
  156009. worldParentNode?: TransformNode;
  156010. }
  156011. /**
  156012. * Interface defining the babylon result of raycasting/hit-test
  156013. */
  156014. export interface IWebXRLegacyHitResult {
  156015. /**
  156016. * Transformation matrix that can be applied to a node that will put it in the hit point location
  156017. */
  156018. transformationMatrix: Matrix;
  156019. /**
  156020. * The native hit test result
  156021. */
  156022. xrHitResult: XRHitResult | XRHitTestResult;
  156023. }
  156024. /**
  156025. * The currently-working hit-test module.
  156026. * Hit test (or Ray-casting) is used to interact with the real world.
  156027. * For further information read here - https://github.com/immersive-web/hit-test
  156028. */
  156029. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  156030. /**
  156031. * options to use when constructing this feature
  156032. */
  156033. readonly options: IWebXRLegacyHitTestOptions;
  156034. private _direction;
  156035. private _mat;
  156036. private _onSelectEnabled;
  156037. private _origin;
  156038. /**
  156039. * The module's name
  156040. */
  156041. static readonly Name: string;
  156042. /**
  156043. * The (Babylon) version of this module.
  156044. * This is an integer representing the implementation version.
  156045. * This number does not correspond to the WebXR specs version
  156046. */
  156047. static readonly Version: number;
  156048. /**
  156049. * Populated with the last native XR Hit Results
  156050. */
  156051. lastNativeXRHitResults: XRHitResult[];
  156052. /**
  156053. * Triggered when new babylon (transformed) hit test results are available
  156054. */
  156055. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  156056. /**
  156057. * Creates a new instance of the (legacy version) hit test feature
  156058. * @param _xrSessionManager an instance of WebXRSessionManager
  156059. * @param options options to use when constructing this feature
  156060. */
  156061. constructor(_xrSessionManager: WebXRSessionManager,
  156062. /**
  156063. * options to use when constructing this feature
  156064. */
  156065. options?: IWebXRLegacyHitTestOptions);
  156066. /**
  156067. * execute a hit test with an XR Ray
  156068. *
  156069. * @param xrSession a native xrSession that will execute this hit test
  156070. * @param xrRay the ray (position and direction) to use for ray-casting
  156071. * @param referenceSpace native XR reference space to use for the hit-test
  156072. * @param filter filter function that will filter the results
  156073. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156074. */
  156075. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  156076. /**
  156077. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  156078. * @param event the (select) event to use to select with
  156079. * @param referenceSpace the reference space to use for this hit test
  156080. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156081. */
  156082. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156083. /**
  156084. * attach this feature
  156085. * Will usually be called by the features manager
  156086. *
  156087. * @returns true if successful.
  156088. */
  156089. attach(): boolean;
  156090. /**
  156091. * detach this feature.
  156092. * Will usually be called by the features manager
  156093. *
  156094. * @returns true if successful.
  156095. */
  156096. detach(): boolean;
  156097. /**
  156098. * Dispose this feature and all of the resources attached
  156099. */
  156100. dispose(): void;
  156101. protected _onXRFrame(frame: XRFrame): void;
  156102. private _onHitTestResults;
  156103. private _onSelect;
  156104. }
  156105. }
  156106. declare module BABYLON {
  156107. /**
  156108. * Options used for hit testing (version 2)
  156109. */
  156110. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  156111. /**
  156112. * Do not create a permanent hit test. Will usually be used when only
  156113. * transient inputs are needed.
  156114. */
  156115. disablePermanentHitTest?: boolean;
  156116. /**
  156117. * Enable transient (for example touch-based) hit test inspections
  156118. */
  156119. enableTransientHitTest?: boolean;
  156120. /**
  156121. * Offset ray for the permanent hit test
  156122. */
  156123. offsetRay?: Vector3;
  156124. /**
  156125. * Offset ray for the transient hit test
  156126. */
  156127. transientOffsetRay?: Vector3;
  156128. /**
  156129. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  156130. */
  156131. useReferenceSpace?: boolean;
  156132. /**
  156133. * Override the default entity type(s) of the hit-test result
  156134. */
  156135. entityTypes?: XRHitTestTrackableType[];
  156136. }
  156137. /**
  156138. * Interface defining the babylon result of hit-test
  156139. */
  156140. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  156141. /**
  156142. * The input source that generated this hit test (if transient)
  156143. */
  156144. inputSource?: XRInputSource;
  156145. /**
  156146. * Is this a transient hit test
  156147. */
  156148. isTransient?: boolean;
  156149. /**
  156150. * Position of the hit test result
  156151. */
  156152. position: Vector3;
  156153. /**
  156154. * Rotation of the hit test result
  156155. */
  156156. rotationQuaternion: Quaternion;
  156157. /**
  156158. * The native hit test result
  156159. */
  156160. xrHitResult: XRHitTestResult;
  156161. }
  156162. /**
  156163. * The currently-working hit-test module.
  156164. * Hit test (or Ray-casting) is used to interact with the real world.
  156165. * For further information read here - https://github.com/immersive-web/hit-test
  156166. *
  156167. * Tested on chrome (mobile) 80.
  156168. */
  156169. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  156170. /**
  156171. * options to use when constructing this feature
  156172. */
  156173. readonly options: IWebXRHitTestOptions;
  156174. private _tmpMat;
  156175. private _tmpPos;
  156176. private _tmpQuat;
  156177. private _transientXrHitTestSource;
  156178. private _xrHitTestSource;
  156179. private initHitTestSource;
  156180. /**
  156181. * The module's name
  156182. */
  156183. static readonly Name: string;
  156184. /**
  156185. * The (Babylon) version of this module.
  156186. * This is an integer representing the implementation version.
  156187. * This number does not correspond to the WebXR specs version
  156188. */
  156189. static readonly Version: number;
  156190. /**
  156191. * When set to true, each hit test will have its own position/rotation objects
  156192. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  156193. * the developers will clone them or copy them as they see fit.
  156194. */
  156195. autoCloneTransformation: boolean;
  156196. /**
  156197. * Triggered when new babylon (transformed) hit test results are available
  156198. * Note - this will be called when results come back from the device. It can be an empty array!!
  156199. */
  156200. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  156201. /**
  156202. * Use this to temporarily pause hit test checks.
  156203. */
  156204. paused: boolean;
  156205. /**
  156206. * Creates a new instance of the hit test feature
  156207. * @param _xrSessionManager an instance of WebXRSessionManager
  156208. * @param options options to use when constructing this feature
  156209. */
  156210. constructor(_xrSessionManager: WebXRSessionManager,
  156211. /**
  156212. * options to use when constructing this feature
  156213. */
  156214. options?: IWebXRHitTestOptions);
  156215. /**
  156216. * attach this feature
  156217. * Will usually be called by the features manager
  156218. *
  156219. * @returns true if successful.
  156220. */
  156221. attach(): boolean;
  156222. /**
  156223. * detach this feature.
  156224. * Will usually be called by the features manager
  156225. *
  156226. * @returns true if successful.
  156227. */
  156228. detach(): boolean;
  156229. /**
  156230. * Dispose this feature and all of the resources attached
  156231. */
  156232. dispose(): void;
  156233. protected _onXRFrame(frame: XRFrame): void;
  156234. private _processWebXRHitTestResult;
  156235. }
  156236. }
  156237. declare module BABYLON {
  156238. /**
  156239. * Configuration options of the anchor system
  156240. */
  156241. export interface IWebXRAnchorSystemOptions {
  156242. /**
  156243. * a node that will be used to convert local to world coordinates
  156244. */
  156245. worldParentNode?: TransformNode;
  156246. /**
  156247. * If set to true a reference of the created anchors will be kept until the next session starts
  156248. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  156249. */
  156250. doNotRemoveAnchorsOnSessionEnded?: boolean;
  156251. }
  156252. /**
  156253. * A babylon container for an XR Anchor
  156254. */
  156255. export interface IWebXRAnchor {
  156256. /**
  156257. * A babylon-assigned ID for this anchor
  156258. */
  156259. id: number;
  156260. /**
  156261. * Transformation matrix to apply to an object attached to this anchor
  156262. */
  156263. transformationMatrix: Matrix;
  156264. /**
  156265. * The native anchor object
  156266. */
  156267. xrAnchor: XRAnchor;
  156268. /**
  156269. * if defined, this object will be constantly updated by the anchor's position and rotation
  156270. */
  156271. attachedNode?: TransformNode;
  156272. }
  156273. /**
  156274. * An implementation of the anchor system for WebXR.
  156275. * For further information see https://github.com/immersive-web/anchors/
  156276. */
  156277. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  156278. private _options;
  156279. private _lastFrameDetected;
  156280. private _trackedAnchors;
  156281. private _referenceSpaceForFrameAnchors;
  156282. private _futureAnchors;
  156283. /**
  156284. * The module's name
  156285. */
  156286. static readonly Name: string;
  156287. /**
  156288. * The (Babylon) version of this module.
  156289. * This is an integer representing the implementation version.
  156290. * This number does not correspond to the WebXR specs version
  156291. */
  156292. static readonly Version: number;
  156293. /**
  156294. * Observers registered here will be executed when a new anchor was added to the session
  156295. */
  156296. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  156297. /**
  156298. * Observers registered here will be executed when an anchor was removed from the session
  156299. */
  156300. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  156301. /**
  156302. * Observers registered here will be executed when an existing anchor updates
  156303. * This can execute N times every frame
  156304. */
  156305. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  156306. /**
  156307. * Set the reference space to use for anchor creation, when not using a hit test.
  156308. * Will default to the session's reference space if not defined
  156309. */
  156310. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  156311. /**
  156312. * constructs a new anchor system
  156313. * @param _xrSessionManager an instance of WebXRSessionManager
  156314. * @param _options configuration object for this feature
  156315. */
  156316. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  156317. private _tmpVector;
  156318. private _tmpQuaternion;
  156319. private _populateTmpTransformation;
  156320. /**
  156321. * Create a new anchor point using a hit test result at a specific point in the scene
  156322. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156323. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156324. *
  156325. * @param hitTestResult The hit test result to use for this anchor creation
  156326. * @param position an optional position offset for this anchor
  156327. * @param rotationQuaternion an optional rotation offset for this anchor
  156328. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156329. */
  156330. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  156331. /**
  156332. * Add a new anchor at a specific position and rotation
  156333. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  156334. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  156335. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156336. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156337. *
  156338. * @param position the position in which to add an anchor
  156339. * @param rotationQuaternion an optional rotation for the anchor transformation
  156340. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  156341. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156342. */
  156343. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  156344. /**
  156345. * detach this feature.
  156346. * Will usually be called by the features manager
  156347. *
  156348. * @returns true if successful.
  156349. */
  156350. detach(): boolean;
  156351. /**
  156352. * Dispose this feature and all of the resources attached
  156353. */
  156354. dispose(): void;
  156355. protected _onXRFrame(frame: XRFrame): void;
  156356. /**
  156357. * avoiding using Array.find for global support.
  156358. * @param xrAnchor the plane to find in the array
  156359. */
  156360. private _findIndexInAnchorArray;
  156361. private _updateAnchorWithXRFrame;
  156362. private _createAnchorAtTransformation;
  156363. }
  156364. }
  156365. declare module BABYLON {
  156366. /**
  156367. * Options used in the plane detector module
  156368. */
  156369. export interface IWebXRPlaneDetectorOptions {
  156370. /**
  156371. * The node to use to transform the local results to world coordinates
  156372. */
  156373. worldParentNode?: TransformNode;
  156374. /**
  156375. * If set to true a reference of the created planes will be kept until the next session starts
  156376. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  156377. */
  156378. doNotRemovePlanesOnSessionEnded?: boolean;
  156379. }
  156380. /**
  156381. * A babylon interface for a WebXR plane.
  156382. * A Plane is actually a polygon, built from N points in space
  156383. *
  156384. * Supported in chrome 79, not supported in canary 81 ATM
  156385. */
  156386. export interface IWebXRPlane {
  156387. /**
  156388. * a babylon-assigned ID for this polygon
  156389. */
  156390. id: number;
  156391. /**
  156392. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  156393. */
  156394. polygonDefinition: Array<Vector3>;
  156395. /**
  156396. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  156397. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  156398. */
  156399. transformationMatrix: Matrix;
  156400. /**
  156401. * the native xr-plane object
  156402. */
  156403. xrPlane: XRPlane;
  156404. }
  156405. /**
  156406. * The plane detector is used to detect planes in the real world when in AR
  156407. * For more information see https://github.com/immersive-web/real-world-geometry/
  156408. */
  156409. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  156410. private _options;
  156411. private _detectedPlanes;
  156412. private _enabled;
  156413. private _lastFrameDetected;
  156414. /**
  156415. * The module's name
  156416. */
  156417. static readonly Name: string;
  156418. /**
  156419. * The (Babylon) version of this module.
  156420. * This is an integer representing the implementation version.
  156421. * This number does not correspond to the WebXR specs version
  156422. */
  156423. static readonly Version: number;
  156424. /**
  156425. * Observers registered here will be executed when a new plane was added to the session
  156426. */
  156427. onPlaneAddedObservable: Observable<IWebXRPlane>;
  156428. /**
  156429. * Observers registered here will be executed when a plane is no longer detected in the session
  156430. */
  156431. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  156432. /**
  156433. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  156434. * This can execute N times every frame
  156435. */
  156436. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  156437. /**
  156438. * construct a new Plane Detector
  156439. * @param _xrSessionManager an instance of xr Session manager
  156440. * @param _options configuration to use when constructing this feature
  156441. */
  156442. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  156443. /**
  156444. * detach this feature.
  156445. * Will usually be called by the features manager
  156446. *
  156447. * @returns true if successful.
  156448. */
  156449. detach(): boolean;
  156450. /**
  156451. * Dispose this feature and all of the resources attached
  156452. */
  156453. dispose(): void;
  156454. protected _onXRFrame(frame: XRFrame): void;
  156455. private _init;
  156456. private _updatePlaneWithXRPlane;
  156457. /**
  156458. * avoiding using Array.find for global support.
  156459. * @param xrPlane the plane to find in the array
  156460. */
  156461. private findIndexInPlaneArray;
  156462. }
  156463. }
  156464. declare module BABYLON {
  156465. /**
  156466. * Options interface for the background remover plugin
  156467. */
  156468. export interface IWebXRBackgroundRemoverOptions {
  156469. /**
  156470. * Further background meshes to disable when entering AR
  156471. */
  156472. backgroundMeshes?: AbstractMesh[];
  156473. /**
  156474. * flags to configure the removal of the environment helper.
  156475. * If not set, the entire background will be removed. If set, flags should be set as well.
  156476. */
  156477. environmentHelperRemovalFlags?: {
  156478. /**
  156479. * Should the skybox be removed (default false)
  156480. */
  156481. skyBox?: boolean;
  156482. /**
  156483. * Should the ground be removed (default false)
  156484. */
  156485. ground?: boolean;
  156486. };
  156487. /**
  156488. * don't disable the environment helper
  156489. */
  156490. ignoreEnvironmentHelper?: boolean;
  156491. }
  156492. /**
  156493. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  156494. */
  156495. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  156496. /**
  156497. * read-only options to be used in this module
  156498. */
  156499. readonly options: IWebXRBackgroundRemoverOptions;
  156500. /**
  156501. * The module's name
  156502. */
  156503. static readonly Name: string;
  156504. /**
  156505. * The (Babylon) version of this module.
  156506. * This is an integer representing the implementation version.
  156507. * This number does not correspond to the WebXR specs version
  156508. */
  156509. static readonly Version: number;
  156510. /**
  156511. * registered observers will be triggered when the background state changes
  156512. */
  156513. onBackgroundStateChangedObservable: Observable<boolean>;
  156514. /**
  156515. * constructs a new background remover module
  156516. * @param _xrSessionManager the session manager for this module
  156517. * @param options read-only options to be used in this module
  156518. */
  156519. constructor(_xrSessionManager: WebXRSessionManager,
  156520. /**
  156521. * read-only options to be used in this module
  156522. */
  156523. options?: IWebXRBackgroundRemoverOptions);
  156524. /**
  156525. * attach this feature
  156526. * Will usually be called by the features manager
  156527. *
  156528. * @returns true if successful.
  156529. */
  156530. attach(): boolean;
  156531. /**
  156532. * detach this feature.
  156533. * Will usually be called by the features manager
  156534. *
  156535. * @returns true if successful.
  156536. */
  156537. detach(): boolean;
  156538. /**
  156539. * Dispose this feature and all of the resources attached
  156540. */
  156541. dispose(): void;
  156542. protected _onXRFrame(_xrFrame: XRFrame): void;
  156543. private _setBackgroundState;
  156544. }
  156545. }
  156546. declare module BABYLON {
  156547. /**
  156548. * Options for the controller physics feature
  156549. */
  156550. export class IWebXRControllerPhysicsOptions {
  156551. /**
  156552. * Should the headset get its own impostor
  156553. */
  156554. enableHeadsetImpostor?: boolean;
  156555. /**
  156556. * Optional parameters for the headset impostor
  156557. */
  156558. headsetImpostorParams?: {
  156559. /**
  156560. * The type of impostor to create. Default is sphere
  156561. */
  156562. impostorType: number;
  156563. /**
  156564. * the size of the impostor. Defaults to 10cm
  156565. */
  156566. impostorSize?: number | {
  156567. width: number;
  156568. height: number;
  156569. depth: number;
  156570. };
  156571. /**
  156572. * Friction definitions
  156573. */
  156574. friction?: number;
  156575. /**
  156576. * Restitution
  156577. */
  156578. restitution?: number;
  156579. };
  156580. /**
  156581. * The physics properties of the future impostors
  156582. */
  156583. physicsProperties?: {
  156584. /**
  156585. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  156586. * Note that this requires a physics engine that supports mesh impostors!
  156587. */
  156588. useControllerMesh?: boolean;
  156589. /**
  156590. * The type of impostor to create. Default is sphere
  156591. */
  156592. impostorType?: number;
  156593. /**
  156594. * the size of the impostor. Defaults to 10cm
  156595. */
  156596. impostorSize?: number | {
  156597. width: number;
  156598. height: number;
  156599. depth: number;
  156600. };
  156601. /**
  156602. * Friction definitions
  156603. */
  156604. friction?: number;
  156605. /**
  156606. * Restitution
  156607. */
  156608. restitution?: number;
  156609. };
  156610. /**
  156611. * the xr input to use with this pointer selection
  156612. */
  156613. xrInput: WebXRInput;
  156614. }
  156615. /**
  156616. * Add physics impostor to your webxr controllers,
  156617. * including naive calculation of their linear and angular velocity
  156618. */
  156619. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  156620. private readonly _options;
  156621. private _attachController;
  156622. private _controllers;
  156623. private _debugMode;
  156624. private _delta;
  156625. private _headsetImpostor?;
  156626. private _headsetMesh?;
  156627. private _lastTimestamp;
  156628. private _tmpQuaternion;
  156629. private _tmpVector;
  156630. /**
  156631. * The module's name
  156632. */
  156633. static readonly Name: string;
  156634. /**
  156635. * The (Babylon) version of this module.
  156636. * This is an integer representing the implementation version.
  156637. * This number does not correspond to the webxr specs version
  156638. */
  156639. static readonly Version: number;
  156640. /**
  156641. * Construct a new Controller Physics Feature
  156642. * @param _xrSessionManager the corresponding xr session manager
  156643. * @param _options options to create this feature with
  156644. */
  156645. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  156646. /**
  156647. * @hidden
  156648. * enable debugging - will show console outputs and the impostor mesh
  156649. */
  156650. _enablePhysicsDebug(): void;
  156651. /**
  156652. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  156653. * @param xrController the controller to add
  156654. */
  156655. addController(xrController: WebXRInputSource): void;
  156656. /**
  156657. * attach this feature
  156658. * Will usually be called by the features manager
  156659. *
  156660. * @returns true if successful.
  156661. */
  156662. attach(): boolean;
  156663. /**
  156664. * detach this feature.
  156665. * Will usually be called by the features manager
  156666. *
  156667. * @returns true if successful.
  156668. */
  156669. detach(): boolean;
  156670. /**
  156671. * Get the headset impostor, if enabled
  156672. * @returns the impostor
  156673. */
  156674. getHeadsetImpostor(): PhysicsImpostor | undefined;
  156675. /**
  156676. * Get the physics impostor of a specific controller.
  156677. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  156678. * @param controller the controller or the controller id of which to get the impostor
  156679. * @returns the impostor or null
  156680. */
  156681. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  156682. /**
  156683. * Update the physics properties provided in the constructor
  156684. * @param newProperties the new properties object
  156685. */
  156686. setPhysicsProperties(newProperties: {
  156687. impostorType?: number;
  156688. impostorSize?: number | {
  156689. width: number;
  156690. height: number;
  156691. depth: number;
  156692. };
  156693. friction?: number;
  156694. restitution?: number;
  156695. }): void;
  156696. protected _onXRFrame(_xrFrame: any): void;
  156697. private _detachController;
  156698. }
  156699. }
  156700. declare module BABYLON {
  156701. /**
  156702. * A babylon interface for a "WebXR" feature point.
  156703. * Represents the position and confidence value of a given feature point.
  156704. */
  156705. export interface IWebXRFeaturePoint {
  156706. /**
  156707. * Represents the position of the feature point in world space.
  156708. */
  156709. position: Vector3;
  156710. /**
  156711. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  156712. */
  156713. confidenceValue: number;
  156714. }
  156715. /**
  156716. * The feature point system is used to detect feature points from real world geometry.
  156717. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  156718. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  156719. */
  156720. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  156721. private _enabled;
  156722. private _featurePointCloud;
  156723. /**
  156724. * The module's name
  156725. */
  156726. static readonly Name: string;
  156727. /**
  156728. * The (Babylon) version of this module.
  156729. * This is an integer representing the implementation version.
  156730. * This number does not correspond to the WebXR specs version
  156731. */
  156732. static readonly Version: number;
  156733. /**
  156734. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  156735. * Will notify the observers about which feature points have been added.
  156736. */
  156737. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  156738. /**
  156739. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  156740. * Will notify the observers about which feature points have been updated.
  156741. */
  156742. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  156743. /**
  156744. * The current feature point cloud maintained across frames.
  156745. */
  156746. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  156747. /**
  156748. * construct the feature point system
  156749. * @param _xrSessionManager an instance of xr Session manager
  156750. */
  156751. constructor(_xrSessionManager: WebXRSessionManager);
  156752. /**
  156753. * Detach this feature.
  156754. * Will usually be called by the features manager
  156755. *
  156756. * @returns true if successful.
  156757. */
  156758. detach(): boolean;
  156759. /**
  156760. * Dispose this feature and all of the resources attached
  156761. */
  156762. dispose(): void;
  156763. /**
  156764. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  156765. */
  156766. protected _onXRFrame(frame: XRFrame): void;
  156767. /**
  156768. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  156769. */
  156770. private _init;
  156771. }
  156772. }
  156773. declare module BABYLON {
  156774. /**
  156775. * Configuration interface for the hand tracking feature
  156776. */
  156777. export interface IWebXRHandTrackingOptions {
  156778. /**
  156779. * The xrInput that will be used as source for new hands
  156780. */
  156781. xrInput: WebXRInput;
  156782. /**
  156783. * Configuration object for the joint meshes
  156784. */
  156785. jointMeshes?: {
  156786. /**
  156787. * Should the meshes created be invisible (defaults to false)
  156788. */
  156789. invisible?: boolean;
  156790. /**
  156791. * A source mesh to be used to create instances. Defaults to a sphere.
  156792. * This mesh will be the source for all other (25) meshes.
  156793. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  156794. */
  156795. sourceMesh?: Mesh;
  156796. /**
  156797. * This function will be called after a mesh was created for a specific joint.
  156798. * Using this function you can either manipulate the instance or return a new mesh.
  156799. * When returning a new mesh the instance created before will be disposed
  156800. */
  156801. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  156802. /**
  156803. * Should the source mesh stay visible. Defaults to false
  156804. */
  156805. keepOriginalVisible?: boolean;
  156806. /**
  156807. * Scale factor for all instances (defaults to 2)
  156808. */
  156809. scaleFactor?: number;
  156810. /**
  156811. * Should each instance have its own physics impostor
  156812. */
  156813. enablePhysics?: boolean;
  156814. /**
  156815. * If enabled, override default physics properties
  156816. */
  156817. physicsProps?: {
  156818. friction?: number;
  156819. restitution?: number;
  156820. impostorType?: number;
  156821. };
  156822. /**
  156823. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  156824. */
  156825. handMesh?: AbstractMesh;
  156826. };
  156827. }
  156828. /**
  156829. * Parts of the hands divided to writs and finger names
  156830. */
  156831. export const enum HandPart {
  156832. /**
  156833. * HandPart - Wrist
  156834. */
  156835. WRIST = "wrist",
  156836. /**
  156837. * HandPart - The THumb
  156838. */
  156839. THUMB = "thumb",
  156840. /**
  156841. * HandPart - Index finger
  156842. */
  156843. INDEX = "index",
  156844. /**
  156845. * HandPart - Middle finger
  156846. */
  156847. MIDDLE = "middle",
  156848. /**
  156849. * HandPart - Ring finger
  156850. */
  156851. RING = "ring",
  156852. /**
  156853. * HandPart - Little finger
  156854. */
  156855. LITTLE = "little"
  156856. }
  156857. /**
  156858. * Representing a single hand (with its corresponding native XRHand object)
  156859. */
  156860. export class WebXRHand implements IDisposable {
  156861. /** the controller to which the hand correlates */
  156862. readonly xrController: WebXRInputSource;
  156863. /** the meshes to be used to track the hand joints */
  156864. readonly trackedMeshes: AbstractMesh[];
  156865. /**
  156866. * Hand-parts definition (key is HandPart)
  156867. */
  156868. handPartsDefinition: {
  156869. [key: string]: number[];
  156870. };
  156871. /**
  156872. * Populate the HandPartsDefinition object.
  156873. * This is called as a side effect since certain browsers don't have XRHand defined.
  156874. */
  156875. private generateHandPartsDefinition;
  156876. /**
  156877. * Construct a new hand object
  156878. * @param xrController the controller to which the hand correlates
  156879. * @param trackedMeshes the meshes to be used to track the hand joints
  156880. */
  156881. constructor(
  156882. /** the controller to which the hand correlates */
  156883. xrController: WebXRInputSource,
  156884. /** the meshes to be used to track the hand joints */
  156885. trackedMeshes: AbstractMesh[]);
  156886. /**
  156887. * Update this hand from the latest xr frame
  156888. * @param xrFrame xrFrame to update from
  156889. * @param referenceSpace The current viewer reference space
  156890. * @param scaleFactor optional scale factor for the meshes
  156891. */
  156892. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156893. /**
  156894. * Get meshes of part of the hand
  156895. * @param part the part of hand to get
  156896. * @returns An array of meshes that correlate to the hand part requested
  156897. */
  156898. getHandPartMeshes(part: HandPart): AbstractMesh[];
  156899. /**
  156900. * Dispose this Hand object
  156901. */
  156902. dispose(): void;
  156903. }
  156904. /**
  156905. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  156906. */
  156907. export class WebXRHandTracking extends WebXRAbstractFeature {
  156908. /**
  156909. * options to use when constructing this feature
  156910. */
  156911. readonly options: IWebXRHandTrackingOptions;
  156912. private static _idCounter;
  156913. /**
  156914. * The module's name
  156915. */
  156916. static readonly Name: string;
  156917. /**
  156918. * The (Babylon) version of this module.
  156919. * This is an integer representing the implementation version.
  156920. * This number does not correspond to the WebXR specs version
  156921. */
  156922. static readonly Version: number;
  156923. /**
  156924. * This observable will notify registered observers when a new hand object was added and initialized
  156925. */
  156926. onHandAddedObservable: Observable<WebXRHand>;
  156927. /**
  156928. * This observable will notify its observers right before the hand object is disposed
  156929. */
  156930. onHandRemovedObservable: Observable<WebXRHand>;
  156931. private _hands;
  156932. /**
  156933. * Creates a new instance of the hit test feature
  156934. * @param _xrSessionManager an instance of WebXRSessionManager
  156935. * @param options options to use when constructing this feature
  156936. */
  156937. constructor(_xrSessionManager: WebXRSessionManager,
  156938. /**
  156939. * options to use when constructing this feature
  156940. */
  156941. options: IWebXRHandTrackingOptions);
  156942. /**
  156943. * Check if the needed objects are defined.
  156944. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  156945. */
  156946. isCompatible(): boolean;
  156947. /**
  156948. * attach this feature
  156949. * Will usually be called by the features manager
  156950. *
  156951. * @returns true if successful.
  156952. */
  156953. attach(): boolean;
  156954. /**
  156955. * detach this feature.
  156956. * Will usually be called by the features manager
  156957. *
  156958. * @returns true if successful.
  156959. */
  156960. detach(): boolean;
  156961. /**
  156962. * Dispose this feature and all of the resources attached
  156963. */
  156964. dispose(): void;
  156965. /**
  156966. * Get the hand object according to the controller id
  156967. * @param controllerId the controller id to which we want to get the hand
  156968. * @returns null if not found or the WebXRHand object if found
  156969. */
  156970. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  156971. /**
  156972. * Get a hand object according to the requested handedness
  156973. * @param handedness the handedness to request
  156974. * @returns null if not found or the WebXRHand object if found
  156975. */
  156976. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156977. protected _onXRFrame(_xrFrame: XRFrame): void;
  156978. private _attachHand;
  156979. private _detachHand;
  156980. }
  156981. }
  156982. declare module BABYLON {
  156983. /**
  156984. * The motion controller class for all microsoft mixed reality controllers
  156985. */
  156986. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156987. protected readonly _mapping: {
  156988. defaultButton: {
  156989. valueNodeName: string;
  156990. unpressedNodeName: string;
  156991. pressedNodeName: string;
  156992. };
  156993. defaultAxis: {
  156994. valueNodeName: string;
  156995. minNodeName: string;
  156996. maxNodeName: string;
  156997. };
  156998. buttons: {
  156999. "xr-standard-trigger": {
  157000. rootNodeName: string;
  157001. componentProperty: string;
  157002. states: string[];
  157003. };
  157004. "xr-standard-squeeze": {
  157005. rootNodeName: string;
  157006. componentProperty: string;
  157007. states: string[];
  157008. };
  157009. "xr-standard-touchpad": {
  157010. rootNodeName: string;
  157011. labelAnchorNodeName: string;
  157012. touchPointNodeName: string;
  157013. };
  157014. "xr-standard-thumbstick": {
  157015. rootNodeName: string;
  157016. componentProperty: string;
  157017. states: string[];
  157018. };
  157019. };
  157020. axes: {
  157021. "xr-standard-touchpad": {
  157022. "x-axis": {
  157023. rootNodeName: string;
  157024. };
  157025. "y-axis": {
  157026. rootNodeName: string;
  157027. };
  157028. };
  157029. "xr-standard-thumbstick": {
  157030. "x-axis": {
  157031. rootNodeName: string;
  157032. };
  157033. "y-axis": {
  157034. rootNodeName: string;
  157035. };
  157036. };
  157037. };
  157038. };
  157039. /**
  157040. * The base url used to load the left and right controller models
  157041. */
  157042. static MODEL_BASE_URL: string;
  157043. /**
  157044. * The name of the left controller model file
  157045. */
  157046. static MODEL_LEFT_FILENAME: string;
  157047. /**
  157048. * The name of the right controller model file
  157049. */
  157050. static MODEL_RIGHT_FILENAME: string;
  157051. profileId: string;
  157052. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157053. protected _getFilenameAndPath(): {
  157054. filename: string;
  157055. path: string;
  157056. };
  157057. protected _getModelLoadingConstraints(): boolean;
  157058. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157059. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157060. protected _updateModel(): void;
  157061. }
  157062. }
  157063. declare module BABYLON {
  157064. /**
  157065. * The motion controller class for oculus touch (quest, rift).
  157066. * This class supports legacy mapping as well the standard xr mapping
  157067. */
  157068. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  157069. private _forceLegacyControllers;
  157070. private _modelRootNode;
  157071. /**
  157072. * The base url used to load the left and right controller models
  157073. */
  157074. static MODEL_BASE_URL: string;
  157075. /**
  157076. * The name of the left controller model file
  157077. */
  157078. static MODEL_LEFT_FILENAME: string;
  157079. /**
  157080. * The name of the right controller model file
  157081. */
  157082. static MODEL_RIGHT_FILENAME: string;
  157083. /**
  157084. * Base Url for the Quest controller model.
  157085. */
  157086. static QUEST_MODEL_BASE_URL: string;
  157087. profileId: string;
  157088. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  157089. protected _getFilenameAndPath(): {
  157090. filename: string;
  157091. path: string;
  157092. };
  157093. protected _getModelLoadingConstraints(): boolean;
  157094. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157095. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157096. protected _updateModel(): void;
  157097. /**
  157098. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  157099. * between the touch and touch 2.
  157100. */
  157101. private _isQuest;
  157102. }
  157103. }
  157104. declare module BABYLON {
  157105. /**
  157106. * The motion controller class for the standard HTC-Vive controllers
  157107. */
  157108. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  157109. private _modelRootNode;
  157110. /**
  157111. * The base url used to load the left and right controller models
  157112. */
  157113. static MODEL_BASE_URL: string;
  157114. /**
  157115. * File name for the controller model.
  157116. */
  157117. static MODEL_FILENAME: string;
  157118. profileId: string;
  157119. /**
  157120. * Create a new Vive motion controller object
  157121. * @param scene the scene to use to create this controller
  157122. * @param gamepadObject the corresponding gamepad object
  157123. * @param handedness the handedness of the controller
  157124. */
  157125. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157126. protected _getFilenameAndPath(): {
  157127. filename: string;
  157128. path: string;
  157129. };
  157130. protected _getModelLoadingConstraints(): boolean;
  157131. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157132. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157133. protected _updateModel(): void;
  157134. }
  157135. }
  157136. declare module BABYLON {
  157137. /**
  157138. * A cursor which tracks a point on a path
  157139. */
  157140. export class PathCursor {
  157141. private path;
  157142. /**
  157143. * Stores path cursor callbacks for when an onchange event is triggered
  157144. */
  157145. private _onchange;
  157146. /**
  157147. * The value of the path cursor
  157148. */
  157149. value: number;
  157150. /**
  157151. * The animation array of the path cursor
  157152. */
  157153. animations: Animation[];
  157154. /**
  157155. * Initializes the path cursor
  157156. * @param path The path to track
  157157. */
  157158. constructor(path: Path2);
  157159. /**
  157160. * Gets the cursor point on the path
  157161. * @returns A point on the path cursor at the cursor location
  157162. */
  157163. getPoint(): Vector3;
  157164. /**
  157165. * Moves the cursor ahead by the step amount
  157166. * @param step The amount to move the cursor forward
  157167. * @returns This path cursor
  157168. */
  157169. moveAhead(step?: number): PathCursor;
  157170. /**
  157171. * Moves the cursor behind by the step amount
  157172. * @param step The amount to move the cursor back
  157173. * @returns This path cursor
  157174. */
  157175. moveBack(step?: number): PathCursor;
  157176. /**
  157177. * Moves the cursor by the step amount
  157178. * If the step amount is greater than one, an exception is thrown
  157179. * @param step The amount to move the cursor
  157180. * @returns This path cursor
  157181. */
  157182. move(step: number): PathCursor;
  157183. /**
  157184. * Ensures that the value is limited between zero and one
  157185. * @returns This path cursor
  157186. */
  157187. private ensureLimits;
  157188. /**
  157189. * Runs onchange callbacks on change (used by the animation engine)
  157190. * @returns This path cursor
  157191. */
  157192. private raiseOnChange;
  157193. /**
  157194. * Executes a function on change
  157195. * @param f A path cursor onchange callback
  157196. * @returns This path cursor
  157197. */
  157198. onchange(f: (cursor: PathCursor) => void): PathCursor;
  157199. }
  157200. }
  157201. declare module BABYLON {
  157202. /** @hidden */
  157203. export var blurPixelShader: {
  157204. name: string;
  157205. shader: string;
  157206. };
  157207. }
  157208. declare module BABYLON {
  157209. /** @hidden */
  157210. export var pointCloudVertexDeclaration: {
  157211. name: string;
  157212. shader: string;
  157213. };
  157214. }
  157215. // Mixins
  157216. interface Window {
  157217. mozIndexedDB: IDBFactory;
  157218. webkitIndexedDB: IDBFactory;
  157219. msIndexedDB: IDBFactory;
  157220. webkitURL: typeof URL;
  157221. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  157222. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  157223. WebGLRenderingContext: WebGLRenderingContext;
  157224. MSGesture: MSGesture;
  157225. CANNON: any;
  157226. AudioContext: AudioContext;
  157227. webkitAudioContext: AudioContext;
  157228. PointerEvent: any;
  157229. Math: Math;
  157230. Uint8Array: Uint8ArrayConstructor;
  157231. Float32Array: Float32ArrayConstructor;
  157232. mozURL: typeof URL;
  157233. msURL: typeof URL;
  157234. VRFrameData: any; // WebVR, from specs 1.1
  157235. DracoDecoderModule: any;
  157236. setImmediate(handler: (...args: any[]) => void): number;
  157237. }
  157238. interface HTMLCanvasElement {
  157239. requestPointerLock(): void;
  157240. msRequestPointerLock?(): void;
  157241. mozRequestPointerLock?(): void;
  157242. webkitRequestPointerLock?(): void;
  157243. /** Track wether a record is in progress */
  157244. isRecording: boolean;
  157245. /** Capture Stream method defined by some browsers */
  157246. captureStream(fps?: number): MediaStream;
  157247. }
  157248. interface CanvasRenderingContext2D {
  157249. msImageSmoothingEnabled: boolean;
  157250. }
  157251. interface MouseEvent {
  157252. mozMovementX: number;
  157253. mozMovementY: number;
  157254. webkitMovementX: number;
  157255. webkitMovementY: number;
  157256. msMovementX: number;
  157257. msMovementY: number;
  157258. }
  157259. interface Navigator {
  157260. mozGetVRDevices: (any: any) => any;
  157261. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157262. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157263. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157264. webkitGetGamepads(): Gamepad[];
  157265. msGetGamepads(): Gamepad[];
  157266. webkitGamepads(): Gamepad[];
  157267. }
  157268. interface HTMLVideoElement {
  157269. mozSrcObject: any;
  157270. }
  157271. interface Math {
  157272. fround(x: number): number;
  157273. imul(a: number, b: number): number;
  157274. }
  157275. interface WebGLRenderingContext {
  157276. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  157277. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  157278. vertexAttribDivisor(index: number, divisor: number): void;
  157279. createVertexArray(): any;
  157280. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  157281. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  157282. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  157283. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  157284. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  157285. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  157286. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  157287. // Queries
  157288. createQuery(): WebGLQuery;
  157289. deleteQuery(query: WebGLQuery): void;
  157290. beginQuery(target: number, query: WebGLQuery): void;
  157291. endQuery(target: number): void;
  157292. getQueryParameter(query: WebGLQuery, pname: number): any;
  157293. getQuery(target: number, pname: number): any;
  157294. MAX_SAMPLES: number;
  157295. RGBA8: number;
  157296. READ_FRAMEBUFFER: number;
  157297. DRAW_FRAMEBUFFER: number;
  157298. UNIFORM_BUFFER: number;
  157299. HALF_FLOAT_OES: number;
  157300. RGBA16F: number;
  157301. RGBA32F: number;
  157302. R32F: number;
  157303. RG32F: number;
  157304. RGB32F: number;
  157305. R16F: number;
  157306. RG16F: number;
  157307. RGB16F: number;
  157308. RED: number;
  157309. RG: number;
  157310. R8: number;
  157311. RG8: number;
  157312. UNSIGNED_INT_24_8: number;
  157313. DEPTH24_STENCIL8: number;
  157314. MIN: number;
  157315. MAX: number;
  157316. /* Multiple Render Targets */
  157317. drawBuffers(buffers: number[]): void;
  157318. readBuffer(src: number): void;
  157319. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  157320. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  157321. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  157322. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  157323. // Occlusion Query
  157324. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  157325. ANY_SAMPLES_PASSED: number;
  157326. QUERY_RESULT_AVAILABLE: number;
  157327. QUERY_RESULT: number;
  157328. }
  157329. interface WebGLProgram {
  157330. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  157331. }
  157332. interface EXT_disjoint_timer_query {
  157333. QUERY_COUNTER_BITS_EXT: number;
  157334. TIME_ELAPSED_EXT: number;
  157335. TIMESTAMP_EXT: number;
  157336. GPU_DISJOINT_EXT: number;
  157337. QUERY_RESULT_EXT: number;
  157338. QUERY_RESULT_AVAILABLE_EXT: number;
  157339. queryCounterEXT(query: WebGLQuery, target: number): void;
  157340. createQueryEXT(): WebGLQuery;
  157341. beginQueryEXT(target: number, query: WebGLQuery): void;
  157342. endQueryEXT(target: number): void;
  157343. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  157344. deleteQueryEXT(query: WebGLQuery): void;
  157345. }
  157346. interface WebGLUniformLocation {
  157347. _currentState: any;
  157348. }
  157349. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  157350. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  157351. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  157352. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157353. interface WebGLRenderingContext {
  157354. readonly RASTERIZER_DISCARD: number;
  157355. readonly DEPTH_COMPONENT24: number;
  157356. readonly TEXTURE_3D: number;
  157357. readonly TEXTURE_2D_ARRAY: number;
  157358. readonly TEXTURE_COMPARE_FUNC: number;
  157359. readonly TEXTURE_COMPARE_MODE: number;
  157360. readonly COMPARE_REF_TO_TEXTURE: number;
  157361. readonly TEXTURE_WRAP_R: number;
  157362. readonly HALF_FLOAT: number;
  157363. readonly RGB8: number;
  157364. readonly RED_INTEGER: number;
  157365. readonly RG_INTEGER: number;
  157366. readonly RGB_INTEGER: number;
  157367. readonly RGBA_INTEGER: number;
  157368. readonly R8_SNORM: number;
  157369. readonly RG8_SNORM: number;
  157370. readonly RGB8_SNORM: number;
  157371. readonly RGBA8_SNORM: number;
  157372. readonly R8I: number;
  157373. readonly RG8I: number;
  157374. readonly RGB8I: number;
  157375. readonly RGBA8I: number;
  157376. readonly R8UI: number;
  157377. readonly RG8UI: number;
  157378. readonly RGB8UI: number;
  157379. readonly RGBA8UI: number;
  157380. readonly R16I: number;
  157381. readonly RG16I: number;
  157382. readonly RGB16I: number;
  157383. readonly RGBA16I: number;
  157384. readonly R16UI: number;
  157385. readonly RG16UI: number;
  157386. readonly RGB16UI: number;
  157387. readonly RGBA16UI: number;
  157388. readonly R32I: number;
  157389. readonly RG32I: number;
  157390. readonly RGB32I: number;
  157391. readonly RGBA32I: number;
  157392. readonly R32UI: number;
  157393. readonly RG32UI: number;
  157394. readonly RGB32UI: number;
  157395. readonly RGBA32UI: number;
  157396. readonly RGB10_A2UI: number;
  157397. readonly R11F_G11F_B10F: number;
  157398. readonly RGB9_E5: number;
  157399. readonly RGB10_A2: number;
  157400. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  157401. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  157402. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  157403. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  157404. readonly DEPTH_COMPONENT32F: number;
  157405. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  157406. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  157407. 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;
  157408. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  157409. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  157410. readonly TRANSFORM_FEEDBACK: number;
  157411. readonly INTERLEAVED_ATTRIBS: number;
  157412. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  157413. createTransformFeedback(): WebGLTransformFeedback;
  157414. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  157415. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  157416. beginTransformFeedback(primitiveMode: number): void;
  157417. endTransformFeedback(): void;
  157418. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  157419. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157420. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157421. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157422. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  157423. }
  157424. interface ImageBitmap {
  157425. readonly width: number;
  157426. readonly height: number;
  157427. close(): void;
  157428. }
  157429. interface WebGLQuery extends WebGLObject {
  157430. }
  157431. declare var WebGLQuery: {
  157432. prototype: WebGLQuery;
  157433. new(): WebGLQuery;
  157434. };
  157435. interface WebGLSampler extends WebGLObject {
  157436. }
  157437. declare var WebGLSampler: {
  157438. prototype: WebGLSampler;
  157439. new(): WebGLSampler;
  157440. };
  157441. interface WebGLSync extends WebGLObject {
  157442. }
  157443. declare var WebGLSync: {
  157444. prototype: WebGLSync;
  157445. new(): WebGLSync;
  157446. };
  157447. interface WebGLTransformFeedback extends WebGLObject {
  157448. }
  157449. declare var WebGLTransformFeedback: {
  157450. prototype: WebGLTransformFeedback;
  157451. new(): WebGLTransformFeedback;
  157452. };
  157453. interface WebGLVertexArrayObject extends WebGLObject {
  157454. }
  157455. declare var WebGLVertexArrayObject: {
  157456. prototype: WebGLVertexArrayObject;
  157457. new(): WebGLVertexArrayObject;
  157458. };
  157459. // Type definitions for WebVR API
  157460. // Project: https://w3c.github.io/webvr/
  157461. // Definitions by: six a <https://github.com/lostfictions>
  157462. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157463. interface VRDisplay extends EventTarget {
  157464. /**
  157465. * Dictionary of capabilities describing the VRDisplay.
  157466. */
  157467. readonly capabilities: VRDisplayCapabilities;
  157468. /**
  157469. * z-depth defining the far plane of the eye view frustum
  157470. * enables mapping of values in the render target depth
  157471. * attachment to scene coordinates. Initially set to 10000.0.
  157472. */
  157473. depthFar: number;
  157474. /**
  157475. * z-depth defining the near plane of the eye view frustum
  157476. * enables mapping of values in the render target depth
  157477. * attachment to scene coordinates. Initially set to 0.01.
  157478. */
  157479. depthNear: number;
  157480. /**
  157481. * An identifier for this distinct VRDisplay. Used as an
  157482. * association point in the Gamepad API.
  157483. */
  157484. readonly displayId: number;
  157485. /**
  157486. * A display name, a user-readable name identifying it.
  157487. */
  157488. readonly displayName: string;
  157489. readonly isConnected: boolean;
  157490. readonly isPresenting: boolean;
  157491. /**
  157492. * If this VRDisplay supports room-scale experiences, the optional
  157493. * stage attribute contains details on the room-scale parameters.
  157494. */
  157495. readonly stageParameters: VRStageParameters | null;
  157496. /**
  157497. * Passing the value returned by `requestAnimationFrame` to
  157498. * `cancelAnimationFrame` will unregister the callback.
  157499. * @param handle Define the hanle of the request to cancel
  157500. */
  157501. cancelAnimationFrame(handle: number): void;
  157502. /**
  157503. * Stops presenting to the VRDisplay.
  157504. * @returns a promise to know when it stopped
  157505. */
  157506. exitPresent(): Promise<void>;
  157507. /**
  157508. * Return the current VREyeParameters for the given eye.
  157509. * @param whichEye Define the eye we want the parameter for
  157510. * @returns the eye parameters
  157511. */
  157512. getEyeParameters(whichEye: string): VREyeParameters;
  157513. /**
  157514. * Populates the passed VRFrameData with the information required to render
  157515. * the current frame.
  157516. * @param frameData Define the data structure to populate
  157517. * @returns true if ok otherwise false
  157518. */
  157519. getFrameData(frameData: VRFrameData): boolean;
  157520. /**
  157521. * Get the layers currently being presented.
  157522. * @returns the list of VR layers
  157523. */
  157524. getLayers(): VRLayer[];
  157525. /**
  157526. * Return a VRPose containing the future predicted pose of the VRDisplay
  157527. * when the current frame will be presented. The value returned will not
  157528. * change until JavaScript has returned control to the browser.
  157529. *
  157530. * The VRPose will contain the position, orientation, velocity,
  157531. * and acceleration of each of these properties.
  157532. * @returns the pose object
  157533. */
  157534. getPose(): VRPose;
  157535. /**
  157536. * Return the current instantaneous pose of the VRDisplay, with no
  157537. * prediction applied.
  157538. * @returns the current instantaneous pose
  157539. */
  157540. getImmediatePose(): VRPose;
  157541. /**
  157542. * The callback passed to `requestAnimationFrame` will be called
  157543. * any time a new frame should be rendered. When the VRDisplay is
  157544. * presenting the callback will be called at the native refresh
  157545. * rate of the HMD. When not presenting this function acts
  157546. * identically to how window.requestAnimationFrame acts. Content should
  157547. * make no assumptions of frame rate or vsync behavior as the HMD runs
  157548. * asynchronously from other displays and at differing refresh rates.
  157549. * @param callback Define the eaction to run next frame
  157550. * @returns the request handle it
  157551. */
  157552. requestAnimationFrame(callback: FrameRequestCallback): number;
  157553. /**
  157554. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  157555. * Repeat calls while already presenting will update the VRLayers being displayed.
  157556. * @param layers Define the list of layer to present
  157557. * @returns a promise to know when the request has been fulfilled
  157558. */
  157559. requestPresent(layers: VRLayer[]): Promise<void>;
  157560. /**
  157561. * Reset the pose for this display, treating its current position and
  157562. * orientation as the "origin/zero" values. VRPose.position,
  157563. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  157564. * updated when calling resetPose(). This should be called in only
  157565. * sitting-space experiences.
  157566. */
  157567. resetPose(): void;
  157568. /**
  157569. * The VRLayer provided to the VRDisplay will be captured and presented
  157570. * in the HMD. Calling this function has the same effect on the source
  157571. * canvas as any other operation that uses its source image, and canvases
  157572. * created without preserveDrawingBuffer set to true will be cleared.
  157573. * @param pose Define the pose to submit
  157574. */
  157575. submitFrame(pose?: VRPose): void;
  157576. }
  157577. declare var VRDisplay: {
  157578. prototype: VRDisplay;
  157579. new(): VRDisplay;
  157580. };
  157581. interface VRLayer {
  157582. leftBounds?: number[] | Float32Array | null;
  157583. rightBounds?: number[] | Float32Array | null;
  157584. source?: HTMLCanvasElement | null;
  157585. }
  157586. interface VRDisplayCapabilities {
  157587. readonly canPresent: boolean;
  157588. readonly hasExternalDisplay: boolean;
  157589. readonly hasOrientation: boolean;
  157590. readonly hasPosition: boolean;
  157591. readonly maxLayers: number;
  157592. }
  157593. interface VREyeParameters {
  157594. /** @deprecated */
  157595. readonly fieldOfView: VRFieldOfView;
  157596. readonly offset: Float32Array;
  157597. readonly renderHeight: number;
  157598. readonly renderWidth: number;
  157599. }
  157600. interface VRFieldOfView {
  157601. readonly downDegrees: number;
  157602. readonly leftDegrees: number;
  157603. readonly rightDegrees: number;
  157604. readonly upDegrees: number;
  157605. }
  157606. interface VRFrameData {
  157607. readonly leftProjectionMatrix: Float32Array;
  157608. readonly leftViewMatrix: Float32Array;
  157609. readonly pose: VRPose;
  157610. readonly rightProjectionMatrix: Float32Array;
  157611. readonly rightViewMatrix: Float32Array;
  157612. readonly timestamp: number;
  157613. }
  157614. interface VRPose {
  157615. readonly angularAcceleration: Float32Array | null;
  157616. readonly angularVelocity: Float32Array | null;
  157617. readonly linearAcceleration: Float32Array | null;
  157618. readonly linearVelocity: Float32Array | null;
  157619. readonly orientation: Float32Array | null;
  157620. readonly position: Float32Array | null;
  157621. readonly timestamp: number;
  157622. }
  157623. interface VRStageParameters {
  157624. sittingToStandingTransform?: Float32Array;
  157625. sizeX?: number;
  157626. sizeY?: number;
  157627. }
  157628. interface Navigator {
  157629. getVRDisplays(): Promise<VRDisplay[]>;
  157630. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  157631. }
  157632. interface Window {
  157633. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  157634. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  157635. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  157636. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157637. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157638. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  157639. }
  157640. interface Gamepad {
  157641. readonly displayId: number;
  157642. }
  157643. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  157644. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  157645. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  157646. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  157647. type XRHandedness = "none" | "left" | "right";
  157648. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  157649. type XREye = "none" | "left" | "right";
  157650. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  157651. interface XRSpace extends EventTarget {}
  157652. interface XRRenderState {
  157653. depthNear?: number;
  157654. depthFar?: number;
  157655. inlineVerticalFieldOfView?: number;
  157656. baseLayer?: XRWebGLLayer;
  157657. }
  157658. interface XRInputSource {
  157659. handedness: XRHandedness;
  157660. targetRayMode: XRTargetRayMode;
  157661. targetRaySpace: XRSpace;
  157662. gripSpace: XRSpace | undefined;
  157663. gamepad: Gamepad | undefined;
  157664. profiles: Array<string>;
  157665. hand: XRHand | undefined;
  157666. }
  157667. interface XRSessionInit {
  157668. optionalFeatures?: string[];
  157669. requiredFeatures?: string[];
  157670. }
  157671. interface XRSession {
  157672. addEventListener: Function;
  157673. removeEventListener: Function;
  157674. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  157675. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  157676. requestAnimationFrame: Function;
  157677. end(): Promise<void>;
  157678. renderState: XRRenderState;
  157679. inputSources: Array<XRInputSource>;
  157680. // hit test
  157681. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  157682. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  157683. // legacy AR hit test
  157684. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157685. // legacy plane detection
  157686. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  157687. }
  157688. interface XRReferenceSpace extends XRSpace {
  157689. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  157690. onreset: any;
  157691. }
  157692. type XRPlaneSet = Set<XRPlane>;
  157693. type XRAnchorSet = Set<XRAnchor>;
  157694. interface XRFrame {
  157695. session: XRSession;
  157696. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  157697. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  157698. // AR
  157699. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  157700. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  157701. // Anchors
  157702. trackedAnchors?: XRAnchorSet;
  157703. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  157704. // Planes
  157705. worldInformation: {
  157706. detectedPlanes?: XRPlaneSet;
  157707. };
  157708. // Hand tracking
  157709. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  157710. }
  157711. interface XRViewerPose extends XRPose {
  157712. views: Array<XRView>;
  157713. }
  157714. interface XRPose {
  157715. transform: XRRigidTransform;
  157716. emulatedPosition: boolean;
  157717. }
  157718. interface XRWebGLLayerOptions {
  157719. antialias?: boolean;
  157720. depth?: boolean;
  157721. stencil?: boolean;
  157722. alpha?: boolean;
  157723. multiview?: boolean;
  157724. framebufferScaleFactor?: number;
  157725. }
  157726. declare var XRWebGLLayer: {
  157727. prototype: XRWebGLLayer;
  157728. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  157729. };
  157730. interface XRWebGLLayer {
  157731. framebuffer: WebGLFramebuffer;
  157732. framebufferWidth: number;
  157733. framebufferHeight: number;
  157734. getViewport: Function;
  157735. }
  157736. declare class XRRigidTransform {
  157737. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  157738. position: DOMPointReadOnly;
  157739. orientation: DOMPointReadOnly;
  157740. matrix: Float32Array;
  157741. inverse: XRRigidTransform;
  157742. }
  157743. interface XRView {
  157744. eye: XREye;
  157745. projectionMatrix: Float32Array;
  157746. transform: XRRigidTransform;
  157747. }
  157748. interface XRInputSourceChangeEvent {
  157749. session: XRSession;
  157750. removed: Array<XRInputSource>;
  157751. added: Array<XRInputSource>;
  157752. }
  157753. interface XRInputSourceEvent extends Event {
  157754. readonly frame: XRFrame;
  157755. readonly inputSource: XRInputSource;
  157756. }
  157757. // Experimental(er) features
  157758. declare class XRRay {
  157759. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  157760. origin: DOMPointReadOnly;
  157761. direction: DOMPointReadOnly;
  157762. matrix: Float32Array;
  157763. }
  157764. declare enum XRHitTestTrackableType {
  157765. "point",
  157766. "plane",
  157767. "mesh",
  157768. }
  157769. interface XRHitResult {
  157770. hitMatrix: Float32Array;
  157771. }
  157772. interface XRTransientInputHitTestResult {
  157773. readonly inputSource: XRInputSource;
  157774. readonly results: Array<XRHitTestResult>;
  157775. }
  157776. interface XRHitTestResult {
  157777. getPose(baseSpace: XRSpace): XRPose | undefined;
  157778. // When anchor system is enabled
  157779. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  157780. }
  157781. interface XRHitTestSource {
  157782. cancel(): void;
  157783. }
  157784. interface XRTransientInputHitTestSource {
  157785. cancel(): void;
  157786. }
  157787. interface XRHitTestOptionsInit {
  157788. space: XRSpace;
  157789. entityTypes?: Array<XRHitTestTrackableType>;
  157790. offsetRay?: XRRay;
  157791. }
  157792. interface XRTransientInputHitTestOptionsInit {
  157793. profile: string;
  157794. entityTypes?: Array<XRHitTestTrackableType>;
  157795. offsetRay?: XRRay;
  157796. }
  157797. interface XRAnchor {
  157798. anchorSpace: XRSpace;
  157799. delete(): void;
  157800. }
  157801. interface XRPlane {
  157802. orientation: "Horizontal" | "Vertical";
  157803. planeSpace: XRSpace;
  157804. polygon: Array<DOMPointReadOnly>;
  157805. lastChangedTime: number;
  157806. }
  157807. interface XRJointSpace extends XRSpace {}
  157808. interface XRJointPose extends XRPose {
  157809. radius: number | undefined;
  157810. }
  157811. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  157812. readonly length: number;
  157813. [index: number]: XRJointSpace;
  157814. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  157815. readonly WRIST: number;
  157816. readonly THUMB_METACARPAL: number;
  157817. readonly THUMB_PHALANX_PROXIMAL: number;
  157818. readonly THUMB_PHALANX_DISTAL: number;
  157819. readonly THUMB_PHALANX_TIP: number;
  157820. readonly INDEX_METACARPAL: number;
  157821. readonly INDEX_PHALANX_PROXIMAL: number;
  157822. readonly INDEX_PHALANX_INTERMEDIATE: number;
  157823. readonly INDEX_PHALANX_DISTAL: number;
  157824. readonly INDEX_PHALANX_TIP: number;
  157825. readonly MIDDLE_METACARPAL: number;
  157826. readonly MIDDLE_PHALANX_PROXIMAL: number;
  157827. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  157828. readonly MIDDLE_PHALANX_DISTAL: number;
  157829. readonly MIDDLE_PHALANX_TIP: number;
  157830. readonly RING_METACARPAL: number;
  157831. readonly RING_PHALANX_PROXIMAL: number;
  157832. readonly RING_PHALANX_INTERMEDIATE: number;
  157833. readonly RING_PHALANX_DISTAL: number;
  157834. readonly RING_PHALANX_TIP: number;
  157835. readonly LITTLE_METACARPAL: number;
  157836. readonly LITTLE_PHALANX_PROXIMAL: number;
  157837. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  157838. readonly LITTLE_PHALANX_DISTAL: number;
  157839. readonly LITTLE_PHALANX_TIP: number;
  157840. }
  157841. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  157842. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  157843. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  157844. interface XRSession {
  157845. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  157846. }
  157847. interface XRFrame {
  157848. featurePointCloud? : Array<number>;
  157849. }